v-zhuravlev / zbx-smartctl

Templates and scripts for monitoring disks health with Zabbix and smartmontools
https://share.zabbix.com/storage-devices/smartmontools/smart-monitoring-with-smartmontools-lld
GNU General Public License v3.0
245 stars 127 forks source link

Zabbix reporting discovery error #48

Closed Jonmccombs closed 6 years ago

Jonmccombs commented 6 years ago

When using template on Zabbix 3.4 I get the following error under Config - Hosts -Discovery = Value should be a JSON object. It is a little vague why since I did not alter the script for .pl in any way.

zingreen commented 6 years ago

I have the same issue on zabbix 3.2.6

v-zhuravlev commented 6 years ago

please run script by hand from the console and check the output of it. Try to run it under zabbix user.

zingreen commented 6 years ago

my output: [root@xenserver-bhyukrpg zabbix]# sudo -u zabbix sudo /etc/zabbix/scripts/smartctl-disks-discovery.pl perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). { "data":[

    {
        "{#DISKNAME}":"/dev/sda -d sat",
        "{#SMART_ENABLED}":"1"
    },
    {
        "{#DISKNAME}":"/dev/sdb -d sat",
        "{#SMART_ENABLED}":"1"
    },
    {
        "{#DISKNAME}":"/dev/sdc -d sat",
        "{#SMART_ENABLED}":"1"
    },
    {
        "{#DISKNAME}":"/dev/sdd -d sat",
        "{#SMART_ENABLED}":"1"
    }
]

}

v-zhuravlev commented 6 years ago

Output is not a valid JSON, you need to suppress those warnings. Try to remove ‘use warnings’ pragma from the script

zingreen commented 6 years ago

If I run on local console (not ssh) I have output without warnings: sudo -u zabbix sudo /etc/zabbix/scripts/smartctl-disks-discovery.pl { "data":[

{ "{#DISKNAME}":"/dev/sda -d sat", "{#SMART_ENABLED}":"1" }, { "{#DISKNAME}":"/dev/sdb -d sat", "{#SMART_ENABLED}":"1" }, { "{#DISKNAME}":"/dev/sdc -d sat", "{#SMART_ENABLED}":"1" }, { "{#DISKNAME}":"/dev/sdd -d sat", "{#SMART_ENABLED}":"1" } ] }

KaMaToZzz commented 6 years ago

Output is not a valid JSON, you need to suppress those warnings. Try to remove ‘use warnings’ pragma from the script

Виталий, Убрал ‘use warnings’ , но заббикс все равно ругается на: Value should be a JSON object. В консоли скрипт выполняется корректно. Спасибо.

v-zhuravlev commented 6 years ago

please try then to use zabbix_get like so: zabbix_get -k uHDD.discovery -s <agent_ip> and then check output with https://jsonlint.com/

KaMaToZzz commented 6 years ago

Hmm, its look like sudo need's tty? Need to add sudoers all console commands? Now:

Defaults:zabbix !requiretty
zabbix ALL= (ALL) NOPASSWD: /usr/sbin/smartctl,/etc/zabbix/scripts/smartctl-disks-discovery.pl

sudo: no tty present and no askpass program specified

decision: add in sudores /usr/bin/perl

proseti commented 6 years ago

Hi, I have the same problem. Added in sudoers /usr/bin/perl didn't resolve the issue :/.

image

UPDATE: I made some test. On server with agent: [root@xenserver-proseti /]# zabbix_agentd -t uHDD.discovery uHDD.discovery [t|{ "data":[

            {
                    "{#DISKNAME}":"/dev/sda -d sat",
                    "{#SMART_ENABLED}":"1"
            }
    ]

}]

v-zhuravlev commented 6 years ago

Check that perl script is executable: chmod +x /etc/zabbix/scripts/smartctl-disks-discovery.pl

v-zhuravlev commented 6 years ago

Most of the time, The problem is with permissions. Please tell me if you have solved the issue and what was it so we can update readme with Troubleshooting section.