diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index fb3e3f380..695107d73 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -158,13 +158,17 @@ echo('
  • Sensors +
  • Health
    diff --git a/html/index.php b/html/index.php index 8862d3bc3..ba998ab74 100755 --- a/html/index.php +++ b/html/index.php @@ -4,7 +4,7 @@ ini_set('allow_url_fopen', 0); ini_set('display_errors', 0); -#$debug=1; +$debug=1; if($debug) { ini_set('display_errors', 1); ini_set('display_startup_errors', 1); diff --git a/html/pages/device.php b/html/pages/device.php index 2d0dd1e10..093100f7b 100644 --- a/html/pages/device.php +++ b/html/pages/device.php @@ -48,13 +48,14 @@ $health = mysql_result(mysql_query("select count(*) from storage WHERE device_i if($health) { echo('
  • - Health + Health
  • '); } -#$cisco_sensors = mysql_result(mysql_query("SELECT count(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entSensorType != '' AND entSensorType NOT LIKE 'No%'"),0); +### This needs to die, rolled into generic sensors! (still need to implement booleans, tx/rx powers and currents) +#$cisco_sensors = mysql_result(mysql_query("SELECT count(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entSensorType != '' AND entSensorType NOT LIKE 'No%'"),0); #if($cisco_sensors) { # echo('
  • # @@ -104,6 +105,9 @@ if($config['enable_bgp'] && $device['bgpLocalAs']) {
  • '); } +### This probably needs to die? DEATH TO NAGIOS! + + #if(@mysql_result(mysql_query("SELECT count(*) FROM nagios_hosts WHERE address = '".$device['hostname']."'", $nagios_link), 0) > '0') { # echo('
  • # diff --git a/html/pages/device/health/processors.inc.php b/html/pages/device/health/processors.inc.php index 4a6d02f81..2a2433386 100644 --- a/html/pages/device/health/processors.inc.php +++ b/html/pages/device/health/processors.inc.php @@ -10,7 +10,11 @@ $mini_url = $config['base_url'] . "/graph.php?id=".$proc['processor_id']."&type=processor&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4"; - + $text_descr = $proc['processor_descr']; + $text_descr = str_replace("Routing Processor", "RP", $text_descr); + $text_descr = str_replace("Switching Processor", "SP", $text_descr); + $text_descr = str_replace("Sub-Module", "Module ", $text_descr); + $text_descr = str_replace("DFC Card", "DFC", $text_descr); $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; $proc_popup .= "
    "; @@ -24,7 +28,8 @@ } elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; } else { $left_background='9abf5b'; $right_background='bbd392'; } - echo("
    " . $text_descr . " + echo(" + " . $text_descr . " ".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $left_background, (100 - $perc)."%" , "ffffff", $right_background)." diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index 1ef6d1d5f..d7b1bdcd6 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -18,6 +18,8 @@ if(mysql_result(mysql_query("SELECT count(*) from processors WHERE device_id = ' $mini_url = $config['base_url'] . "/graph.php?id=".$proc['processor_id']."&type=processor&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4"; + ## REPLACE THIS SHITTY CODE. IT IS ALSO ELSEWHERE. + $text_descr = $proc['processor_descr']; $text_descr = str_replace("Routing Processor", "RP", $text_descr); $text_descr = str_replace("Switching Processor", "SP", $text_descr); diff --git a/html/pages/sensors.php b/html/pages/health.php similarity index 54% rename from html/pages/sensors.php rename to html/pages/health.php index c346d62ac..8e0f818ad 100644 --- a/html/pages/sensors.php +++ b/html/pages/health.php @@ -1,6 +1,8 @@ "); } - echo(" " . $texttype ."\n"); + echo(" " . $texttype ."\n"); if ($_GET['opta'] == $type) { echo(""); } $sep = ' | '; } @@ -22,13 +24,16 @@ print_optionbar_end(); switch ($_GET['opta']) { + case 'processors': + case 'memory': + case 'storage': case 'temperatures': case 'voltages': case 'fanspeeds': - include('pages/sensors/'.$_GET['opta'].'.php'); + include('pages/health/'.$_GET['opta'].'.inc.php'); break; default: - include('pages/sensors/temperatures.php'); + include('pages/health/temperatures.inc.php'); break; } diff --git a/html/pages/sensors/fanspeeds.php b/html/pages/health/fanspeeds.inc.php similarity index 100% rename from html/pages/sensors/fanspeeds.php rename to html/pages/health/fanspeeds.inc.php diff --git a/html/pages/health/memory.inc.php b/html/pages/health/memory.inc.php new file mode 100644 index 000000000..a4388159b --- /dev/null +++ b/html/pages/health/memory.inc.php @@ -0,0 +1,77 @@ +"); + echo(""); + $i = '1'; + $mempools = mysql_query("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.device_id = M.device_id"); + while($mempool = mysql_fetch_array($mempools)) { + if(devicepermitted($mempool['device_id'])) { + if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + + $proc_url = "?page=device/".$device['device_id']."/health/memory/"; + + $text_descr = $mempool['mempool_descr']; + + $mempool_url = "/device/".$device['device_id']."/health/memory/"; + $mini_url = $config['base_url'] . "/graph.php?id=".$mempool['mempool_id']."&type=mempool&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4"; + + $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; + $mempool_popup .= "
    "; + $mempool_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); + + $perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100); + + if($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; + } elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; + } elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; + } elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; + } else { $left_background='9abf5b'; $right_background='bbd392'; } + + echo(" + + + + + + "); + + + echo(""); + + $i++; + } + } + echo("
    ".generatedevicelink($mempool)."" . $text_descr . " + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free , "ffffff", $right_background)." + ".$perc."%
    "); + + $daily_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$day&to=$now&width=211&height=100"; + $daily_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$day&to=$now&width=400&height=150"; + + $weekly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$week&to=$now&width=211&height=100"; + $weekly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$week&to=$now&width=400&height=150"; + + $monthly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$month&to=$now&width=211&height=100"; + $monthly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$month&to=$now&width=400&height=150"; + + $yearly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$year&to=$now&width=211&height=100"; + $yearly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=$year&to=$now&width=400&height=150"; + + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("
    "); + echo(""); + + +?> + diff --git a/html/pages/health/processors.inc.php b/html/pages/health/processors.inc.php new file mode 100644 index 000000000..744fead04 --- /dev/null +++ b/html/pages/health/processors.inc.php @@ -0,0 +1,78 @@ +"); + echo(""); + $i = '1'; + $procs = mysql_query("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id"); + while($proc = mysql_fetch_array($procs)) { + + if(devicepermitted($proc['device_id'])) { + + $device = $proc; + + $text_descr = $proc['processor_descr']; + $text_descr = str_replace("Routing Processor", "RP", $text_descr); + $text_descr = str_replace("Switching Processor", "SP", $text_descr); + $text_descr = str_replace("Sub-Module", "Module ", $text_descr); + $text_descr = str_replace("DFC Card", "DFC", $text_descr); + + + $proc_url = "?page=device/".$device['device_id']."/health/processors/"; + + $mini_url = $config['base_url'] . "/graph.php?id=".$proc['processor_id']."&type=processor&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4"; + + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + + $perc = round($proc['processor_usage']); + + if($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; + } elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; + } elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; + } elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; + } else { $left_background='9abf5b'; $right_background='bbd392'; } + + echo(" + + + + + + "); + + echo(""); + + $i++; + } + + } + echo("
    ".generatedevicelink($proc)."" . $text_descr . " + ".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $left_background, (100 - $perc)."%" , "ffffff", $right_background)." +
    "); + + $daily_graph = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$day&to=$now&width=211&height=100"; + $daily_url = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$day&to=$now&width=400&height=150"; + + $weekly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$week&to=$now&width=211&height=100"; + $weekly_url = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$week&to=$now&width=400&height=150"; + + $monthly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$month&to=$now&width=211&height=100"; + $monthly_url = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$month&to=$now&width=400&height=150"; + + $yearly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$year&to=$now&width=211&height=100"; + $yearly_url = "graph.php?id=" . $proc['processor_id'] . "&type=processor&from=$year&to=$now&width=400&height=150"; + + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("
    "); + echo(""); + + +?> diff --git a/html/pages/health/storage.inc.php b/html/pages/health/storage.inc.php new file mode 100644 index 000000000..2daef94f8 --- /dev/null +++ b/html/pages/health/storage.inc.php @@ -0,0 +1,81 @@ + + "); + +echo(" + + + + + + "); + +$row = 1; + +while($drive = mysql_fetch_array($query)) { + + if(devicepermitted($drive['device_id'])){ + + $skipdrive = 0; + + if ($drive["os"] == "junos") { + foreach ($config['ignore_junos_os_drives'] as $jdrive) { + if (preg_match($jdrive, $drive["storage_descr"])) { + $skipdrive = 1; + } + } + $drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]); + } + + if ($drive['os'] == "freebsd") { + foreach ($config['ignore_bsd_os_drives'] as $jdrive) { + if (preg_match($jdrive, $drive["storage_descr"])) { + $skipdrive = 1; + } + } + } + + if ($skipdrive) { continue; } + if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + + $perc = round($drive['storage_perc'], 0); + $total = formatStorage($drive['storage_size']); + $free = formatStorage($drive['storage_free']); + $used = formatStorage($drive['storage_used']); + + $store_url = "graph.php?id=" . $drive['storage_id'] . "&type=storage&from=$month&to=$now&width=400&height=125"; + $store_popup = "onmouseover=\"return overlib('', LEFT);\" onmouseout=\"return nd();\""; + + $mini_graph = $config['base_url'] . "/graph.php?id=".$drive['storage_id']."&type=storage&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4"; + + if($perc > '90') { $left_background='c4323f'; $right_background='C96A73'; + } elseif($perc > '75') { $left_background='bf5d5b'; $right_background='d39392'; + } elseif($perc > '50') { $left_background='bf875b'; $right_background='d3ae92'; + } elseif($perc > '25') { $left_background='5b93bf'; $right_background='92b7d3'; + } else { $left_background='9abf5b'; $right_background='bbd392'; } + + + echo(" + + "); + + + $row++; + + } + +} + +echo("
    DeviceStorageUsageUsed
    " . generatedevicelink($drive) . "" . $drive['storage_descr'] . " + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, formatStorage($free), "ffffff", $right_background)." + $perc"."%
    "); + + +?> + diff --git a/html/pages/sensors/temperatures.php b/html/pages/health/temperatures.inc.php similarity index 100% rename from html/pages/sensors/temperatures.php rename to html/pages/health/temperatures.inc.php diff --git a/html/pages/sensors/voltages.php b/html/pages/health/voltages.inc.php similarity index 100% rename from html/pages/sensors/voltages.php rename to html/pages/health/voltages.inc.php