From 9c63bb28ddd89bf6ccfd3119aaedf1106f65c421 Mon Sep 17 00:00:00 2001 From: BiloxiGeek Date: Sat, 2 Jul 2016 16:26:38 -0500 Subject: [PATCH] Created Stats monitoring in check_mk_agent (markdown) --- Stats-monitoring-in-check_mk_agent.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Stats-monitoring-in-check_mk_agent.md 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"