Difference between revisions of "Custom comand execution with Zabbix and SNMP"

From Bitbull Wiki
Jump to navigation Jump to search
(Created page with "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 ex...")
 
Line 66: Line 66:
  
 
</pre>
 
</pre>
 +
 +
=Zabbix Config=
 +
==Create Check==
 +
<div><ul>
 +
<li style="display: inline-block; vertical-align: top;">[[Image:zabbix-snmp-cmd-01.png|300px|thumb|none|CentOS 8 Core - Boot Screen]]</li>
 +
</div></ul>
 +
 +
==Create Trigger==
 +
<div><ul>
 +
<li style="display: inline-block; vertical-align: top;">[[Image:zabbix-snmp-cmd-01.png|300px|thumb|none|CentOS 8 Core - Boot Screen]]</li>
 +
</div></ul>
 +
 +
==Test==
  
 
[[Category:Zabbix]]
 
[[Category:Zabbix]]

Revision as of 19:21, 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.

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

2 Zabbix Config

2.1 Create Check

  • CentOS 8 Core - Boot Screen

2.2 Create Trigger

  • CentOS 8 Core - Boot Screen

2.3 Test