From b8e3ba656ac6e76f8ecce9530362753b6352adda Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Wed, 6 Jun 2007 09:23:41 +0000 Subject: [PATCH] Lots of pretty things! git-svn-id: http://www.observium.org/svn/observer/trunk@99 61d68cd4-352d-0410-923a-c4978735b2b8 --- discover-cisco-temp.php | 2 +- discover-temperatures.php | 5 +- html/graph.php | 10 +++- html/includes/print-interface-graphs.php | 8 ++-- html/includes/print-menubar.php | 9 ++-- html/includes/print-service.inc | 2 +- html/pages/device/dev-graphs.inc | 9 ++-- html/pages/device/dev-overview.inc | 7 ++- html/pages/iftype.php | 28 ++++-------- includes/functions.php | 2 + includes/graphing.php | 58 +++++++++++++++++++++++- includes/polling/temperatures.inc.php | 13 ++++-- includes/unix-graphing.php | 48 +++++++++++++++++++- poll-device.php | 1 + 14 files changed, 154 insertions(+), 48 deletions(-) diff --git a/discover-cisco-temp.php b/discover-cisco-temp.php index c85315b84..5a6c27b5c 100755 --- a/discover-cisco-temp.php +++ b/discover-cisco-temp.php @@ -5,7 +5,7 @@ include("includes/functions.php"); $device_query = mysql_query("SELECT * FROM `devices` WHERE `os` = 'IOS' AND `status` = '1'"); while ($device = mysql_fetch_array($device_query)) { - $id = $device['id']; + $id = $device['device_id']; $hostname = $device['hostname']; $community = $device['community']; echo("Detecting IOS temperature sensors for $hostname\n"); diff --git a/discover-temperatures.php b/discover-temperatures.php index b5a68b2a1..39f4d157f 100755 --- a/discover-temperatures.php +++ b/discover-temperatures.php @@ -69,14 +69,13 @@ while ($sensor = mysql_fetch_array($query)) { $i = 0; while ($i < count($temp_exists) && !$exists) { $thistemp = $sensor['temp_host'] . " " . $sensor['temp_oid']; - if ($temp_exists[$i] == $thistemp) { $exists = 1; echo("Match!"); } + if ($temp_exists[$i] == $thistemp) { $exists = 1; } $i++; - echo("$temp_exists[$i] == $thistemp \n"); } if(!$exists) { echo("Deleting...\n"); -# mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'"); + mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'"); } diff --git a/html/graph.php b/html/graph.php index eb34be280..a8c9029d4 100644 --- a/html/graph.php +++ b/html/graph.php @@ -58,8 +58,11 @@ case 'uptime': $graph = uptimegraph ($hostname . "-uptime.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); break; + case 'unixfs_dev': + $graph = unixfsgraph_dev ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical); + break; case 'unixfs': - $graph = unixfsgraph ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical); + $graph = unixfsgraph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical); break; case 'calls': $graph = callsgraphSNOM ($hostname . "-data.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); @@ -90,7 +93,10 @@ } break; case 'temp': - $graph = temp_graph ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical); + $graph = temp_graph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical); + break; + case 'dev_temp': + $graph = temp_graph_dev ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical); break; case 'mem': if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "NetBSD" ) { diff --git a/html/includes/print-interface-graphs.php b/html/includes/print-interface-graphs.php index 145e93938..ab752c116 100644 --- a/html/includes/print-interface-graphs.php +++ b/html/includes/print-interface-graphs.php @@ -1,15 +1,15 @@ ', LEFT);\" onmouseout=\"return nd();\"> diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 60f35a805..7e887dc58 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -76,14 +76,14 @@ echo("

  • Locations
  • -
  • Interfaces +
  • Ports
  • - +
  • Temperatures
  • Configuration
  • diff --git a/html/includes/print-service.inc b/html/includes/print-service.inc index 483b77ebd..be042a09f 100644 --- a/html/includes/print-service.inc +++ b/html/includes/print-service.inc @@ -23,7 +23,7 @@ if(!$samehost) { echo(" - " . $service['service_id'] . "."); + "); if($device_id) { if(!$samehost) { diff --git a/html/pages/device/dev-graphs.inc b/html/pages/device/dev-graphs.inc index 7ba210b72..77dce56a2 100644 --- a/html/pages/device/dev-graphs.inc +++ b/html/pages/device/dev-graphs.inc @@ -5,7 +5,6 @@ while($device = mysql_fetch_array($device_query)) { $hostname = $device[hostname]; $bg="#ffffff"; - echo("
    "); switch ($device['os']) { @@ -62,13 +61,13 @@ while($device = mysql_fetch_array($device_query)) { if(mysql_result(mysql_query("SELECT count(storage_id) FROM storage WHERE host_id = '" . $device['device_id'] . "'"),0)) { echo("
    Storage
    "); - $graph_type = "unixfs"; include ("includes/print-device-graph.php"); + $graph_type = "unixfs_dev"; include ("includes/print-device-graph.php"); echo("
    "); } if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '" . $device['device_id'] . "'"),0)) { echo("
    Temperatures
    "); - $graph_type = "temp"; include ("includes/print-device-graph.php"); + $graph_type = "dev_temp"; include ("includes/print-device-graph.php"); echo("
    "); } echo("
    IP Statistics
    "); @@ -124,9 +123,9 @@ while($device = mysql_fetch_array($device_query)) { echo("
    "); $graph_type = "mem"; include ("includes/print-device-graph.php"); echo("
    "); - if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '$device[id]'"),0)) { + if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '" . $device['device_id'] . "'"),0)) { echo("
    Temperatures
    "); - $graph_type = "temp"; include ("includes/print-device-graph.php"); + $graph_type = "dev_temp"; include ("includes/print-device-graph.php"); echo("
    "); } echo("
    IP Statistics
    "); diff --git a/html/pages/device/dev-overview.inc b/html/pages/device/dev-overview.inc index 2191eb966..f52c72dbc 100644 --- a/html/pages/device/dev-overview.inc +++ b/html/pages/device/dev-overview.inc @@ -37,6 +37,7 @@ if(mysql_result(mysql_query("SELECT count(storage_id) from storage WHERE host_id echo("

    Storage

    "); echo(""); $i = '1'; + echo(""); $drives = mysql_query("SELECT * FROM `storage` WHERE host_id = '" . $device['device_id'] . "'"); @@ -46,8 +47,12 @@ if(mysql_result(mysql_query("SELECT count(storage_id) from storage WHERE host_id $perc = $drive['storage_perc']; $total = formatStorage($total); $used = formatStorage($used); + + $store_url = "graph.php?id=" . $drive['storage_id'] . "&type=unixfs&from=$month&to=$now&width=400&height=125"; + $store_popup = "onmouseover=\"return overlib('', LEFT);\" onmouseout=\"return nd();\""; + if($perc > '80') { $drv_class='red'; } else { $drvclass=''; } - echo(""); $i++; } diff --git a/html/pages/iftype.php b/html/pages/iftype.php index f0fc8917e..d5c5d7840 100644 --- a/html/pages/iftype.php +++ b/html/pages/iftype.php @@ -2,33 +2,25 @@ if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; } echo("
    MountpointUsage%Total Used
    " . $drive['hrStorageDescr'] . " + echo("
    " . $drive['hrStorageDescr'] . " " . $perc . "%" . $total . "" . $used . "
    "); -if($_GET['id']) { - $type = $_GET['id']; - $sql = "select *, I.id as iid, I.ifIndex as ifIndex, D.id as did, D.hostname as hostname, I.if as ifname, I.name as ifalias "; - $sql .= "from interfaces as I, devices as D WHERE `name` like '$type: %' AND I.host = D.id ORDER BY I.name"; +if($_GET['type']) { + $type = $_GET['type']; + $sql = "select * from interfaces as I, devices as D WHERE `ifAlias` like '$type: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; $query = mysql_query($sql); while($data = mysql_fetch_array($query)) { $done = "yes"; unset($class); - $iid = $data[iid]; - $ifIndex = $data[ifIndex]; - $did = $data[did]; - $hostname = $data[hostname]; - $up = $data[up]; - $up_admin = $data[up_admin]; - $ifname = fixifname($data[ifname]); - $ifalias = $data[ifalias]; - $ifalias = str_replace($type . ": ", "", $ifalias); - $ifalias = str_replace("[PNI]", "Private", $ifalias); - $ifclass = ifclass($up, $up_admin); + $data['ifAlias'] = str_replace($type . ": ", "", $data['ifAlias']); + $data['ifAlias'] = str_replace("[PNI]", "Private", $data['ifAlias']); + $ifclass = ifclass($data['ifOperStatus'], $data['ifAdminStatus']); if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; } echo(" -
    $ifalias
    - $hostname $ifname
    "); + " . $data['ifAlias'] . "
    + " . $data['hostname'] . " " . $data['ifDescr'] . "
    "); -if(file_exists("rrd/" . $hostname . ".". $ifIndex . ".rrd")) { +if(file_exists("rrd/" . $data['hostname'] . "." . $data['ifIndex'] . ".rrd")) { $graph_type = "bits"; + $iid = $data['interface_id']; include("includes/print-interface-graphs.php"); } diff --git a/includes/functions.php b/includes/functions.php index 2a33f5cd2..99dada22c 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -7,6 +7,8 @@ include("windows.php"); include("procurve.php"); include("snom.php"); include("graphing.php"); +include("print-functions.php"); + function formatStorage($size) { $sizes = Array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'); diff --git a/includes/graphing.php b/includes/graphing.php index 81d6d0b92..c57e9eddd 100644 --- a/includes/graphing.php +++ b/includes/graphing.php @@ -1,6 +1,54 @@