Cacti/OpenWRT: Difference between revisions
From fakedWiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
== Cacti == | |||
'''/usr/share/cacti/resource/scripts/get_iwinfo.sh''' | |||
<pre> | |||
#!/bin/bash | |||
if [ ${#} -ne 3 ]; then | |||
echo "Usage: $0 <host> <community> <interface>" | |||
exit 0 | |||
fi | |||
snmptable -c${2} -v1 ${1} .1.3.6.1.4.1.2021.8 | sed -n "s/.*iwinfo_${3}\ .*${3}\ *0\ *\(.*\)\ *noError/\1/p" | |||
</pre> | |||
== OpenWRT == | |||
*Make sure you have the packages '''bash''', '''iwinfo''' and '''snmpd''' installed | |||
'''/etc/config/snmpd''' | '''/etc/config/snmpd''' | ||
<pre> | <pre> | ||
config exec | config exec | ||
option name iwinfo_wlan0 | option name iwinfo_wlan0 | ||
option prog / | option prog /etc/snmp/iwinfo.sh | ||
option args wlan0 | option args wlan0 | ||
config exec | config exec | ||
option name iwinfo_wlan1 | option name iwinfo_wlan1 | ||
option prog / | option prog /etc/snmp/iwinfo.sh | ||
option args wlan1 | option args wlan1 | ||
</pre> | </pre> | ||
'''/ | '''/etc/snmp/iwinfo.sh''' | ||
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash |
Revision as of 00:13, 11 January 2016
Cacti
/usr/share/cacti/resource/scripts/get_iwinfo.sh
#!/bin/bash if [ ${#} -ne 3 ]; then echo "Usage: $0 <host> <community> <interface>" exit 0 fi snmptable -c${2} -v1 ${1} .1.3.6.1.4.1.2021.8 | sed -n "s/.*iwinfo_${3}\ .*${3}\ *0\ *\(.*\)\ *noError/\1/p"
OpenWRT
- Make sure you have the packages bash, iwinfo and snmpd installed
/etc/config/snmpd
config exec option name iwinfo_wlan0 option prog /etc/snmp/iwinfo.sh option args wlan0 config exec option name iwinfo_wlan1 option prog /etc/snmp/iwinfo.sh option args wlan1
/etc/snmp/iwinfo.sh
#!/bin/bash if [ ${#} -ne 1 ]; then echo "Usage: $0 <interface>" exit 0 fi INFO=`iwinfo ${1} info` CHANNEL=`echo "${INFO}" | sed -n 's/.*Channel:\ \(.*\)\ (.*)/\1/p'` TXPOWER=`echo "${INFO}" | sed -n 's/.*Tx-Power:\ \(.*\)\ dBm.*/\1/p'` SIGNAL=`echo "${INFO}" | sed -n 's/.*Signal:\ -\(.*\)\ dBm\ \ Noise.*/\1/p'` NOISE=`echo "${INFO}" | sed -n 's/.*Noise:\ -\(.*\)\ dBm.*/\1/p'` BITRATE=`echo "${INFO}" | sed -n 's/.*Bit\ Rate:\ \(.*\)\ MBit.*/\1/p'` echo "channel:${CHANNEL} txpower:${TXPOWER} signal:${SIGNAL} noise:${NOISE} bitrate:${BITRATE}" exit 0