Helping to Deliver at Interop, One Flashing Light at a Time!
May 1st, 2008 by Timothy May
Technical Opportunities for increasing the EM7 visibility at Interop.
I have been manning the NOC help desk for the past week and it has been a complete blast working with a world class team of engineers to set-up the “largest Temporary network in the world!”
First you start with the problem.
The problem was how to collect and real-time graph the aggregate inbound and outbound bandwidth from 4 Enterasys core network routers (Enterasys XSR 3250 Routers) on 42” & 52” flat screens used in the NOC at Interop Las Vegas.
In addition, the Director of the Interop NOC got really creative and wanted to represent visual alerting so that it would actually turn-on (activate) a bright blue flashing police light to alert the NOC that we were approaching 75% of our aggregate available show bandwidth (135mbps of a total of 180mbps).
How did we accomplish this feat?
I wrote a custom script to grab this data and massage it into a measurement format that they wanted vs. the original format we collect the information, the Math: (octets – 8bits per octet times the total bandwidth and divided by 1 megabyte, then we do by a minute calculation and then per second calculation.)
Next part was extending the SNMP agent to execute the script whenever the unique OID was polled by EM7.
We had one EM7 dynamic app to collect the bandwidth and another EM7 dynamic application to monitor the bandwidth and turn on the light.
The collection dynamic app is an SNMP collection from EM7, however the dynamic application to alert and activate the light is a EM7 database dynamic application.
Final result was a glorious waste of electrons, that was really really cool to show on the dozens of NOC tours that have blown through the Interop NOC during the past few days!
Here is the PHP Code Snippet:
#!/usr/local/bin/php -c /usr/local/silo/bin/proc/php.ini -q
<?php
ini_set("display_errors", 0);
// this is the array of tables to get data from
$tables = array("stats_2247","stats_2260","stats_2158","stats_2171");
// parse the config file for database params
$SILO_ConfigFile="/etc/silo.conf";
$SILO_array = parse_ini_file($SILO_ConfigFile, true);
$system_host = $SILO_array['CENTRAL']['dbserver'];
$system_user = $SILO_array['CENTRAL']['dbuser'];
$system_password = $SILO_array['CENTRAL']['dbpasswd'];
$system_port = $SILO_array['CENTRAL']['dbport'];
// connect to the database
$link = mysql_connect("$system_host:$system_port",
$system_user,
$system_password);
// set our constants
$database_name = "stats_if_data";
$total_data = 0;
// this is a power database, now lets do that thing you do
$q_2 = "SHOW TABLES FROM $database_name";
$em7_tables = mysql_query($q_2);
// loop through the tables we get back
if ($row2 = mysql_fetch_array($em7_tables)) {
do {
$table_name = $row2[0];
$table_check = in_array($table_name, $tables);
// we found an fstats table
if ($table_check == true) {
// we need to get 2 rows of data, one is the current poll, the other
// is the last poll since this is a counter
$data_q = "SELECT in_octets, out_octets
FROM $database_name.$table_name
ORDER BY date DESC, time
DESC LIMIT 2";
$data_query = mysql_query($data_q);
// we found good data, it is a counter, so we need to loop through the
// last poll to get the previous values
if ($row3 = mysql_fetch_array($data_query)) {
$this_pass=0;
do {
if ($this_pass == 0) {
$new_poll_in = $row3[0];
$new_poll_out = $row3[1];
}
else {
$old_poll_in = $row3[0];
$old_poll_out = $row3[1];
}
$this_pass++;
} while($row3 = mysql_fetch_array($data_query));
// this is a counter so we have to compare the previous pool and this one
$my_in = $new_poll_in – $old_poll_in;
$my_out = $new_poll_out – $old_poll_out;
// here we multiply the octets by 8 and then divide by what a megabyte is to make it mega bytes then we need to divide by 300 seconds
// since our polls are going
$final_data_in = ($my_in*8/1048576)/300;
$final_data_out = ($my_out*8/1048576)/300;
}
// sum it all up
$total_data_in += $final_data_in;
$total_data_out += $final_data_out;
}
} while($row2 = mysql_fetch_array($em7_tables));
}
// we have to echo this out to STDOUT so that Net-SNMP can consume it
echo round($total_data_in)."\n";
echo round($total_data_out)."\n";
?>
Net-SNMP Configuration Directive:
exec .1.3.6.1.4.1.2021.7961.1 Noc_bandwidth /usr/local/bin/php -q /home/totalbandwidth.php
Popularity: 15% [?]
Add comment May 1st, 2008



Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed