diff --git a/html/includes/edit-host.inc b/html/includes/edit-host.inc index 0b65bede20..f40dbac05c 100644 --- a/html/includes/edit-host.inc +++ b/html/includes/edit-host.inc @@ -1,16 +1,25 @@ 0) { + $update_message = mysql_affected_rows() . " Device record updated."; + $updated = 1; + } elseif ($rows_updated = '-1') { + $update_message = "Device record unchanged. No update necessary."; + $updated = -1; + } else { + $update_message = "Device record update error."; + $updated = 0; + } ?> diff --git a/html/pages/default.php b/html/pages/default.php index 6821c10f78..138aacd460 100644 --- a/html/pages/default.php +++ b/html/pages/default.php @@ -1,7 +1,6 @@ '0' AND `uptime` < '86400'"); +$sql = mysql_query("SELECT * FROM `devices` AS D, `device_uptime` AS U WHERE D.id = U.device_id AND U.device_uptime > '0' AND U.device_uptime < '86400'"); while($device = mysql_fetch_array($sql)){ $rebooted[] = "$device[id]"; } diff --git a/html/pages/device.php b/html/pages/device.php index 2bb13bfcab..020ede3324 100644 --- a/html/pages/device.php +++ b/html/pages/device.php @@ -87,7 +87,7 @@ echo(""); echo("
"); -include("includes/$section.inc"); +include("pages/$page/$section.inc"); echo("
"); diff --git a/html/pages/list.php b/html/pages/list.php index 0537c2d461..fba9bf92bb 100644 --- a/html/pages/list.php +++ b/html/pages/list.php @@ -1,12 +1,10 @@ "); diff --git a/includes/snom-graphing.php b/includes/snom-graphing.php index d728042037..116c27cb11 100644 --- a/includes/snom-graphing.php +++ b/includes/snom-graphing.php @@ -14,8 +14,8 @@ function callsgraphSNOM ($rrd, $graph, $from, $to, $width, $height, $title, $ver "GPRINT:calls:LAST:Cu\: %2.0lf/min", "GPRINT:calls:AVERAGE:Av\: %2.0lf/min", "GPRINT:calls:MAX:Mx\: %2.0lf/min\\n"); - if($width <= "300") {$optsb = array("--font", "LEGEND:7:$installdir/DejaVuSansMono.ttf", - "--font", "AXIS:6:$installdir/DejaVuSansMono.ttf", + if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font", + "--font", "AXIS:6:$mono_font", "--font-render-mode", "normal");} $opts = array_merge($optsa, $optsb); diff --git a/includes/unix-graphing.php b/includes/unix-graphing.php index ccf332c111..a30953d0af 100755 --- a/includes/unix-graphing.php +++ b/includes/unix-graphing.php @@ -585,43 +585,3 @@ function apachebitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, return $imgfile; } } - -function tempgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) -{ - global $rrdtool, $installdir, $mono_font; - $database = "rrd/" . $rrd; - $imgfile = "graphs/" . "$graph"; - - $optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical ,"--alt-autoscale-max", - "-E", "-l 0", "--title", $title, - "DEF:cpu=$database:cputemp:AVERAGE", - "DEF:sys=$database:systemp:AVERAGE", - "LINE1.25:cpu#cc0000:CPU ", - "GPRINT:cpu:LAST:Cur\:%6.2lf", - "GPRINT:cpu:AVERAGE:Avg\: %6.2lf", - "GPRINT:cpu:MIN:Min\:%6.2lf", - "GPRINT:cpu:MAX:Max\:%6.2lf\\n", - "LINE1.25:sys#009900:System ", - "GPRINT:sys:LAST:Cur\:%6.2lf", - "GPRINT:sys:AVERAGE:Avg\: %6.2lf", - "GPRINT:sys:MIN:Min\:%6.2lf", - "GPRINT:sys:MAX:Max\:%6.2lf\\n"); - - if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font", - "--font", "AXIS:6:$mono_font", - "--font-render-mode", "normal");} - - $opts = array_merge($optsa, $optsb); - - - $ret = rrd_graph("$imgfile", $opts, count($opts)); - if( !is_array($ret) ) { - $err = rrd_error(); -# echo "rrd_graph() ERROR: $err\n"; - return FALSE; - } else { - return $imgfile; - } -} - -?> diff --git a/poll-device.php b/poll-device.php index 98315c28e3..ca7746504d 100755 --- a/poll-device.php +++ b/poll-device.php @@ -188,13 +188,7 @@ while ($device = mysql_fetch_array($device_query)) { $update .= $seperator . "`uptime` = '$newuptime'"; $seperator = ", "; } - if ( $newuptime && $newuptime < $uptime ) { - $update .= $seperator . "`lastchange` = NOW()"; - $seperator = ", "; - } elseif($status != $newstatus) { - $update .= $seperator . "`lastchange` = NOW()"; - $seperator = ", "; - } + if( $status != $newstatus ) { $update .= $seperator . "`status` = '$newstatus'"; $seperator = ", "; @@ -206,6 +200,15 @@ while ($device = mysql_fetch_array($device_query)) { } mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('$id', NULL, NOW(), 'Device status changed to $stat')"); } + + if ( $newuptime ) { + $update_uptime = mysql_query("UPDATE device_uptime SET device_uptime = '$newuptime' WHERE `device_id` = '$id'"); + if(mysql_affected_rows() == '0') { + $insert_uptime = mysql_query("INSERT INTO device_uptime (`device_uptime`, `device_id`) VALUES ('$newuptime','$id')"); + } + } + + if ($update) { $update_query = "UPDATE `devices` SET "; $update_query .= $update;