I'm running MRTG version 2.10.15 on windows and I'm having a problem with the data not being stored to the log file correctly. The script I made (apcaccess.pl) talks to apcaccess.exe (which is part of apcupsd). The problem output is a counter that only counts up when the UPS is on the battery. I think my problem is in my config file. I included all the relevant parts, I think.
Thanks for any help. Output from my external script 553 0 0 Back-UPS XS 1300 Part of my config ################################################################## # APC Back-UPS XS 1300 Time on battery Target[XS-1300_Onbatt]: `perl apcaccess.pl onbatt` PageTop[XS-1300_Onbatt]: <center><H1>APC Back-UPS XS 1300</center></H1></center> ShortLegend[XS-1300_Onbatt]: Seconds Legend1[XS-1300_Onbatt]: Seconds Legend2[XS-1300_Onbatt]: Legend3[XS-1300_Onbatt]: Maximal 5 Minute Time on Battery Legend4[XS-1300_Onbatt]: LegendI[XS-1300_Onbatt]: Seconds: LegendO[XS-1300_Onbatt]: Options[XS-1300_Onbatt]: growright, nobanner, pngdate, transparent, nopercent, noo #Unscaled[XS-1300_Onbatt]: dwmy MaxBytes1[XS-1300_Onbatt]: 300 MaxBytes2[XS-1300_Onbatt]: 300 #AbsMax[XS-1300_Onbatt]: 1000 Title[XS-1300_Onbatt]: XS-1300 Time on Battery Ylegend[XS-1300_Onbatt]: Seconds snippet from log file 1230945301 533 0 1230945301 0 0 0 0 1230945002 0 0 0 0 1230945000 0 0 0 0 1230944700 0 0 0 0
#!/usr/bin/perl # # # apcaccess.pl Thu 1/1/2009 7:37 PM # # John Liebl <[email protected]> # # Script for apcupsd apcaccess output. # # Usage: apcaccess.pl [option] # # Valid command line options are: # # Load, Battery, and Time # # Each of which will extract the corresponding data from the log file. # One and only one option can be used at a time. # ###################################################################### # Change line to a 1 to debug. $debug=0; $arg = $ARGV[0]; # Default location $_ = `c:\\apcupsd\\bin\\apcaccess.exe`; print "$_\n" if $debug; ################################################ # Will be used to compute uptime. # Output of STARTTIME format "Thu Jan 01 13:54:57 Eastern Standard Time 2009" /STARTTIME:\s(.+)/; print "StartTime = $1\n" if $debug; $stime=$1; # Upime not completed yet $Uptime=0; /MODEL\s+:\s(.+)/; print "Model = $1\n" if $debug; $Model=$1; /LOADPCT\s+:\s+(\d{1,3}.\d)/; print "UPS Load = $1\n" if $debug; $load=$1; /BCHARGE\s+:\s+(\d{1,3}.\d)/; print "Battery Charge = $1\n" if $debug; $charge=$1; /BATTV\s+:\s+(\d{1,3}.\d)/; print "Battery Voltage = $1\n" if $debug; $battery=$1; /LINEV\s+:\s+(\d{1,3}.\d)/; print "Line Voltage = $1\n" if $debug; $line=$1; /TIMELEFT\s+:\s+(\d{1,3}.\d)/; print "Time Left = $1\n" if $debug; $time=$1; /CUMONBATT:\s+(\d+)/; print "Time on battery = $1\n" if $debug; $onbattery=$1; ################################################ # Let's check command line ... if ( $arg =~ /^-?Load$/i ) { $Input = $load; $Output = $charge; } elsif ( $arg =~ /^-?Time$/i ) { $Input = $time; $Output = 0; } elsif ( $arg =~ /^-?Onbatt$/i ) { $Input = $onbattery; $Output = 0; } elsif ( $arg =~ /^-?Voltage$/i ) { $Input = $battery; $Output = $line; } else { print "\nInvalid option specified on command line.\n"; &usage; exit 0; } ################################################ print "\n Debug Input: $Input, Output: $Output\n" if $debug; # Output to MRTG print " $Input\n $Output\n $Uptime\n $Model\n"; sub usage { print "\nValid options are: Load, Voltage, Onbatt, and Time,\n"; } #--- eof apcaccess.pl
signature.asc
Description: OpenPGP digital signature
_______________________________________________ mrtg mailing list [email protected] https://lists.oetiker.ch/cgi-bin/listinfo/mrtg
