cyberpower_status.py #31

Merged
merged 12 commits into from Dec 20, 2012

Projects

None yet

3 participants

@tsuehpsyde

Wrote a plugin to monitor and build metrics for the information provided by the CyberPower UPS family. Used my specific setup as an example, but it should work for all units. Here are the example inputs and the output it provides:

pwrstat -status

The UPS information shows as following:

Properties:
    Model Name................... CP850PFCLCD
    Firmware Number.............. CRDA103-461
    Rating Voltage............... 120 V
    Rating Power................. 510 Watt

Current UPS status:
    State........................ Normal
    Power Supply by.............. Utility Power
    Utility Voltage.............. 123 V
    Output Voltage............... 123 V
    Battery Capacity............. 100 %
    Remaining Runtime............ 21 min.
    Load......................... 122 Watt(24 %)
    Line Interaction............. None
    Test Result.................. Passed at 2011/09/28 18:16:09
    Last Power Event............. None

/usr/lib/cloudkick-agent/plugins/cyberpower_status.py

status ok Our CP850PFCLCD UPS is in a 'Normal' state.
metric Firmware_Number string CRDA103-461
metric Last_Power_Event string None
metric Utility_Voltage int 123
metric Battery_Percentage int 100
metric Rating_Voltage int 120
metric Line_Interaction string None
metric Minutes_Remaining int 21
metric Rating_Wattage int 510
metric State string Normal
metric Output_Voltage int 123
metric Load_Wattage int 122
metric Model_Name string CP850PFCLCD
metric Watt_Percentage int 24
metric Test_Result string Passed at 2011/09/28 18:16:09
metric Power_Supply_by string Utility Power

@Kami Kami commented on an outdated diff Oct 5, 2011
cyberpower_status.py
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+import commands
+import os
+import sys
+
+def getInfo():
+ """
+ Get all pertinent information from our CyberPower UPS
+ """
+
+ # Ensure pwrstat is present. If not, abort.
+ status, out = commands.getstatusoutput('pwrstat -status')
+ if status:
+ msg = "Unable to find PowerPanel software.\n"
@Kami
Kami Oct 5, 2011 Cloudkick member

Ideally, you would print 'status err ' on an error condition. It will make debugging using just the control panel easier.

@tsuehpsyde

I changed all exits to be status err =) Let me know if you have any other feedback!

@fsargent fsargent merged commit defdd24 into cloudkick:master Dec 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment