Closed Jonmccombs closed 6 years ago
I have the same issue on zabbix 3.2.6
please run script by hand from the console and check the output of it. Try to run it under zabbix
user.
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"
}
]
}
Output is not a valid JSON, you need to suppress those warnings. Try to remove ‘use warnings’ pragma from the script
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" } ] }
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. В консоли скрипт выполняется корректно. Спасибо.
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/
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
Hi, I have the same problem. Added in sudoers /usr/bin/perl didn't resolve the issue :/.
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"
}
]
}]
Check that perl script is executable: chmod +x /etc/zabbix/scripts/smartctl-disks-discovery.pl
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.
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.