Download details

check_openhab check_openhab.php Beliebt Aktualisiert

Informationen
Erstelldatum 28.12.2020
Änderungsdatum 04.05.2021
Version 1.20210422
Dateigröße 4.42 KB
Downloads 108
Lizenz MIT Lizenz external
Preis Donate PayPal

 

Nagios Plugin to check Things and Items from an Openhab Server

You need to install php-curl


/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m State -i mihome:sensor_magnet_aq2:7c49eb17e658:158d00044ee1e9
OK - ONLINE

/usr/bin/php  ./check_openhab.php -H 192.168.2.213 -P 8080 -m Number -i TEMPER01_Batterieladung -mi Battery -w ~75 -c ~50
WARNING - 58.00 % | Battery=58.00

/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m Contact -i WINDOW11_OpenClose
CRITICAL - OPEN

/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m Contact+ -i WINDOW11_OpenClose
OK - OPEN

/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m Number -i TEMPER07_Temperature -mi Temperatur -w 10:15 -c 3:30
WARNING - 9.82 °C | Temperatur=9.82

/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m String+ -mi "Bedeckt" -i WEATHERFORCAST_ForecastHours06_VorhergesagteWetterlage
CRITICAL - Bedeckt

/usr/bin/php ./check_openhab.php -H 192.168.2.216 -T
oh.nagios.En5S2bbp1RPKgGRyTjD9s97YskZm8RkS1Q3uwf89hvAqV6sA8oUGwL985QzIcXafyZCTpxQKRN7w2jF9EH3Hgs
-m state -i deconz:openclosesensor:00212E06A601:00158d00044ee1e9010006 -d

{"statusInfo":{"status":"OFFLINE","statusDetail":"BRIDGE_OFFLINE"},"editable":true,"label":"DOOR02","bridgeUID":
"deconz:deconz:00212E06A612","configuration":
{"lastSeenPolling":1440,"id":"3"},"properties":{"uid":"00:15:8d:00:04:4e:e1:e9-01-0006"},
"UID":"deconz:openclosesensor:00212E06A612:00158d00044ee1e9010006","thingTypeUID":"deconz:openclosesensor","channels":
[{"linkedItems":["DOOR02_OpenClose"],"uid":"deconz:openclosesensor:00212E06A612:00158d00044ee1e9010006:open","id":"open",
"channelTypeUID":"deconz:open",
"itemType":"Contact","kind":"STATE","label":"Open/Close","description":"Open/Close detected",
"defaultTags":[],"properties":{},"configuration":{}},{"linkedItems":[],"uid":"deconz:openclosesensor:00212E06A612:00158d00044ee1e9010006:
last_updated","id":"last_updated","channelTypeUID":"deconz:last_updated","itemType":"DateTime","kind":"STATE","label":
"Last Updated","description":"The date and time when the sensor was last updated.","defaultTags":[],"properties":{},"configuration":{}}]}

CRITICAL - DOOR02 (OFFLINE): BRIDGE_OFFLINE

/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m state+ -i DOOR01,DOOR02 -c 0
CRITICAL - Total: 45 - Online: 44 - Offline: 1 (SWITCH01)

/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m group -i Temperatur -mi temperatur -w 18:21 -c 10:25
CRITICAL - Total: 9 /W: 1 (TEMPER01_Temperature) /C: 2 (TEMPER07_Temperature 27.07°C,TEMPER09_Temperature 28.47°C) | TOTAL= 9;;;; OK=6 WARNING=1 CRITICAL=2

/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m gcontact -i Window
CRITICAL - Total: 11 - Open: 1 (WINDOW08_OpenClose)

/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m gcontact -i Window -gl
CRITICAL - Total: 11 - Open: 1 (WINDOW08)

/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m gswitch+ -i Detector
CRITICAL - Total: 3 - Off: 3 (DETECTOR01_Fire,DETECTOR02_CarbonMonoxide,DETECTOR03_Fire)

/usr/bin/php ./check_openhab.php -H 192.168.2.213 -P 8080 -m Contact+ -i WINDOW01_OpenClose -l WINDOW
CRITICAL - WINDOW: CLOSED
 


 

Usage:

/usr/bin/php check_openhab.php -H [Openhab Server] -P [Port] -m [mode] -i [Item/ Thing or Group] ( -mi[numbertype/string] -w [Warning] -c [Critical] -s =https -l [label] -gl =group label -T [Token] -d =debug -h =help)

 

mode

number + warn crit 
= number value(Item)

Contact or Contact+
= Contact (Open - Critical, Closed - OK (Item)), Contact+ (Closed - Critical, Open - OK (Item))

Switch or Switch+
= Switch (On - Critical, Off - OK (Item)), Switch+ (Off - Critical, On - OK (Item))

State
= Offline - Critical, Online - OK (Thing)

State+
= total of Things Online/ Offline with warning and critcal (-i comma separated don't test things(label))

Date
= Date format: [D.M.Y H:m:s] (Item)

String or String+
= find a string in a item to get OK, or find a String to get Critical

Group
= test a hole group (only numbers)

GContact or GContact+
= test a hole group of Contacts (Open - Critical, Closed - OK (Item)), GContact+ (Closed - Critical, Open - OK (Item))

GSwitch  or GSwitch+
= test a hole group of Switchies (On - Critical, Off - OK (Item)), GSwitch+ (Off - Critical, On - OK (Item))

numbertype Temperatur = °C
Humidity   = %
Pressure   = kPa
Battery    = %
or String to find/ not find

-gl  can be used to print the label of an item instead of the name (Group/GContact/Gcontact+/Gswitch/Gstich+)

Token since openhab 3.0 you can create a token to access the rest api. You can create it in the web interface of openhab

  

Example Critical
and Warning Numbers:
 
-w 10 -c 20 = warning > 10 and critical > 20
-w ~20 -c ~10 = warning < 20 and critical < 10
-c @10:20 = critical ≥ 10 and ≤ 20, (inside the range of {10 .. 20})
-c 10:20 = critical < 10 or > 20, (outside the range of {10 .. 20})
-w 10:20 -c 5:25 = warning < 10 or > 20, (outside the range of {10 .. 20}) and critical < 5 or > 25,(outside the range of {5 .. 25})

 


 

openhab openhab_battery2

Changelog

Version 1.20210422
add -gl group label


Version 1.20210412
add -l label


Version 1.20210405
add GSwitch/GSwitch+
add GContact/GContact+


Version 1.20210402
add Group


1.20210325
update information, if there is no connection 


Version 1.20210203
add State+ (total of Things Online/ Offline with warning and critcal)


Version 1.20210124
minor bugs fixes


Version 1.20210115
add String and String+ to find not, or find a string in a item 


 Version 1.20210113
add Token (possible since openhab 3.0)
debug now with api output 


Version 1.20210112
add Contact+ and Switch+ to change OK/CRITICAL state


Version: 1.20202127
first Release


 

  

Would you like to support me?
Then donate to PayPal...