Ad Widget

Collapse

How to debug discovery rule

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jancs
    Member
    • Jul 2014
    • 30

    #1

    How to debug discovery rule

    Hi!

    I am trying to set up the SMART monitoring using https://share.zabbix.com/storage-dev...rtmontools-lld, but discovery rule is not functioning, saying that JSON object is expected. Locally, testing it with su -c "/etc/zabbix/scripts/smartctl-disks-discovery.pl" -s /bin/sh zabbix, discovery script returns:
    {
    "data":[

    {
    "{#DISKMODEL}":"",
    "{#DISKSN}":"WD-WMAYUE605097",
    "{#DISKNAME}":"/dev/sda",
    "{#DISKCMD}":"/dev/sda -d scsi",
    "{#SMART_ENABLED}":"0",
    "{#DISKTYPE}":"2"
    }
    ]
    }
    which looks like the expected result.

    How can I test discovery rule from Zabbix server side to see what it actually receives?

    Janis
  • Linwood
    Senior Member
    • Dec 2013
    • 398

    #2
    Are you sure that's ALL it is returning, no extra data before or after, no extra control characters other than new lines? No extra debug printout or anything?

    I can't tell you how many times I've stared at json like this wondering why it won't "take". Never found a good answer, turning on debug in zabbix might help but you get such a huge amount of output -- you might try (if it's acceptable) disabling all hosts but one then enable debugging. I think it's the poller process that does LLD, but not certain.

    But my best bet has alwys been to do what you did (though often run it into a file and then look with a good editor that will show all characters).

    Comment

    • jancs
      Member
      • Jul 2014
      • 30

      #3
      does not show anything else on the screen. Outputting the result to file and looking at in in hex also does not show anything out of the picture.

      Comment

      • jancs
        Member
        • Jul 2014
        • 30

        #4
        actually - in debug mode i found the reason: 3102:20180819:183851.784 Sending back [Smartctl open device: /dev/sda failed: Permission denied and then the data follows which make me wonder - if under user zabbix locally everything works (initially I got the same error, which disappeared after adding of zabbix to disk group) , under what user the script is being executed? zabbixagent?

        Comment

        • Linwood
          Senior Member
          • Dec 2013
          • 398

          #5
          Any chance you need a service restart after adding it to the disk group?

          Comment

          • jancs
            Member
            • Jul 2014
            • 30

            #6
            I tried the su - test with both zabbix and zabbixagent - being in the disk group both worked locally

            There is smth else - the problem in discovery script is somehow due to the thing that smartctl is called from within the perl script... ha, the comment in the script says "#must be run as root" so it must be sudo-ed at least.

            Isn't it possible indeed to see the output of the discovery rule as sent to server?

            Comment

            Working...