Extend snmpd to add detailed CPU statistics, per CPU (again)

For easier use with Cacti, it is easier to group statistics per type instead of per CPU. So you would have a parent OID for CPU time spent by user with many values (one per CPU).

Put the following in /etc/snmp/percpudetail:

case "$1" in
    grep ^cpu /proc/stat | awk '{print 2}' ;;
    grep ^cpu /proc/stat | awk '{print 3}' ;;
    grep ^cpu /proc/stat | awk '{print 4}' ;;
    grep ^cpu /proc/stat | awk '{print 5}' ;;
    grep ^cpu /proc/stat | awk '{print 6}' ;;
    grep ^cpu /proc/stat | awk '{print 7}' ;;
    grep ^cpu /proc/stat | awk '{print 8}' ;;

Make it executable:

chmod +x /etc/snmp/percpudetail

Then in your /etc/snmp/snmpd.conf file, put the following lines:

extend cpuuser /etc/snmp/percpudetail user
extend cpunice /etc/snmp/percpudetail nice
extend cpusystem /etc/snmp/percpudetail system
extend cpuidle /etc/snmp/percpudetail idle
extend cpuiowait /etc/snmp/percpudetail iowait
extend cpuirq /etc/snmp/percpudetail irq
extend cpusoftirq /etc/snmp/percpudetail softirq

Restart snmpd and you can poll those new OIDs.

This entry was posted in Computer, Linux, Networking. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *