Snmp call script and independent log configuration

  

net-snmp can call external script extensions, such as: vi /etc/snmp/snmpd.conf

exec .1.3.6.1.4.1.2021.18 tcpCurrEstab /etc /snmp/tcpconn.shexec .1.3.6.1.4.1.2021.19 tcpCurrHttp /etc/snmp/tcphttp.shexec .1.3.6.1.4.1.2021.20 tcpCurrPhp-fpm /etc/snmp/tcpphp.shexec .1.3.6.1.4.1.2021.21 tcpCurrMemcache /etc/snmp/tcpmemcache.sh above is the old version of the configuration, has been deprecated, the new version uses:

extend .1.3.6.1.4.1.2021.18 tcpCurrEstab /etc/snmp/tcpconn.shextend .1.3 .6.1.4.1.2021.19 tcpCurrHttp /etc/snmp/tcphttp.shextend .1.3.6.1.4.1.2021.20 tcpCurrPhp-fpm /etc/snmp/tcpphp.shextend .1.3.6.1.4.1.2021.21 tcpCurrMemcache /etc/snmp/tcpmemcache. Shsnmpd wants to allow a segment access, configured as:

com2sec notConfigUser 192.168.1.0/24 public[root@ha1 log]# cat /etc/snmp/tcpconn.sh

#!/bin /shconn=`netstat -s -t |  Grep connections\\ established | Awk '{print $1}'`echo $conn[root@ha1 log]# cat /etc/snmp/tcphttp.sh

#!/bin/shnetstat -an |  Grep ':80 ' |  Grep ESTABLISHED |  Wc -l[root@ha1 log]# cat /etc/snmp/tcpmemcache.sh

#!/bin/shnetstat -an |  Grep :11211 |  Grep ESTABLISHED |  Wc -l[root@ha1 log]# cat /etc/snmp/tcpphp.sh

#!/bin/shnetstat -an |  Grep :9000 |  Grep ESTABLISHED |  Wc -l restart net-snmpd:

service snmpd restart test: [root@ha1 log]# snmpwalk -v 2c -c public 192.168.1.4 .1.3.6.1.4.1.2021.18

UCD-SNMP-MIB::ucdavis.18.1.1 = INTEGER: 1UCD-SNMP-MIB::ucdavis.18.2.1 = STRING: "tcpCurrEstab"UCD-SNMP-MIB::ucdavis.18.3.1 = STRING: " ;/etc/snmp/tcpconn.sh"UCD-SNMP-MIB::ucdavis.18.100.1 = INTEGER: 0UCD-SNMP-MIB::ucdavis.18.101.1 = STRING: "5023"UCD-SNMP-MIB: :ucdavis.18.102.1 = INTEGER: 0UCD-SNMP-MIB::ucdavis.18.103.1 = ""There is an information output indicating success. The default net-snmpd output logs to /var/log/messes and want to output to a separate log file, configured as: vi /etc/sysconfig/snmpd.options

# snmpd command line options# OPTIONS=" -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a"OPTIONS="-Lf /var/log/snmpd.log"Restart net-snmpd:

service snmpd restartcat /var/log/snmpd.log

Copyright © Windows knowledge All Rights Reserved