Use cacti monitor http online users

1.vi /etc/snmp/snmpd.conf, add scripts

extend .1.3.6.1.4.1.2021.50 tuhttp /bin/bash /opt/httpd2/conf/tuhttp.sh

2.vi tuhttp.sh

#!/bin/bash
num=$(ps -e |grep http|grep -v grep|grep -v jkhttp|wc -l)
#num=$(grep “ONLINE USERS=” /opt/photo/log/tu.log | sed ‘$!d’ | sed ’s/\(.*\)USERS=\([0-9]*\)$/\2/’)
echo $num
echo OK

ps: tu.log is my system log, ignore

3.reload snmpd

/etc/init.d/snmpd reload

4.check snmp info

snmpwalk -v 2c 10.30.0.22 -c public .1.3.6.1.4.1.2021.50

display:

UCD-SNMP-MIB::ucdavis.50.1.0 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.50.2.1.2.6.116.117.104.116.116.112 = STRING: “/bin/bash”
UCD-SNMP-MIB::ucdavis.50.2.1.3.6.116.117.104.116.116.112 = STRING: “/opt/httpd2/conf/tuhttp.sh”
UCD-SNMP-MIB::ucdavis.50.2.1.4.6.116.117.104.116.116.112 = “”
UCD-SNMP-MIB::ucdavis.50.2.1.5.6.116.117.104.116.116.112 = INTEGER: 5
UCD-SNMP-MIB::ucdavis.50.2.1.6.6.116.117.104.116.116.112 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.50.2.1.7.6.116.117.104.116.116.112 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.50.2.1.20.6.116.117.104.116.116.112 = INTEGER: 4
UCD-SNMP-MIB::ucdavis.50.2.1.21.6.116.117.104.116.116.112 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.50.3.1.1.6.116.117.104.116.116.112 = STRING: “3″
UCD-SNMP-MIB::ucdavis.50.3.1.2.6.116.117.104.116.116.112 = STRING: “3
OK”
UCD-SNMP-MIB::ucdavis.50.3.1.3.6.116.117.104.116.116.112 = INTEGER: 2
UCD-SNMP-MIB::ucdavis.50.3.1.4.6.116.117.104.116.116.112 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.50.4.1.2.6.116.117.104.116.116.112.1 = STRING: “3″
UCD-SNMP-MIB::ucdavis.50.4.1.2.6.116.117.104.116.116.112.2 = STRING: “OK”

ps:we need .1.3.6.1.4.1.2021.50.3.1.1.6.116.117.104.116.116.112

5.add cacti data templates
Console -> Data Templates
data_templates

6.add cacti graph templates
Console -> Graph Templates
graph_templates

7.add these templates to host
Console -> Devices -> Create Graphs for this Host

8.All Done
cacti_httpnum

refer: http://bbs.linuxtone.org/thread-1372-1-1.html

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>