In this article we consider the example of monitoring emails postfix queue via SNMP. Initial Setup SNMP made in this article.
The number of messages in the queue will be calculated using this script:
#!/bin/bash queuelength=/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'
queuecount=echo $queuelength | grep "[0-9]"
if [ “$queuecount” == “” ]; then echo 0; else echo ${queuelength}; fi exit 35
#!/bin/bash
queuelength=/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'
queuecount=echo $queuelength | grep "[0-9]"
if [ “$queuecount” == “” ]; then
echo 0;
else
echo ${queuelength};
fi
exit 35
Save it, say, and do /var/snmp-scripts/queue.sh start:
# Chmod + x /var/snmp-scripts/queue.sh
Now add the following lines in /etc/snmp/snmpd.conf:
extend .1.3.6.1.4.1.9999.44.1 / bin / bash /var/snmp-scripts/queue.sh
extend .1.3.6.1.4.1.9999.44.1 /bin/bash /var/snmp-scripts/queue.sh
Make the dough using snmpwalk:
# snmpwalk -v1 -c public 127.0.0.1 1.3.6.1.4.1.9999.44.1
iso.3.6.1.4.1.9999.44.1.1.0 = INTEGER: 1
iso.3.6.1.4.1.9999.44.1.2.1.2.9.47.98.105.110.47.98.97.115.104 = STRING: “/var/snmp-scripts/queue.sh”
iso.3.6.1.4.1.9999.44.1.2.1.3.9.47.98.105.110.47.98.97.115.104 = “”
iso.3.6.1.4.1.9999.44.1.2.1.4.9.47.98.105.110.47.98.97.115.104 = “”
iso.3.6.1.4.1.9999.44.1.2.1.5.9.47.98.105.110.47.98.97.115.104 = INTEGER: 5
iso.3.6.1.4.1.9999.44.1.2.1.6.9.47.98.105.110.47.98.97.115.104 = INTEGER: 1
iso.3.6.1.4.1.9999.44.1.2.1.7.9.47.98.105.110.47.98.97.115.104 = INTEGER: 1
iso.3.6.1.4.1.9999.44.1.2.1.20.9.47.98.105.110.47.98.97.115.104 = INTEGER: 4
iso.3.6.1.4.1.9999.44.1.2.1.21.9.47.98.105.110.47.98.97.115.104 = INTEGER: 1
iso.3.6.1.4.1.9999.44.1.3.1.1.9.47.98.105.110.47.98.97.115.104 = STRING: “0”
iso.3.6.1.4.1.9999.44.1.3.1.2.9.47.98.105.110.47.98.97.115.104 = STRING: “0”
iso.3.6.1.4.1.9999.44.1.3.1.3.9.47.98.105.110.47.98.97.115.104 = INTEGER: 1
iso.3.6.1.4.1.9999.44.1.3.1.4.9.47.98.105.110.47.98.97.115.104 = INTEGER: 35
iso.3.6.1.4.1.9999.44.1.4.1.2.9.47.98.105.110.47.98.97.115.104.1 = STRING: “0”
The last value is the desired value given to the script, ie the number of messages in queue – 1.3.6.1.4.1.9999.44.1.4.1.2.9.47.98.105.110.47.98.97.115.104.1 = STRING: “0”
Leave a Reply