diff options
author | Simon Rettberg | 2017-10-06 18:00:59 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-10-06 18:00:59 +0200 |
commit | 2933768b0dc7d58f0b0ba7f2efcbaf1806eb275b (patch) | |
tree | 487583c2145bd86cd98ced3705f46af455323267 /modules-available/dnbd3/inc/dnbd3rpc.inc.php | |
parent | Allow page modules with digits in name (diff) | |
download | slx-admin-2933768b0dc7d58f0b0ba7f2efcbaf1806eb275b.tar.gz slx-admin-2933768b0dc7d58f0b0ba7f2efcbaf1806eb275b.tar.xz slx-admin-2933768b0dc7d58f0b0ba7f2efcbaf1806eb275b.zip |
[dnbd3] New module for managing dnbd3 servers - WIP
Diffstat (limited to 'modules-available/dnbd3/inc/dnbd3rpc.inc.php')
-rw-r--r-- | modules-available/dnbd3/inc/dnbd3rpc.inc.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/modules-available/dnbd3/inc/dnbd3rpc.inc.php b/modules-available/dnbd3/inc/dnbd3rpc.inc.php new file mode 100644 index 00000000..41dcefd4 --- /dev/null +++ b/modules-available/dnbd3/inc/dnbd3rpc.inc.php @@ -0,0 +1,33 @@ +<?php + +class Dnbd3Rpc { + + /** + * Query given DNBD3 server for status information. + * + * @param bool $stats include general stats + * @param bool $clients include client list + * @param bool $images include image list + * @param string $server server address + * @param int $port server port + * @return false|array the queried data as an array, or false on error + */ + public static function query($stats, $clients, $images, $server, $port = 5003) + { + $url = 'http://' . $server . ':' . $port . '/query?'; + if ($stats) { + $url .= 'q=stats&'; + } + if ($clients) { + $url .= 'q=clients&'; + } + if ($images) { + $url .= 'q=images&'; + } + $str = Download::asString($url, 3, $code); + if ($str === false || $code !== 200) + return false; + return json_decode($str, true); + } + +} |