├── README.md ├── lgpl-3.0.txt ├── offline ├── config.php.feral ├── config.php.inc ├── fs └── getservers.php └── web ├── css └── style.css ├── functions.php └── index.php /README.md: -------------------------------------------------------------------------------- 1 | # Pinger script from https://thehawken.org/fs 2 | 3 | ## Setup 4 | This system runs with some files in a web directory and some files outside of the web directory. You will find web/config.php.inc which has to be configured and renamed to config.php. After this, you will find offline/getservers.php and offline/fs. Both have to be configured to reflect what you decided in config.php. Afterwards, the fs script has to be added to your crontab: 5 | ``` 6 | */5 * * * * www-data bash /offline/path/fs 7 | ``` 8 | This will make it run every 5 minutes. 9 | If it doesn't work, I'm 90% sure you can blame file permissions. Make sure the user used by your webserver matches crontab, and make sure example.status is writable and accessible. 10 | 11 | ### Dependencies 12 | * php5-cli 13 | * web server with php 14 | * fping 15 | * bash 16 | 17 | You might also need to mess with PHPs permissions in order to get it to read files outside of your web directory. Generally found in /etc/php5 18 | 19 | 20 | ## Files 21 | 22 | ### fs 23 | Script that is run at some interval from crontab. Fetches list of servers using getservers.php pings them with fping. 24 | ### functions.php 25 | Functions used from index.php: gradient, parse and read the ping result file 26 | ### getservers.php 27 | Creates a list of servers to ping, suitable for bash scripting. Limited to local invocation, but not foolproof. 28 | ### config.php 29 | $config and $tags array that contains the configuration, and server list 30 | ### index.php 31 | Main page, depends on tags.php and functions.php 32 | ### css/style.css 33 | Stylesheet used to create the fancy design 34 | -------------------------------------------------------------------------------- /lgpl-3.0.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /offline/config.php.feral: -------------------------------------------------------------------------------- 1 | . */ 14 | 15 | $config = array( 16 | // $1 of this function (.*?) is used to fetch the human readable server name, 17 | // as well as filtering the pingable servers from the other infrastructure 18 | 'shorten_regex' => '/^(.*?)\.feralhosting\.com$/', 19 | 20 | // File with the fping stats 21 | 'cur_file' => '/offline/path/pinger.status', 22 | 'lock_file' => '/offline/path/pinger.lock', 23 | 24 | 'location' => 'City?', 25 | 'route' => 'cogent/amsix/whatever', 26 | 'ISP' => 'Service Provider AS', 27 | // it's you! 28 | 'responsible_person' => '', 29 | ); 30 | 31 | /* Information given by Feralhosting */ 32 | $tags = array( 33 | "FR/OVH-RBX5/S45/F11" => array( 34 | "maroon.feralhosting.com", 35 | ), 36 | "R01B01" => array( 37 | "gaia.feralhosting.com", 38 | "hypnos.feralhosting.com", 39 | "morpheus.feralhosting.com", 40 | "nesoi.feralhosting.com", 41 | "helios.feralhosting.com", 42 | "eurynome.feralhosting.com", 43 | "theia.feralhosting.com", 44 | "eurybia.feralhosting.com" 45 | ), 46 | "R01B02" => array( 47 | "chapterhouse.feralhosting.com", 48 | "asteria.feralhosting.com", 49 | "nyx.feralhosting.com", 50 | "uranus.feralhosting.com", 51 | "hemera.feralhosting.com", 52 | "ourea.feralhosting.com", 53 | "eos.feralhosting.com", 54 | "coeus.feralhosting.com", 55 | "crius.feralhosting.com" 56 | ), 57 | "R01B03" => array( 58 | "moo-moo-moo", 59 | "chirp-chirp-chirp", 60 | "hoot-hoot-hoot", 61 | "quack-quack-quack", 62 | "bzzz-bzzz-bzzz", 63 | "miaow-miaow-miaow", 64 | ), 65 | "R01B04" => array( 66 | "pontus.feralhosting.com", 67 | "iapetus.feralhosting.com", 68 | "thanatos.feralhosting.com", 69 | "tartarus.feralhosting.com", 70 | "atlas.feralhosting.com", 71 | "astraeus.feralhosting.com", 72 | "themis.feralhosting.com", 73 | "aura.feralhosting.com" 74 | ), 75 | "R01B05" => array( 76 | "leto.feralhosting.com", 77 | "asia.feralhosting.com", 78 | "metis.feralhosting.com", 79 | "ophion.feralhosting.com", 80 | "pallas.feralhosting.com", 81 | "perses.feralhosting.com", 82 | "prometheus.feralhosting.com", 83 | "selene.feralhosting.com" 84 | ), 85 | "R01B06" => array( 86 | "lion.feralhosting.com", 87 | "nemesis.feralhosting.com", 88 | "mimas.feralhosting.com", 89 | "gration.feralhosting.com", 90 | "lelantos.feralhosting.com", 91 | "clytius.feralhosting.com", 92 | "eurytus.feralhosting.com", 93 | "hippolytus.feralhosting.com" 94 | ), 95 | "R01B07" => array( 96 | "porphyrion.feralhosting.com", 97 | "thoon.feralhosting.com", 98 | "anax.feralhosting.com", 99 | "antiphates.feralhosting.com", 100 | "argus.feralhosting.com", 101 | "cacus.feralhosting.com", 102 | "arges.feralhosting.com", 103 | "brontes.feralhosting.com" 104 | ), 105 | "R02B01" => array( 106 | "demeter.feralhosting.com", 107 | "artemis.feralhosting.com", 108 | "aphrodite.feralhosting.com", 109 | "hermes.feralhosting.com", 110 | "hera.feralhosting.com", 111 | "athena.feralhosting.com", 112 | "hades.feralhosting.com", 113 | "hestia.feralhosting.com" 114 | ), 115 | "R02B02" => array( 116 | "clymene.feralhosting.com", 117 | "epimetheus.feralhosting.com", 118 | "dione.feralhosting.com", 119 | "aether.feralhosting.com", 120 | "zeus.feralhosting.com", 121 | "rhea.feralhosting.com", 122 | "ananke.feralhosting.com" 123 | ), 124 | "R02B03" => array( 125 | "gobble-gobble-gobble", 126 | "junction.feralhosting.com", 127 | "cronus.feralhosting.com", 128 | "thalassa.feralhosting.com", 129 | "hyperion.feralhosting.com", 130 | "phanes.feralhosting.com", 131 | "poseidon.feralhosting.com", 132 | "apollo.feralhosting.com", 133 | "dionysus.feralhosting.com", 134 | "ares.feralhosting.com" 135 | ), 136 | "R02B04" => array( 137 | "mnemosyne.feralhosting.com", 138 | "oceanus.feralhosting.com", 139 | "phoebe.feralhosting.com", 140 | "tethys.feralhosting.com", 141 | "chaos.feralhosting.com", 142 | "chronos.feralhosting.com", 143 | "erebus.feralhosting.com", 144 | "eros.feralhosting.com" 145 | ), 146 | "R02B05" => array( 147 | "styx.feralhosting.com", 148 | "cottus.feralhosting.com", 149 | "gyges.feralhosting.com", 150 | "agrius.feralhosting.com", 151 | "aloadae.feralhosting.com", 152 | "otos.feralhosting.com", 153 | "antaeus.feralhosting.com", 154 | ), 155 | "R02B06" => array( 156 | "hephaestus.feralhosting.com", 157 | "menoetius.feralhosting.com", 158 | "alcyoneus.feralhosting.com", 159 | "chthonius.feralhosting.com", 160 | "enceladus.feralhosting.com", 161 | "ephialtes.feralhosting.com", 162 | "eurymedon.feralhosting.com", 163 | "polybotes.feralhosting.com", 164 | ), 165 | "R02B07" => array( 166 | "thoas.feralhosting.com", 167 | "steropes.feralhosting.com", 168 | "polyphemus.feralhosting.com", 169 | "gegenees.feralhosting.com", 170 | "geryon.feralhosting.com", 171 | "briareus.feralhosting.com", 172 | "aigaion.feralhosting.com", 173 | "orion.feralhosting.com" 174 | ), 175 | ); 176 | 177 | $other = array( 178 | ); 179 | 180 | $staticdns = array( 181 | "miaow-miaow-miaow" => "185.21.216.129" 182 | ); 183 | -------------------------------------------------------------------------------- /offline/config.php.inc: -------------------------------------------------------------------------------- 1 | . */ 14 | 15 | $config = array( 16 | // $1 of this function (.*?) is used to fetch the human readable server name, 17 | // as well as filtering the pingable servers from the other infrastructure 18 | 'shorten_regex' => '/^(.*?)\.example\.com$/', 19 | 20 | // File of the ping statistics 21 | 'cur_file' => '/offline/path/pinger.status', 22 | // Lock file 23 | 'lock_file' => '/offline/path/pinger.lock', 24 | 25 | 26 | 'location' => 'City?', 27 | 'route' => 'cogent/amsix/whatever', 28 | 'ISP' => 'Service Provider AS', 29 | // Yes, it's you! 30 | 'responsible_person' => '', 31 | ); 32 | 33 | $tags = array( 34 | "Rack location/Rackname" => array( 35 | 'some-unpingable-switch', 36 | 'pingableserver.example.com', 37 | 'upordown.example.com', 38 | 'www.example.com', 39 | ), 40 | "AnotherRack" => array( 41 | 'another.example.com', 42 | 'another-switch', 43 | ), 44 | ); 45 | 46 | $other = array( 47 | ); 48 | 49 | $staticdns = array( 50 | "hostname" => "ipv4" 51 | ); 52 | -------------------------------------------------------------------------------- /offline/fs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This program is free software: you can redistribute it and/or modify 3 | # it under the terms of the GNU Lesser General Public License as published by 4 | # the Free Software Foundation, either version 3 of the License, or 5 | # (at your option) any later version. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU Lesser General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU Lesser General Public License 13 | # along with this program. If not, see . 14 | 15 | # Just to make sure you can launch it from anywhere you like 16 | cd /offline/path 17 | 18 | FILE=pinger.status 19 | LOCK=pinger.lock 20 | 21 | export SERVERS="$(php getservers.php)" 22 | 23 | date > status.new 24 | # See the fping manpage to tweak these. Encouraged to make it finish within one minute 25 | ((fping $SERVERS -c 100 -p 500 -i 5 -q) 2>&1) >> status.new 26 | date >> status.new 27 | 28 | while test -e "$LOCK"; do 29 | sleep 0.1 30 | done 31 | 32 | touch "$LOCK" 33 | cp status.new "$FILE" 34 | rm "$LOCK" 35 | -------------------------------------------------------------------------------- /offline/getservers.php: -------------------------------------------------------------------------------- 1 | . */ 14 | 15 | 16 | // Run this outside of your web root for maximum security 17 | require_once '/offline/path/config.php'; 18 | 19 | function addit($server) { 20 | global $out; 21 | global $staticdns; 22 | global $config; 23 | 24 | if(isset($staticdns[$server])) { 25 | $out[] = $staticdns[$server]; 26 | } else if(preg_match($config['shorten_regex'], $server)) { 27 | $out[] = $server; 28 | } 29 | } 30 | 31 | $out = array(); 32 | foreach($tags as $rack) 33 | foreach($rack as $server) 34 | addit($server); 35 | foreach($other as $server) 36 | addit($server); 37 | 38 | 39 | echo implode(" ", $out)."\n"; 40 | -------------------------------------------------------------------------------- /web/css/style.css: -------------------------------------------------------------------------------- 1 | /* This program is free software: you can redistribute it and/or modify 2 | * it under the terms of the GNU Lesser General Public License as published by 3 | * the Free Software Foundation, either version 3 of the License, or 4 | * (at your option) any later version. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU Lesser General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU Lesser General Public License 12 | * along with this program. If not, see . */ 13 | 14 | html, body, .container 15 | { 16 | height: 100%; 17 | min-height: 100%; 18 | font-family: Sans-Serif; 19 | } 20 | 21 | .bigbox { 22 | float: left; 23 | width: 420px; 24 | height: 250px; 25 | background-color: #eee; 26 | text-align: center; 27 | padding: 10px; 28 | margin: 5px; 29 | border-radius: 5px; 30 | } 31 | 32 | /* For space efficiency in dumb mode :D */ 33 | .bigthinbox { 34 | float: left; 35 | width: 195px; 36 | height: 260px; 37 | background-color: #eee; 38 | text-align: center; 39 | padding: 10px; 40 | margin: 5px; 41 | border-radius: 5px; 42 | } 43 | 44 | .box { 45 | float: left; 46 | padding: 2px; 47 | margin: 1px; 48 | border-radius: 5px; 49 | } 50 | 51 | /* Passive entries with detail */ 52 | .borderedbox { 53 | border: 1px solid #888; 54 | width: 198px; 55 | height: 36px; 56 | } 57 | 58 | /* Passive entries without detailed info */ 59 | .borderedtinybox { 60 | border: 1px solid #888; 61 | width: 188px; 62 | height: 16px; 63 | } 64 | 65 | .highbox { 66 | height: 80px; 67 | } 68 | 69 | /* For active entries with detailed info */ 70 | .smallbox { 71 | width: 200px; 72 | height: 40px; 73 | } 74 | 75 | /* For active entries without extra info */ 76 | .tinybox { 77 | width: 190px; 78 | height: 18px; 79 | } 80 | 81 | table,td,tr { 82 | border: 1px solid #888888; 83 | border-collapse: collapse; 84 | padding: 2px; 85 | } 86 | -------------------------------------------------------------------------------- /web/functions.php: -------------------------------------------------------------------------------- 1 | . */ 14 | 15 | require_once '/offline/path/config.php'; 16 | 17 | function preprocess($name) { 18 | global $config; 19 | if(preg_match($config['shorten_regex'], $name, $m)) 20 | return $m[1]; 21 | return $name; 22 | } 23 | 24 | function draw_server($name, $stats, $dumb=false) { 25 | $name = preprocess($name); 26 | $tag = ""; 27 | $text = ""; 28 | 29 | if($stats === null){ 30 | if($dumb) { 31 | $tag = "class=\"box borderedtinybox\""; 32 | } else { 33 | $tag = "class=\"box borderedbox\""; 34 | } 35 | } else { 36 | 37 | 38 | if(!$dumb) { 39 | $tag = "class=\"box smallbox\" "; 40 | $sent = intval($stats['tx']); 41 | $received = intval($stats['rx']); 42 | $loss = 100 - $received*100./$sent; 43 | $min = $stats['min']; 44 | $avg = $stats['avg']; 45 | $max = $stats['max']; 46 | $text = "
$loss%/$min/$avg/$max"; 47 | } else { 48 | $tag = "class=\"box tinybox\" "; 49 | } 50 | $tag .= ' style="background-color: '.gradient(intval($stats['loss'])).'"'; 51 | } 52 | 53 | echo "\t
$name$text
\n"; 54 | } 55 | 56 | // This hasn't been touched in years (2013?), pretty dusty function... 57 | // Builds on the principle of best compromise... 58 | function gradient($perc){ 59 | // 0 #00ff00 60 | // 50 #ffff00 61 | // 100 #ff0000 62 | /*if($perc==1) $perc=10; 63 | else if($perc==2) $perc=20; 64 | else if($perc==3) $perc=30; 65 | else if($perc>0 && $perc<50) $perc=50; 66 | else if($perc<90 && $perc>80) $perc=80; 67 | else if($perc<100 && $perc>90) $perc=90; */ 68 | 69 | if($perc<=50) 70 | $red = 2.55*$perc*2; 71 | else 72 | $red = 255; 73 | 74 | if($perc<=50) 75 | $green = 255; 76 | else 77 | $green = (100-$perc)*2*2.55; 78 | 79 | $blue = 80; 80 | 81 | $red = round($red); $green = round($green); $blue = round($blue); 82 | 83 | $red = dechex($red); $red = str_repeat("0",2-strlen($red)).$red; 84 | $green = dechex($green); $green = str_repeat("0",2-strlen($green)).$green; 85 | $blue = dechex($blue); $blue = str_repeat("0",2-strlen($blue)).$blue; 86 | 87 | return "#$red$green$blue"; 88 | } 89 | 90 | // read.. and.. parse.. the file..! 91 | function parse_read_file($fname, $lname) { 92 | $ret = array(); 93 | while(file_exists($lname)) 94 | sleep(1); 95 | $lines = explode("\n",trim(file_get_contents($fname),"\n")); 96 | $ret['start'] = array_shift($lines); 97 | $ret['stop'] = array_pop($lines); 98 | $ret['servers'] = parse_fping($lines); 99 | return $ret; 100 | } 101 | 102 | function parse_fping($lines) { 103 | global $config; 104 | $servers = array(); 105 | foreach($lines as $l){ 106 | if(!preg_match('/^([a-z0-9\.]+) +: xmt\/rcv\/%loss = ([0-9]+)\/([0-9]+)\/([0-9]+)%(, min\/avg\/max = ([0-9\.]+)\/([0-9\.]+)\/([0-9\.]+))?$/', $l, $m)){ 107 | echo "Poke ".$config['responsible_person']." with this:
".$l."

\n"; 108 | continue; 109 | } 110 | $s = $m[1]; 111 | if(isset($m[7])) { 112 | $servers[$s] = array( 113 | 'tx' => $m[2], 114 | 'rx' => $m[3], 115 | 'loss' => $m[4], 116 | 'min' => $m[6], 117 | 'avg' => $m[7], 118 | 'max' => $m[8], 119 | ); 120 | } else { 121 | $servers[$s] = array( 122 | 'tx' => $m[2], 123 | 'rx' => $m[3], 124 | 'loss' => $m[4], 125 | 'min' => '?', 126 | 'avg' => '?', 127 | 'max' => '?', 128 | ); 129 | } 130 | } 131 | return $servers; 132 | } 133 | -------------------------------------------------------------------------------- /web/index.php: -------------------------------------------------------------------------------- 1 | . */ 14 | 15 | require_once '/offline/path/config.php'; 16 | require_once 'functions.php'; 17 | 18 | extract(parse_read_file($config['cur_file'], $config['lock_file'])); 19 | 20 | $short = isset($_REQUEST['s']) ? $_REQUEST['s'] == true : false; 21 | 22 | ?> 23 | 24 | 25 | 26 | 27 | 28 | 29 | \n"; 32 | echo "\t
Legend: Server name
\n"; 33 | echo "\t
Location: ".$config['location']."
\n"; 34 | echo "\t
Route: ".$config['route']."
\n"; 35 | echo "\t
ISP: ".$config['ISP']."
\n"; 36 | echo "\t
Start: ".$start."
\n"; 37 | echo "\t
Stop: ".$stop."
\n"; 38 | echo "\t\n"; 39 | echo "\t\n"; 40 | echo "\n"; 41 | } else { 42 | echo "
\n"; 43 | echo "\t
Legend
Server name
loss%/min/avg/max
(latency in ms)
\n"; 44 | echo "\t
Location
".$config['location']."
\n"; 45 | echo "\t
Route
".$config['route']."
\n"; 46 | echo "\t
ISP
".$config['ISP']."
\n"; 47 | echo "\t
Start: ".$start."
\n"; 48 | echo "\t
Stop: ".$stop."
\n"; 49 | echo "\t\n"; 50 | echo "\t
Source code on Github
\n"; 51 | echo "
\n"; 52 | } 53 | foreach($tags as $rack=>$info){ 54 | if($short) { 55 | echo "
\n"; 56 | } else { 57 | echo "
\n"; 58 | } 59 | echo "\t
$rack
\n"; 60 | foreach($info as $srv){ 61 | if(isset($staticdns[$srv])) { 62 | $lookup = $staticdns[$srv]; 63 | } else { 64 | $lookup = $srv; 65 | } 66 | 67 | if(isset($servers[$lookup])) { 68 | $stats = $servers[$lookup]; 69 | unset($servers[$lookup]); 70 | } else 71 | $stats = null; 72 | 73 | draw_server($srv, $stats, $short); 74 | } 75 | echo "
\n"; 76 | } 77 | if(count($servers)) { 78 | if($short) { 79 | echo "
\n"; 80 | } else { 81 | echo "
\n"; 82 | } 83 | echo "\t
Other
\n"; 84 | foreach($servers as $srv=>$stats) { 85 | draw_server($srv, $stats, $short); 86 | } 87 | echo "
\n"; 88 | } 89 | 90 | ?> 91 | --------------------------------------------------------------------------------