Skip to content

Commit

Permalink
Merge pull request #15 from PromoFaux/PendingChronometerChanges
Browse files Browse the repository at this point in the history
Pending chronometer.sh changes
  • Loading branch information
jacobsalmela committed Jan 19, 2016
2 parents 6b645d1 + 6685d7b commit 6b89b27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
16 changes: 2 additions & 14 deletions api.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
<?php
$domains_being_blocked = exec("wc -l /etc/pihole/gravity.list | awk '{print $1}'");
$dns_queries_today = exec("cat /var/log/pihole.log | awk '/query/ {print $6}' | wc -l");
$ads_blocked_today = exec("cat /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l");
$ads_percentage_today = $ads_blocked_today / $dns_queries_today * 100;
$arr = array(
'domains_being_blocked' => $domains_being_blocked,
'dns_queries_today' => $dns_queries_today,
'ads_blocked_today' => $ads_blocked_today,
'ads_percentage_today' => $ads_percentage_today
);

header('Content-type: application/json');
echo json_encode($arr);
<?php
echo exec("/usr/local/bin/chronometer.sh -j");
?>
10 changes: 6 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php
$domains_being_blocked = exec("wc -l /etc/pihole/pihole.3.eventHorizon.txt | awk '{print $1}'");
$dns_queries_today = exec("cat /var/log/pihole.log | awk '/query/ {print $6}' | wc -l");
$ads_blocked_today = exec("cat /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l");
$ads_percentage_today = $ads_blocked_today / $dns_queries_today * 100;
$output = exec('/usr/local/bin/chronometer.sh -j');
$outj = json_decode($output);
$domains_being_blocked = $outj->domains_being_blocked;
$dns_queries_today = $outj->dns_queries_today;
$ads_blocked_today = $outj->ads_blocked_today;
$ads_percentage_today = $outj->ads_percentage_today;
?>
<!DOCTYPE html>
<html>
Expand Down

0 comments on commit 6b89b27

Please sign in to comment.