You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
567 B
Plaintext
24 lines
567 B
Plaintext
8 years ago
|
<?php
|
||
|
|
||
|
require('func.php');
|
||
|
|
||
|
$data = file_get_contents('/var/lib/dhcp/dhcpd.leases');
|
||
|
|
||
|
preg_match_all('/lease ([\d\.]+) \{[^\}]+ends \d+ (\d{4}\/\d{2}\/\d{2} \d+:\d{2}:\d{2});[^\}]+}/s', $data, $match);
|
||
|
|
||
|
unset($data, $match[0]);
|
||
|
|
||
|
$dend = time()-120;
|
||
|
|
||
|
$clients = 0;
|
||
|
|
||
|
foreach($match[2] as $timeout) {
|
||
|
$end = strtotime($timeout.' UTC');
|
||
|
if($end > $dend) $clients++;
|
||
|
}
|
||
|
|
||
|
$data = 'clients,host={{ ansible_hostname }},type=backend value='.$clients;
|
||
|
sendflux($data);
|
||
|
|
||
|
?>
|