Crossfire Ping Monitoring Part 3: The Presentation
In part one of this series we set up a ping monitoring script on each of our servers. In part two we covered importing the data to a centralized database.
The number of potential different uses for this information is making my head spin, but in this installment we will focus on spitting it out out in a way which we can gain some basic insights.
<?php $sql_host = ''; $sql_user = ''; $sql_pass = ''; $sql_base = ''; $sql_h = mysql_pconnect($sql_host, $sql_user, $sql_pass); $sql_d = mysql_select_db($sql_base, $sql_h); $now = empty($_GET['time']) ? time() : mysql_real_escape_string($_GET['time']); $intervals = 100; $interval = 300; // 5 minutes $before = $now - $interval; print("<html> <head> <meta http-equiv=\"refresh\" content=\"$interval\"> <title>Crossfire PoC</title> <style type=\"text/css\"> body{background: white; color: black; margin: 10px; padding: 0px; font-family: Arial, sans; font-size: 9pt;} td, th{font-family: Arial, sans; font-size: 8pt; white-space: nowrap;} td{vertical-align: top;} tr.darkrow{background-color: #dddddd;} tr.lightrow{background-color: #eeeeee;} a{text-decoration: none;} h1{margin: 0px 0px 10px 0px; padding: 0px; border-bottom: 1px solid black;} h2{margin: 10px 0px 5px 0px; padding: 0px; border-top: 1px solid black;} </style> </head> <body> <h1>Crossfire Ping Monitoring PoC on <a href=\"http://foxpa.ws/\">foxpa.ws</a></h1> This is a proof-of-concept showing how it is possible to use a group of hosts which constantly ping-monitor each other to visualize connectivity problems and general downtime.<br> Each column is a different host. Each row is a slice of 5 minutes. Each cell contains how that host was seen by every other host in the pool during that time.<br> The monitoring script pings each host 4 times every 5 minutes. If a host does not respond at all it will show up in <span style=\"color: red; font-weight: bolder;\">red</span>. If a host responds to one or more pings it will show up in black. An empty cell means no host reported any problems. <br><br> <a href=\"?time=".($now - ($interval * $intervals))."\">< back</a> • <a href=\"?time=".($now + ($interval * $intervals))."\"> forward ></a> <table> <tr class=\"darkrow\"> <th>Time</th>"); $hosts = array(); $h_result = mysql_query("select * from `hosts` order by `id` desc"); while($h_array = mysql_fetch_array($h_result)) { $hosts["{$h_array['id']}"] = $h_array; print("<th>{$h_array['name']}</th>"); } print("</tr>"); $counter = 0; while($counter < $intervals) { $after = $before + $interval; if($counter % 2) $class = 'dark'; else $class = 'light'; print("<tr class=\"{$class}row\"><th>".date("Md/y H:i", $before).' - '.date("H:i", $after).'</th>'); foreach($hosts as $host) { print("<td>"); $log_result = mysql_query("select * from `logs` where `date` > '$before' and `date` < '$after' and `ip` = '{$host['ip']}'"); while($log_object = mysql_fetch_object($log_result)) { if($log_object->packets == 0){print("<span style=\"color: red; font-weight: bolder;\">");} print('• '.$hosts["{$log_object->host}"]['name']." reports {$log_object->packets} replies."); if($log_object->packets == 0){print("</span>");} print("<br>"); } print("</td>"); } print('</tr>'); $before = $before - $interval; $counter++; } print(" </table> <a href=\"?time=".($now - ($interval * $intervals))."\">< back</a> • <a href=\"?time=".($now + ($interval * $intervals))."\"> forward ></a> <h2>So Can You!</h2> <a href=\"http://foxpa.ws/2013/05/28/crossfire-ping-monitoring-part-1-the-setup/\">Crossfire Ping Monitoring Part 1: The Setup</a><br> <a href=\"http://foxpa.ws/2013/05/28/crossfire-ping-monitoring-part-2-collecting-the-data/\">Crossfire Ping Monitoring Part 2: Collecting the Data</a><br> <a href=\"http://foxpa.ws/2013/05/28/crossfire-ping-monitoring-part-3-the-presentation/\">Crossfire Ping Monitoring Part 3: The Presentation</a> </body> </html>"); ?>
Again, we have a very inefficient (in terms of SQL queries) script and I encourage anyone who is interested to improve upon it.
You can see my live PoC at http://foxpa.ws/crossfire/.
Comments
There are no comments for this item.