Difference between revisions of "Custom comand execution with Zabbix and SNMP"
Jump to navigation
Jump to search
Line 70: | Line 70: | ||
==Create Check== | ==Create Check== | ||
<div><ul> | <div><ul> | ||
− | <li style="display: inline-block; vertical-align: top;">[[Image:zabbix-snmp-cmd-01.png|300px|thumb|none| | + | <li style="display: inline-block; vertical-align: top;">[[Image:zabbix-snmp-cmd-01.png|300px|thumb|none|Zabbix > Configuration > Hosts > xxx > Items > Create]]</li> |
</div></ul> | </div></ul> | ||
==Create Trigger== | ==Create Trigger== | ||
<div><ul> | <div><ul> | ||
− | <li style="display: inline-block; vertical-align: top;">[[Image:zabbix-snmp-cmd- | + | <li style="display: inline-block; vertical-align: top;">[[Image:zabbix-snmp-cmd-02.png|300px|thumb|none|Zabbix > Configuration > Hosts > xxx > Triggers > Create]]</li> |
</div></ul> | </div></ul> | ||
==Test== | ==Test== | ||
+ | <div><ul> | ||
+ | <li style="display: inline-block; vertical-align: top;">[[Image:zabbix-snmp-cmd-03.png|300px|thumb|none|test alert with the chmod cmd above]]</li> | ||
+ | </div></ul> | ||
+ | [[Category:Pages with broken file links]] | ||
[[Category:Zabbix]] | [[Category:Zabbix]] |
Latest revision as of 19:23, 11 November 2020
With Zabbix, you can as well as with Nagios check custom scripts and check them via SNMP. Then you can create a trigger which checks the output of the SNMP comand that gets executed.
Contents
1 configure snmpd
1.1 /etc/snmpd.conf
syscontact support@stiftung-buehl.ch rouser safereader auth rwuser safewriter priv rocommunity ***xxx*** 10.0.10.124 rocommunity ***xxx*** 10.0.10.125 rocommunity ***xxx*** localhost exec fs-root-rw /bin/sh -c "echo > /zabbix_fs_test >/dev/null && echo ROOT-OK" exec fs-opt-rw /bin/sh -c "echo > /opt/zabbix_fs_test >/dev/null && echo OPT-OK"
1.2 configure the check files
root@mail:/etc/snmp# systemctl restart snmpd root@mail:/etc/snmp# ps -ef | grep snmp Debian-+ 15548 1 0 20:10 ? 00:00:00 /usr/sbin/snmpd -Lsd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux mteTrigger mteTriggerConf -f root@mail:/etc/snmp# getent passwd | grep -i Debi Debian-snmp:x:113:121::/var/lib/snmp:/bin/false root@mail:/etc/snmp# touch /zabbix_fs_test /opt/zabbix_fs_test ; chown Debian-snmp /opt/zabbix_fs_test /zabbix_fs_test ; chmod 700 /opt/zabbix_fs_test /zabbix_fs_test root@mail:/etc/snmp# snmpwalk -v2c -O n -c '***l0cal***' localhost .1.3.6.1.4.1.2021.8.1 .1.3.6.1.4.1.2021.8.1.1.1 = INTEGER: 1 .1.3.6.1.4.1.2021.8.1.1.2 = INTEGER: 2 .1.3.6.1.4.1.2021.8.1.2.1 = STRING: "fs-root-rw" .1.3.6.1.4.1.2021.8.1.2.2 = STRING: "fs-opt-rw" .1.3.6.1.4.1.2021.8.1.3.1 = STRING: "/bin/sh -c \"echo > /zabbix_fs_test >/dev/null && echo ROOT-OK\"" .1.3.6.1.4.1.2021.8.1.3.2 = STRING: "/bin/sh -c \"echo > /opt/zabbix_fs_test >/dev/null && echo OPT-OK\"" .1.3.6.1.4.1.2021.8.1.100.1 = INTEGER: 0 .1.3.6.1.4.1.2021.8.1.100.2 = INTEGER: 0 .1.3.6.1.4.1.2021.8.1.101.1 = STRING: "ROOT-OK" .1.3.6.1.4.1.2021.8.1.101.2 = STRING: "OPT-OK" .1.3.6.1.4.1.2021.8.1.102.1 = INTEGER: 0 .1.3.6.1.4.1.2021.8.1.102.2 = INTEGER: 0 .1.3.6.1.4.1.2021.8.1.103.1 = "" .1.3.6.1.4.1.2021.8.1.103.2 = "" root@mail:/etc/snmp# chmod 000 /opt/zabbix_fs_test root@mail:/etc/snmp# snmpwalk -v2c -O n -c '***l0cal***' localhost .1.3.6.1.4.1.2021.8.1 .1.3.6.1.4.1.2021.8.1.1.1 = INTEGER: 1 .1.3.6.1.4.1.2021.8.1.1.2 = INTEGER: 2 .1.3.6.1.4.1.2021.8.1.2.1 = STRING: "fs-root-rw" .1.3.6.1.4.1.2021.8.1.2.2 = STRING: "fs-opt-rw" .1.3.6.1.4.1.2021.8.1.3.1 = STRING: "/bin/sh -c \"echo > /zabbix_fs_test >/dev/null && echo ROOT-OK\"" .1.3.6.1.4.1.2021.8.1.3.2 = STRING: "/bin/sh -c \"echo > /opt/zabbix_fs_test >/dev/null && echo OPT-OK\"" .1.3.6.1.4.1.2021.8.1.100.1 = INTEGER: 0 .1.3.6.1.4.1.2021.8.1.100.2 = INTEGER: 2 .1.3.6.1.4.1.2021.8.1.101.1 = STRING: "ROOT-OK" .1.3.6.1.4.1.2021.8.1.101.2 = STRING: "/bin/sh: 1: cannot create /opt/zabbix_fs_test: Permission denied" .1.3.6.1.4.1.2021.8.1.102.1 = INTEGER: 0 .1.3.6.1.4.1.2021.8.1.102.2 = INTEGER: 0 .1.3.6.1.4.1.2021.8.1.103.1 = "" .1.3.6.1.4.1.2021.8.1.103.2 = "" root@mail:/etc/snmp# touch /zabbix_fs_test /opt/zabbix_fs_test ; chown Debian-snmp /opt/zabbix_fs_test /zabbix_fs_test ; chmod 700 /opt/zabbix_fs_test /zabbix_fs_test