Skip to content

Commit

Permalink
Added perfdata
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan T. Bein committed Jun 2, 2017
1 parent 6f55582 commit d36991e
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions check_hydra.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import sys
import getopt

# constants
ledMaxHD = {'blue': 23137, 'uv': 8577, 'cool_white': 32272, 'royal': 33350, 'deep_red': 6950, 'green': 8769, 'violet': 8654}
ledMaxNo = {'blue': 19975, 'uv': 7270, 'cool_white': 23592, 'royal': 23888, 'deep_red': 3768, 'green': 4190, 'violet': 7317}

# variables
host = ''
mode = ''
Expand All @@ -18,18 +22,29 @@
else:
print("Usage: %s -h host -m mode" % sys.argv[0])

if mode == 'power':
ledMaxHD = {'blue': 23137, 'uv': 8577, 'cool_white': 32272, 'royal': 33350, 'deep_red': 6950, 'green': 8769, 'violet': 8654}
ledMaxNo = {'blue': 19975, 'uv': 7270, 'cool_white': 23592, 'royal': 23888, 'deep_red': 3768, 'green': 4190, 'violet': 7317}

if mode == 'leds':
ledNowReq = requests.get("http://" + host + "/api/colors")
ledNowVal = json.loads(ledNowReq.text)

leds = ",".join(["=".join([key, str(val*1.0/10)]) for key, val in ledNowVal.items()])

print("OK - LED's: " + leds + "|" + leds)
sys.exit(0)

elif mode == 'power':
ledNowReq = requests.get("http://" + host + "/api/colors")
ledNowVal = json.loads(ledNowReq.text)

wattsByLed = {}
watts = 0.0
for key, value in ledMaxNo.iteritems():
watts = watts + (value/100 * ledNowVal[key]/10)
wattsByLed[key] = (value/100 * ledNowVal[key]/10)
watts = watts + wattsByLed[key]

print(watts/1000)
perfWattsByLed = ",".join(["=".join([key, str(val*1.0/1000)]) for key, val in wattsByLed.items()])

print("OK - "+str(watts/1000)+" Watt's are in use. | watt=" + str(watts/1000) + "," + perfWattsByLed)
sys.exit(0)
else:
print("Modes are: leds, power")
print("UNKNOWN - Mode's are: leds, power")
sys.exit(3)

0 comments on commit d36991e

Please sign in to comment.