I wanted to monitor the amount of emails in sendmail's outbound queue using snmp without any sed/awk/shell/Perl scripts in between. On FreeBSD that's fairly easy:
view systemonly included .1Remove any other view systemonly ... line
# sysrc snmpd_enable=YES # service snmpd start
$ snmpget -c public -v 2c localhost .1.3.6.1.2.1.28.2.1.4.1.10 MTA-MIB::mtaGroupStoredMessages.1.10 = Gauge32: 0
Does it work?
# mailq
/var/spool/mqueue is empty
Total requests: 0
# snmpget -c public -v 2c localhost .1.3.6.1.2.1.28.2.1.4.1.10
MTA-MIB::mtaGroupStoredMessages.1.10 = Gauge32: 0
# ipfw add 2000 deny tcp from any to any 25
02000 deny tcp from any to any dst-port 25
# sendmail root
subject: test 1
foobar 1
.
# mailq
/var/spool/mqueue (1 request)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
v2BDihhV003399 9 Sat Mar 11 14:44 <root@where.ever>
(Deferred: Permission denied)
user@some.where
Total requests: 1
# snmpget -c public -v 2c localhost .1.3.6.1.2.1.28.2.1.4.1.10
MTA-MIB::mtaGroupStoredMessages.1.10 = Gauge32: 1
# ipfw delete 02000
# sendmail -qf
# mailq
/var/spool/mqueue is empty
Total requests: 0
# snmpget -c public -v 2c localhost .1.3.6.1.2.1.28.2.1.4.1.10
MTA-MIB::mtaGroupStoredMessages.1.10 = Gauge32: 0