diff options
author | Niklas Yann Wettengel <niyawe@niyawe.de> | 2017-03-20 20:56:39 +0100 |
---|---|---|
committer | Niklas Yann Wettengel <niyawe@niyawe.de> | 2017-03-20 20:56:39 +0100 |
commit | eade06a930c16f5cb08edd454d9e41364edf8103 (patch) | |
tree | 51dde0c60cf6c6486269edaa574efad4ad4d90a1 /roles/install_monitoring/templates/ffmyk-influx/dhcp.php.j2 | |
parent | 892aba103d0b58a888813a42bbb0fb00e852adfd (diff) |
install_monitoring: added ffmyk-influx
Diffstat (limited to 'roles/install_monitoring/templates/ffmyk-influx/dhcp.php.j2')
-rw-r--r-- | roles/install_monitoring/templates/ffmyk-influx/dhcp.php.j2 | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/roles/install_monitoring/templates/ffmyk-influx/dhcp.php.j2 b/roles/install_monitoring/templates/ffmyk-influx/dhcp.php.j2 new file mode 100644 index 0000000..66371ef --- /dev/null +++ b/roles/install_monitoring/templates/ffmyk-influx/dhcp.php.j2 @@ -0,0 +1,23 @@ +<?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); + +?> |