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/fastd.php.j2 | |
parent | 892aba103d0b58a888813a42bbb0fb00e852adfd (diff) |
install_monitoring: added ffmyk-influx
Diffstat (limited to 'roles/install_monitoring/templates/ffmyk-influx/fastd.php.j2')
-rw-r--r-- | roles/install_monitoring/templates/ffmyk-influx/fastd.php.j2 | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/roles/install_monitoring/templates/ffmyk-influx/fastd.php.j2 b/roles/install_monitoring/templates/ffmyk-influx/fastd.php.j2 new file mode 100644 index 0000000..985d7d3 --- /dev/null +++ b/roles/install_monitoring/templates/ffmyk-influx/fastd.php.j2 @@ -0,0 +1,35 @@ +<?php +require('func.php'); + +function fastdGetPeers($file) { + if (($sock = socket_create(AF_UNIX, SOCK_STREAM, NULL)) === false) { + echo "socket_create() fehlgeschlagen: Grund: " . socket_strerror(socket_last_error()) . "\n"; + } + + if (($result = socket_connect($sock, $file)) === false) { + echo "socket_connect() fehlgeschlagen.\nGrund: ($result) " . socket_strerror(socket_last_error($sock)) . "\n"; + } + + $json = ""; + #stream_set_timeout($sock, 5); + while ($out = socket_read($sock, 2048)) { + $json .= $out; + } + + $json = json_decode($json); + + $peers = 0; + foreach($json->peers as $peer) { + if($peer->connection != NULL) $peers++; + } + + return $peers; +} + +$fastd_1280 = fastdGetPeers('/run/ffmyk.socket'); + +$data = 'fastdclient,mtu=1280,host={{ ansible_hostname }},type=backend value='.$fastd_1280."\n"; + +sendflux($data); + +?> |