In addition to the APC PDU’s which you can graph nicely to see the power usage, it is also possible to graph a UPS so you can monitor the UPS with mrtg.
In this case I will be using a APC Smart-UPS VT 40 which supports graphing the battery temperature, battery capacity, input & output frequency, minimum & maximum line voltage and the reason why the UPS switched to battery (see below for a example)
First create your MRTG config dir in /etc/ if it doesn’t exists yet and create a mrtg dir in your www root (in my case /var/www) the name of the UPS I will be monitoring is ‘UPS001′.
trouble@sun:$ sudo mkdir -p /var/www/mrtg/UPS001
Then create the mrtg config file: /etc/mrtg/APC001.cfg and add the following content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
WorkDir: /var/www/mrtg/UPS001 ################################ # Battery temperature ################################ Target[batt-temp]: 1.3.6.1.4.1.318.1.1.1.2.2.2.0&1.3.6.1.4.1.318.1.1.1.2.2.2.0:COMMUNITY@YOUR.APC.IP Directory[batt-temp]: apc_ups MaxBytes[batt-temp]: 100 Title[batt-temp]: APC-UPS Temperature PageTop[batt-temp]: <H1>APC-UPS Temperature</H1> Options[batt-temp]: growright, gauge, nopercent, absolute YLegend[batt-temp]: Temp Legend1[batt-temp]: Temperature Legend2[batt-temp]: . Legend3[batt-temp]: Max value per interval on graph Legend4[batt-temp]: . LegendI[batt-temp]: UPS Battery Temperature LegendO[batt-temp]: . ################################ # Battery capacity ################################ YLegend[batt-cap]: Percent ShortLegend[batt-cap]: % Directory[batt-cap]: apc_ups Legend1[batt-cap]: Battery Capacity Legend2[batt-cap]: Load Legend3[batt-cap]: Max Capacity Legend4[batt-cap]: Max Load LegendI[batt-cap]: Battery Capacity LegendO[batt-cap]: Load WithPeak[batt-cap]: ywm Unscaled[batt-cap]: dwmy MaxBytes[batt-cap]: 110 Options[batt-cap]: growright, gauge, nopercent Title[batt-cap]: APC Battery Capacity & Load Target[batt-cap]: 1.3.6.1.4.1.318.1.1.1.2.2.1.0&1.3.6.1.4.1.318.1.1.1.4.2.3.0:COMMUNITY@YOUR.APC.IP PageTop[batt-cap]: <H1>Battery Capacity & Load</H1> ################################ # Input & output frequency ################################ YLegend[batt-iofreq]: Hertz ShortLegend[batt-iofreq]: Hz Directory[batt-iofreq]: apc_ups Legend1[batt-iofreq]: Input Frequency Legend2[batt-iofreq]: Output Frequency Legend3[batt-iofreq]: Max Input Frequency Legend4[batt-iofreq]: Max Output Frequency LegendI[batt-iofreq]: Input Hz LegendO[batt-iofreq]: Output Hz WithPeak[batt-iofreq]: ywm MaxBytes[batt-iofreq]: 100 Unscaled[batt-iofreq]: dwmy Options[batt-iofreq]: growright, gauge, nopercent Title[batt-iofreq]: APC Input & Output Frequency Target[batt-iofreq]: 1.3.6.1.4.1.318.1.1.1.3.2.4.0&1.3.6.1.4.1.318.1.1.1.4.2.2.0:COMMUNITY@YOUR.APC.IP PageTop[batt-iofreq]: <H1>APC Input & Output Frequency</H1> ################################ # Minimum & Maximum line voltage ################################ YLegend[batt-mimaxline]: Volts AC ShortLegend[batt-mimaxline]: VAC Directory[batt-mimaxline]: apc_ups Legend1[batt-mimaxline]: Minimum Line Voltage Legend2[batt-mimaxline]: Maximum Line Voltage Legend3[batt-mimaxline]: Minimum Line Voltage Legend4[batt-mimaxline]: Maximum Line Voltage LegendI[batt-mimaxline]: Min VAC LegendO[batt-mimaxline]: Max VAC WithPeak[batt-mimaxline]: ywm MaxBytes[batt-mimaxline]: 500 Options[batt-mimaxline]: growright, gauge, nopercent Title[batt-mimaxline]: APC Minimum & Maximum line voltage Target[batt-mimaxline]: 1.3.6.1.4.1.318.1.1.1.3.2.3.0&1.3.6.1.4.1.318.1.1.1.3.2.2.0:COMMUNITY@YOUR.APC.IP PageTop[batt-mimaxline]: <H1>APC Minimum & Maximum line voltage</H1> ################################ # Last-Reason-On-Battery ################################ YLegend[batt-lrob]: Reason ShortLegend[batt-lrob]: Directory[batt-lrob]: apc_ups Legend1[batt-lrob]: Last-Reason-On-Battery Legend2[batt-lrob]: Last-Reason-On-Battery Legend3[batt-lrob]: Last-Reason-On-Battery Legend4[batt-lrob]: Last-Reason-On-Battery LegendI[batt-lrob]: LROB LegendO[batt-lrob]: LROB WithPeak[batt-lrob]: ywm MaxBytes[batt-lrob]: 11 Unscaled[batt-lrob]: dwmy Options[batt-lrob]: growright, gauge, nopercent Title[batt-lrob]: apc_ups Last Reason On Battery Target[batt-lrob]: 1.3.6.1.4.1.318.1.1.1.3.2.5.0&1.3.6.1.4.1.318.1.1.1.3.2.5.0:COMMUNITY@YOUR.APC.IP PageTop[batt-lrob]: <H1>APC Last Reason On Battery</H1> <TABLE> <TR><TD>System:</TD><TD>APC in OXIVOCC</TD></TR> <TR><TD>Maintainer:</TD><TD>operations</TD></TR> <TR><TD VALIGN="top">Description:</TD><TD>LROB Values<BR> 1) No Transfer<BR> 2) High Line Voltage<BR> 3) 40% - 100% Line Power<BR> 4) 0% - 40% Line Power<BR> 5) <5 Sec Shallow Voltage Sag<BR> 6) <5 Sec Deep Voltage Sag<BR> 7) <5 Sec Small Voltage Spike<BR> 8) <5 Sec Large Voltage Spike<BR> 9) UPS Self Test<BR> 10) Significant Voltage Delta</TD></TR> <TR><TD>Resource:</TD><TD>Last Reason On Battery</TD></TR> </TABLE> |
Be sure to change the SNMP community and IP to your settings and the location of your www root if you use some other location.
Now add the following line to your crontab to run mrtg every 5 minutes.
1 |
*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/UPS001.cfg >> /var/log/mrtg/mrtg.log 2>&1 |
Create a index.html in /var/www/mrtg/UPS001:
Now browse to your webserver and you should see the graphs.
Temperature:

APC Minimum & Maximum line voltage:

Last Reason On Battery:

Input & Output Frequency:

Battery Capacity & Load:


