Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-15943

Discovered hosts are not removed from table "dhosts" after removing and adding the corresponding discovery check

    XMLWordPrintable

    Details

    • Team:
      Team A
    • Sprint:
      Sprint 51 (Apr 2019), Sprint 52 (May 2019), Sprint 53 (Jun 2019)
    • Story Points:
      0.5

      Description

      Problem description: If a network discovery check is removed from the discovery rule the hosts that were discovered by this check are not deleted from DB (table dhosts). When adding another (or the same) check that discovers the same hosts, these hosts are once again added to DB, thus there are double records for these hosts in table "dhosts".
      This leads to the following issues:
      1 - dhost.get API returns these host in double (only 1 version contains dservices info as for the older records the corresponding data was deleted after removing the "dservices" table).
      2 - drule.get API returns incorrect number of hosts if parameter "selectDHosts" is specified as "count".

      Steps to reproduce:
      1. Navigate to Configuration => Discovery
      2. Create a Discovery rule with at least 2 checks - make sure that at least one of the checks will be able to discover something.
      3. Wait until the hosts are discovered. Check DB table "dhosts" execute the following APIs to verify that the number of discovered hosts is the same as in ftontend in Monitoring => Discovery:
      drule.get

      {
          "jsonrpc": "2.0",
          "method": "drule.get",
          "params": {
          	"output": "extend",
          	"selectDHosts": "count"
          	},
          "auth": "7ab09928905ec44ff2cbafb27497c1a5",
          "id": 1
      }
      

      dhost.get

      {
          "jsonrpc": "2.0",
          "method": "dhost.get",
          "params": {
          	"countOutput": false,
          	"output": "extend",
          	"selectDServices": "extend"
          },
          "auth": "7ab09928905ec44ff2cbafb27497c1a5",
          "id": 1
      }
      

      4. Navigate back to Configuration =>Discovery and remove the check that discovered the afore mentioned hosts from the previously created discovery rule.
      5. Navigate to Monitoring => Discovery to make sure that the hosts that were discovered by the removed check have disappeared.
      6. Check DB - the corresponding records are still present in "dhosts" table.
      7. Navigate to Configuration => Discovery and add the previously deleted check once again to the discovery rule.
      8. Wait until the hosts are discovered. Check the frontend view Monitoring => Discovery and DB table "dhosts", and execute the previously executed dhost.get and drule.get APIs

      Result:
      1. The number of records in DB table "dhosts" is higher than the number of hosts in Monitoring => Discovery by the number of the hosts discovered by the deleted check.
      2. The "dhosts" field value in output of the "drule.get" API is higher than the number of hosts in Monitoring => Discovery by the number of the hosts discovered by the deleted check:

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "druleid": "2",
                  "proxy_hostid": "0",
                  "name": "Local network",
                  "iprange": "192.168.3.30-31",
                  "delay": "10s",
                  "nextcheck": "1554384485",
                  "status": "0",
                  "dhosts": "4"  <- only 2 hosts are displayed under _Monitoring => Discovery_
              }
          ],
          "id": 1
      }
      

      3. In the output of the "dhost.get" API both the hosts that were discovered before removing the check and the hosts that were discovered after the check are returned. For the hosts that were discovered before removing the corresponding check "dservices" array is empty:

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "dhostid": "33",
                  "druleid": "2",
                  "status": "0",
                  "lastup": "1554382621",
                  "lastdown": "0",
                  "dservices": []
              },
              {
                  "dhostid": "34",
                  "druleid": "2",
                  "status": "0",
                  "lastup": "1554382621",
                  "lastdown": "0",
                  "dservices": []
              },
              {
                  "dhostid": "35",
                  "druleid": "2",
                  "status": "0",
                  "lastup": "1554383342",
                  "lastdown": "0",
                  "dservices": [
                      {
                          "dserviceid": "35",
                          "dhostid": "35",
                          "value": "",
                          "port": "80",
                          "status": "0",
                          "lastup": "1554383342",
                          "lastdown": "0",
                          "dcheckid": "9",
                          "ip": "192.168.3.30",
                          "dns": "demo1-ilo.zabbix.lan"
                      }
                  ]
              },
              {
                  "dhostid": "36",
                  "druleid": "2",
                  "status": "0",
                  "lastup": "1554383342",
                  "lastdown": "0",
                  "dservices": [
                      {
                          "dserviceid": "36",
                          "dhostid": "36",
                          "value": "",
                          "port": "80",
                          "status": "0",
                          "lastup": "1554383342",
                          "lastdown": "0",
                          "dcheckid": "9",
                          "ip": "192.168.3.31",
                          "dns": "jmsc.zabbix.lan"
                      }
                  ]
              }
          ],
          "id": 1
      }
      

      Expected:
      1 - The number of records in DB table "dhosts" should be the same as displayed in frontend in Monitoring => Discovery view
      2 - The "dhosts" field value in output of the "drule.get" API should be the same as the number of hosts displayed in Monitoring => Discovery view
      3 - In the output of the "dhost.get" API the hosts that were discovered by the deleted check should not be returned.

      Scenario:

        Attachments

          Activity

            People

            Assignee:
            ak Andrejs Kozlovs
            Reporter:
            solonkins Sergejs Olonkins
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: