11.1 SNMPD running all but one extend

Status
Not open for further replies.

Evan Richardson

Explorer
Joined
Dec 11, 2015
Messages
76
my /usr/local/etc/snmpd.conf file looks like this:

Code:
extend ntp-client /etc/snmp/ntp-client.sh
extend fbsdnfsserver /etc/snmp/fbsdnfsserver
extend smart /etc/snmp/smart
extend nfs-server /usr/bin/nfsstat
extend ups-nut /etc/snmp/ups-nut.sh

All of these work (via the conf file, adding to auxillary area in gui does nothing), except the UPS-nut. if I run it manually (./ups-nut.sh) as root, it works:
Code:
root@mediastore:/etc/snmp # ./ups-nut.sh
100
592
1320
53.8
48
120
122.0
56

but when I use snmp walk, it doesn't get any output:
Code:
root@mediastore:/etc/snmp # snmpwalk -v2c -c <community> x.x.x.x NET-SNMP-EXTEND-MIB::nsExtendObjects | grep ups-nut
NET-SNMP-EXTEND-MIB::nsExtendCommand."ups-nut" = STRING: /etc/snmp/ups-nut.sh
NET-SNMP-EXTEND-MIB::nsExtendArgs."ups-nut" = STRING:
NET-SNMP-EXTEND-MIB::nsExtendInput."ups-nut" = STRING:
NET-SNMP-EXTEND-MIB::nsExtendCacheTime."ups-nut" = INTEGER: 5
NET-SNMP-EXTEND-MIB::nsExtendExecType."ups-nut" = INTEGER: exec(1)
NET-SNMP-EXTEND-MIB::nsExtendRunType."ups-nut" = INTEGER: run-on-read(1)
NET-SNMP-EXTEND-MIB::nsExtendStorage."ups-nut" = INTEGER: permanent(4)
NET-SNMP-EXTEND-MIB::nsExtendStatus."ups-nut" = INTEGER: active(1)
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."ups-nut" = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."ups-nut" = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutNumLines."ups-nut" = INTEGER: 8
NET-SNMP-EXTEND-MIB::nsExtendResult."ups-nut" = INTEGER: 0
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".1 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".2 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".3 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".4 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".5 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".6 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".7 = STRING: Unknown
NET-SNMP-EXTEND-MIB::nsExtendOutLine."ups-nut".8 = STRING: Unknown

contents of ups-nut:
Code:
UPS_NAME='ups'

PATH=$PATH:/usr/bin:/bin
TMP=$(upsc $UPS_NAME 2>/dev/null)

for value in "battery\.charge: [0-9.]+" "battery\.(runtime\.)?low: [0-9]+" "battery\.runtime: [0-9]+" "battery\.voltage: [0-9.]+" "battery\.voltage\.nominal: [0-9]+" "input\.voltage\.nominal: [0-9.]+" "input\.voltage: [0-9.]+" "ups\.load: [0-9.]+"
do
		OUT=$(echo $TMP | grep -Eo "$value" | awk '{print $2}' | LANG=C sort | head -n 1)
		if [ -n "$OUT" ]; then
				echo $OUT
		else
				echo "Unknown"
		fi
done


AFAICT, snmp is running as root, so why does the .sh file work, but snmpd can't get any results from this one script? for reference, this came from librenms. Thanks!

Also, as a side question, shouldn't the GUI option take "extends"? I tried putting these lines in there, but could not find any file they got put in, and got zero metrics from the scripts. Only when I put them in /usr/local/etc/snmpd.conf did it finally work.
 
D

dlavigne

Guest
Please create a report at bugs.freenas.org and post the issue number here.
 

Kezine

Cadet
Joined
Jul 31, 2016
Messages
1
May be usefull for someone.

The process running the script seems to run with a blank $PATH env variable.
The binary 'upsc' is not located in path used by the script (/usr/bin:/bin)

Replace the line
Code:
PATH=$PATH:/usr/bin:/bin

by
Code:
PATH=$PATH:/usr/bin:/bin:/usr/local/bin


In the ups-nut.sh script.
 
Status
Not open for further replies.
Top