Last active
June 15, 2016 12:45
-
-
Save binarybucks/4ba7e299a011b52ae738725eb92842fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Host "me.owntracks.alr.st" { | |
import "owntracks-host" | |
} | |
object Host "5s.owntracks.alr.st" { | |
import "owntracks-host" | |
} | |
object Host "sm.owntracks.alr.st" { | |
import "owntracks-host" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local icinga2Cmd | |
function otr_init() | |
otr.log("recorder lua hooks starting") | |
icinga2Cmd = io.open("/var/run/icinga2/cmd/icinga2.cmd", "a") | |
end | |
function otr_hook(topic, _type, data) | |
if _type == "location" then | |
local batt = data['batt'] | |
local status = 0; | |
local code = "OK" | |
if batt < 20 then | |
status = 1 | |
code = "WARNING" | |
end | |
if batt < 10 then | |
status = 2 | |
code ="CRITICAL" | |
end | |
local locationOut = "[" .. data['tst'] .. "] PROCESS_SERVICE_CHECK_RESULT;" .. data['tid'] .. ".owntracks.alr.st;location;0;" .. data['addr'] .. "\n" | |
local batteryOut = "[" .. data['tst'] .. "] PROCESS_SERVICE_CHECK_RESULT;" .. data['tid'] .. ".owntracks.alr.st;battery;" .. status .. ";BATTERY " .. code .. " - " .. batt .. "%\n" | |
icinga2Cmd:write(locationOut) | |
icinga2Cmd:write(batteryOut) | |
icinga2Cmd:flush() | |
end | |
end | |
function otr_exit() | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply Service "location" { | |
import "generic-service" | |
check_command = "dummy" | |
vars.dummy_state = 3 | |
vars.dummy_text = "No Passive Check Result Received." | |
assign where host.vars.os == "owntracks" | |
enable_active_checks = false | |
max_check_attempts = 3 | |
retry_interval = 1m | |
check_interval = 12h | |
} | |
apply Service "battery" { | |
import "generic-service" | |
check_command = "dummy" | |
vars.dummy_state = 3 | |
vars.dummy_text = "No Passive Check Result Received." | |
assign where host.vars.os == "owntracks" | |
enable_active_checks = false | |
max_check_attempts = 3 | |
retry_interval = 1m | |
check_interval = 12h | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template Host "owntracks-host" { | |
check_command = "dummy" | |
max_check_attempts = 3 | |
vars.os = "owntracks" | |
vars.dummy_state = 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment