diff --git a/Stats-monitoring-in-check_mk_agent.md b/Stats-monitoring-in-check_mk_agent.md new file mode 100644 index 0000000..8e31507 --- /dev/null +++ b/Stats-monitoring-in-check_mk_agent.md @@ -0,0 +1,22 @@ +I've written this extremely simple local check for the check_mk_agent. If you've installed the agent on your Pi-Hole place this into an executable file wherever your check_mk_agent expects to find local plugins. Alternatively this could be installed on any system that has access to the Pi-Hole console, I decided to put it on the Pi-Hole directly. I named mine "mk_pihole_stats.py" but as long as it's in the correct subdirectory and the agent script can execute it it should work just fine. + + #!/usr/bin/python + # Simple (always OK) check_mk local check to track # of ads blocked today. + # Since the console/logs rotate everyday, so will the perf data for this + # service. + + import urllib2 + import json + + # Define your Pi-Hole console address + console = "http://192.168.1.2/admin/" + + try: + url = console + "api.php" + result = urllib2.urlopen(url, timeout = 5).read() + json = json.loads(result) + count = json['ads_blocked_today'] + print "0 PiHole_Ads blocked=" + count + " OK " + count + " ads blocked today." + + except: + print "3 PiHole_Ads Unknown"