check_openhab.php

Category: nagios
Downloaded: 1155

 

Nagios Plugin to check Things and Items from an Openhab Server

You need to install php-curl

If you find a bug or have a request, write me.

 


Usage:

/usr/bin/php check_openhab.php -H [Openhab Server] -P [Port] -m [mode] -i [Item/ Thing or Group] 
( -u [user] -p [password] -T [Token] -U =unique -mi[numbertype/string] -A [YYYY-mm-dd] [startnumber]-w [Warning] -c [Critical] -s =https -l [label] -gl =group label -C [configfile] -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)) - disabled thing will not counted

Switch or Switch+
= Switch (On - Critical, Off - OK (Item)), Switch+ (Off - Critical, On - OK (Item)) - disabled thing will not counted

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

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

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     = %
Lightsensor = lx (mode number)
every unit  = [unit] (mode number)

or String to find/ not find

-A only number - set Date to calculate average with a startnumber
( -A [YYYY-mm-dd] [startnumber] ) 
-t

only number/contact(+)/state(+) test if thing of an item is ONLINE or OFFLINE

-U

only State+, unique Things

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

-T [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

-C

config file (default=openhab.php) instead of the controller parameters -H, -P, -s, -T (you can specify any file with path)
example:

<?php
$host='192.168.2.216'; # IP or Hostname Openhab Server
$port='8080'; # Openhab Port
$prot='http'; # Value http or https
$token='' # Token
$user='' # User
$password='' # Password
?>


MIT-Lizenz


 

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