diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 20189f67b..f241c1a9a 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -75,7 +75,7 @@ function generatedevicelink($device, $text=0, $start=0, $end=0) } $text = htmlentities($text); $link = overlib_link($url, $text, $contents, $class); - if(devicepermitted($device['device_id'])) { + if(device_permitted($device['device_id'])) { return $link; } else { return $device['hostname']; @@ -156,13 +156,14 @@ function bill_permitted($bill_id) return $allowed; } -function interfacepermitted($interface_id, $device_id = NULL) +function port_permitted($interface_id, $device_id = NULL) { global $_SESSION; global $permissions; - if(!$device_id) { $device_id = mysql_result(mysql_query("SELECT `device_id` from ports WHERE interface_id = '".$interface_id."'"),0); } + if(!is_numeric($device_id)) { $device_id = get_device_id_by_interface_id($interface_id); } + if ($_SESSION['userlevel'] >= "5") { $allowed = TRUE; - } elseif ( devicepermitted($device_id)) { + } elseif ( device_permitted($device_id)) { $allowed = TRUE; } elseif ( $permissions['port'][$interface_id]) { $allowed = TRUE; @@ -172,7 +173,29 @@ function interfacepermitted($interface_id, $device_id = NULL) return $allowed; } -function devicepermitted($device_id) +function application_permitted($app_id, $device_id = NULL) +{ + global $_SESSION; global $permissions; + if(is_numeric($app_id)) + { + if(!$device_id) { $device_id = device_by_id_cache ($app_id); } + if ($_SESSION['userlevel'] >= "5") { + $allowed = TRUE; + } elseif ( device_permitted($device_id)) { + $allowed = TRUE; + } elseif ( $permissions['application'][$app_id]) { + $allowed = TRUE; + } else { + $allowed = FALSE; + } + } else { + $allowed = FALSE; + } + return $allowed; +} + + +function device_permitted($device_id) { global $_SESSION; global $permissions; if ($_SESSION['userlevel'] >= "5") { @@ -250,7 +273,7 @@ function generate_if_link($args, $text = NULL) $url = $config['base_url']."/device/".$args['device_id']."/interface/" . $args['interface_id'] . "/"; - if(interfacepermitted($args['interface_id'])) { + if(port_permitted($args['interface_id'])) { return overlib_link($url, $text, $content, $class); } else { return fixifName($text); diff --git a/html/includes/graphs/application/apache_bytes.inc.php b/html/includes/graphs/application/apache_bytes.inc.php index fb62e3479..677dece2d 100755 --- a/html/includes/graphs/application/apache_bytes.inc.php +++ b/html/includes/graphs/application/apache_bytes.inc.php @@ -2,12 +2,7 @@ include("includes/graphs/common.inc.php"); -$query = mysql_query("SELECT * FROM `applications` AS A, `devices` AS D WHERE A.app_id = '".mres($_GET['id'])."' - AND A.device_id = D.device_id"); - -$app = mysql_fetch_array($query); - -$apache_rrd = $config['rrd_dir'] . "/" . $app['hostname'] . "/app-apache-".$app['app_id'].".rrd"; +$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; if(is_file($apache_rrd)) { $rrd_filename = $apache_rrd; diff --git a/html/includes/graphs/application/apache_cpu.inc.php b/html/includes/graphs/application/apache_cpu.inc.php index 668baccc6..c41a98378 100755 --- a/html/includes/graphs/application/apache_cpu.inc.php +++ b/html/includes/graphs/application/apache_cpu.inc.php @@ -2,12 +2,7 @@ include("includes/graphs/common.inc.php"); -$query = mysql_query("SELECT * FROM `applications` AS A, `devices` AS D WHERE A.app_id = '".mres($_GET['id'])."' - AND A.device_id = D.device_id"); - -$app = mysql_fetch_array($query); - -$apache_rrd = $config['rrd_dir'] . "/" . $app['hostname'] . "/app-apache-".$app['app_id'].".rrd"; +$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; if(is_file($apache_rrd)) { $rrd_filename = $apache_rrd; diff --git a/html/includes/graphs/application/apache_hits.inc.php b/html/includes/graphs/application/apache_hits.inc.php index f696e0ebc..061caaf3c 100755 --- a/html/includes/graphs/application/apache_hits.inc.php +++ b/html/includes/graphs/application/apache_hits.inc.php @@ -2,12 +2,7 @@ include("includes/graphs/common.inc.php"); -$query = mysql_query("SELECT * FROM `applications` AS A, `devices` AS D WHERE A.app_id = '".mres($_GET['id'])."' - AND A.device_id = D.device_id"); - -$app = mysql_fetch_array($query); - -$apache_rrd = $config['rrd_dir'] . "/" . $app['hostname'] . "/app-apache-".$app['app_id'].".rrd"; +$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; if(is_file($apache_rrd)) { $rrd_filename = $apache_rrd; diff --git a/html/includes/graphs/application/apache_scoreboard.inc.php b/html/includes/graphs/application/apache_scoreboard.inc.php index 89e02e406..70c5733b2 100755 --- a/html/includes/graphs/application/apache_scoreboard.inc.php +++ b/html/includes/graphs/application/apache_scoreboard.inc.php @@ -2,12 +2,7 @@ include("includes/graphs/common.inc.php"); -$query = mysql_query("SELECT * FROM `applications` AS A, `devices` AS D WHERE A.app_id = '".mres($_GET['id'])."' - AND A.device_id = D.device_id"); - -$app = mysql_fetch_array($query); - -$apache_rrd = $config['rrd_dir'] . "/" . $app['hostname'] . "/app-apache-".$app['app_id'].".rrd"; +$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; if(is_file($apache_rrd)) { $rrd_filename = $apache_rrd; diff --git a/html/includes/graphs/application/auth.inc.php b/html/includes/graphs/application/auth.inc.php new file mode 100644 index 000000000..d73038bb6 --- /dev/null +++ b/html/includes/graphs/application/auth.inc.php @@ -0,0 +1,12 @@ + + +if(is_numeric($id) && application_permitted($id)) +{ + $app = get_application_by_id($id); + $device = device_by_id_cache($app['device_id']); + $title = generatedevicelink($device); + $title .= $graph_subtype; + $auth = TRUE; +} + +?> diff --git a/html/includes/graphs/customer/auth.inc.php b/html/includes/graphs/customer/auth.inc.php new file mode 100755 index 000000000..921d689bb --- /dev/null +++ b/html/includes/graphs/customer/auth.inc.php @@ -0,0 +1,10 @@ + + +if ($_SESSION['userlevel'] >= "5") +{ + $id = mres($_GET['id']); + $title = generatedevicelink($device); + $auth = TRUE; +} + +?> diff --git a/html/includes/graphs/device/auth.inc.php b/html/includes/graphs/device/auth.inc.php index 3109b12c2..8fdbe9994 100644 --- a/html/includes/graphs/device/auth.inc.php +++ b/html/includes/graphs/device/auth.inc.php @@ -1,11 +1,10 @@ -if(is_numeric($id)) { +if(is_numeric($id) && device_permitted($id)) +{ $device = device_by_id_cache($id); + $title = generatedevicelink($device); + $auth = TRUE; } -#if(!device_permitted($device['device_id'])) { echo("Not Permitted"); exit; } - -$title = generatedevicelink($device); - ?> diff --git a/html/includes/graphs/diskio/auth.inc.php b/html/includes/graphs/diskio/auth.inc.php new file mode 100644 index 000000000..89bd5d7f8 --- /dev/null +++ b/html/includes/graphs/diskio/auth.inc.php @@ -0,0 +1,24 @@ + diff --git a/html/includes/graphs/diskio/bits.inc.php b/html/includes/graphs/diskio/bits.inc.php index 83aceb370..5b6058f2d 100644 --- a/html/includes/graphs/diskio/bits.inc.php +++ b/html/includes/graphs/diskio/bits.inc.php @@ -1,14 +1,5 @@ ".$rrd_cmd.""); } -# $thing = popen($config['rrdtool'] . " -",'w'); -# fputs($thing, "graph $graphfile $rrd_options"); -# pclose($thing); - if(is_file($graphfile)) { - header('Content-type: image/png'); - $fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd); - unlink($graphfile); - } else { - header('Content-type: image/png'); - $string = "Graph Generation Error"; - $im = imagecreate($width, $height); - $orange = imagecolorallocate($im, 255, 255, 255); - $px = (imagesx($im) - 7.5 * strlen($string)) / 2; - imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0)); - imagepng($im); - imagedestroy($im); + if($config['rrdcached']) { $rrd_switches = " --daemon ".$config['rrdcached'] . " "; } + $rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches; + $woo = shell_exec($rrd_cmd); + if($_GET['debug']) { echo("
".$rrd_cmd.""); } +# $thing = popen($config['rrdtool'] . " -",'w'); +# fputs($thing, "graph $graphfile $rrd_options"); +# pclose($thing); + if(is_file($graphfile)) { + header('Content-type: image/png'); + $fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd); + unlink($graphfile); + } else { + header('Content-type: image/png'); + $string = "Graph Generation Error"; + $im = imagecreate($width, $height); + $orange = imagecolorallocate($im, 255, 255, 255); + $px = (imagesx($im) - 7.5 * strlen($string)) / 2; + imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0)); + imagepng($im); + imagedestroy($im); + } } + } else { + $fd = fopen($config['install_dir']."/html/images/no-48.png",r);fpassthru($fd);fclose($fd); } - ?> diff --git a/html/includes/graphs/mempool/auth.inc.php b/html/includes/graphs/mempool/auth.inc.php new file mode 100755 index 000000000..3a8b7614c --- /dev/null +++ b/html/includes/graphs/mempool/auth.inc.php @@ -0,0 +1,18 @@ + + +if(is_numeric($_GET['id'])) +{ + $sql = mysql_query("SELECT * FROM `mempools` AS C, `devices` AS D where C.`mempool_id` = '".mres($_GET['id'])."' AND C.device_id = D.device_id"); + $mempool = mysql_fetch_assoc($sql); + + if(is_numeric($mempool['device_id']) && device_permitted($mempool['device_id'])) + { + $device = device_by_id_cache($mempool['device_id']); + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("mempool-".$mempool['mempool_type']."-".$mempool['mempool_index'].".rrd"); + $title = generatedevicelink($device); + $title .= " :: Memory Pool :: " . htmlentities($mempool['mempool_descr']); + $auth = TRUE; + } +} + +?> diff --git a/html/includes/graphs/mempool/usage.inc.php b/html/includes/graphs/mempool/usage.inc.php index 1a709bf08..db38b0cfd 100644 --- a/html/includes/graphs/mempool/usage.inc.php +++ b/html/includes/graphs/mempool/usage.inc.php @@ -5,27 +5,23 @@ include("includes/graphs/common.inc.php"); $rrd_options .= " -u 100 -l 0 -E -b 1024 "; $iter = "1"; - $sql = mysql_query("SELECT * FROM `mempools` AS C, `devices` AS D where C.`mempool_id` = '".mres($_GET['id'])."' AND C.device_id = D.device_id"); - $rrd_options .= " COMMENT:' Used\\n'"; - while($mempool = mysql_fetch_array($sql)) { - if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE"; - } elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D"; - } elseif($iter=="7") {$colour="FF0084"; unset($iter); } - $descr = substr(str_pad(short_hrDeviceDescr($mempool['mempool_descr']), 24),0,24); - $descr = str_replace(":", "\:", $descr); - $rrd = $config['rrd_dir'] . "/".$mempool['hostname']."/" . safename("mempool-".$mempool['mempool_type']."-".$mempool['mempool_index'].".rrd"); - $rrd_options .= " DEF:mempoolfree=$rrd:free:AVERAGE "; - $rrd_options .= " DEF:mempoolused=$rrd:used:AVERAGE "; - $rrd_options .= " CDEF:mempooltotal=mempoolused,mempoolfree,+ "; - $rrd_options .= " CDEF:mempoolperc=mempoolused,mempoolused,mempoolfree,+,/,100,* "; - $rrd_options .= " LINE1:mempoolperc#" . $colour . ":'" . $descr . "' "; - $rrd_options .= " GPRINT:mempoolused:LAST:%6.2lf%sB"; - #$rrd_options .= " GPRINT:mempooltotal:LAST:%6.2lf%sB"; - $rrd_options .= " GPRINT:mempoolperc:LAST:%3.0lf%%\\\\n"; - #$rrd_options .= " GPRINT:mempoolperc:MAX:%3.0lf"; - $iter++; - } + $rrd_options .= " COMMENT:' Used\\n'"; + if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE"; + } elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D"; + } elseif($iter=="7") {$colour="FF0084"; unset($iter); } + $descr = substr(str_pad(short_hrDeviceDescr($mempool['mempool_descr']), 24),0,24); + $descr = str_replace(":", "\:", $descr); + + $rrd_options .= " DEF:mempoolfree=$rrd_filename:free:AVERAGE "; + $rrd_options .= " DEF:mempoolused=$rrd_filename:used:AVERAGE "; + $rrd_options .= " CDEF:mempooltotal=mempoolused,mempoolfree,+ "; + $rrd_options .= " CDEF:mempoolperc=mempoolused,mempoolused,mempoolfree,+,/,100,* "; + $rrd_options .= " LINE1:mempoolperc#" . $colour . ":'" . $descr . "' "; + $rrd_options .= " GPRINT:mempoolused:LAST:%6.2lf%sB"; + #$rrd_options .= " GPRINT:mempooltotal:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:mempoolperc:LAST:%3.0lf%%\\\\n"; + #$rrd_options .= " GPRINT:mempoolperc:MAX:%3.0lf"; ?> diff --git a/html/includes/graphs/port/auth.inc.php b/html/includes/graphs/port/auth.inc.php index 3c0751793..13f221032 100644 --- a/html/includes/graphs/port/auth.inc.php +++ b/html/includes/graphs/port/auth.inc.php @@ -1,14 +1,11 @@ -if(is_numeric($_GET['id']) && interfacepermitted($_GET['id'])) { - $port = get_port_by_id($_GET['id']); +if(is_numeric($id) && port_permitted($id)) { + $port = get_port_by_id($id); $device = device_by_id_cache($port['device_id']); - $title = generatedevicelink($device); $title .= " :: Port ".generateiflink($port); - $auth = TRUE; - } ?> diff --git a/html/includes/graphs/processor/auth.inc.php b/html/includes/graphs/processor/auth.inc.php new file mode 100755 index 000000000..0e9df72f1 --- /dev/null +++ b/html/includes/graphs/processor/auth.inc.php @@ -0,0 +1,15 @@ + + +$sql = mysql_query("SELECT * FROM `processors` where `processor_id` = '".mres($_GET['id'])."'"); +$proc = mysql_fetch_assoc($sql); + +if(is_numeric($proc['device_id']) && device_permitted($proc['device_id'])) +{ + $device = device_by_id_cache($proc['device_id']); + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-" . $proc['processor_type'] . "-" . $proc['processor_index'] . ".rrd"); + $title = generatedevicelink($device); + $title .= " :: Processor :: " . htmlentities($proc['processor_descr']); + $auth = TRUE; +} + +?> diff --git a/html/includes/graphs/processor/usage.inc.php b/html/includes/graphs/processor/usage.inc.php index c1179e3aa..9f3291762 100755 --- a/html/includes/graphs/processor/usage.inc.php +++ b/html/includes/graphs/processor/usage.inc.php @@ -1,5 +1,4 @@ diff --git a/html/includes/graphs/sensor/auth.inc.php b/html/includes/graphs/sensor/auth.inc.php index 07c6d7cb1..1fd0d832b 100644 --- a/html/includes/graphs/sensor/auth.inc.php +++ b/html/includes/graphs/sensor/auth.inc.php @@ -1,8 +1,23 @@ diff --git a/html/includes/graphs/sensor/current.inc.php b/html/includes/graphs/sensor/current.inc.php index 8e6ed8ecf..9c7755e63 100644 --- a/html/includes/graphs/sensor/current.inc.php +++ b/html/includes/graphs/sensor/current.inc.php @@ -4,18 +4,14 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("current-" . $sensor['sensor_descr'] . ".rrd"); + $rrd_options .= " COMMENT:' Last Max\\n'"; - $current = mysql_fetch_array(mysql_query("SELECT * FROM sensors WHERE sensor_class='current' AND sensor_id = '".mres($_GET['id'])."'")); - - $hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $current['device_id'] . "'"),0); - - $current['sensor_descr_fixed'] = substr(str_pad($current['sensor_descr'], 28),0,28); - - $rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("current-" . $current['sensor_descr'] . ".rrd"); + $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 28),0,28); $rrd_options .= " DEF:current=$rrd_filename:current:AVERAGE"; - $rrd_options .= " LINE1.5:current#cc0000:'" . $current['sensor_descr_fixed']."'"; + $rrd_options .= " LINE1.5:current#cc0000:'" . $sensor['sensor_descr_fixed']."'"; $rrd_options .= " GPRINT:current:LAST:%3.0lfA"; $rrd_options .= " GPRINT:current:MAX:%3.0lfA\\\\l"; diff --git a/html/includes/graphs/sensor/fanspeed.inc.php b/html/includes/graphs/sensor/fanspeed.inc.php new file mode 100644 index 000000000..982d250f0 --- /dev/null +++ b/html/includes/graphs/sensor/fanspeed.inc.php @@ -0,0 +1,18 @@ + diff --git a/html/includes/graphs/sensor/frequency.inc.php b/html/includes/graphs/sensor/frequency.inc.php index a6ad07fa0..a81e5c83b 100644 --- a/html/includes/graphs/sensor/frequency.inc.php +++ b/html/includes/graphs/sensor/frequency.inc.php @@ -4,18 +4,14 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("freq-" . $sensor['sensor_descr'] . ".rrd"); + $rrd_options .= " COMMENT:' Last Max\\n'"; - $frequency = mysql_fetch_array(mysql_query("SELECT * FROM sensors where sensor_class='freq' AND sensor_id = '".mres($_GET['id'])."'")); - - $hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $frequency['device_id'] . "'"),0); - - $frequency['sensor_descr_fixed'] = substr(str_pad($frequency['sensor_descr'], 28),0,28); - - $rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("freq-" . $frequency['sensor_descr'] . ".rrd"); + $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 28),0,28); $rrd_options .= " DEF:freq=$rrd_filename:freq:AVERAGE"; - $rrd_options .= " LINE1.5:freq#cc0000:'" . $frequency['sensor_descr_fixed']."'"; + $rrd_options .= " LINE1.5:freq#cc0000:'" . $sensor['sensor_descr_fixed']."'"; $rrd_options .= " GPRINT:freq:LAST:%3.0lfHz"; $rrd_options .= " GPRINT:freq:MAX:%3.0lfHz\\\\l"; diff --git a/html/includes/graphs/sensor/humidity.inc.php b/html/includes/graphs/sensor/humidity.inc.php index 512668163..3c6757bbb 100644 --- a/html/includes/graphs/sensor/humidity.inc.php +++ b/html/includes/graphs/sensor/humidity.inc.php @@ -7,29 +7,23 @@ include("includes/graphs/common.inc.php"); $rrd_options .= " COMMENT:' Last Max\\n'"; - $humidity = mysql_fetch_array(mysql_query("SELECT * FROM sensors WHERE sensor_class='humidity' AND sensor_id = '".mres($_GET['id'])."'")); + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("humidity-" . $sensor['sensor_descr'] . ".rrd"); - $hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $humidity['device_id'] . "'"),0); - - $humidity['sensor_descr_fixed'] = substr(str_pad($humidity['sensor_descr'], 28),0,28); - - $rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("humidity-" . $humidity['sensor_descr'] . ".rrd"); + $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 28),0,28); $rrd_options .= " DEF:humidity=$rrd_filename:humidity:AVERAGE"; $rrd_options .= " DEF:humidity_max=$rrd_filename:humidity:MAX"; $rrd_options .= " DEF:humidity_min=$rrd_filename:humidity:MIN"; - $rrd_options .= " CDEF:humiditywarm=humidity_max,".$humidity['sensor_limit'].",GT,humidity,UNKN,IF"; + $rrd_options .= " CDEF:humiditywarm=humidity_max,".$sensor['sensor_limit'].",GT,humidity,UNKN,IF"; $rrd_options .= " CDEF:humiditycold=humidity_min,20,LT,humidity,UNKN,IF"; $rrd_options .= " AREA:humidity_max#c5c5c5"; $rrd_options .= " AREA:humidity_min#ffffffff"; - - # $rrd_options .= " AREA:humidity#bbd392"; # $rrd_options .= " AREA:humiditywarm#FFCCCC"; # $rrd_options .= " AREA:humiditycold#CCCCFF"; - $rrd_options .= " LINE1:humidity#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($humidity['sensor_descr_fixed'])))."'"; # Ugly hack :( + $rrd_options .= " LINE1:humidity#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($sensor['sensor_descr_fixed'])))."'"; # Ugly hack :( $rrd_options .= " LINE1:humiditywarm#660000"; $rrd_options .= " GPRINT:humidity:LAST:%3.0lf%%"; $rrd_options .= " GPRINT:humidity:MAX:%3.0lf%%\\\\l"; diff --git a/html/includes/graphs/sensor/temperature.inc.php b/html/includes/graphs/sensor/temperature.inc.php index 86ce17a23..d0b8da519 100644 --- a/html/includes/graphs/sensor/temperature.inc.php +++ b/html/includes/graphs/sensor/temperature.inc.php @@ -7,14 +7,13 @@ include("includes/graphs/common.inc.php"); $rrd_options .= " COMMENT:' Cur Min Max\\n'"; - $sensor = mysql_fetch_array(mysql_query("SELECT * FROM sensors where sensor_id = '".mres($_GET['id'])."'")); - $device = device_by_id_cache($sensor['device_id']); + ### FIXME: Overwrite default because it won't work here yet + $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/temp-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; + $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 22),0,22); $sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed'])); - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/temp-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; - $rrd_options .= " DEF:temp=$rrd_filename:temp:AVERAGE"; $rrd_options .= " DEF:temp_max=$rrd_filename:temp:MAX"; $rrd_options .= " DEF:temp_min=$rrd_filename:temp:MIN"; diff --git a/html/includes/graphs/sensor/voltage.inc.php b/html/includes/graphs/sensor/voltage.inc.php index 2d5e6ca59..239b27f41 100644 --- a/html/includes/graphs/sensor/voltage.inc.php +++ b/html/includes/graphs/sensor/voltage.inc.php @@ -4,15 +4,14 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); -$rrd_options .= " -A "; +$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/volt-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; +$rrd_options .= " -A "; $rrd_options .= " COMMENT:' Last Max\\n'"; $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 22),0,22); $sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed'])); -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/volt-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; - $rrd_options .= " DEF:volt=$rrd_filename:volt:AVERAGE"; $rrd_options .= " DEF:volt_max=$rrd_filename:volt:MAX"; $rrd_options .= " DEF:volt_min=$rrd_filename:volt:MIN"; diff --git a/html/includes/graphs/storage/usage.inc.php b/html/includes/graphs/storage/usage.inc.php index aa71be974..c02ad16af 100644 --- a/html/includes/graphs/storage/usage.inc.php +++ b/html/includes/graphs/storage/usage.inc.php @@ -9,18 +9,17 @@ $rrd_options .= " -b 1024"; $iter = "1"; - $sql = mysql_query("SELECT * FROM storage where storage_id = '".mres($_GET['id'])."'"); + $rrd_options .= " COMMENT:' Size Free % Used\\n'"; - while($storage = mysql_fetch_array($sql)) { + $hostname = gethostbyid($storage['device_id']); if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE"; } elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D"; } elseif($iter=="7") {$colour="FF0084"; $iter = "0"; } $descr = substr(str_pad($storage[storage_descr], 12),0,12); $descr = str_replace(":","\:",$descr); - $rrd = $config['rrd_dir'] . "/" . $hostname . "/" . safename("storage-" . $storage['storage_mib'] . "-" . $storage['storage_descr'] . ".rrd"); - $rrd_options .= " DEF:$storage[storage_id]used=$rrd:used:AVERAGE"; - $rrd_options .= " DEF:$storage[storage_id]free=$rrd:free:AVERAGE"; + $rrd_options .= " DEF:$storage[storage_id]used=$rrd_filename:used:AVERAGE"; + $rrd_options .= " DEF:$storage[storage_id]free=$rrd_filename:free:AVERAGE"; $rrd_options .= " CDEF:$storage[storage_id]size=$storage[storage_id]used,$storage[storage_id]free,+"; $rrd_options .= " CDEF:$storage[storage_id]perc=$storage[storage_id]used,$storage[storage_id]size,/,100,*"; $rrd_options .= " LINE1.25:$storage[storage_id]perc#" . $colour . ":'$descr'"; @@ -28,6 +27,5 @@ $rrd_options .= " -b 1024"; $rrd_options .= " GPRINT:$storage[storage_id]free:LAST:%6.2lf%sB"; $rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\\\n"; $iter++; - } ?> diff --git a/html/includes/print-interface-adsl.inc.php b/html/includes/print-interface-adsl.inc.php index 12626f488..d215f1016 100644 --- a/html/includes/print-interface-adsl.inc.php +++ b/html/includes/print-interface-adsl.inc.php @@ -53,7 +53,7 @@ echo(formatRates($interface['ifInOctets_rate'] * 8)."
";
} else { $mac = ""; }
- echo("
');
-if(devicepermitted($_GET['id']) && $config['show_overview_tab']) {
+if(device_permitted($_GET['id']) && $config['show_overview_tab']) {
echo("
Graphs
@@ -48,7 +48,7 @@ if(devicepermitted($_GET['id'])) {
CollectD
@@ -97,7 +97,7 @@ if(devicepermitted($_GET['id']) && is_dir($config['collectd_dir'] . "/" . $devic
Ports
@@ -105,7 +105,7 @@ if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(inter
VLANs
@@ -113,7 +113,7 @@ if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(vlan_
VRFs
@@ -122,7 +122,7 @@ if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(*) fr
}
-if(devicepermitted($_GET['id']) && $config['enable_bgp'] && $device['bgpLocalAs']) {
+if(device_permitted($_GET['id']) && $config['enable_bgp'] && $device['bgpLocalAs']) {
echo('
BGP
@@ -149,13 +149,13 @@ if($_SESSION['userlevel'] >= "5" && mysql_result(mysql_query("SELECT count(*) FR
Inventory
Inventory
@@ -163,7 +163,7 @@ if(devicepermitted($_GET['id']) && $config['enable_inventory'] && @mysql_result(
Events
@@ -188,7 +188,7 @@ if(devicepermitted($_GET['id'])) {
Syslog
diff --git a/html/pages/device/bgp.inc.php b/html/pages/device/bgp.inc.php
index f1a4775b2..e1dc514bd 100644
--- a/html/pages/device/bgp.inc.php
+++ b/html/pages/device/bgp.inc.php
@@ -86,14 +86,14 @@ print_optionbar_end();
foreach(explode(" ", $_GET['opta']) as $graph_type) {
if($graph_type == "cbgp_prefixes") { list($afi, $safi) = explode(".", $_GET['optb']); $afisafi = "&afi=$afi&safi=$safi"; }
if($graph_type == "bgp_updates" || $valid_afi_safi[$afi][$safi]) {
- $daily_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100$afisafi";
- $daily_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150$afisafi";
- $weekly_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=210&height=100$afisafi";
- $weekly_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150$afisafi";
- $monthly_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=210&height=100$afisafi";
- $monthly_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150$afisafi";
- $yearly_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=210&height=100$afisafi";
- $yearly_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150$afisafi";
+ $daily_traffic = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100$afisafi";
+ $daily_url = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150$afisafi";
+ $weekly_traffic = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=210&height=100$afisafi";
+ $weekly_url = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150$afisafi";
+ $monthly_traffic = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=210&height=100$afisafi";
+ $monthly_url = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150$afisafi";
+ $yearly_traffic = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=210&height=100$afisafi";
+ $yearly_url = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150$afisafi";
echo("| ' . generatedevicelink($interface) . ' | diff --git a/html/pages/ipv6.inc.php b/html/pages/ipv6.inc.php index f33dea0a7..b2879eb64 100644 --- a/html/pages/ipv6.inc.php +++ b/html/pages/ipv6.inc.php @@ -73,7 +73,7 @@ if(!$ignore) { $error_img = generateiflink($interface,"|
| " . generatedevicelink($interface) . " | diff --git a/html/pages/ports/default.inc.php b/html/pages/ports/default.inc.php index 185a9980e..834d4f4cc 100644 --- a/html/pages/ports/default.inc.php +++ b/html/pages/ports/default.inc.php @@ -138,7 +138,7 @@ while($interface = mysql_fetch_array($query)) { $error_img = generateiflink($interface,"|