mirror of
https://github.com/pi-hole/pi-hole
synced 2024-11-25 17:48:11 +00:00
Updated Stats monitoring in check_mk_agent (markdown)
parent
a831286cbb
commit
6cdcc48e6b
@ -39,6 +39,40 @@ After you reinventory the client where you installed this you should have three
|
||||
After the logs rotated for the first time since I started using this check the ads_blocked_today perf data zero'd out. I'm not quite sure why yet though, check_mk should still see previous values even if current values are zero.
|
||||
Found the problem. The script was returning ads_blocked and queries values with commas "," in them. Check_mk doesn't like that. So I've stripped the comma out of each returned number and it looks much better now.
|
||||
|
||||
Just re-wrote this in perl, only because I'm more comforatable working with perl. There's three modules you'll need to ensure are available for this to work.
|
||||
|
||||
#!/usr/bin/perl
|
||||
use LWP::Simple;
|
||||
use JSON;
|
||||
use Data::Dumper;
|
||||
|
||||
# api output:
|
||||
# {"domains_being_blocked":"104,574","dns_queries_today":"37,188","ads_blocked_today":"708","ads_percentage_today":"1.9" }
|
||||
#
|
||||
# Convert json to perl array:
|
||||
# $VAR1 = {
|
||||
# 'domains_being_blocked' => '104,574',
|
||||
# 'ads_percentage_today' => '1.9',
|
||||
# 'ads_blocked_today' => '716',
|
||||
# 'dns_queries_today' => '37,496'
|
||||
# };
|
||||
|
||||
my $data = get("http://192.168.1.2/admin/api.php");
|
||||
|
||||
$data1 = decode_json $data;
|
||||
|
||||
$pct = $data1->{ads_percentage_today};
|
||||
$blocked = $data1->{ads_blocked_today};
|
||||
$dns = $data1->{dns_queries_today};
|
||||
|
||||
$blocked =~ s/,//g;
|
||||
$dns =~ s/,//g;
|
||||
|
||||
print "0 PiHole_Ads ads_blocked=$blocked OK $blocked ads blocked today\n";
|
||||
print "0 PiHole_Percent ads_percent=$pct OK ${pct}% of dns requests were for ad domains\n";
|
||||
print "0 PiHole_DNS queries=$dns OK $dns DNS queries today\n";
|
||||
|
||||
|
||||
Example graphs:
|
||||
|
||||
![Ads blocked - 1 week](https://github.com/BiloxiGeek/Contributions/blob/master/ads-blocked-1week.png)
|
||||
|
Loading…
Reference in New Issue
Block a user