Debian Codegraph @

contrib/munin_plugins/dhcpstats_abs.php

raw symbols SCIP
1 #!/usr/bin/env php
2 <?php
3 error_reporting(E_ALL);
4 ini_set("display_errors", true);
5
6 $ret="";
7 $xml = exec("dhcpd-pools --format x --sort n", $ret);
8 $xml = join($ret);
9
10 $xml = new SimpleXMLElement($xml);
11
12
13 if ($argc>1 && $argv[1]=="autoconf") {
14 echo "yes\n";
15 return;
16 } elseif ($argc>1 && $argv[1]=="config") {
17 $xml2 = $xml->xpath("subnet");
18 echo "graph_title dhcp usage (number of machines)\n";
19 echo "graph_vlabel nb of machines\n";
20 echo "graph_scale no\n";
21 echo "graph_category network\n";
22 foreach ($xml2 as $xml3) {
23 $location = (string) $xml3->location;
24 $range = (string) $xml3->range;
25 echo "$location.label $location ($range)\n";
26 }
27 } else {
28 $xml2 = $xml->xpath("shared-network");
29 foreach ($xml2 as $xml3) {
30 $location = (string) $xml3->location;
31 $used = (int) $xml3->used;
32 $defined = (int) $xml3->defined;
33 $pourcent = ceil($used*10000/$defined)/100;
34 echo "$location.value $used\n";
35 }
36 }
37