I have created a graph on Cacti about time to access to a specific page on our infrastructure with cacti and net-snmp.
I have extended the capability with adding two new lines in file /etc/snmp/snmpd.conf :
extend stat_page1 /usr/local/bin/cacti/access_page.sh context1
extend stat_page2 /usr/local/bin/cacti/access_page.sh context2
I have restarted the daemon snmpd to load this configuration.
The script called is describe below, with other value, because for some reason, i can show this.
#!/bin/bash
domain="mydomain"
cookie_name="myCookie"
token="myToken"
if [ $# -eq 1 ]
then
if [ "$1" = "context1" ]
then
target_url="https://${domain}/${1}/page1.html"
TIME=$(curl -s -w "%{time_total}" -o /dev/null --cookie \"${cookie_name}=${token}\" ${target_url})
echo "$TIME"
elif [ "$1" = "context2" ]
then
target_url="https://${domain}/${1}/page2.html"
TIME=$(curl -s -w "%{time_total}" -o /dev/null --cookie \"${cookie_name}=${token}\" ${target_url})
echo "$TIME"
fi
If I launch the script manually i have this
$ /usr/local/bin/cacti/access_page.sh context2
0.061
$ /usr/local/bin/cacti/access_page.sh context1
0.041
When I launch the script with snmpget, I have this result:
snmpwalk -v2c -c myCommunity localhost NET-SNMP-EXTEND-MIB::nsExtendOutput2Table
NET-SNMP-EXTEND-MIB::nsExtendOutLine."stat_page1".1 = STRING: 0.000
NET-SNMP-EXTEND-MIB::nsExtendOutLine."stat_page2".1 = STRING: 0.000
All time, I get 0.000 value by snmp
command and manually a real value.
Could you help me about it?, please
thanks for your reply.
I have tried to add in my script the complete path and I have the same result and I have test with adding an export of path as export PATH=$PATH:/usr/bin/:/bin/, but it the same :( – user3249935 Dec 12 '14 at 16:20