From bdc4deb4355c5a81f7bbd6fe2e35e02fe72978f8 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 1 Jun 2015 23:27:41 +0100 Subject: [PATCH 01/43] Updated to use mac address data --- html/includes/print-map.inc.php | 66 ++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index c8fcf1249..6902db4b1 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -36,13 +36,66 @@ foreach (dbFetchRows("SELECT DISTINCT least(`devices`.`device_id`, `remote_devic array_push($tmp_ids,$link_devices['remote_device_id']); } -$tmp_ids = implode(',',$tmp_ids); - -$nodes = json_encode($tmp_devices); +$tmp_exp_ids = implode(',',$tmp_ids); + +$port_ids = array(); +foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL", array()) as $macs) { + if (!in_array($macs['local_port_id'], $port_ids) && port_permitted($macs['local_port_id'])) { + $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($macs['local_port_id'])); + $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['local_port_id'])); + if (!in_array($port_dev['device_id'],$tmp_ids)) { + $mac_devices[] = array('id'=>$port_dev['device_id'], 'label'=>$port_dev['hostname'], 'title'=>generate_device_link($port_dev,'',array(),'','','',0),'group'=>$port_dev['location'], 'shape'=>'box'); + array_push($port_ids, $port_dev['device_id']); + $port_data = $port_det; + $from = $port_dev['device_id']; + $port = shorten_interface_type($port_det['ifName']); + $speed = $port_det['ifSpeed']/1000/1000; + if ($speed == 100) { + $width = 3; + } elseif ($speed == 1000) { + $width = 5; + } elseif ($speed == 10000) { + $width = 10; + } elseif ($speed == 40000) { + $width = 15; + } elseif ($speed == 100000) { + $width = 20; + } else { + $width = 1; + } + $link_in_used = ($port_det['ifInOctets_rate'] * 8) / $port_det['ifSpeed'] * 100; + $link_out_used = ($port_det['ifOutOctets_rate'] * 8) / $port_det['ifSpeed'] * 100; + if ($link_in_used > $link_out_used) { + $link_used = $link_in_used; + } else { + $link_used = $link_out_used; + } + $link_used = round($link_used, -1); + if ($link_used > 100) { + $link_used = 100; + } + $link_color = $config['map_legend'][$link_used]; + } + } + if (!in_array($macs['remote_port_id'], $port_ids) && port_permitted($macs['remote_port_id'])) { + $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($macs['remote_port_id'])); + $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['remote_port_id'])); + if (!in_array($port_dev['device_id'],$tmp_ids)) { + $mac_devices[] = array('id'=>$port_dev['device_id'], 'label'=>$port_dev['hostname'], 'title'=>generate_device_link($port_dev,'',array(),'','','',0),'group'=>$port_dev['location'], 'shape'=>'box'); + array_push($port_ids, $port_dev['device_id']); + $to = $port_dev['device_id']; + $port .= ' > ' . shorten_interface_type($port_det['ifName']); + } + } + $tmp_links[] = array('from'=>$from,'to'=>$to,'label'=>$port,'title'=>generate_port_link($port_data, "",'',0,1),'width'=>$width,'color'=>$link_color); +} + +$node_devices = array_merge($tmp_devices,$mac_devices); +$nodes = json_encode($node_devices); if (is_array($tmp_devices[0])) { $tmp_links = array(); - foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.*, `remote_port` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ($tmp_ids) AND `remote_device_id` IN ($tmp_ids))") as $link_devices) { + foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.*, `remote_port` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ($tmp_exp_ids) AND `remote_device_id` IN ($tmp_exp_ids))") as $link_devices) { foreach ($tmp_devices as $k=>$v) { if ($v['id'] == $link_devices['local_device_id']) { $from = $v['id']; @@ -85,6 +138,8 @@ if (is_array($tmp_devices[0])) { } $edges = json_encode($tmp_links); +} + ?> @@ -147,7 +202,6 @@ network.redraw(); From 988cb3b2407ed533d8f30f890aafb256e6da1994 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 2 Jun 2015 00:03:06 +0100 Subject: [PATCH 02/43] Last update to get map working for mac addresses --- html/includes/print-map.inc.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index 6902db4b1..fb1d16f70 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -16,6 +16,8 @@ $tmp_devices = array(); if (!empty($device['hostname'])) { $sql = ' WHERE `devices`.`hostname`=?'; $sql_array = array($device['hostname']); + $mac_sql = ' AND `D`.`hostname` = ?'; + $mac_array = array($device['hostname']); } else { $sql = ' WHERE 1'; } @@ -39,13 +41,15 @@ foreach (dbFetchRows("SELECT DISTINCT least(`devices`.`device_id`, `remote_devic $tmp_exp_ids = implode(',',$tmp_ids); $port_ids = array(); -foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL", array()) as $macs) { +$port_devices = array(); +foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` LEFT JOIN `devices` AS `D` ON `P`.`device_id`=`D`.`device_id` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL $mac_sql", $mac_array) as $macs) { if (!in_array($macs['local_port_id'], $port_ids) && port_permitted($macs['local_port_id'])) { - $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($macs['local_port_id'])); $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['local_port_id'])); - if (!in_array($port_dev['device_id'],$tmp_ids)) { + $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($port_det['device_id'])); + if (!in_array($port_dev['device_id'],$tmp_ids) && !in_array($port_dev['device_id'],$port_devices)) { $mac_devices[] = array('id'=>$port_dev['device_id'], 'label'=>$port_dev['hostname'], 'title'=>generate_device_link($port_dev,'',array(),'','','',0),'group'=>$port_dev['location'], 'shape'=>'box'); - array_push($port_ids, $port_dev['device_id']); + array_push($port_ids, $port_det['port_id']); + array_push($port_devices, $port_dev['device_id']); $port_data = $port_det; $from = $port_dev['device_id']; $port = shorten_interface_type($port_det['ifName']); @@ -78,11 +82,12 @@ foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `re } } if (!in_array($macs['remote_port_id'], $port_ids) && port_permitted($macs['remote_port_id'])) { - $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($macs['remote_port_id'])); $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['remote_port_id'])); - if (!in_array($port_dev['device_id'],$tmp_ids)) { + $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($port_det['device_id'])); + if (!in_array($port_dev['device_id'],$tmp_ids) && !in_array($port_dev['device_id'],$port_devices)) { $mac_devices[] = array('id'=>$port_dev['device_id'], 'label'=>$port_dev['hostname'], 'title'=>generate_device_link($port_dev,'',array(),'','','',0),'group'=>$port_dev['location'], 'shape'=>'box'); - array_push($port_ids, $port_dev['device_id']); + array_push($port_ids, $port_det['port_id']); + array_push($port_devices, $port_dev['device_id']); $to = $port_dev['device_id']; $port .= ' > ' . shorten_interface_type($port_det['ifName']); } @@ -94,7 +99,6 @@ $node_devices = array_merge($tmp_devices,$mac_devices); $nodes = json_encode($node_devices); if (is_array($tmp_devices[0])) { - $tmp_links = array(); foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.*, `remote_port` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ($tmp_exp_ids) AND `remote_device_id` IN ($tmp_exp_ids))") as $link_devices) { foreach ($tmp_devices as $k=>$v) { if ($v['id'] == $link_devices['local_device_id']) { @@ -136,10 +140,9 @@ if (is_array($tmp_devices[0])) { $tmp_links[] = array('from'=>$from,'to'=>$to,'label'=>$port,'title'=>generate_port_link($port_data, "",'',0,1),'width'=>$width,'color'=>$link_color); } - - $edges = json_encode($tmp_links); } +$edges = json_encode($tmp_links); ?> From f0395e453eb4cfcabc431a9a4005d2e47a0cb9cc Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Jun 2015 00:37:34 +0100 Subject: [PATCH 03/43] Final final updates to get better map support --- html/includes/print-map.inc.php | 10 +++++++++- html/includes/print-menubar.php | 8 -------- html/pages/device.inc.php | 4 ---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index fb1d16f70..bfadc788d 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -42,7 +42,7 @@ $tmp_exp_ids = implode(',',$tmp_ids); $port_ids = array(); $port_devices = array(); -foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` LEFT JOIN `devices` AS `D` ON `P`.`device_id`=`D`.`device_id` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL $mac_sql", $mac_array) as $macs) { +foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` LEFT JOIN `devices` AS `D` ON `P`.`device_id`=`D`.`device_id` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL AND `M`.`port_id` != 0 AND `P`.`port_id` != 0 $mac_sql", $mac_array) as $macs) { if (!in_array($macs['local_port_id'], $port_ids) && port_permitted($macs['local_port_id'])) { $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['local_port_id'])); $port_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($port_det['device_id'])); @@ -143,6 +143,8 @@ if (is_array($tmp_devices[0])) { } $edges = json_encode($tmp_links); + +if (count($node_devices) > 1 && count($tmp_links) > 0) { ?> @@ -205,6 +207,12 @@ network.redraw(); diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index ca30ad6c3..ab43b2a9e 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -147,17 +147,9 @@ if ($config['show_locations'])
  • Delete Device
  • '); } -if ($links['count'] > 0) { - ?>
  • Network Map Network Map
  • - - diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index c72daf9bf..245c29dd3 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -256,15 +256,11 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) '); } - if ($_SESSION['userlevel'] >= "5" && dbFetchCell("SELECT COUNT(*) FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) - { - $discovery_links = TRUE; echo('
  • Map
  • '); - } if (@dbFetchCell("SELECT COUNT(*) FROM `packages` WHERE device_id = '".$device['device_id']."'") > '0') { From 841cb803b3fc8f9e244e46973e9c142ff8f47e50 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Jun 2015 00:50:09 +0100 Subject: [PATCH 04/43] Some tidying up of variables/array --- html/includes/print-map.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index bfadc788d..1e4311351 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -42,6 +42,7 @@ $tmp_exp_ids = implode(',',$tmp_ids); $port_ids = array(); $port_devices = array(); +$tmp_links = array(); foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `remote_port_id`, GREATEST(`P`.`port_id`,`M`.`port_id`) AS `local_port_id` FROM `ipv4_mac` AS `M` LEFT JOIN `ports` AS `P` ON `M`.`mac_address` = `P`.`ifPhysAddress` LEFT JOIN `devices` AS `D` ON `P`.`device_id`=`D`.`device_id` WHERE `P`.`port_id` IS NOT NULL AND `M`.`port_id` IS NOT NULL AND `M`.`port_id` != 0 AND `P`.`port_id` != 0 $mac_sql", $mac_array) as $macs) { if (!in_array($macs['local_port_id'], $port_ids) && port_permitted($macs['local_port_id'])) { $port_det = dbFetchRow("SELECT * FROM `ports` WHERE `port_id`=?", array($macs['local_port_id'])); @@ -93,6 +94,7 @@ foreach (dbFetchRows("SELECT DISTINCT LEAST(`M`.`port_id`, `P`.`port_id`) AS `re } } $tmp_links[] = array('from'=>$from,'to'=>$to,'label'=>$port,'title'=>generate_port_link($port_data, "",'',0,1),'width'=>$width,'color'=>$link_color); + unset($port); } $node_devices = array_merge($tmp_devices,$mac_devices); From 116a64deb95d6a71c322f4fa1d5da6395165a728 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 27 Jun 2015 22:52:01 +0100 Subject: [PATCH 05/43] Added basic detection for Mellanox devices --- html/images/os/mellanox.png | Bin 0 -> 1323 bytes includes/definitions.inc.php | 10 ++++++++++ includes/discovery/os/mellanox.inc.php | 7 +++++++ includes/polling/os/mellanox.inc.php | 8 ++++++++ 4 files changed, 25 insertions(+) create mode 100644 html/images/os/mellanox.png create mode 100644 includes/discovery/os/mellanox.inc.php create mode 100644 includes/polling/os/mellanox.inc.php diff --git a/html/images/os/mellanox.png b/html/images/os/mellanox.png new file mode 100644 index 0000000000000000000000000000000000000000..a1b9b4b0eb2c6da64d5f4a738eee97ac947863c3 GIT binary patch literal 1323 zcmc(e|2xwO0LMS14xLbXqA2B(WY1N0aea|x3U!XnMCHtvk(2K`C2BKLhI=;G^+g>C z8z)+&xoxT0WH$LWh7t2^n^|m{jhS)ouekT~yx*_q{qy^I=Lh(oGc(<33IKqauMZTq zPW%6CykR||mH5_m*r2^b(D0-f^!12T6aa}%ibUD_CPc)dV5o@bj1(^FBmfv-11S0u zCsVGe$y{P9=UVW;qcF6c z(bOxEDsXv}uI@3FYDuHflB!!*SM>^oy7W0qEK#(!a&$U9Hn)CqYF0ERzn)nmomTet zO-{?^Kd}0hN(EpWz0EP`BXsuRDa5&<%Y4x2!BZ9NfO|aG@ z*|zzjXT!J7&#KEd^R^NW5KdhkzjauU`m<-zZd_RT3pkEsx?pl&nKfqf&j$NW_Io3j z6zg6;jNHIuQ|OGzm@0snP0qnmJS{9?X$>Yw*Kq2o>}0#bYwUjCy6IHOscXfIrixxr zCTxpPzuWz-qe*8+yfH>48v$dKEk+-LS)8^+krOok41IlAAnJYm~21#_1?nh(n=R3!@WoE_2 z_6Q*Xi?Ph8(Od#fd{2m{THg)10W*KH%V`(9Bzii?w!&y_rF&B>-m=+&=qGg@rk*Z= zdT~fD#(Q}cNc%u-6f2N02A+YMIwpIl@^M>SeBAcEnu)L{xA}$@A_}P0lAVU|qPk%V zq`hmcLBb9J=w-&^$e@Gb2{6gy<#PM({~t Date: Mon, 29 Jun 2015 16:28:58 +0100 Subject: [PATCH 06/43] Updated NX-OS to avoid conflicts elsewhere --- includes/discovery/os/nxos.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/discovery/os/nxos.inc.php b/includes/discovery/os/nxos.inc.php index 989021c93..5e374396a 100644 --- a/includes/discovery/os/nxos.inc.php +++ b/includes/discovery/os/nxos.inc.php @@ -2,7 +2,7 @@ if (!$os) { - if (strstr($sysDescr, "NX-OS")) { $os = "nxos"; } + if (strstr($sysDescr, "NX-OS(tm)")) { $os = "nxos"; } } -?> \ No newline at end of file +?> From e4f4eb44dc0fb6470ed9765f98a13efe0e926e10 Mon Sep 17 00:00:00 2001 From: Job Snijders Date: Thu, 9 Jul 2015 21:39:24 +0200 Subject: [PATCH 07/43] Remove effectively empty file --- includes/polling/ups.inc.php | 37 ------------------------------------ 1 file changed, 37 deletions(-) delete mode 100644 includes/polling/ups.inc.php diff --git a/includes/polling/ups.inc.php b/includes/polling/ups.inc.php deleted file mode 100644 index bacba0723..000000000 --- a/includes/polling/ups.inc.php +++ /dev/null @@ -1,37 +0,0 @@ - From ebd0f6fc3578a0ea124e49a7e963f0398a4a1328 Mon Sep 17 00:00:00 2001 From: Job Snijders Date: Fri, 10 Jul 2015 13:36:21 +0200 Subject: [PATCH 08/43] Apply "Squiz" code style on old (pre-2014) files --- check-errors.php | 67 +-- check-services.php | 128 ++-- config_to_json.php | 40 +- html/includes/collectd/config.php | 114 ++-- .../graphs/XXX_device_memory_windows.inc.php | 86 ++- .../includes/graphs/accesspoints/auth.inc.php | 20 +- .../graphs/accesspoints/interference.inc.php | 24 +- .../graphs/accesspoints/numasoclients.inc.php | 24 +- .../graphs/accesspoints/nummonbssid.inc.php | 25 +- .../graphs/accesspoints/nummonclients.inc.php | 24 +- .../graphs/accesspoints/radioutil.inc.php | 24 +- .../graphs/accesspoints/txpow.inc.php | 25 +- .../graphs/altiga_ssl_sessions.inc.php | 36 +- html/includes/graphs/application/auth.inc.php | 15 +- .../graphs/application/drbd_queue.inc.php | 52 +- .../application/mailscanner_reject.inc.php | 48 +- .../application/mailscanner_sent.inc.php | 33 +- .../application/mailscanner_spam.inc.php | 42 +- .../graphs/application/memcached.inc.php | 8 +- .../application/memcached_commands.inc.php | 34 +- .../graphs/application/memcached_data.inc.php | 61 +- .../application/memcached_items.inc.php | 55 +- .../application/memcached_threads.inc.php | 22 +- .../application/memcached_uptime.inc.php | 18 +- .../mysql_command_counters.inc.php | 82 ++- .../application/mysql_connections.inc.php | 70 ++- .../application/mysql_files_tables.inc.php | 46 +- .../mysql_innodb_buffer_pool.inc.php | 51 +- .../mysql_innodb_buffer_pool_activity.inc.php | 49 +- .../mysql_innodb_insert_buffer.inc.php | 49 +- .../application/mysql_innodb_io.inc.php | 11 +- .../mysql_innodb_io_pending.inc.php | 57 +- .../application/mysql_innodb_log.inc.php | 11 +- .../mysql_innodb_row_operations.inc.php | 51 +- .../mysql_innodb_semaphores.inc.php | 49 +- .../mysql_innodb_transactions.inc.php | 45 +- .../application/mysql_myisam_indexes.inc.php | 51 +- .../application/mysql_network_traffic.inc.php | 17 +- .../application/mysql_query_cache.inc.php | 68 ++- .../mysql_query_cache_memory.inc.php | 47 +- .../application/mysql_select_types.inc.php | 53 +- .../application/mysql_slow_queries.inc.php | 46 +- .../graphs/application/mysql_sorts.inc.php | 52 +- .../graphs/application/mysql_status.inc.php | 78 +-- .../application/mysql_table_locks.inc.php | 48 +- .../mysql_temporary_objects.inc.php | 50 +- .../application/nginx_connections.inc.php | 58 +- .../graphs/application/nginx_req.inc.php | 33 +- .../graphs/application/ntpclient_freq.inc.php | 23 +- .../application/ntpclient_stats.inc.php | 49 +- .../application/ntpdserver_bits.inc.php | 47 +- .../application/ntpdserver_buffer.inc.php | 47 +- .../application/ntpdserver_freq.inc.php | 23 +- .../application/ntpdserver_packets.inc.php | 52 +- .../application/ntpdserver_stats.inc.php | 49 +- .../application/ntpdserver_stratum.inc.php | 23 +- .../application/ntpdserver_uptime.inc.php | 55 +- .../graphs/application/powerdns_fail.inc.php | 56 +- .../application/powerdns_latency.inc.php | 23 +- .../application/powerdns_packetcache.inc.php | 56 +- .../application/powerdns_queries.inc.php | 61 +- .../application/powerdns_queries_udp.inc.php | 61 +- .../application/powerdns_querycache.inc.php | 49 +- .../application/powerdns_recursing.inc.php | 49 +- .../graphs/application/shoutcast_bits.inc.php | 36 +- .../application/shoutcast_multi_bits.inc.php | 74 ++- .../application/shoutcast_multi_stats.inc.php | 165 ++--- .../application/shoutcast_stats.inc.php | 66 +- html/includes/graphs/atmvp/auth.inc.php | 27 +- html/includes/graphs/atmvp/bits.inc.php | 8 +- html/includes/graphs/atmvp/cells.inc.php | 22 +- html/includes/graphs/atmvp/errors.inc.php | 22 +- html/includes/graphs/atmvp/packets.inc.php | 22 +- html/includes/graphs/bgp/auth.inc.php | 21 +- html/includes/graphs/bgp/prefixes.inc.php | 16 +- .../graphs/bgp/prefixes_ipv4multicast.inc.php | 6 +- .../graphs/bgp/prefixes_ipv4unicast.inc.php | 6 +- .../graphs/bgp/prefixes_ipv4vpn.inc.php | 6 +- .../graphs/bgp/prefixes_ipv6multicast.inc.php | 6 +- .../graphs/bgp/prefixes_ipv6unicast.inc.php | 6 +- .../graphs/bgp/prefixes_ipv6vpn.inc.php | 6 +- html/includes/graphs/bgp/updates.inc.php | 26 +- html/includes/graphs/bill/auth.inc.php | 20 +- html/includes/graphs/bill/bits.inc.php | 51 +- html/includes/graphs/c6kxbar/auth.inc.php | 18 +- html/includes/graphs/c6kxbar/util.inc.php | 22 +- .../includes/graphs/cefswitching/auth.inc.php | 22 +- .../graphs/cefswitching/graph.inc.php | 38 +- html/includes/graphs/device/agent.inc.php | 24 +- .../device/arubacontroller_numaps.inc.php | 24 +- .../device/arubacontroller_numclients.inc.php | 25 +- .../graphs/device/cipsec_flow_bits.inc.php | 10 +- .../graphs/device/cipsec_flow_pkts.inc.php | 24 +- .../graphs/device/cipsec_flow_tunnels.inc.php | 20 +- .../graphs/device/cras_sessions.inc.php | 16 +- html/includes/graphs/device/current.inc.php | 10 +- html/includes/graphs/device/dbm.inc.php | 10 +- html/includes/graphs/device/diskio.inc.php | 4 +- .../graphs/device/diskio_common.inc.php | 22 +- html/includes/graphs/device/fanspeed.inc.php | 10 +- .../graphs/device/fortigate_cpu.inc.php | 18 +- .../graphs/device/fortigate_sessions.inc.php | 18 +- html/includes/graphs/device/frequency.inc.php | 10 +- .../graphs/device/hr_processes.inc.php | 18 +- html/includes/graphs/device/hr_users.inc.php | 18 +- html/includes/graphs/device/humidity.inc.php | 10 +- .../graphs/device/ipSystemStats.inc.php | 64 +- .../graphs/device/ipsystemstats_ipv4.inc.php | 38 +- .../device/ipsystemstats_ipv4_frag.inc.php | 50 +- .../graphs/device/ipsystemstats_ipv6.inc.php | 38 +- .../device/ipsystemstats_ipv6_frag.inc.php | 50 +- html/includes/graphs/device/mempool.inc.php | 71 ++- .../graphs/device/netscaler_tcp_bits.inc.php | 10 +- .../graphs/device/netscaler_tcp_conn.inc.php | 28 +- .../graphs/device/netscaler_tcp_pkts.inc.php | 24 +- .../graphs/device/netstat_icmp.inc.php | 52 +- .../graphs/device/netstat_icmp_info.inc.php | 52 +- .../includes/graphs/device/netstat_ip.inc.php | 50 +- .../graphs/device/netstat_ip_frag.inc.php | 54 +- .../graphs/device/netstat_snmp.inc.php | 48 +- .../graphs/device/netstat_snmp_pkt.inc.php | 24 +- .../graphs/device/netstat_tcp.inc.php | 40 +- .../graphs/device/netstat_udp.inc.php | 37 +- .../graphs/device/nfsen_common.inc.php | 92 +-- .../graphs/device/nfsen_flows.inc.php | 8 +- .../graphs/device/nfsen_packets.inc.php | 8 +- .../graphs/device/nfsen_traffic.inc.php | 8 +- .../graphs/device/panos_sessions.inc.php | 16 +- html/includes/graphs/device/power.inc.php | 10 +- html/includes/graphs/device/processor.inc.php | 14 +- .../graphs/device/processor_separate.inc.php | 36 +- .../graphs/device/processor_stack.inc.php | 38 +- .../graphs/device/screenos_sessions.inc.php | 28 +- .../device/smokeping_all_common.inc.php | 131 ++-- .../device/smokeping_all_common_avg.inc.php | 139 ++--- .../graphs/device/smokeping_common.inc.php | 35 +- .../graphs/device/smokeping_in_all.inc.php | 6 +- .../device/smokeping_in_all_avg.inc.php | 6 +- .../graphs/device/smokeping_out_all.inc.php | 6 +- .../device/smokeping_out_all_avg.inc.php | 6 +- html/includes/graphs/device/storage.inc.php | 64 +- .../graphs/device/temperature.inc.php | 10 +- html/includes/graphs/device/toner.inc.php | 98 +-- html/includes/graphs/device/ucd_io.inc.php | 12 +- html/includes/graphs/device/ucd_load.inc.php | 18 +- .../includes/graphs/device/ucd_memory.inc.php | 6 +- .../graphs/device/ucd_swap_io.inc.php | 12 +- html/includes/graphs/device/uptime.inc.php | 18 +- html/includes/graphs/device/voltage.inc.php | 10 +- .../graphs/device/vpdn_sessions_l2tp.inc.php | 23 +- .../graphs/device/vpdn_tunnels_l2tp.inc.php | 23 +- .../graphs/device/wifi_clients.inc.php | 40 +- html/includes/graphs/diskio/auth.inc.php | 22 +- html/includes/graphs/diskio/bits.inc.php | 10 +- html/includes/graphs/diskio/ops.inc.php | 22 +- html/includes/graphs/generic_duplex.inc.php | 201 +++---- html/includes/graphs/generic_multi.inc.php | 112 ++-- .../graphs/generic_multi_bits.inc.php | 171 +++--- .../graphs/generic_multi_data.inc.php | 189 +++--- .../generic_multi_data_separated.inc.php | 204 ++++--- .../graphs/generic_multi_line.inc.php | 112 ++-- .../generic_multi_simplex_seperated.inc.php | 240 ++++---- html/includes/graphs/generic_simplex.inc.php | 209 +++---- html/includes/graphs/global/auth.inc.php | 7 +- html/includes/graphs/global/bits.inc.php | 92 ++- .../graphs/global/processor_separate.inc.php | 36 +- .../graphs/global/processor_stack.inc.php | 38 +- html/includes/graphs/ipsectunnel/auth.inc.php | 22 +- html/includes/graphs/ipsectunnel/bits.inc.php | 10 +- html/includes/graphs/ipsectunnel/pkts.inc.php | 22 +- html/includes/graphs/location/auth.inc.php | 16 +- html/includes/graphs/location/bits.inc.php | 101 ++-- .../graphs/macaccounting/auth.inc.php | 72 +-- .../graphs/macaccounting/bits.inc.php | 8 +- .../graphs/macaccounting/pkts.inc.php | 22 +- html/includes/graphs/mempool/usage.inc.php | 90 ++- html/includes/graphs/multiport/auth.inc.php | 22 +- html/includes/graphs/multiport/bits.inc.php | 39 +- .../graphs/multiport/bits_duo.inc.php | 231 +++---- .../graphs/multiport/bits_separate.inc.php | 38 +- .../graphs/multiport/bits_trio.inc.php | 347 ++++++----- html/includes/graphs/munin/graph.inc.php | 84 ++- .../graphs/netscalervsvr/auth.inc.php | 23 +- .../graphs/netscalervsvr/bits.inc.php | 8 +- .../graphs/netscalervsvr/conns.inc.php | 26 +- .../graphs/netscalervsvr/hitmiss.inc.php | 28 +- .../graphs/netscalervsvr/pkts.inc.php | 22 +- .../graphs/netscalervsvr/reqs.inc.php | 26 +- .../graphs/old_generic_simplex.inc.php | 137 ++--- .../graphs/port/adsl_attainable.inc.php | 27 +- .../graphs/port/adsl_attenuation.inc.php | 27 +- html/includes/graphs/port/adsl_power.inc.php | 27 +- html/includes/graphs/port/adsl_snr.inc.php | 27 +- html/includes/graphs/port/adsl_speed.inc.php | 27 +- html/includes/graphs/port/bits.inc.php | 8 +- html/includes/graphs/port/errors.inc.php | 42 +- html/includes/graphs/port/etherlike.inc.php | 55 +- .../graphs/port/mac_acc_total.inc.php | 212 ++++--- html/includes/graphs/port/nupkts.inc.php | 93 ++- html/includes/graphs/port/pagp_bits.inc.php | 33 +- html/includes/graphs/port/upkts.inc.php | 22 +- html/includes/graphs/rserver/auth.inc.php | 24 +- .../includes/graphs/screenos_sessions.inc.php | 29 +- html/includes/graphs/sensor/auth.inc.php | 26 +- html/includes/graphs/sensor/current.inc.php | 21 +- html/includes/graphs/sensor/dbm.inc.php | 21 +- html/includes/graphs/sensor/fanspeed.inc.php | 19 +- html/includes/graphs/sensor/frequency.inc.php | 21 +- html/includes/graphs/sensor/humidity.inc.php | 37 +- html/includes/graphs/sensor/power.inc.php | 27 +- .../graphs/sensor/temperature.inc.php | 33 +- html/includes/graphs/sensor/voltage.inc.php | 27 +- html/includes/graphs/service/auth.inc.php | 24 +- html/includes/graphs/smokeping/auth.inc.php | 13 +- html/includes/graphs/smokeping/in.inc.php | 115 ++-- html/includes/graphs/smokeping/out.inc.php | 115 ++-- html/includes/graphs/storage/usage.inc.php | 59 +- html/includes/graphs/vserver/auth.inc.php | 24 +- html/includes/graphs/vserver/bits.inc.php | 8 +- html/includes/graphs/vserver/pkts.inc.php | 22 +- html/includes/port-edit.inc.php | 109 ++-- .../includes/print-accesspoint-graphs.inc.php | 8 +- html/includes/print-accesspoint.inc.php | 144 ++--- html/includes/print-device-graph.php | 27 +- html/includes/print-interface-adsl.inc.php | 175 +++--- html/includes/print-interface-graphs.inc.php | 8 +- html/includes/print-service.inc.php | 89 +-- html/includes/print-vlan.inc.php | 94 +-- html/includes/print-vm.inc.php | 52 +- html/includes/print-vrf.inc.php | 66 +- html/includes/service-delete.inc.php | 11 +- html/pages/apps/overview.inc.php | 77 ++- html/pages/bill/actions.inc.php | 165 ++--- html/pages/bill/pdf_css.inc.php | 2 - html/pages/deleted-ports.inc.php | 57 +- html/pages/device/accesspoint.inc.php | 19 +- html/pages/device/apps.inc.php | 80 +-- html/pages/device/apps/apache.inc.php | 35 +- html/pages/device/apps/drbd.inc.php | 36 +- html/pages/device/apps/mailscanner.inc.php | 33 +- html/pages/device/apps/memcached.inc.php | 37 +- html/pages/device/apps/mysql.inc.php | 110 ++-- html/pages/device/apps/nginx.inc.php | 31 +- html/pages/device/apps/ntp-client.inc.php | 28 +- html/pages/device/apps/ntpd-server.inc.php | 38 +- html/pages/device/apps/powerdns.inc.php | 41 +- html/pages/device/apps/shoutcast.inc.php | 106 ++-- html/pages/device/collectd.inc.php | 150 +++-- html/pages/device/edit/icon.inc.php | 75 ++- html/pages/device/entphysical.inc.php | 161 ++--- html/pages/device/graphs/cpu.inc.php | 11 +- .../device/graphs/fortigate-sessions.inc.php | 11 +- html/pages/device/graphs/hrprocesses.inc.php | 11 +- html/pages/device/graphs/hrusers.inc.php | 11 +- html/pages/device/graphs/ipSytemStats.inc.php | 26 +- html/pages/device/graphs/memory.inc.php | 11 +- html/pages/device/graphs/netstats.inc.php | 89 ++- .../device/graphs/netstats_icmp_info.inc.php | 11 +- .../device/graphs/netstats_icmp_stat.inc.php | 11 +- html/pages/device/graphs/netstats_ip.inc.php | 17 +- .../pages/device/graphs/netstats_snmp.inc.php | 17 +- html/pages/device/graphs/netstats_tcp.inc.php | 11 +- html/pages/device/graphs/netstats_udp.inc.php | 11 +- .../device/graphs/screenos-sessions.inc.php | 11 +- html/pages/device/graphs/screenos.inc.php | 11 +- html/pages/device/graphs/uptime.inc.php | 8 +- html/pages/device/graphs/wireless.inc.php | 11 +- html/pages/device/health/dbm.inc.php | 10 +- html/pages/device/health/diskio.inc.php | 73 +-- html/pages/device/health/fanspeed.inc.php | 10 +- html/pages/device/health/frequency.inc.php | 10 +- html/pages/device/health/power.inc.php | 10 +- html/pages/device/health/sensors.inc.php | 42 +- html/pages/device/health/temperature.inc.php | 10 +- html/pages/device/health/voltage.inc.php | 10 +- html/pages/device/latency.inc.php | 205 +++---- html/pages/device/loadbalancer.inc.php | 101 ++-- .../device/loadbalancer/ace_rservers.inc.php | 135 +++-- .../loadbalancer/netscaler_vsvr.inc.php | 243 ++++---- html/pages/device/nfsen.inc.php | 21 +- .../pages/device/overview/sensors/dbm.inc.php | 12 +- .../device/overview/sensors/fanspeeds.inc.php | 12 +- .../overview/sensors/frequencies.inc.php | 12 +- .../device/overview/sensors/power.inc.php | 12 +- .../overview/sensors/temperatures.inc.php | 12 +- .../device/overview/sensors/voltages.inc.php | 12 +- html/pages/device/packages.inc.php | 35 +- html/pages/device/port/adsl.inc.php | 31 +- html/pages/device/port/arp.inc.php | 55 +- html/pages/device/port/graphs.inc.php | 42 +- html/pages/device/port/junose-atm-vp.inc.php | 82 +-- html/pages/device/port/macaccounting.inc.php | 244 ++++---- html/pages/device/port/realtime.inc.php | 39 +- html/pages/device/port/vlans.inc.php | 88 +-- html/pages/device/ports/adsl.inc.php | 22 +- html/pages/device/ports/arp.inc.php | 60 +- html/pages/device/ports/neighbours.inc.php | 55 +- html/pages/device/pseudowires.inc.php | 176 +++--- html/pages/device/routing.inc.php | 113 ++-- html/pages/device/routing/cef.inc.php | 180 +++--- .../device/routing/ipsec_tunnels.inc.php | 155 ++--- html/pages/device/routing/ospf.inc.php | 309 ++++++---- html/pages/device/routing/vrf.inc.php | 93 +-- html/pages/device/services.inc.php | 92 +-- html/pages/device/slas.inc.php | 96 +-- html/pages/device/toner.inc.php | 11 +- html/pages/device/vlans.inc.php | 109 ++-- html/pages/device/vm.inc.php | 17 +- html/pages/health/current.inc.php | 10 +- html/pages/health/dbm.inc.php | 10 +- html/pages/health/fanspeed.inc.php | 10 +- html/pages/health/frequency.inc.php | 10 +- html/pages/health/humidity.inc.php | 10 +- html/pages/health/power.inc.php | 10 +- html/pages/health/temperature.inc.php | 10 +- html/pages/health/toner.inc.php | 77 ++- html/pages/health/voltage.inc.php | 10 +- html/pages/packages.inc.php | 101 ++-- html/pages/ports/graph.inc.php | 110 ++-- html/pages/pseudowires.inc.php | 177 +++--- html/pages/purgeports.inc.php | 11 +- html/pages/routing.inc.php | 83 +-- html/pages/routing/ospf.inc.php | 82 ++- html/pages/routing/overview.inc.php | 43 +- html/pages/routing/vrf.inc.php | 427 +++++++------ .../discovery/cisco-entity-sensor.inc.php | 316 +++++----- includes/discovery/cisco-sla.inc.php | 171 +++--- includes/discovery/current.inc.php | 15 +- .../discovery/current/gamatronicups.inc.php | 61 +- includes/discovery/current/ipoman.inc.php | 96 ++- includes/discovery/current/mgeups.inc.php | 111 ++-- includes/discovery/current/netvision.inc.php | 61 +- includes/discovery/current/sentry3.inc.php | 190 +++--- includes/discovery/current/xups.inc.php | 113 ++-- includes/discovery/fanspeeds.inc.php | 15 +- includes/discovery/fanspeeds/areca.inc.php | 41 +- .../discovery/fanspeeds/lmsensors.inc.php | 48 +- .../discovery/fanspeeds/supermicro.inc.php | 75 ++- includes/discovery/frequencies.inc.php | 15 +- includes/discovery/frequencies/apc.inc.php | 133 +++-- includes/discovery/frequencies/ipoman.inc.php | 69 +-- includes/discovery/frequencies/mgeups.inc.php | 94 +-- .../discovery/frequencies/netvision.inc.php | 37 +- includes/discovery/frequencies/xups.inc.php | 69 +-- includes/discovery/humidity/akcp.inc.php | 73 +-- includes/discovery/humidity/apc.inc.php | 44 +- includes/discovery/humidity/ipoman.inc.php | 32 +- includes/discovery/humidity/mgeups.inc.php | 115 ++-- includes/discovery/humidity/netbotz.inc.php | 55 +- includes/discovery/humidity/pcoweb.inc.php | 79 ++- includes/discovery/humidity/sentry3.inc.php | 74 +-- includes/discovery/mempools/avaya-ers.inc.php | 39 +- includes/discovery/mempools/fortigate.inc.php | 8 +- includes/discovery/mempools/netscaler.inc.php | 14 +- includes/discovery/mempools/vrp.inc.php | 51 +- includes/discovery/os/acsw.inc.php | 25 +- includes/discovery/os/airport.inc.php | 17 +- includes/discovery/os/akcp.inc.php | 14 +- includes/discovery/os/apc.inc.php | 21 +- includes/discovery/os/arubaos.inc.php | 9 +- includes/discovery/os/avocent.inc.php | 14 +- includes/discovery/os/axiscam.inc.php | 14 +- includes/discovery/os/axisdocserver.inc.php | 9 +- includes/discovery/os/bcm963.inc.php | 9 +- includes/discovery/os/bnt.inc.php | 14 +- includes/discovery/os/brother.inc.php | 9 +- includes/discovery/os/cometsystem.inc.php | 15 +- includes/discovery/os/dell-laser.inc.php | 17 +- includes/discovery/os/deltaups.inc.php | 9 +- includes/discovery/os/dlink.inc.php | 21 +- includes/discovery/os/dlinkap.inc.php | 17 +- includes/discovery/os/epson.inc.php | 9 +- includes/discovery/os/gamatronicups.inc.php | 15 +- includes/discovery/os/ies.inc.php | 9 +- includes/discovery/os/ipoman.inc.php | 9 +- includes/discovery/os/jetdirect.inc.php | 17 +- includes/discovery/os/konica.inc.php | 9 +- includes/discovery/os/kyocera.inc.php | 9 +- includes/discovery/os/liebert.inc.php | 9 +- includes/discovery/os/mgepdu.inc.php | 9 +- includes/discovery/os/mgeups.inc.php | 21 +- includes/discovery/os/mrvld.inc.php | 9 +- includes/discovery/os/netopia.inc.php | 9 +- includes/discovery/os/netvision.inc.php | 9 +- includes/discovery/os/netware.inc.php | 9 +- includes/discovery/os/nrg.inc.php | 9 +- includes/discovery/os/okilan.inc.php | 9 +- includes/discovery/os/packetshaper.inc.php | 9 +- includes/discovery/os/panos.inc.php | 9 +- includes/discovery/os/poweralert.inc.php | 9 +- includes/discovery/os/powervault.inc.php | 9 +- includes/discovery/os/powerware.inc.php | 9 +- includes/discovery/os/prestige.inc.php | 13 +- includes/discovery/os/redback.inc.php | 9 +- includes/discovery/os/ricoh.inc.php | 9 +- includes/discovery/os/routeros.inc.php | 28 +- includes/discovery/os/sonicwall.inc.php | 9 +- .../discovery/os/supermicro-switch.inc.php | 17 +- includes/discovery/os/symbol.inc.php | 9 +- includes/discovery/os/tranzeo.inc.php | 9 +- includes/discovery/os/vrp.inc.php | 20 +- includes/discovery/os/windows.inc.php | 14 +- includes/discovery/os/wxgoos.inc.php | 19 +- includes/discovery/os/xerox.inc.php | 13 +- includes/discovery/os/zxr10.inc.php | 9 +- includes/discovery/os/zywall.inc.php | 9 +- includes/discovery/os/zyxeles.inc.php | 9 +- includes/discovery/os/zyxelnwa.inc.php | 9 +- includes/discovery/power.inc.php | 15 +- includes/discovery/power/ipoman.inc.php | 93 ++- .../discovery/processors/avaya-ers.inc.php | 23 +- .../discovery/processors/fortigate.inc.php | 29 +- .../discovery/processors/netscaler.inc.php | 47 +- includes/discovery/processors/radlan.inc.php | 27 +- includes/discovery/processors/vrp.inc.php | 51 +- .../discovery/processors/watchguard.inc.php | 29 +- includes/discovery/sensors-netscaler.inc.php | 56 +- includes/discovery/services.inc.php | 56 +- includes/discovery/temperatures/akcp.inc.php | 71 +-- .../discovery/temperatures/aos-device.inc.php | 22 +- includes/discovery/temperatures/areca.inc.php | 90 +-- .../discovery/temperatures/avaya-ers.inc.php | 37 +- .../temperatures/cometsystem-p85xx.inc.php | 82 ++- includes/discovery/temperatures/dell.inc.php | 112 ++-- .../temperatures/ftos-c-series.inc.php | 36 +- .../temperatures/ftos-e-series.inc.php | 40 +- .../temperatures/ftos-s-series.inc.php | 34 +- .../discovery/temperatures/ipoman.inc.php | 32 +- .../discovery/temperatures/ironware.inc.php | 62 +- includes/discovery/temperatures/junos.inc.php | 52 +- .../discovery/temperatures/junose.inc.php | 41 +- .../discovery/temperatures/lm-sensors.inc.php | 54 +- .../discovery/temperatures/mgeups.inc.php | 104 ++-- .../discovery/temperatures/netbotz.inc.php | 50 +- .../temperatures/observernms-custom.inc.php | 45 +- .../temperatures/papouch-tme.inc.php | 24 +- .../discovery/temperatures/pcoweb.inc.php | 184 ++++-- .../discovery/temperatures/rfc1628.inc.php | 45 +- .../discovery/temperatures/sentry3.inc.php | 68 ++- .../discovery/temperatures/supermicro.inc.php | 68 +-- includes/discovery/temperatures/xups.inc.php | 57 +- .../discovery/temperatures/zyxel-ies.inc.php | 36 +- includes/discovery/vlans/q-bridge-mib.inc.php | 38 +- includes/discovery/voltages/apc.inc.php | 191 +++--- includes/discovery/voltages/areca.inc.php | 49 +- .../discovery/voltages/gamatronicups.inc.php | 56 +- includes/discovery/voltages/ipoman.inc.php | 71 +-- includes/discovery/voltages/linux.inc.php | 47 +- includes/discovery/voltages/mgeups.inc.php | 91 +-- includes/discovery/voltages/netvision.inc.php | 82 +-- includes/discovery/voltages/rfc1628.inc.php | 160 ++--- includes/discovery/voltages/sentry3.inc.php | 51 +- .../discovery/voltages/supermicro.inc.php | 77 ++- includes/discovery/voltages/xups.inc.php | 157 ++--- includes/include-dir.inc.php | 32 +- includes/polling/applications.inc.php | 40 +- includes/polling/applications/apache.inc.php | 43 +- includes/polling/applications/drbd.inc.php | 54 +- .../polling/applications/mailscanner.inc.php | 25 +- .../polling/applications/memcached.inc.php | 50 +- includes/polling/applications/mysql.inc.php | 261 ++++---- includes/polling/applications/nginx.inc.php | 29 +- .../polling/applications/ntp-client.inc.php | 25 +- .../polling/applications/ntpd-server.inc.php | 29 +- .../polling/applications/powerdns.inc.php | 35 +- .../polling/applications/shoutcast.inc.php | 57 +- .../polling/cisco-ace-loadbalancer.inc.php | 94 +-- .../polling/cisco-ace-serverfarms.inc.php | 104 ++-- includes/polling/cisco-sla.inc.php | 88 +-- includes/polling/entity-physical.inc.php | 144 ++--- includes/polling/mempools/avaya-ers.inc.php | 24 +- includes/polling/mempools/fortigate.inc.php | 15 +- includes/polling/mempools/hpLocal.inc.php | 35 +- includes/polling/mempools/netscaler.inc.php | 20 +- includes/polling/mempools/vrp.inc.php | 33 +- includes/polling/netscaler-stats.inc.php | 179 ++++-- includes/polling/netscaler-vsvr.inc.php | 230 +++---- includes/polling/os.inc.php | 58 +- includes/polling/os/acsw.inc.php | 78 ++- includes/polling/os/airport.inc.php | 4 +- includes/polling/os/allied.inc.php | 67 +-- includes/polling/os/areca.inc.php | 31 +- includes/polling/os/arubaos.inc.php | 36 +- includes/polling/os/avaya-ers.inc.php | 48 +- includes/polling/os/avocent.inc.php | 13 +- includes/polling/os/bnt.inc.php | 7 +- includes/polling/os/brother.inc.php | 64 +- includes/polling/os/dell-laser.inc.php | 45 +- includes/polling/os/drac.inc.php | 8 +- includes/polling/os/extremeware.inc.php | 70 +-- includes/polling/os/fabos.inc.php | 6 +- includes/polling/os/firebox.inc.php | 12 +- includes/polling/os/ftos.inc.php | 75 +-- includes/polling/os/ies.inc.php | 6 +- includes/polling/os/ipoman.inc.php | 15 +- includes/polling/os/ironware.inc.php | 22 +- includes/polling/os/jetdirect.inc.php | 32 +- includes/polling/os/junos.inc.php | 26 +- includes/polling/os/junose.inc.php | 28 +- includes/polling/os/jwos.inc.php | 21 +- includes/polling/os/konica.inc.php | 14 +- includes/polling/os/kyocera.inc.php | 17 +- includes/polling/os/mgeups.inc.php | 17 +- includes/polling/os/minkelsrms.inc.php | 7 +- includes/polling/os/netmanplus.inc.php | 4 +- includes/polling/os/netscaler.inc.php | 21 +- includes/polling/os/nrg.inc.php | 21 +- includes/polling/os/okilan.inc.php | 11 +- includes/polling/os/panos.inc.php | 27 +- includes/polling/os/poweralert.inc.php | 23 +- includes/polling/os/powerconnect.inc.php | 13 +- includes/polling/os/powervault.inc.php | 4 +- includes/polling/os/radlan.inc.php | 29 +- includes/polling/os/ricoh.inc.php | 14 +- includes/polling/os/sonicwall.inc.php | 30 +- includes/polling/os/speedtouch.inc.php | 17 +- includes/polling/os/symbol.inc.php | 13 +- includes/polling/os/tranzeo.inc.php | 23 +- includes/polling/os/vrp.inc.php | 8 +- includes/polling/os/vyatta.inc.php | 4 +- includes/polling/os/xerox.inc.php | 28 +- includes/polling/os/zxr10.inc.php | 2 - includes/polling/os/zywall.inc.php | 2 - includes/polling/os/zyxelnwa.inc.php | 2 - includes/polling/ospf.inc.php | 563 ++++++++++-------- includes/polling/processors/ucd-old.inc.php | 13 +- includes/polling/ucd-diskio.inc.php | 63 +- includes/polling/unix-agent/dmi.inc.php | 9 +- includes/polling/unix-agent/hddtemp.inc.php | 37 +- includes/port-descr-parser.inc.php | 41 +- includes/services.inc.php | 17 +- includes/snom-graphing.php | 78 ++- includes/static-config.php | 4 +- includes/vmware_guestid.inc.php | 185 +++--- renamehost.php | 54 +- scripts/geshi-ios.php | 232 ++++---- snmptrap.php | 36 +- upgrade-scripts/fix-port-rrd.php | 159 +++-- upgrade-scripts/fix-sensor-rrd.php | 138 ++--- 539 files changed, 13587 insertions(+), 13219 deletions(-) diff --git a/check-errors.php b/check-errors.php index 9290425ef..702004f91 100755 --- a/check-errors.php +++ b/check-errors.php @@ -10,51 +10,50 @@ * @subpackage alerts * @author Adam Armstrong * @copyright (C) 2006 - 2012 Adam Armstrong - * */ chdir(dirname($argv[0])); -include("includes/defaults.inc.php"); -include("config.php"); -include("includes/definitions.inc.php"); -include("includes/functions.php"); -include("html/includes/functions.inc.php"); +require 'includes/defaults.inc.php'; +require 'config.php'; +require 'includes/definitions.inc.php'; +require 'includes/functions.php'; +require 'html/includes/functions.inc.php'; // Check all of our interface RRD files for errors +if ($argv[1]) { + $where = 'AND `port_id` = ?'; + $params = array($argv[1]); +} -if ($argv[1]) { $where = "AND `port_id` = ?"; $params = array($argv[1]); } - -$i = 0; +$i = 0; $errored = 0; -foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where", $params) as $interface) -{ - $errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta']; - if ($errors > '1') - { - $errored[] = generate_device_link($interface, $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta']); - $errored++; - } - $i++; -} +foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where", $params) as $interface) { + $errors = ($interface['ifInErrors_delta'] + $interface['ifOutErrors_delta']); + if ($errors > '1') { + $errored[] = generate_device_link($interface, $interface['hostname'].' - '.$interface['ifDescr'].' - '.$interface['ifAlias'].' - '.$interface['ifInErrors_delta'].' - '.$interface['ifOutErrors_delta']); + $errored++; + } -echo("Checked $i interfaces\n"); - -if (is_array($errored)) -{ // If there are errored ports - $i = 0; - $msg = "Interfaces with errors : \n\n"; - - foreach ($errored as $int) - { - $msg .= "$int\n"; // Add a line to the report email warning about them $i++; - } - // Send the alert email - notify($device, $config['project_name'] . " detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg); } -echo("$errored interfaces with errors over the past 5 minutes.\n"); +echo "Checked $i interfaces\n"; -?> +if (is_array($errored)) { + // If there are errored ports + $i = 0; + $msg = "Interfaces with errors : \n\n"; + + foreach ($errored as $int) { + $msg .= "$int\n"; + // Add a line to the report email warning about them + $i++; + } + + // Send the alert email + notify($device, $config['project_name']." detected errors on $i interface".($i != 1 ? 's' : ''), $msg); +} + +echo "$errored interfaces with errors over the past 5 minutes.\n"; diff --git a/check-services.php b/check-services.php index 2f6f33ab6..6cbba11ec 100755 --- a/check-services.php +++ b/check-services.php @@ -1,7 +1,7 @@ #!/usr/bin/env php * @copyright (C) 2006 - 2012 Adam Armstrong - * */ chdir(dirname($argv[0])); -include("includes/defaults.inc.php"); -include("config.php"); -include("includes/definitions.inc.php"); -include("includes/functions.php"); +require 'includes/defaults.inc.php'; +require 'config.php'; +require 'includes/definitions.inc.php'; +require 'includes/functions.php'; -foreach (dbFetchRows("SELECT * FROM `devices` AS D, `services` AS S WHERE S.device_id = D.device_id ORDER by D.device_id DESC") as $service) -{ - if ($service['status'] = "1") - { - unset($check, $service_status, $time, $status); - $service_status = $service['service_status']; - $service_type = strtolower($service['service_type']); - $service_param = $service['service_param']; - $checker_script = $config['install_dir'] . "/includes/services/" . $service_type . "/check.inc"; +foreach (dbFetchRows('SELECT * FROM `devices` AS D, `services` AS S WHERE S.device_id = D.device_id ORDER by D.device_id DESC') as $service) { + if ($service['status'] = '1') { + unset($check, $service_status, $time, $status); + $service_status = $service['service_status']; + $service_type = strtolower($service['service_type']); + $service_param = $service['service_param']; + $checker_script = $config['install_dir'].'/includes/services/'.$service_type.'/check.inc'; - if (is_file($checker_script)) - { - include($checker_script); + if (is_file($checker_script)) { + include $checker_script; + } + else { + $status = '2'; + $check = "Error : Script not found ($checker_script)"; + } + + $update = array(); + + if ($service_status != $status) { + $update['service_changed'] = time(); + + if ($service['sysContact']) { + $email = $service['sysContact']; + } + else { + $email = $config['email_default']; + } + + if ($status == '1') { + $msg = 'Service Up: '.$service['service_type'].' on '.$service['hostname']; + notify($device, 'Service Up: '.$service['service_type'].' on '.$service['hostname'], $msg); + } + else if ($status == '0') { + $msg = 'Service Down: '.$service['service_type'].' on '.$service['hostname']; + notify($device, 'Service Down: '.$service['service_type'].' on '.$service['hostname'], $msg); + } + } + else { + unset($updated); + } + + $update = array_merge(array('service_status' => $status, 'service_message' => $check, 'service_checked' => time()), $update); + dbUpdate($update, 'services', '`service_id` = ?', array($service['service_id'])); + unset($update); } - else - { - $status = "2"; - $check = "Error : Script not found ($checker_script)"; + else { + $status = '0'; + }//end if + + $rrd = $config['rrd_dir'].'/'.$service['hostname'].'/'.safename('service-'.$service['service_type'].'-'.$service['service_id'].'.rrd'); + + if (!is_file($rrd)) { + rrdtool_create($rrd, 'DS:status:GAUGE:600:0:1 '.$config['rrd_rra']); } - $update = array(); - - if ($service_status != $status) - { - $update['service_changed'] = time(); - - if ($service['sysContact']) { $email = $service['sysContact']; } else { $email = $config['email_default']; } - if ($status == "1") - { - $msg = "Service Up: " . $service['service_type'] . " on " . $service['hostname']; - notify($device, "Service Up: " . $service['service_type'] . " on " . $service['hostname'], $msg); - } - elseif ($status == "0") - { - $msg = "Service Down: " . $service['service_type'] . " on " . $service['hostname']; - notify($device, "Service Down: " . $service['service_type'] . " on " . $service['hostname'], $msg); - } - } else { unset($updated); } - - $update = array_merge(array('service_status' => $status, 'service_message' => $check, 'service_checked' => time()), $update); - dbUpdate($update, 'services', '`service_id` = ?', array($service['service_id'])); - unset($update); - - } else { - $status = "0"; - } - - $rrd = $config['rrd_dir'] . "/" . $service['hostname'] . "/" . safename("service-" . $service['service_type'] . "-" . $service['service_id'] . ".rrd"); - - if (!is_file($rrd)) - { - rrdtool_create ($rrd, "DS:status:GAUGE:600:0:1 ".$config['rrd_rra']); - } - if ($status == "1" || $status == "0") - { - rrdtool_update($rrd,"N:".$status); - } else { - rrdtool_update($rrd,"N:U"); - } - -} # while - -?> + if ($status == '1' || $status == '0') { + rrdtool_update($rrd, 'N:'.$status); + } + else { + rrdtool_update($rrd, 'N:U'); + } +} //end foreach diff --git a/config_to_json.php b/config_to_json.php index ae4a32d82..e1012a788 100644 --- a/config_to_json.php +++ b/config_to_json.php @@ -1,33 +1,31 @@ - -*/ + * Configuration to JSON converter + * Written by Job Snijders + * + */ $defaults_file = 'includes/defaults.inc.php'; -$config_file = 'config.php'; +$config_file = 'config.php'; // move to install dir chdir(dirname($argv[0])); -function iscli() { - - if(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { - return true; - } else { - return false; - } +function iscli() +{ + if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { + return true; + } + else { + return false; + } + } // check if we are running throw the CLI, otherwise abort - -if ( iscli() ) { - - require_once($defaults_file); - require_once($config_file); - print(json_encode($config)); +if (iscli()) { + include_once $defaults_file; + include_once $config_file; + print (json_encode($config)); } - -?> diff --git a/html/includes/collectd/config.php b/html/includes/collectd/config.php index f65db26e8..812c5857a 100644 --- a/html/includes/collectd/config.php +++ b/html/includes/collectd/config.php @@ -1,53 +1,91 @@ -'hour', 'label'=>'past hour', 'seconds'=>3600), - array('name'=>'day', 'label'=>'past day', 'seconds'=>86400), - array('name'=>'week', 'label'=>'past week', 'seconds'=>604800), - array('name'=>'month', 'label'=>'past month', 'seconds'=>2678400), - array('name'=>'year', 'label'=>'past year', 'seconds'=>31622400)); +$config['timespan'] = array( + array( + 'name' => 'hour', + 'label' => 'past hour', + 'seconds' => 3600, + ), + array( + 'name' => 'day', + 'label' => 'past day', + 'seconds' => 86400, + ), + array( + 'name' => 'week', + 'label' => 'past week', + 'seconds' => 604800, + ), + array( + 'name' => 'month', + 'label' => 'past month', + 'seconds' => 2678400, + ), + array( + 'name' => 'year', + 'label' => 'past year', + 'seconds' => 31622400, + ), +); // Interval at which values are collectd (currently ignored) -$config['rrd_interval'] = 10; +$config['rrd_interval'] = 10; // Average rows/rra (currently ignored) -$config['rrd_rows'] = 2400; +$config['rrd_rows'] = 2400; // Additional options to pass to rrdgraph -#$config['rrd_opts'] = (isset($config['rrdgraph_defaults']) ? $config['rrdgraph_defaults'] : ''); -#$config['rrd_opts'] = array('-E', "-c", "SHADEA#a5a5a5", "-c", "SHADEB#a5a5a5", "-c", "FONT#000000", "-c", "CANVAS#FFFFFF", "-c", "GRID#aaaaaa", -# "-c", "MGRID#FFAAAA", "-c", "FRAME#3e3e3e", "-c", "ARROW#5e5e5e", "-R", "normal"); +// $config['rrd_opts'] = (isset($config['rrdgraph_defaults']) ? $config['rrdgraph_defaults'] : ''); +// $config['rrd_opts'] = array('-E', "-c", "SHADEA#a5a5a5", "-c", "SHADEB#a5a5a5", "-c", "FONT#000000", "-c", "CANVAS#FFFFFF", "-c", "GRID#aaaaaa", +// "-c", "MGRID#FFAAAA", "-c", "FRAME#3e3e3e", "-c", "ARROW#5e5e5e", "-R", "normal"); // Predefined set of colors for use by collectd_draw_rrd() -$config['rrd_colors'] = array( - 'h_1'=>'F7B7B7', 'f_1'=>'FF0000', // Red - 'h_2'=>'B7EFB7', 'f_2'=>'00E000', // Green - 'h_3'=>'B7B7F7', 'f_3'=>'0000FF', // Blue - 'h_4'=>'F3DFB7', 'f_4'=>'F0A000', // Yellow - 'h_5'=>'B7DFF7', 'f_5'=>'00A0FF', // Cyan - 'h_6'=>'DFB7F7', 'f_6'=>'A000FF', // Magenta - 'h_7'=>'FFC782', 'f_7'=>'FF8C00', // Orange - 'h_8'=>'DCFF96', 'f_8'=>'AAFF00', // Lime - 'h_9'=>'83FFCD', 'f_9'=>'00FF99', - 'h_10'=>'81D9FF', 'f_10'=>'00B2FF', - 'h_11'=>'FF89F5', 'f_11'=>'FF00EA', - 'h_12'=>'FF89AE', 'f_12'=>'FF0051', - 'h_13'=>'BBBBBB', 'f_13'=>'555555', - ); +$config['rrd_colors'] = array( + 'h_1' => 'F7B7B7', + 'f_1' => 'FF0000', // Red + 'h_2' => 'B7EFB7', + 'f_2' => '00E000', // Green + 'h_3' => 'B7B7F7', + 'f_3' => '0000FF', // Blue + 'h_4' => 'F3DFB7', + 'f_4' => 'F0A000', // Yellow + 'h_5' => 'B7DFF7', + 'f_5' => '00A0FF', // Cyan + 'h_6' => 'DFB7F7', + 'f_6' => 'A000FF', // Magenta + 'h_7' => 'FFC782', + 'f_7' => 'FF8C00', // Orange + 'h_8' => 'DCFF96', + 'f_8' => 'AAFF00', // Lime + 'h_9' => '83FFCD', + 'f_9' => '00FF99', + 'h_10' => '81D9FF', + 'f_10' => '00B2FF', + 'h_11' => 'FF89F5', + 'f_11' => 'FF00EA', + 'h_12' => 'FF89AE', + 'f_12' => 'FF0051', + 'h_13' => 'BBBBBB', + 'f_13' => '555555', +); /* * URL to collectd's unix socket (unixsock plugin) * enabled: 'unix:///var/run/collectd/collectd-unixsock' @@ -58,11 +96,9 @@ $config['collectd_sock'] = null; * Path to TTF font file to use in error images * (fallback when file does not exist is GD fixed font) */ -$config['error_font'] = '/usr/share/fonts/corefonts/arial.ttf'; +$config['error_font'] = '/usr/share/fonts/corefonts/arial.ttf'; /* * Constant defining full path to rrdtool */ define('RRDTOOL', $config['rrdtool']); - -?> diff --git a/html/includes/graphs/XXX_device_memory_windows.inc.php b/html/includes/graphs/XXX_device_memory_windows.inc.php index cd964a856..7122762da 100644 --- a/html/includes/graphs/XXX_device_memory_windows.inc.php +++ b/html/includes/graphs/XXX_device_memory_windows.inc.php @@ -1,12 +1,12 @@ \ No newline at end of file +$rrd_options .= ' LINE1:totalreal#050505:total'; +$rrd_options .= ' GPRINT:totalreal:AVERAGE:\ \ %7.2lf%sB'; diff --git a/html/includes/graphs/accesspoints/auth.inc.php b/html/includes/graphs/accesspoints/auth.inc.php index 7f479a0f2..16f3c57ba 100644 --- a/html/includes/graphs/accesspoints/auth.inc.php +++ b/html/includes/graphs/accesspoints/auth.inc.php @@ -1,17 +1,13 @@ diff --git a/html/includes/graphs/accesspoints/interference.inc.php b/html/includes/graphs/accesspoints/interference.inc.php index 03128f2ad..07bb8e393 100644 --- a/html/includes/graphs/accesspoints/interference.inc.php +++ b/html/includes/graphs/accesspoints/interference.inc.php @@ -1,25 +1,21 @@ diff --git a/html/includes/graphs/accesspoints/numasoclients.inc.php b/html/includes/graphs/accesspoints/numasoclients.inc.php index e0ee8a15d..9f4bde6fe 100644 --- a/html/includes/graphs/accesspoints/numasoclients.inc.php +++ b/html/includes/graphs/accesspoints/numasoclients.inc.php @@ -1,25 +1,21 @@ diff --git a/html/includes/graphs/accesspoints/nummonbssid.inc.php b/html/includes/graphs/accesspoints/nummonbssid.inc.php index c3f5c4ac6..85b3b10b5 100644 --- a/html/includes/graphs/accesspoints/nummonbssid.inc.php +++ b/html/includes/graphs/accesspoints/nummonbssid.inc.php @@ -1,26 +1,21 @@ diff --git a/html/includes/graphs/accesspoints/nummonclients.inc.php b/html/includes/graphs/accesspoints/nummonclients.inc.php index 9033ac1d8..5539f5af6 100644 --- a/html/includes/graphs/accesspoints/nummonclients.inc.php +++ b/html/includes/graphs/accesspoints/nummonclients.inc.php @@ -1,25 +1,21 @@ diff --git a/html/includes/graphs/accesspoints/radioutil.inc.php b/html/includes/graphs/accesspoints/radioutil.inc.php index cde1ed17e..d012ed294 100644 --- a/html/includes/graphs/accesspoints/radioutil.inc.php +++ b/html/includes/graphs/accesspoints/radioutil.inc.php @@ -1,25 +1,21 @@ diff --git a/html/includes/graphs/accesspoints/txpow.inc.php b/html/includes/graphs/accesspoints/txpow.inc.php index 86ecf0729..1dab4340d 100644 --- a/html/includes/graphs/accesspoints/txpow.inc.php +++ b/html/includes/graphs/accesspoints/txpow.inc.php @@ -1,26 +1,21 @@ diff --git a/html/includes/graphs/altiga_ssl_sessions.inc.php b/html/includes/graphs/altiga_ssl_sessions.inc.php index e9e93c9f1..a69f68178 100644 --- a/html/includes/graphs/altiga_ssl_sessions.inc.php +++ b/html/includes/graphs/altiga_ssl_sessions.inc.php @@ -1,33 +1,31 @@ \ No newline at end of file diff --git a/html/includes/graphs/application/auth.inc.php b/html/includes/graphs/application/auth.inc.php index b1662bc85..15c8f01ca 100644 --- a/html/includes/graphs/application/auth.inc.php +++ b/html/includes/graphs/application/auth.inc.php @@ -1,12 +1,9 @@ diff --git a/html/includes/graphs/application/drbd_queue.inc.php b/html/includes/graphs/application/drbd_queue.inc.php index 08a90f8c3..a04a4080b 100644 --- a/html/includes/graphs/application/drbd_queue.inc.php +++ b/html/includes/graphs/application/drbd_queue.inc.php @@ -1,37 +1,37 @@ 'Local I/O', - 'pe' => 'Pending', - 'ua' => 'UnAcked', - 'ap' => 'App Pending', -); + 'lo' => 'Local I/O', + 'pe' => 'Pending', + 'ua' => 'UnAcked', + 'ap' => 'App Pending', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 0; -$unit_text = ""; +$unit_text = ''; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mailscanner_reject.inc.php b/html/includes/graphs/application/mailscanner_reject.inc.php index b45e72398..9298460db 100644 --- a/html/includes/graphs/application/mailscanner_reject.inc.php +++ b/html/includes/graphs/application/mailscanner_reject.inc.php @@ -1,36 +1,32 @@ array('descr' => 'Rejected'), - 'msg_relay' => array('descr' => 'Relayed'), - 'msg_waiting' => array('descr' => 'Waiting'), - ); + 'msg_rejected' => array('descr' => 'Rejected'), + 'msg_relay' => array('descr' => 'Relayed'), + 'msg_waiting' => array('descr' => 'Waiting'), + ); -$i = 0; -$x = 0; +$i = 0; +$x = 0; -if (is_file($rrd_filename)) -{ - $max_colours = count($config['graph_colours'][$colours]); - foreach ($array as $ds => $vars) - { - $x = (($x<=$max_colours) ? $x : 0); - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$x]; - $i++; - $x++; - } +if (is_file($rrd_filename)) { + $max_colours = count($config['graph_colours'][$colours]); + foreach ($array as $ds => $vars) { + $x = (($x <= $max_colours) ? $x : 0); + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$x]; + $i++; + $x++; + } } -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/mailscanner_sent.inc.php b/html/includes/graphs/application/mailscanner_sent.inc.php index c006f5c5a..f9cb4c4a6 100644 --- a/html/includes/graphs/application/mailscanner_sent.inc.php +++ b/html/includes/graphs/application/mailscanner_sent.inc.php @@ -1,27 +1,24 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/application/mailscanner_spam.inc.php b/html/includes/graphs/application/mailscanner_spam.inc.php index 2e913f65c..f68b5200b 100644 --- a/html/includes/graphs/application/mailscanner_spam.inc.php +++ b/html/includes/graphs/application/mailscanner_spam.inc.php @@ -1,30 +1,32 @@ array('descr' => 'Spam', 'colour' => 'FF8800'), - 'virus' => array('descr' => 'Virus', 'colour' => 'FF0000') - ); + 'spam' => array( + 'descr' => 'Spam', + 'colour' => 'FF8800', + ), + 'virus' => array( + 'descr' => 'Virus', + 'colour' => 'FF0000', + ), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } } -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/memcached.inc.php b/html/includes/graphs/application/memcached.inc.php index 8afd6bd1c..6bd8d5882 100644 --- a/html/includes/graphs/application/memcached.inc.php +++ b/html/includes/graphs/application/memcached.inc.php @@ -1,7 +1,5 @@ diff --git a/html/includes/graphs/application/memcached_commands.inc.php b/html/includes/graphs/application/memcached_commands.inc.php index e7f0788b3..d3665e98b 100644 --- a/html/includes/graphs/application/memcached_commands.inc.php +++ b/html/includes/graphs/application/memcached_commands.inc.php @@ -1,25 +1,23 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/application/memcached_data.inc.php b/html/includes/graphs/application/memcached_data.inc.php index 6aec349b6..9b2f43db7 100644 --- a/html/includes/graphs/application/memcached_data.inc.php +++ b/html/includes/graphs/application/memcached_data.inc.php @@ -1,34 +1,41 @@ array('descr' => 'Capacity', 'colour' => '555555'), - 'bytes' => array('descr' => 'Used', 'colour' => 'cc0000', 'areacolour' => 'ff999955'), - ); +$scale_min = 0; +$colours = 'mixed'; +$nototal = 0; +$unit_text = 'Packets/sec'; +$array = array( + 'limit_maxbytes' => array( + 'descr' => 'Capacity', + 'colour' => '555555', + ), + 'bytes' => array( + 'descr' => 'Used', + 'colour' => 'cc0000', + 'areacolour' => 'ff999955', + ), +); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - if (!empty($vars['areacolour'])) { $rrd_list[$i]['areacolour'] = $vars['areacolour']; } - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + if (!empty($vars['areacolour'])) { + $rrd_list[$i]['areacolour'] = $vars['areacolour']; + } + + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/memcached_items.inc.php b/html/includes/graphs/application/memcached_items.inc.php index 5d8b41d36..067c6496c 100644 --- a/html/includes/graphs/application/memcached_items.inc.php +++ b/html/includes/graphs/application/memcached_items.inc.php @@ -1,33 +1,36 @@ array('descr' => 'Items', 'colour' => '555555'), - ); +$scale_min = 0; +$colours = 'mixed'; +$nototal = 0; +$unit_text = 'Items'; +$array = array( + 'curr_items' => array( + 'descr' => 'Items', + 'colour' => '555555', + ), +); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - if (!empty($vars['areacolour'])) { $rrd_list[$i]['areacolour'] = $vars['areacolour']; } - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + if (!empty($vars['areacolour'])) { + $rrd_list[$i]['areacolour'] = $vars['areacolour']; + } + + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/memcached_threads.inc.php b/html/includes/graphs/application/memcached_threads.inc.php index 1802f44e7..0792bd971 100644 --- a/html/includes/graphs/application/memcached_threads.inc.php +++ b/html/includes/graphs/application/memcached_threads.inc.php @@ -1,20 +1,18 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/memcached_uptime.inc.php b/html/includes/graphs/application/memcached_uptime.inc.php index ed76dda95..3a18bad68 100644 --- a/html/includes/graphs/application/memcached_uptime.inc.php +++ b/html/includes/graphs/application/memcached_uptime.inc.php @@ -1,18 +1,16 @@ diff --git a/html/includes/graphs/application/mysql_command_counters.inc.php b/html/includes/graphs/application/mysql_command_counters.inc.php index a8e17557c..5ca5d7d68 100644 --- a/html/includes/graphs/application/mysql_command_counters.inc.php +++ b/html/includes/graphs/application/mysql_command_counters.inc.php @@ -1,37 +1,63 @@ array('descr' => 'Delete', 'colour' => '22FF22'), - 'CIt' => array('descr' => 'Insert', 'colour' => '0022FF'), - 'CISt' => array('descr' => 'Insert Select', 'colour' => 'FF0000'), - 'CLd' => array('descr' => 'Load Data', 'colour' => '00AAAA'), - 'CRe' => array('descr' => 'Replace', 'colour' => 'FF00FF'), - 'CRSt' => array('descr' => 'Replace Select', 'colour' => 'FFA500'), - 'CSt' => array('descr' => 'Select', 'colour' => 'CC0000'), - 'CUe' => array('descr' => 'Update', 'colour' => '0000CC'), - 'CUMi' => array('descr' => 'Update Multiple', 'colour' => '0080C0'), -); +$array = array( + 'CDe' => array( + 'descr' => 'Delete', + 'colour' => '22FF22', + ), + 'CIt' => array( + 'descr' => 'Insert', + 'colour' => '0022FF', + ), + 'CISt' => array( + 'descr' => 'Insert Select', + 'colour' => 'FF0000', + ), + 'CLd' => array( + 'descr' => 'Load Data', + 'colour' => '00AAAA', + ), + 'CRe' => array( + 'descr' => 'Replace', + 'colour' => 'FF00FF', + ), + 'CRSt' => array( + 'descr' => 'Replace Select', + 'colour' => 'FFA500', + ), + 'CSt' => array( + 'descr' => 'Select', + 'colour' => 'CC0000', + ), + 'CUe' => array( + 'descr' => 'Update', + 'colour' => '0000CC', + ), + 'CUMi' => array( + 'descr' => 'Update Multiple', + 'colour' => '0080C0', + ), + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; -# $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { echo("file missing: $file"); } +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + // $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "Commands"; +$unit_text = 'Commands'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_connections.inc.php b/html/includes/graphs/application/mysql_connections.inc.php index 5feb7bf49..d8024a9ed 100644 --- a/html/includes/graphs/application/mysql_connections.inc.php +++ b/html/includes/graphs/application/mysql_connections.inc.php @@ -1,36 +1,54 @@ array('descr' => 'Max Connections', 'colour' => '22FF22'), - 'MUCs' => array('descr' => 'Max Used Connections', 'colour' => '0022FF'), - 'ACs' => array('descr' => 'Aborted Clients', 'colour' => 'FF0000'), - 'AdCs' => array('descr' => 'Aborted Connects', 'colour' => '0080C0'), - 'TCd' => array('descr' => 'Threads Connected', 'colour' => 'FF0000'), - 'Cs' => array('descr' => 'New Connections', 'colour' => '0080C0'), -); +$array = array( + 'MaCs' => array( + 'descr' => 'Max Connections', + 'colour' => '22FF22', + ), + 'MUCs' => array( + 'descr' => 'Max Used Connections', + 'colour' => '0022FF', + ), + 'ACs' => array( + 'descr' => 'Aborted Clients', + 'colour' => 'FF0000', + ), + 'AdCs' => array( + 'descr' => 'Aborted Connects', + 'colour' => '0080C0', + ), + 'TCd' => array( + 'descr' => 'Threads Connected', + 'colour' => 'FF0000', + ), + 'Cs' => array( + 'descr' => 'New Connections', + 'colour' => '0080C0', + ), + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; -# $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { echo("file missing: $file"); } +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + // $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "Connections"; +$unit_text = 'Connections'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_files_tables.inc.php b/html/includes/graphs/application/mysql_files_tables.inc.php index 758ec51e6..f02593e60 100644 --- a/html/includes/graphs/application/mysql_files_tables.inc.php +++ b/html/includes/graphs/application/mysql_files_tables.inc.php @@ -1,32 +1,32 @@ array('descr' => 'Table Cache'), - 'OFs' => array('descr' => 'Open Files'), - 'OTs' => array('descr' => 'Open Tables'), - 'OdTs' => array('descr' => 'Opened Tables'), -); +$array = array( + 'TOC' => array('descr' => 'Table Cache'), + 'OFs' => array('descr' => 'Open Files'), + 'OTs' => array('descr' => 'Open Tables'), + 'OdTs' => array('descr' => 'Opened Tables'), + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; -# $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { echo("file missing: $file"); } +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + // $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = ""; +$unit_text = ''; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php b/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php index 84adc77ba..6f9255ffa 100644 --- a/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php +++ b/html/includes/graphs/application/mysql_innodb_buffer_pool.inc.php @@ -1,36 +1,37 @@ 'Buffer Pool Size', - 'IBPDBp' => 'Database Pages', - 'IBPFe' => 'Free Pages', - 'IBPMps' => 'Modified Pages', -); +$array = array( + 'IBPse' => 'Buffer Pool Size', + 'IBPDBp' => 'Database Pages', + 'IBPFe' => 'Free Pages', + 'IBPMps' => 'Modified Pages', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "Commands"; +$unit_text = 'Commands'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php b/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php index 11f282488..e2e3f8441 100644 --- a/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php +++ b/html/includes/graphs/application/mysql_innodb_buffer_pool_activity.inc.php @@ -1,35 +1,36 @@ 'Pages Read', - 'IBCd' => 'Pages Created', - 'IBWr' => 'Pages Written', -); +$array = array( + 'IBRd' => 'Pages Read', + 'IBCd' => 'Pages Created', + 'IBWr' => 'Pages Written', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "activity"; +$unit_text = 'activity'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php b/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php index da09b08ce..9cbde97ff 100644 --- a/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php +++ b/html/includes/graphs/application/mysql_innodb_insert_buffer.inc.php @@ -1,35 +1,36 @@ 'Inserts', - 'IBIMRd' => 'Merged Records', - 'IBIMs' => 'Merges', -); +$array = array( + 'IBIIs' => 'Inserts', + 'IBIMRd' => 'Merged Records', + 'IBIMs' => 'Merges', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = ""; +$unit_text = ''; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_innodb_io.inc.php b/html/includes/graphs/application/mysql_innodb_io.inc.php index 8af3ff1b6..014030370 100644 --- a/html/includes/graphs/application/mysql_innodb_io.inc.php +++ b/html/includes/graphs/application/mysql_innodb_io.inc.php @@ -1,12 +1,11 @@ diff --git a/html/includes/graphs/application/mysql_innodb_io_pending.inc.php b/html/includes/graphs/application/mysql_innodb_io_pending.inc.php index 7214675d7..7b578e052 100644 --- a/html/includes/graphs/application/mysql_innodb_io_pending.inc.php +++ b/html/includes/graphs/application/mysql_innodb_io_pending.inc.php @@ -1,39 +1,40 @@ 'AIO Log', - 'IBISc' => 'AIO Sync', - 'IBIFLg' => 'Buf Pool Flush', - 'IBFBl' => 'Log Flushes', - 'IBIIAo' => 'Insert Buf AIO Read', - 'IBIAd' => 'Normal AIO Read', - 'IBIAe' => 'Normal AIO Writes', -); +$array = array( + 'IBILog' => 'AIO Log', + 'IBISc' => 'AIO Sync', + 'IBIFLg' => 'Buf Pool Flush', + 'IBFBl' => 'Log Flushes', + 'IBIIAo' => 'Insert Buf AIO Read', + 'IBIAd' => 'Normal AIO Read', + 'IBIAe' => 'Normal AIO Writes', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = ""; +$unit_text = ''; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_innodb_log.inc.php b/html/includes/graphs/application/mysql_innodb_log.inc.php index 89750845d..b68890b84 100644 --- a/html/includes/graphs/application/mysql_innodb_log.inc.php +++ b/html/includes/graphs/application/mysql_innodb_log.inc.php @@ -1,12 +1,11 @@ diff --git a/html/includes/graphs/application/mysql_innodb_row_operations.inc.php b/html/includes/graphs/application/mysql_innodb_row_operations.inc.php index f178387a7..f3b74a58b 100644 --- a/html/includes/graphs/application/mysql_innodb_row_operations.inc.php +++ b/html/includes/graphs/application/mysql_innodb_row_operations.inc.php @@ -1,36 +1,37 @@ 'Deletes', - 'IDBRId' => 'Inserts', - 'IDBRRd' => 'Reads', - 'IDBRUd' => 'Updates', -); +$array = array( + 'IDBRDd' => 'Deletes', + 'IDBRId' => 'Inserts', + 'IDBRRd' => 'Reads', + 'IDBRUd' => 'Updates', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 0; -$unit_text = "Rows"; +$unit_text = 'Rows'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_innodb_semaphores.inc.php b/html/includes/graphs/application/mysql_innodb_semaphores.inc.php index 27e33aa18..4b259ed7a 100644 --- a/html/includes/graphs/application/mysql_innodb_semaphores.inc.php +++ b/html/includes/graphs/application/mysql_innodb_semaphores.inc.php @@ -1,35 +1,36 @@ 'Spin Rounds', - 'IBSWs' => 'Spin Waits', - 'IBOWs' => 'OS Waits', -); +$array = array( + 'IBSRs' => 'Spin Rounds', + 'IBSWs' => 'Spin Waits', + 'IBOWs' => 'OS Waits', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "Semaphores"; +$unit_text = 'Semaphores'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_innodb_transactions.inc.php b/html/includes/graphs/application/mysql_innodb_transactions.inc.php index 2f53e561b..87e64f73e 100644 --- a/html/includes/graphs/application/mysql_innodb_transactions.inc.php +++ b/html/includes/graphs/application/mysql_innodb_transactions.inc.php @@ -1,33 +1,32 @@ 'Transactions created', -); +$array = array('IBTNx' => 'Transactions created'); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "transactions"; +$unit_text = 'transactions'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_myisam_indexes.inc.php b/html/includes/graphs/application/mysql_myisam_indexes.inc.php index 883b496b1..a4d8a36e3 100644 --- a/html/includes/graphs/application/mysql_myisam_indexes.inc.php +++ b/html/includes/graphs/application/mysql_myisam_indexes.inc.php @@ -1,36 +1,37 @@ 'read requests', - 'KRs' => 'reads', - 'KWR' => 'write requests', - 'KWs' => 'writes', -); +$array = array( + 'KRRs' => 'read requests', + 'KRs' => 'reads', + 'KWR' => 'write requests', + 'KWs' => 'writes', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "Keys"; +$unit_text = 'Keys'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_network_traffic.inc.php b/html/includes/graphs/application/mysql_network_traffic.inc.php index d606a1cdd..c37372eee 100644 --- a/html/includes/graphs/application/mysql_network_traffic.inc.php +++ b/html/includes/graphs/application/mysql_network_traffic.inc.php @@ -1,19 +1,16 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/application/mysql_query_cache.inc.php b/html/includes/graphs/application/mysql_query_cache.inc.php index 132e66dd0..1de063436 100644 --- a/html/includes/graphs/application/mysql_query_cache.inc.php +++ b/html/includes/graphs/application/mysql_query_cache.inc.php @@ -1,38 +1,52 @@ array('descr' => 'Queries in cache', 'colour' => '22FF22'), - 'QCHs' => array('descr' => 'Cache hits', 'colour' => '0022FF'), - 'QCIs' => array('descr' => 'Inserts', 'colour' => 'FF0000'), - 'QCNCd' => array('descr' => 'Not cached', 'colour' => '00AAAA'), - 'QCLMPs' => array('descr' => 'Low-memory prunes', 'colour' => 'FF00FF'), -); +$array = array( + 'QCQICe' => array( + 'descr' => 'Queries in cache', + 'colour' => '22FF22', + ), + 'QCHs' => array( + 'descr' => 'Cache hits', + 'colour' => '0022FF', + ), + 'QCIs' => array( + 'descr' => 'Inserts', + 'colour' => 'FF0000', + ), + 'QCNCd' => array( + 'descr' => 'Not cached', + 'colour' => '00AAAA', + ), + 'QCLMPs' => array( + 'descr' => 'Low-memory prunes', + 'colour' => 'FF00FF', + ), + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; -# $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { echo("file missing: $file"); } +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + // $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "Commands"; +$unit_text = 'Commands'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_query_cache_memory.inc.php b/html/includes/graphs/application/mysql_query_cache_memory.inc.php index bc72499d5..f4dcf4737 100644 --- a/html/includes/graphs/application/mysql_query_cache_memory.inc.php +++ b/html/includes/graphs/application/mysql_query_cache_memory.inc.php @@ -1,34 +1,35 @@ 'Cache size', - 'QCeFy' => 'Free mem', -); +$array = array( + 'QCs' => 'Cache size', + 'QCeFy' => 'Free mem', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "Bytes"; +$unit_text = 'Bytes'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_select_types.inc.php b/html/includes/graphs/application/mysql_select_types.inc.php index 7d25324e4..77f15948f 100644 --- a/html/includes/graphs/application/mysql_select_types.inc.php +++ b/html/includes/graphs/application/mysql_select_types.inc.php @@ -1,37 +1,38 @@ 'Full Join', - 'SFRJn' => 'Full Range', - 'SRe' => 'Range', - 'SRCk' => 'Range Check', - 'SSn' => 'Scan', -); +$array = array( + 'SFJn' => 'Full Join', + 'SFRJn' => 'Full Range', + 'SRe' => 'Range', + 'SRCk' => 'Range Check', + 'SSn' => 'Scan', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 0; -$unit_text = "Queries"; +$unit_text = 'Queries'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_slow_queries.inc.php b/html/includes/graphs/application/mysql_slow_queries.inc.php index 6abffdd0c..c8304c678 100644 --- a/html/includes/graphs/application/mysql_slow_queries.inc.php +++ b/html/includes/graphs/application/mysql_slow_queries.inc.php @@ -1,34 +1,32 @@ 'Slow queries', -); +$array = array('SQs' => 'Slow queries'); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "Queries"; +$unit_text = 'Queries'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_sorts.inc.php b/html/includes/graphs/application/mysql_sorts.inc.php index d2f44720b..15396df98 100644 --- a/html/includes/graphs/application/mysql_sorts.inc.php +++ b/html/includes/graphs/application/mysql_sorts.inc.php @@ -1,37 +1,37 @@ 'Rows Sorted', - 'SRange' => 'Range', - 'SMPs' => 'Merge Passes', - 'SScan' => 'Scan', -); + 'SRows' => 'Rows Sorted', + 'SRange' => 'Range', + 'SMPs' => 'Merge Passes', + 'SScan' => 'Scan', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 0; -$unit_text = ""; +$unit_text = ''; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_status.inc.php b/html/includes/graphs/application/mysql_status.inc.php index ffbb8c176..9e8b1fa06 100644 --- a/html/includes/graphs/application/mysql_status.inc.php +++ b/html/includes/graphs/application/mysql_status.inc.php @@ -1,51 +1,51 @@ 'd2', - 'State_copying_to_tmp_table' => 'd3', - 'State_end' => 'd4', - 'State_freeing_items' => 'd5', - 'State_init' => 'd6', - 'State_locked' => 'd7', - 'State_login' => 'd8', - 'State_preparing' => 'd9', - 'State_reading_from_net' => 'da', - 'State_sending_data' => 'db', - 'State_sorting_result' => 'dc', - 'State_statistics' => 'dd', - 'State_updating' => 'de', - 'State_writing_to_net' => 'df', - 'State_none' => 'dg', - 'State_other' => 'dh' + 'State_closing_tables' => 'd2', + 'State_copying_to_tmp_table' => 'd3', + 'State_end' => 'd4', + 'State_freeing_items' => 'd5', + 'State_init' => 'd6', + 'State_locked' => 'd7', + 'State_login' => 'd8', + 'State_preparing' => 'd9', + 'State_reading_from_net' => 'da', + 'State_sending_data' => 'db', + 'State_sorting_result' => 'dc', + 'State_statistics' => 'dd', + 'State_updating' => 'de', + 'State_writing_to_net' => 'df', + 'State_none' => 'dg', + 'State_other' => 'dh', ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $vars => $ds) - { - $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; +if (is_file($rrd_filename)) { + foreach ($array as $vars => $ds) { + $rrd_list[$i]['filename'] = $rrd_filename; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['descr'] = str_replace('_', ' ', $rrd_list[$i]['descr']); + $rrd_list[$i]['descr'] = str_replace('State ', '', $rrd_list[$i]['descr']); + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['descr'] = str_replace("_", " ", $rrd_list[$i]['descr']); - $rrd_list[$i]['descr'] = str_replace("State ", "", $rrd_list[$i]['descr']); - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "activity"; +$unit_text = 'activity'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_table_locks.inc.php b/html/includes/graphs/application/mysql_table_locks.inc.php index 08234d735..7a7b0ed0a 100644 --- a/html/includes/graphs/application/mysql_table_locks.inc.php +++ b/html/includes/graphs/application/mysql_table_locks.inc.php @@ -1,35 +1,35 @@ 'immed', - 'TLWd' => 'waited', -); + 'TLIe' => 'immed', + 'TLWd' => 'waited', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 0; -$unit_text = "Table locks"; +$unit_text = 'Table locks'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/mysql_temporary_objects.inc.php b/html/includes/graphs/application/mysql_temporary_objects.inc.php index ec22c6925..149ec713e 100644 --- a/html/includes/graphs/application/mysql_temporary_objects.inc.php +++ b/html/includes/graphs/application/mysql_temporary_objects.inc.php @@ -1,36 +1,36 @@ 'disk tables', - 'CTMPTs' => 'tables', - 'CTMPFs' => 'files', -); + 'CTMPDTs' => 'disk tables', + 'CTMPTs' => 'tables', + 'CTMPFs' => 'files', + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - if (is_array($vars)) - { - $rrd_list[$i]['descr'] = $vars['descr']; - } else { - $rrd_list[$i]['descr'] = $vars; +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + if (is_array($vars)) { + $rrd_list[$i]['descr'] = $vars['descr']; + } + else { + $rrd_list[$i]['descr'] = $vars; + } + + $rrd_list[$i]['ds'] = $ds; + $i++; } - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { echo("file missing: $file"); } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 0; -$unit_text = "Temp"; +$unit_text = 'Temp'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/nginx_connections.inc.php b/html/includes/graphs/application/nginx_connections.inc.php index d2dc35915..44e2e3a5d 100644 --- a/html/includes/graphs/application/nginx_connections.inc.php +++ b/html/includes/graphs/application/nginx_connections.inc.php @@ -2,33 +2,45 @@ $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-nginx-".$app['app_id'].".rrd"; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-nginx-'.$app['app_id'].'.rrd'; -$array = array('Reading' => array('descr' => 'Reading', 'colour' => '750F7DFF'), - 'Writing' => array('descr' => 'Writing', 'colour' => '00FF00FF'), - 'Waiting' => array('descr' => 'Waiting', 'colour' => '4444FFFF'), - 'Active' => array('descr' => 'Starting', 'colour' => '157419FF'), -); +$array = array( + 'Reading' => array( + 'descr' => 'Reading', + 'colour' => '750F7DFF', + ), + 'Writing' => array( + 'descr' => 'Writing', + 'colour' => '00FF00FF', + ), + 'Waiting' => array( + 'descr' => 'Waiting', + 'colour' => '4444FFFF', + ), + 'Active' => array( + 'descr' => 'Starting', + 'colour' => '157419FF', + ), + ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { echo("file missing: $file"); } +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "Workers"; +$unit_text = 'Workers'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/nginx_req.inc.php b/html/includes/graphs/application/nginx_req.inc.php index a512b9a94..97bff73ae 100644 --- a/html/includes/graphs/application/nginx_req.inc.php +++ b/html/includes/graphs/application/nginx_req.inc.php @@ -1,25 +1,22 @@ diff --git a/html/includes/graphs/application/ntpclient_freq.inc.php b/html/includes/graphs/application/ntpclient_freq.inc.php index 01288ad9f..36d580a50 100644 --- a/html/includes/graphs/application/ntpclient_freq.inc.php +++ b/html/includes/graphs/application/ntpclient_freq.inc.php @@ -1,21 +1,18 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/ntpclient_stats.inc.php b/html/includes/graphs/application/ntpclient_stats.inc.php index c83993ebd..b7c668054 100644 --- a/html/includes/graphs/application/ntpclient_stats.inc.php +++ b/html/includes/graphs/application/ntpclient_stats.inc.php @@ -1,34 +1,31 @@ array('descr' => 'Offset'), - 'jitter' => array('descr' => 'Jitter'), - 'noise' => array('descr' => 'Noise'), - 'stability' => array('descr' => 'Stability') - ); + 'offset' => array('descr' => 'Offset'), + 'jitter' => array('descr' => 'Jitter'), + 'noise' => array('descr' => 'Noise'), + 'stability' => array('descr' => 'Stability'), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i]; - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i]; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/ntpdserver_bits.inc.php b/html/includes/graphs/application/ntpdserver_bits.inc.php index f3cbb7428..b96f3c5a5 100644 --- a/html/includes/graphs/application/ntpdserver_bits.inc.php +++ b/html/includes/graphs/application/ntpdserver_bits.inc.php @@ -1,35 +1,30 @@ +// include("includes/graphs/generic_bits.inc.php"); +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/application/ntpdserver_buffer.inc.php b/html/includes/graphs/application/ntpdserver_buffer.inc.php index 47c930f8e..3e47555f9 100644 --- a/html/includes/graphs/application/ntpdserver_buffer.inc.php +++ b/html/includes/graphs/application/ntpdserver_buffer.inc.php @@ -1,34 +1,31 @@ array('descr' => 'Received'), - 'buffer_used' => array('descr' => 'Used'), - 'buffer_free' => array('descr' => 'Free') - ); + 'buffer_recv' => array('descr' => 'Received'), + 'buffer_used' => array('descr' => 'Used'), + 'buffer_free' => array('descr' => 'Free'), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i]; - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i]; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/ntpdserver_freq.inc.php b/html/includes/graphs/application/ntpdserver_freq.inc.php index f74fc0d09..13f64c295 100644 --- a/html/includes/graphs/application/ntpdserver_freq.inc.php +++ b/html/includes/graphs/application/ntpdserver_freq.inc.php @@ -1,21 +1,18 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/ntpdserver_packets.inc.php b/html/includes/graphs/application/ntpdserver_packets.inc.php index 780039700..6eee73cab 100644 --- a/html/includes/graphs/application/ntpdserver_packets.inc.php +++ b/html/includes/graphs/application/ntpdserver_packets.inc.php @@ -1,34 +1,36 @@ array('descr' => 'Dropped', 'colour' => '880000FF'), - 'packets_ignore' => array('descr' => 'Ignored', 'colour' => 'FF8800FF') - ); + 'packets_drop' => array( + 'descr' => 'Dropped', + 'colour' => '880000FF', + ), + 'packets_ignore' => array( + 'descr' => 'Ignored', + 'colour' => 'FF8800FF', + ), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; } -// include("includes/graphs/generic_multi_line.inc.php"); - -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +// include("includes/graphs/generic_multi_line.inc.php"); +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/ntpdserver_stats.inc.php b/html/includes/graphs/application/ntpdserver_stats.inc.php index 70e129557..e6d79d292 100644 --- a/html/includes/graphs/application/ntpdserver_stats.inc.php +++ b/html/includes/graphs/application/ntpdserver_stats.inc.php @@ -1,34 +1,31 @@ array('descr' => 'Offset'), - 'jitter' => array('descr' => 'Jitter'), - 'noise' => array('descr' => 'Noise'), - 'stability' => array('descr' => 'Stability') - ); + 'offset' => array('descr' => 'Offset'), + 'jitter' => array('descr' => 'Jitter'), + 'noise' => array('descr' => 'Noise'), + 'stability' => array('descr' => 'Stability'), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i]; - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i]; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/ntpdserver_stratum.inc.php b/html/includes/graphs/application/ntpdserver_stratum.inc.php index e0d59019c..debff062e 100644 --- a/html/includes/graphs/application/ntpdserver_stratum.inc.php +++ b/html/includes/graphs/application/ntpdserver_stratum.inc.php @@ -1,21 +1,18 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/ntpdserver_uptime.inc.php b/html/includes/graphs/application/ntpdserver_uptime.inc.php index 03c94ce8a..e1b007f3d 100644 --- a/html/includes/graphs/application/ntpdserver_uptime.inc.php +++ b/html/includes/graphs/application/ntpdserver_uptime.inc.php @@ -1,40 +1,37 @@ +$rrd_options .= ' AREA:cuptime#'.$colour_area.':'; +$rrd_options .= ' LINE1.25:cuptime#'.$colour_line.':Uptime'; +$rrd_options .= ' GPRINT:cuptime:LAST:%6.2lf'; +$rrd_options .= ' GPRINT:cuptime:AVERAGE:%6.2lf'; +$rrd_options .= ' GPRINT:cuptime:MAX:%6.2lf'; +$rrd_options .= " GPRINT:cuptime:AVERAGE:%6.2lf\\n"; diff --git a/html/includes/graphs/application/powerdns_fail.inc.php b/html/includes/graphs/application/powerdns_fail.inc.php index a5b92fb65..469b633ac 100644 --- a/html/includes/graphs/application/powerdns_fail.inc.php +++ b/html/includes/graphs/application/powerdns_fail.inc.php @@ -1,34 +1,40 @@ array('descr' => 'Corrupt', 'colour' => 'FF8800FF'), - 'servfailPackets' => array('descr' => 'Failed', 'colour' => 'FF0000FF'), - 'q_timedout' => array('descr' => 'Timedout', 'colour' => 'FFFF00FF'), - ); + 'corruptPackets' => array( + 'descr' => 'Corrupt', + 'colour' => 'FF8800FF', + ), + 'servfailPackets' => array( + 'descr' => 'Failed', + 'colour' => 'FF0000FF', + ), + 'q_timedout' => array( + 'descr' => 'Timedout', + 'colour' => 'FFFF00FF', + ), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/powerdns_latency.inc.php b/html/includes/graphs/application/powerdns_latency.inc.php index fb8ceb5ff..5e716a8dc 100644 --- a/html/includes/graphs/application/powerdns_latency.inc.php +++ b/html/includes/graphs/application/powerdns_latency.inc.php @@ -1,21 +1,18 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/powerdns_packetcache.inc.php b/html/includes/graphs/application/powerdns_packetcache.inc.php index 13f574b4a..abd3297cc 100644 --- a/html/includes/graphs/application/powerdns_packetcache.inc.php +++ b/html/includes/graphs/application/powerdns_packetcache.inc.php @@ -1,34 +1,40 @@ array('descr' => 'Hits', 'colour' => '008800FF'), - 'pc_miss' => array('descr' => 'Misses', 'colour' => '880000FF'), - 'pc_size' => array('descr' => 'Size', 'colour' => '006699FF'), - ); + 'pc_hit' => array( + 'descr' => 'Hits', + 'colour' => '008800FF', + ), + 'pc_miss' => array( + 'descr' => 'Misses', + 'colour' => '880000FF', + ), + 'pc_size' => array( + 'descr' => 'Size', + 'colour' => '006699FF', + ), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/powerdns_queries.inc.php b/html/includes/graphs/application/powerdns_queries.inc.php index 71b2a0be0..49f5b8d20 100644 --- a/html/includes/graphs/application/powerdns_queries.inc.php +++ b/html/includes/graphs/application/powerdns_queries.inc.php @@ -1,35 +1,44 @@ array('descr' => 'TCP Answers', 'colour' => '008800FF'), - 'q_tcpQueries' => array('descr' => 'TCP Queries', 'colour' => '00FF00FF'), - 'q_udpAnswers' => array('descr' => 'UDP Answers', 'colour' => '336699FF'), - 'q_udpQueries' => array('descr' => 'UDP Queries', 'colour' => '6699CCFF'), - ); + 'q_tcpAnswers' => array( + 'descr' => 'TCP Answers', + 'colour' => '008800FF', + ), + 'q_tcpQueries' => array( + 'descr' => 'TCP Queries', + 'colour' => '00FF00FF', + ), + 'q_udpAnswers' => array( + 'descr' => 'UDP Answers', + 'colour' => '336699FF', + ), + 'q_udpQueries' => array( + 'descr' => 'UDP Queries', + 'colour' => '6699CCFF', + ), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/powerdns_queries_udp.inc.php b/html/includes/graphs/application/powerdns_queries_udp.inc.php index ef2b6afd7..e680f72da 100644 --- a/html/includes/graphs/application/powerdns_queries_udp.inc.php +++ b/html/includes/graphs/application/powerdns_queries_udp.inc.php @@ -1,35 +1,44 @@ array('descr' => 'UDP4 Answers', 'colour' => '00008888'), - 'q_udp4Queries' => array('descr' => 'UDP4 Queries', 'colour' => '000088FF'), - 'q_udp6Answers' => array('descr' => 'UDP6 Answers', 'colour' => '88000088'), - 'q_udp6Queries' => array('descr' => 'UDP6 Queries', 'colour' => '880000FF'), - ); + 'q_udp4Answers' => array( + 'descr' => 'UDP4 Answers', + 'colour' => '00008888', + ), + 'q_udp4Queries' => array( + 'descr' => 'UDP4 Queries', + 'colour' => '000088FF', + ), + 'q_udp6Answers' => array( + 'descr' => 'UDP6 Answers', + 'colour' => '88000088', + ), + 'q_udp6Queries' => array( + 'descr' => 'UDP6 Queries', + 'colour' => '880000FF', + ), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/powerdns_querycache.inc.php b/html/includes/graphs/application/powerdns_querycache.inc.php index 1ad4f3821..694bb88f7 100644 --- a/html/includes/graphs/application/powerdns_querycache.inc.php +++ b/html/includes/graphs/application/powerdns_querycache.inc.php @@ -1,33 +1,36 @@ array('descr' => 'Misses', 'colour' => '750F7DFF'), - 'qc_hit' => array('descr' => 'Hits', 'colour' => '00FF00FF'), - ); + 'qc_miss' => array( + 'descr' => 'Misses', + 'colour' => '750F7DFF', + ), + 'qc_hit' => array( + 'descr' => 'Hits', + 'colour' => '00FF00FF', + ), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/powerdns_recursing.inc.php b/html/includes/graphs/application/powerdns_recursing.inc.php index 758b3ee23..32a94799a 100644 --- a/html/includes/graphs/application/powerdns_recursing.inc.php +++ b/html/includes/graphs/application/powerdns_recursing.inc.php @@ -1,33 +1,36 @@ array('descr' => 'Questions', 'colour' => '6699CCFF'), - 'rec_answers' => array('descr' => 'Answers', 'colour' => '336699FF'), - ); + 'rec_questions' => array( + 'descr' => 'Questions', + 'colour' => '6699CCFF', + ), + 'rec_answers' => array( + 'descr' => 'Answers', + 'colour' => '336699FF', + ), + ); -$i = 0; +$i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { - echo("file missing: $file"); +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/application/shoutcast_bits.inc.php b/html/includes/graphs/application/shoutcast_bits.inc.php index e1ac058d8..020ce76b9 100644 --- a/html/includes/graphs/application/shoutcast_bits.inc.php +++ b/html/includes/graphs/application/shoutcast_bits.inc.php @@ -1,27 +1,25 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/application/shoutcast_multi_bits.inc.php b/html/includes/graphs/application/shoutcast_multi_bits.inc.php index 3d9ba7d70..69b7b482b 100644 --- a/html/includes/graphs/application/shoutcast_multi_bits.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_bits.inc.php @@ -2,55 +2,49 @@ $device = device_by_id_cache($vars['id']); -$units = "b"; -$total_units = "B"; -$colours_in = "greens"; -$multiplier = "8"; -$colours_out = "blues"; +$units = 'b'; +$total_units = 'B'; +$colours_in = 'greens'; +$multiplier = '8'; +$colours_out = 'blues'; -$nototal = 1; +$nototal = 1; -$ds_in = "traf_in"; -$ds_out = "traf_out"; +$ds_in = 'traf_in'; +$ds_out = 'traf_out'; -$graph_title = "Traffic Statistic"; +$graph_title = 'Traffic Statistic'; -$colour_line_in = "006600"; -$colour_line_out = "000099"; -$colour_area_in = "CDEB8B"; -$colour_area_out = "C3D9FF"; +$colour_line_in = '006600'; +$colour_line_out = '000099'; +$colour_area_in = 'CDEB8B'; +$colour_area_out = 'C3D9FF'; -$rrddir = $config['rrd_dir']."/".$device['hostname']; -$files = array(); -$i = 0; +$rrddir = $config['rrd_dir'].'/'.$device['hostname']; +$files = array(); +$i = 0; -if ($handle = opendir($rrddir)) -{ - while (false !== ($file = readdir($handle))) - { - if ($file != "." && $file != "..") +if ($handle = opendir($rrddir)) { + while (false !== ($file = readdir($handle))) { - if (eregi("app-shoutcast-".$app['app_id'], $file)) - { - array_push($files, $file); - } + if ($file != '.' && $file != '..') { + if (eregi('app-shoutcast-'.$app['app_id'], $file)) { + array_push($files, $file); + } + } } - } } -foreach ($files as $id => $file) -{ - $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); - $hostname = eregi_replace('.rrd', '', $hostname); - list($host, $port) = split('_', $hostname, 2); - $rrd_filenames[] = $rrddir."/".$file; - $rrd_list[$i]['filename'] = $rrddir."/".$file; - $rrd_list[$i]['descr'] = $host.":".$port; - $rrd_list[$i]['ds_in'] = $ds_in; - $rrd_list[$i]['ds_out'] = $ds_out; - $i++; +foreach ($files as $id => $file) { + $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); + $hostname = eregi_replace('.rrd', '', $hostname); + list($host, $port) = split('_', $hostname, 2); + $rrd_filenames[] = $rrddir.'/'.$file; + $rrd_list[$i]['filename'] = $rrddir.'/'.$file; + $rrd_list[$i]['descr'] = $host.':'.$port; + $rrd_list[$i]['ds_in'] = $ds_in; + $rrd_list[$i]['ds_out'] = $ds_out; + $i++; } -include("includes/graphs/generic_multi_bits_separated.inc.php"); - -?> +require 'includes/graphs/generic_multi_bits_separated.inc.php'; diff --git a/html/includes/graphs/application/shoutcast_multi_stats.inc.php b/html/includes/graphs/application/shoutcast_multi_stats.inc.php index e0345a95b..3d901e14b 100644 --- a/html/includes/graphs/application/shoutcast_multi_stats.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_stats.inc.php @@ -2,103 +2,106 @@ $device = device_by_id_cache($vars['id']); -//$colour = "random"; -$unit_text = "ShoutCast Server"; -$total_text = "Total of all ShoutCast Servers"; +// $colour = "random"; +$unit_text = 'ShoutCast Server'; +$total_text = 'Total of all ShoutCast Servers'; $nototal = 0; -$rrddir = $config['rrd_dir']."/".$device['hostname']; -$files = array(); -$i = 0; -$x = 0; +$rrddir = $config['rrd_dir'].'/'.$device['hostname']; +$files = array(); +$i = 0; +$x = 0; -if ($handle = opendir($rrddir)) -{ - while (false !== ($file = readdir($handle))) - { - if ($file != "." && $file != "..") +if ($handle = opendir($rrddir)) { + while (false !== ($file = readdir($handle))) { - if (eregi("app-shoutcast-".$app['app_id'], $file)) - { - array_push($files, $file); - } + if ($file != '.' && $file != '..') { + if (eregi('app-shoutcast-'.$app['app_id'], $file)) { + array_push($files, $file); + } + } } - } } -foreach ($files as $id => $file) -{ - $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); - $hostname = eregi_replace('.rrd', '', $hostname); - list($host, $port) = split('_', $hostname, 2); - $rrd_filenames[] = $rrddir."/".$file; - $rrd_list[$i]['filename'] = $rrddir."/".$file; - $rrd_list[$i]['descr'] = $host.":".$port; - $rrd_list[$i]['colour'] = $colour; - $i++; +foreach ($files as $id => $file) { + $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); + $hostname = eregi_replace('.rrd', '', $hostname); + list($host, $port) = split('_', $hostname, 2); + $rrd_filenames[] = $rrddir.'/'.$file; + $rrd_list[$i]['filename'] = $rrddir.'/'.$file; + $rrd_list[$i]['descr'] = $host.':'.$port; + $rrd_list[$i]['colour'] = $colour; + $i++; } -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -if ($width > "500") -{ - $descr_len = 38; -} else { - $descr_len = 8; - $descr_len += round(($width - 250) / 8); +if ($width > '500') { + $descr_len = 38; +} +else { + $descr_len = 8; + $descr_len += round(($width - 250) / 8); } -if ($width > "500") -{ - $rrd_options .= " COMMENT:\"".substr(str_pad($unit_text, $descr_len+2), 0, $descr_len+2)." Current Unique Average Peak\\n\""; -} else { - $rrd_options .= " COMMENT:\"".substr(str_pad($unit_text, $descr_len+5), 0, $descr_len+5)." Now Unique Average Peak\\n\""; +if ($width > '500') { + $rrd_options .= ' COMMENT:"'.substr(str_pad($unit_text, ($descr_len + 2)), 0, ($descr_len + 2))." Current Unique Average Peak\\n\""; +} +else { + $rrd_options .= ' COMMENT:"'.substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." Now Unique Average Peak\\n\""; } -foreach ($rrd_list as $rrd) -{ - $colours = (isset($rrd['colour']) ? $rrd['colour'] : "default"); - $strlen = ((strlen($rrd['descr'])<$descr_len) ? ($descr_len - strlen($rrd['descr'])) : "0"); - $descr = (isset($rrd['descr']) ? rrdtool_escape($rrd['descr'], $desc_len+$strlen) : "Unkown"); - for ($z=0; $z<$strlen; $z++) { $descr .= " "; } - if ($i) { $stack = "STACK"; } +foreach ($rrd_list as $rrd) { + $colours = (isset($rrd['colour']) ? $rrd['colour'] : 'default'); + $strlen = ((strlen($rrd['descr']) < $descr_len) ? ($descr_len - strlen($rrd['descr'])) : '0'); + $descr = (isset($rrd['descr']) ? rrdtool_escape($rrd['descr'], ($desc_len + $strlen)) : 'Unkown'); + for ($z = 0; $z < $strlen; + $z++) { + $descr .= ' '; + } + + if ($i) { + $stack = 'STACK'; + } + $colour = $config['graph_colours'][$colours][$x]; - $rrd_options .= " DEF:cur".$x."=".$rrd['filename'].":current:AVERAGE"; - $rrd_options .= " DEF:peak".$x."=".$rrd['filename'].":peak:MAX"; - $rrd_options .= " DEF:unique".$x."=".$rrd['filename'].":unique:AVERAGE"; - $rrd_options .= " VDEF:avg".$x."=cur".$x.",AVERAGE"; - $rrd_options .= " AREA:cur".$x."#".$colour.":\"".$descr."\":$stack"; - $rrd_options .= " GPRINT:cur".$x.":LAST:\"%6.2lf\""; - $rrd_options .= " GPRINT:unique".$x.":LAST:\"%6.2lf%s\""; - $rrd_options .= " GPRINT:avg".$x.":\"%6.2lf\""; - $rrd_options .= " GPRINT:peak".$x.":LAST:\"%6.2lf\""; + $rrd_options .= ' DEF:cur'.$x.'='.$rrd['filename'].':current:AVERAGE'; + $rrd_options .= ' DEF:peak'.$x.'='.$rrd['filename'].':peak:MAX'; + $rrd_options .= ' DEF:unique'.$x.'='.$rrd['filename'].':unique:AVERAGE'; + $rrd_options .= ' VDEF:avg'.$x.'=cur'.$x.',AVERAGE'; + $rrd_options .= ' AREA:cur'.$x.'#'.$colour.':"'.$descr."\":$stack"; + $rrd_options .= ' GPRINT:cur'.$x.':LAST:"%6.2lf"'; + $rrd_options .= ' GPRINT:unique'.$x.':LAST:"%6.2lf%s"'; + $rrd_options .= ' GPRINT:avg'.$x.':"%6.2lf"'; + $rrd_options .= ' GPRINT:peak'.$x.':LAST:"%6.2lf"'; $rrd_options .= " COMMENT:\"\\n\""; - if ($x) - { - $totcur .= ",cur".$x.",+"; - $totpeak .= ",peak".$x.",+"; - $totunique .= ",unique".$x.",+"; + if ($x) { + $totcur .= ',cur'.$x.',+'; + $totpeak .= ',peak'.$x.',+'; + $totunique .= ',unique'.$x.',+'; } - $x = (($x +if (!$nototal) { + $strlen = ((strlen($total_text) < $descr_len) ? ($descr_len - strlen($total_text)) : '0'); + $descr = (isset($total_text) ? rrdtool_escape($total_text, ($desc_len + $strlen)) : 'Total'); + $colour = $config['graph_colours'][$colours][$x]; + for ($z = 0; $z < $strlen; + $z++) { + $descr .= ' '; + } + + $rrd_options .= ' CDEF:totcur=cur0'.$totcur; + $rrd_options .= ' CDEF:totunique=unique0'.$totunique; + $rrd_options .= ' CDEF:totpeak=peak0'.$totpeak; + $rrd_options .= ' VDEF:totavg=totcur,AVERAGE'; + $rrd_options .= ' LINE2:totcur#'.$colour.':"'.$descr.'"'; + $rrd_options .= ' GPRINT:totcur:LAST:"%6.2lf"'; + $rrd_options .= ' GPRINT:totunique:LAST:"%6.2lf%s"'; + $rrd_options .= ' GPRINT:totavg:"%6.2lf"'; + $rrd_options .= ' GPRINT:totpeak:LAST:"%6.2lf"'; + $rrd_options .= " COMMENT:\"\\n\""; +} diff --git a/html/includes/graphs/application/shoutcast_stats.inc.php b/html/includes/graphs/application/shoutcast_stats.inc.php index c383fc5ca..15f1e654a 100644 --- a/html/includes/graphs/application/shoutcast_stats.inc.php +++ b/html/includes/graphs/application/shoutcast_stats.inc.php @@ -1,45 +1,43 @@ = 355) -{ - $rrd_options .= " GPRINT:cur:LAST:\"\:%8.2lf\""; - $rrd_options .= " GPRINT:max:LAST:\"from%8.2lf\""; - $rrd_options .= " GPRINT:bitrate:LAST:\"(bitrate\:%8.2lf%s\""; - $rrd_options .= " COMMENT:\")\\n\""; -} else { - $rrd_options .= " GPRINT:cur:LAST:\"\:%8.2lf\\n\""; +if ($width >= 355) { + $rrd_options .= ' GPRINT:cur:LAST:"\:%8.2lf"'; + $rrd_options .= ' GPRINT:max:LAST:"from%8.2lf"'; + $rrd_options .= ' GPRINT:bitrate:LAST:"(bitrate\:%8.2lf%s"'; + $rrd_options .= " COMMENT:\")\\n\""; +} +else { + $rrd_options .= " GPRINT:cur:LAST:\"\:%8.2lf\\n\""; } -$rrd_options .= " AREA:unique#AADEFEFF:\"Unique Listeners \""; +$rrd_options .= ' AREA:unique#AADEFEFF:"Unique Listeners "'; $rrd_options .= " GPRINT:unique:LAST:\"\:%8.2lf%s\\n\""; -$rrd_options .= " HRULE:avg#FF9000FF:\"Average Listeners\""; +$rrd_options .= ' HRULE:avg#FF9000FF:"Average Listeners"'; $rrd_options .= " GPRINT:avg:\"\:%8.2lf\\n\""; -$rrd_options .= " LINE1:peak#C000FFFF:\"Peak Listeners \""; +$rrd_options .= ' LINE1:peak#C000FFFF:"Peak Listeners "'; $rrd_options .= " GPRINT:peak:LAST:\"\:%8.2lf\\n\""; $rrd_options .= " TICK:stream_offline#B4FF00FF:1.0:\"Streaming client offline\\n\""; -$rrd_options .= " TICK:server_offline".$warn_colour_b."FF:1.0:\"Streaming server offline\""; - -?> +$rrd_options .= ' TICK:server_offline'.$warn_colour_b.'FF:1.0:"Streaming server offline"'; diff --git a/html/includes/graphs/atmvp/auth.inc.php b/html/includes/graphs/atmvp/auth.inc.php index b307266b6..caf963e38 100644 --- a/html/includes/graphs/atmvp/auth.inc.php +++ b/html/includes/graphs/atmvp/auth.inc.php @@ -1,18 +1,17 @@ +$vp = dbFetchRow('SELECT * FROM `juniAtmVp` as J, `ports` AS I, `devices` AS D WHERE J.juniAtmVp_id = ? AND I.port_id = J.port_id AND I.device_id = D.device_id', array($atm_vp_id)); + +if ($auth || port_permitted($vp['port_id'])) { + $port = $vp; + $device = device_by_id_cache($port['device_id']); + $title = generate_device_link($device); + $title .= ' :: Port '.generate_port_link($port); + $title .= ' :: VP '.$vp['vp_id']; + $auth = true; + $rrd_filename = $config['rrd_dir'].'/'.$vp['hostname'].'/'.safename('vp-'.$vp['ifIndex'].'-'.$vp['vp_id'].'.rrd'); +} diff --git a/html/includes/graphs/atmvp/bits.inc.php b/html/includes/graphs/atmvp/bits.inc.php index a571ec7ed..f158d9c7a 100644 --- a/html/includes/graphs/atmvp/bits.inc.php +++ b/html/includes/graphs/atmvp/bits.inc.php @@ -1,8 +1,6 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/atmvp/cells.inc.php b/html/includes/graphs/atmvp/cells.inc.php index dc4387f58..36d067b6c 100644 --- a/html/includes/graphs/atmvp/cells.inc.php +++ b/html/includes/graphs/atmvp/cells.inc.php @@ -1,19 +1,17 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/atmvp/errors.inc.php b/html/includes/graphs/atmvp/errors.inc.php index 7035a5385..b36562f58 100644 --- a/html/includes/graphs/atmvp/errors.inc.php +++ b/html/includes/graphs/atmvp/errors.inc.php @@ -1,20 +1,18 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/atmvp/packets.inc.php b/html/includes/graphs/atmvp/packets.inc.php index 34c5b8c93..fbfc62797 100644 --- a/html/includes/graphs/atmvp/packets.inc.php +++ b/html/includes/graphs/atmvp/packets.inc.php @@ -1,19 +1,17 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/bgp/auth.inc.php b/html/includes/graphs/bgp/auth.inc.php index 96d999555..79ab1be2c 100644 --- a/html/includes/graphs/bgp/auth.inc.php +++ b/html/includes/graphs/bgp/auth.inc.php @@ -1,18 +1,13 @@ diff --git a/html/includes/graphs/bgp/prefixes.inc.php b/html/includes/graphs/bgp/prefixes.inc.php index 7a6170b36..db9290fb2 100644 --- a/html/includes/graphs/bgp/prefixes.inc.php +++ b/html/includes/graphs/bgp/prefixes.inc.php @@ -1,18 +1,16 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/bgp/prefixes_ipv4multicast.inc.php b/html/includes/graphs/bgp/prefixes_ipv4multicast.inc.php index 77dede1ba..8f2cfe54d 100644 --- a/html/includes/graphs/bgp/prefixes_ipv4multicast.inc.php +++ b/html/includes/graphs/bgp/prefixes_ipv4multicast.inc.php @@ -1,7 +1,5 @@ +require 'includes/graphs/bgp/prefixes.inc.php'; diff --git a/html/includes/graphs/bgp/prefixes_ipv4unicast.inc.php b/html/includes/graphs/bgp/prefixes_ipv4unicast.inc.php index 4efdd65be..6fbfa01cc 100644 --- a/html/includes/graphs/bgp/prefixes_ipv4unicast.inc.php +++ b/html/includes/graphs/bgp/prefixes_ipv4unicast.inc.php @@ -1,7 +1,5 @@ +require 'includes/graphs/bgp/prefixes.inc.php'; diff --git a/html/includes/graphs/bgp/prefixes_ipv4vpn.inc.php b/html/includes/graphs/bgp/prefixes_ipv4vpn.inc.php index 810b3525e..9ff56248e 100644 --- a/html/includes/graphs/bgp/prefixes_ipv4vpn.inc.php +++ b/html/includes/graphs/bgp/prefixes_ipv4vpn.inc.php @@ -1,7 +1,5 @@ +require 'includes/graphs/bgp/prefixes.inc.php'; diff --git a/html/includes/graphs/bgp/prefixes_ipv6multicast.inc.php b/html/includes/graphs/bgp/prefixes_ipv6multicast.inc.php index d6dc8d14a..8ed9bc649 100644 --- a/html/includes/graphs/bgp/prefixes_ipv6multicast.inc.php +++ b/html/includes/graphs/bgp/prefixes_ipv6multicast.inc.php @@ -1,7 +1,5 @@ +require 'includes/graphs/bgp/prefixes.inc.php'; diff --git a/html/includes/graphs/bgp/prefixes_ipv6unicast.inc.php b/html/includes/graphs/bgp/prefixes_ipv6unicast.inc.php index f902af499..f1b6a49ad 100644 --- a/html/includes/graphs/bgp/prefixes_ipv6unicast.inc.php +++ b/html/includes/graphs/bgp/prefixes_ipv6unicast.inc.php @@ -1,7 +1,5 @@ +require 'includes/graphs/bgp/prefixes.inc.php'; diff --git a/html/includes/graphs/bgp/prefixes_ipv6vpn.inc.php b/html/includes/graphs/bgp/prefixes_ipv6vpn.inc.php index 633d06aaf..730f66d31 100644 --- a/html/includes/graphs/bgp/prefixes_ipv6vpn.inc.php +++ b/html/includes/graphs/bgp/prefixes_ipv6vpn.inc.php @@ -1,7 +1,5 @@ +require 'includes/graphs/bgp/prefixes.inc.php'; diff --git a/html/includes/graphs/bgp/updates.inc.php b/html/includes/graphs/bgp/updates.inc.php index 04d8f44b2..2458a453b 100644 --- a/html/includes/graphs/bgp/updates.inc.php +++ b/html/includes/graphs/bgp/updates.inc.php @@ -1,24 +1,22 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/bill/auth.inc.php b/html/includes/graphs/bill/auth.inc.php index af4363b57..524082501 100644 --- a/html/includes/graphs/bill/auth.inc.php +++ b/html/includes/graphs/bill/auth.inc.php @@ -1,21 +1,17 @@ diff --git a/html/includes/graphs/bill/bits.inc.php b/html/includes/graphs/bill/bits.inc.php index 55edf988f..2e80ef792 100644 --- a/html/includes/graphs/bill/bits.inc.php +++ b/html/includes/graphs/bill/bits.inc.php @@ -1,41 +1,36 @@ +require 'includes/graphs/generic_multi_bits_separated.inc.php'; diff --git a/html/includes/graphs/c6kxbar/auth.inc.php b/html/includes/graphs/c6kxbar/auth.inc.php index 96076c92c..57212efb8 100644 --- a/html/includes/graphs/c6kxbar/auth.inc.php +++ b/html/includes/graphs/c6kxbar/auth.inc.php @@ -1,18 +1,14 @@ diff --git a/html/includes/graphs/c6kxbar/util.inc.php b/html/includes/graphs/c6kxbar/util.inc.php index c3b3145a6..dbf8eb8d7 100644 --- a/html/includes/graphs/c6kxbar/util.inc.php +++ b/html/includes/graphs/c6kxbar/util.inc.php @@ -1,19 +1,17 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/cefswitching/auth.inc.php b/html/includes/graphs/cefswitching/auth.inc.php index d95498efa..3db047851 100644 --- a/html/includes/graphs/cefswitching/auth.inc.php +++ b/html/includes/graphs/cefswitching/auth.inc.php @@ -1,19 +1,15 @@ diff --git a/html/includes/graphs/cefswitching/graph.inc.php b/html/includes/graphs/cefswitching/graph.inc.php index 212dba9c8..5a1b31419 100644 --- a/html/includes/graphs/cefswitching/graph.inc.php +++ b/html/includes/graphs/cefswitching/graph.inc.php @@ -1,28 +1,26 @@ +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/device/agent.inc.php b/html/includes/graphs/device/agent.inc.php index 56a46c10d..f37f864f9 100644 --- a/html/includes/graphs/device/agent.inc.php +++ b/html/includes/graphs/device/agent.inc.php @@ -2,27 +2,25 @@ $scale_min = 0; -require "includes/graphs/common.inc.php"; +require 'includes/graphs/common.inc.php'; -$agent_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/agent.rrd"; +$agent_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/agent.rrd'; if (is_file($agent_rrd)) { $rrd_filename = $agent_rrd; } -$ds = "time"; +$ds = 'time'; -$colour_area = "EEEEEE"; -$colour_line = "36393D"; +$colour_area = 'EEEEEE'; +$colour_line = '36393D'; -$colour_area_max = "FFEE99"; +$colour_area_max = 'FFEE99'; -$graph_max = 1; -$multiplier = 1000; -$multiplier_action = "/"; +$graph_max = 1; +$multiplier = 1000; +$multiplier_action = '/'; -$unit_text = "Seconds"; +$unit_text = 'Seconds'; -require "includes/graphs/generic_simplex.inc.php"; - -?> +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/device/arubacontroller_numaps.inc.php b/html/includes/graphs/device/arubacontroller_numaps.inc.php index ea071fc2a..1aa6b2c62 100644 --- a/html/includes/graphs/device/arubacontroller_numaps.inc.php +++ b/html/includes/graphs/device/arubacontroller_numaps.inc.php @@ -1,22 +1,20 @@ diff --git a/html/includes/graphs/device/arubacontroller_numclients.inc.php b/html/includes/graphs/device/arubacontroller_numclients.inc.php index 6b7669c18..e86b4d758 100644 --- a/html/includes/graphs/device/arubacontroller_numclients.inc.php +++ b/html/includes/graphs/device/arubacontroller_numclients.inc.php @@ -1,26 +1,21 @@ diff --git a/html/includes/graphs/device/cipsec_flow_bits.inc.php b/html/includes/graphs/device/cipsec_flow_bits.inc.php index 7d19dafbb..861c01252 100644 --- a/html/includes/graphs/device/cipsec_flow_bits.inc.php +++ b/html/includes/graphs/device/cipsec_flow_bits.inc.php @@ -1,10 +1,8 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/device/cipsec_flow_pkts.inc.php b/html/includes/graphs/device/cipsec_flow_pkts.inc.php index 639dcbef8..526b02011 100644 --- a/html/includes/graphs/device/cipsec_flow_pkts.inc.php +++ b/html/includes/graphs/device/cipsec_flow_pkts.inc.php @@ -1,21 +1,19 @@ \ No newline at end of file +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/device/cipsec_flow_tunnels.inc.php b/html/includes/graphs/device/cipsec_flow_tunnels.inc.php index e1e77f7a1..f45a73736 100644 --- a/html/includes/graphs/device/cipsec_flow_tunnels.inc.php +++ b/html/includes/graphs/device/cipsec_flow_tunnels.inc.php @@ -1,15 +1,13 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/device/cras_sessions.inc.php b/html/includes/graphs/device/cras_sessions.inc.php index 90ae4b539..9feeefa25 100644 --- a/html/includes/graphs/device/cras_sessions.inc.php +++ b/html/includes/graphs/device/cras_sessions.inc.php @@ -1,10 +1,10 @@ diff --git a/html/includes/graphs/device/current.inc.php b/html/includes/graphs/device/current.inc.php index 4fb096550..23f8ef43e 100644 --- a/html/includes/graphs/device/current.inc.php +++ b/html/includes/graphs/device/current.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/dbm.inc.php b/html/includes/graphs/device/dbm.inc.php index 6243f739b..3c2fda3dc 100644 --- a/html/includes/graphs/device/dbm.inc.php +++ b/html/includes/graphs/device/dbm.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/diskio.inc.php b/html/includes/graphs/device/diskio.inc.php index 6fb4fa419..58f751509 100644 --- a/html/includes/graphs/device/diskio.inc.php +++ b/html/includes/graphs/device/diskio.inc.php @@ -1,5 +1,3 @@ \ No newline at end of file +require 'diskio_ops.inc.php'; diff --git a/html/includes/graphs/device/diskio_common.inc.php b/html/includes/graphs/device/diskio_common.inc.php index 36b0b56f2..2fbb00336 100644 --- a/html/includes/graphs/device/diskio_common.inc.php +++ b/html/includes/graphs/device/diskio_common.inc.php @@ -2,17 +2,13 @@ $i = 1; -foreach (dbFetchRows("SELECT * FROM `ucd_diskio` AS U, `devices` AS D WHERE D.device_id = ? AND U.device_id = D.device_id", array($device['device_id'])) as $disk) -{ - $rrd_filename = $config['rrd_dir'] . "/" . $disk['hostname'] . "/ucd_diskio-" . safename($disk['diskio_descr'] . ".rrd"); - if (is_file($rrd_filename)) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $disk['diskio_descr']; - $rrd_list[$i]['ds_in'] = $ds_in; - $rrd_list[$i]['ds_out'] = $ds_out; - $i++; - } +foreach (dbFetchRows('SELECT * FROM `ucd_diskio` AS U, `devices` AS D WHERE D.device_id = ? AND U.device_id = D.device_id', array($device['device_id'])) as $disk) { + $rrd_filename = $config['rrd_dir'].'/'.$disk['hostname'].'/ucd_diskio-'.safename($disk['diskio_descr'].'.rrd'); + if (is_file($rrd_filename)) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $disk['diskio_descr']; + $rrd_list[$i]['ds_in'] = $ds_in; + $rrd_list[$i]['ds_out'] = $ds_out; + $i++; + } } - -?> diff --git a/html/includes/graphs/device/fanspeed.inc.php b/html/includes/graphs/device/fanspeed.inc.php index 7680f3372..21692b1e3 100644 --- a/html/includes/graphs/device/fanspeed.inc.php +++ b/html/includes/graphs/device/fanspeed.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/fortigate_cpu.inc.php b/html/includes/graphs/device/fortigate_cpu.inc.php index 4733263f6..d4474641c 100644 --- a/html/includes/graphs/device/fortigate_cpu.inc.php +++ b/html/includes/graphs/device/fortigate_cpu.inc.php @@ -1,20 +1,18 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/device/fortigate_sessions.inc.php b/html/includes/graphs/device/fortigate_sessions.inc.php index c2bfcef00..18d8f902f 100644 --- a/html/includes/graphs/device/fortigate_sessions.inc.php +++ b/html/includes/graphs/device/fortigate_sessions.inc.php @@ -1,20 +1,18 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/device/frequency.inc.php b/html/includes/graphs/device/frequency.inc.php index 41cd6a772..d1fdbcb38 100644 --- a/html/includes/graphs/device/frequency.inc.php +++ b/html/includes/graphs/device/frequency.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/hr_processes.inc.php b/html/includes/graphs/device/hr_processes.inc.php index 290f40838..07f451bed 100644 --- a/html/includes/graphs/device/hr_processes.inc.php +++ b/html/includes/graphs/device/hr_processes.inc.php @@ -1,21 +1,19 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/device/hr_users.inc.php b/html/includes/graphs/device/hr_users.inc.php index a8469e174..6d54484a3 100644 --- a/html/includes/graphs/device/hr_users.inc.php +++ b/html/includes/graphs/device/hr_users.inc.php @@ -1,21 +1,19 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/device/humidity.inc.php b/html/includes/graphs/device/humidity.inc.php index 58cd7b5bb..078cbc382 100644 --- a/html/includes/graphs/device/humidity.inc.php +++ b/html/includes/graphs/device/humidity.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/ipSystemStats.inc.php b/html/includes/graphs/device/ipSystemStats.inc.php index 0a3048f54..afcbc6cb7 100644 --- a/html/includes/graphs/device/ipSystemStats.inc.php +++ b/html/includes/graphs/device/ipSystemStats.inc.php @@ -1,9 +1,9 @@ diff --git a/html/includes/graphs/device/ipsystemstats_ipv4.inc.php b/html/includes/graphs/device/ipsystemstats_ipv4.inc.php index edda01e76..8c280d376 100644 --- a/html/includes/graphs/device/ipsystemstats_ipv4.inc.php +++ b/html/includes/graphs/device/ipsystemstats_ipv4.inc.php @@ -1,8 +1,8 @@ +$rrd_options .= ' LINE1.25:InReceives#9DaB6B:'; +$rrd_options .= ' LINE1.25:OutRequests_n#93a6eF:'; diff --git a/html/includes/graphs/device/ipsystemstats_ipv4_frag.inc.php b/html/includes/graphs/device/ipsystemstats_ipv4_frag.inc.php index a4e5344cf..c59fd3780 100644 --- a/html/includes/graphs/device/ipsystemstats_ipv4_frag.inc.php +++ b/html/includes/graphs/device/ipsystemstats_ipv4_frag.inc.php @@ -1,8 +1,8 @@ diff --git a/html/includes/graphs/device/ipsystemstats_ipv6.inc.php b/html/includes/graphs/device/ipsystemstats_ipv6.inc.php index 57cedb29d..1542b14b5 100644 --- a/html/includes/graphs/device/ipsystemstats_ipv6.inc.php +++ b/html/includes/graphs/device/ipsystemstats_ipv6.inc.php @@ -1,8 +1,8 @@ +$rrd_options .= ' LINE1.25:InReceives#9DaB6B:'; +$rrd_options .= ' LINE1.25:OutRequests_n#93a6eF:'; diff --git a/html/includes/graphs/device/ipsystemstats_ipv6_frag.inc.php b/html/includes/graphs/device/ipsystemstats_ipv6_frag.inc.php index 2b9912df3..1cb81d47b 100644 --- a/html/includes/graphs/device/ipsystemstats_ipv6_frag.inc.php +++ b/html/includes/graphs/device/ipsystemstats_ipv6_frag.inc.php @@ -1,8 +1,8 @@ diff --git a/html/includes/graphs/device/mempool.inc.php b/html/includes/graphs/device/mempool.inc.php index ded4c7531..8c8fba677 100644 --- a/html/includes/graphs/device/mempool.inc.php +++ b/html/includes/graphs/device/mempool.inc.php @@ -1,40 +1,57 @@ +$rrd_options .= ' HRULE:0#999999'; diff --git a/html/includes/graphs/device/netscaler_tcp_bits.inc.php b/html/includes/graphs/device/netscaler_tcp_bits.inc.php index c2bfa177f..401e25f66 100644 --- a/html/includes/graphs/device/netscaler_tcp_bits.inc.php +++ b/html/includes/graphs/device/netscaler_tcp_bits.inc.php @@ -1,12 +1,10 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/device/netscaler_tcp_conn.inc.php b/html/includes/graphs/device/netscaler_tcp_conn.inc.php index 06edbde3d..2e18e777e 100644 --- a/html/includes/graphs/device/netscaler_tcp_conn.inc.php +++ b/html/includes/graphs/device/netscaler_tcp_conn.inc.php @@ -1,24 +1,22 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/device/netscaler_tcp_pkts.inc.php b/html/includes/graphs/device/netscaler_tcp_pkts.inc.php index e95b000f9..ae3015c24 100644 --- a/html/includes/graphs/device/netscaler_tcp_pkts.inc.php +++ b/html/includes/graphs/device/netscaler_tcp_pkts.inc.php @@ -1,21 +1,19 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/device/netstat_icmp.inc.php b/html/includes/graphs/device/netstat_icmp.inc.php index c84409fac..d44b2e320 100644 --- a/html/includes/graphs/device/netstat_icmp.inc.php +++ b/html/includes/graphs/device/netstat_icmp.inc.php @@ -1,36 +1,34 @@ '00cc00', - 'icmpOutMsgs' => '006600', - 'icmpInErrors' => 'cc0000', - 'icmpOutErrors' => '660000', - 'icmpInEchos' => '0066cc', - 'icmpOutEchos' => '003399', - 'icmpInEchoReps' => 'cc00cc', - 'icmpOutEchoReps' => '990099'); +$stats = array( + 'icmpInMsgs' => '00cc00', + 'icmpOutMsgs' => '006600', + 'icmpInErrors' => 'cc0000', + 'icmpOutErrors' => '660000', + 'icmpInEchos' => '0066cc', + 'icmpOutEchos' => '003399', + 'icmpInEchoReps' => 'cc00cc', + 'icmpOutEchoReps' => '990099', +); -$i=0; +$i = 0; -foreach ($stats as $stat => $colour) -{ - $i++; - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = str_replace("icmp", "", $stat); - $rrd_list[$i]['ds'] = $stat; - if (strpos($stat, "Out") !== FALSE) - { - $rrd_list[$i]['invert'] = TRUE; - } +foreach ($stats as $stat => $colour) { + $i++; + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = str_replace('icmp', '', $stat); + $rrd_list[$i]['ds'] = $stat; + if (strpos($stat, 'Out') !== false) { + $rrd_list[$i]['invert'] = true; + } } -$colours='mixed'; +$colours = 'mixed'; -$scale_min = "0"; -$nototal = 1; -$simple_rrd = TRUE; +$scale_min = '0'; +$nototal = 1; +$simple_rrd = true; -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/netstat_icmp_info.inc.php b/html/includes/graphs/device/netstat_icmp_info.inc.php index 9d029320a..38ab1e719 100644 --- a/html/includes/graphs/device/netstat_icmp_info.inc.php +++ b/html/includes/graphs/device/netstat_icmp_info.inc.php @@ -1,36 +1,34 @@ array(), - 'icmpOutSrcQuenchs' => array(), - 'icmpInRedirects' => array(), - 'icmpOutRedirects' => array(), - 'icmpInAddrMasks' => array(), - 'icmpOutAddrMasks' => array(), - 'icmpInAddrMaskReps' => array(), - 'icmpOutAddrMaskReps' => array()); +$stats = array( + 'icmpInSrcQuenchs' => array(), + 'icmpOutSrcQuenchs' => array(), + 'icmpInRedirects' => array(), + 'icmpOutRedirects' => array(), + 'icmpInAddrMasks' => array(), + 'icmpOutAddrMasks' => array(), + 'icmpInAddrMaskReps' => array(), + 'icmpOutAddrMaskReps' => array(), +); -$i=0; +$i = 0; -foreach ($stats as $stat => $array) -{ - $i++; - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = str_replace("icmp", "", $stat); - $rrd_list[$i]['ds'] = $stat; - if (strpos($stat, "Out") !== FALSE) - { - $rrd_list[$i]['invert'] = TRUE; - } +foreach ($stats as $stat => $array) { + $i++; + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = str_replace('icmp', '', $stat); + $rrd_list[$i]['ds'] = $stat; + if (strpos($stat, 'Out') !== false) { + $rrd_list[$i]['invert'] = true; + } } -$colours='mixed'; +$colours = 'mixed'; -$scale_min = "0"; -$nototal = 1; -$simple_rrd = TRUE; +$scale_min = '0'; +$nototal = 1; +$simple_rrd = true; -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/netstat_ip.inc.php b/html/includes/graphs/device/netstat_ip.inc.php index 35fd810b0..4c0dfad3e 100644 --- a/html/includes/graphs/device/netstat_ip.inc.php +++ b/html/includes/graphs/device/netstat_ip.inc.php @@ -1,34 +1,32 @@ array(), - 'ipInDelivers' => array(), - 'ipInReceives' => array(), - 'ipOutRequests' => array(), - 'ipInDiscards' => array(), - 'ipOutDiscards' => array(), - 'ipOutNoRoutes' => array()); +$stats = array( + 'ipForwDatagrams' => array(), + 'ipInDelivers' => array(), + 'ipInReceives' => array(), + 'ipOutRequests' => array(), + 'ipInDiscards' => array(), + 'ipOutDiscards' => array(), + 'ipOutNoRoutes' => array(), +); -$i=0; -foreach ($stats as $stat => $array) -{ - $i++; - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = str_replace("ip", "", $stat); - $rrd_list[$i]['ds'] = $stat; - if (strpos($stat, "Out") !== FALSE) - { - $rrd_list[$i]['invert'] = TRUE; - } +$i = 0; +foreach ($stats as $stat => $array) { + $i++; + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = str_replace('ip', '', $stat); + $rrd_list[$i]['ds'] = $stat; + if (strpos($stat, 'Out') !== false) { + $rrd_list[$i]['invert'] = true; + } } -$colours='mixed'; +$colours = 'mixed'; -$scale_min = "0"; -$nototal = 1; -$simple_rrd = TRUE; +$scale_min = '0'; +$nototal = 1; +$simple_rrd = true; -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/netstat_ip_frag.inc.php b/html/includes/graphs/device/netstat_ip_frag.inc.php index 3fc3ba3ca..da5ea0249 100644 --- a/html/includes/graphs/device/netstat_ip_frag.inc.php +++ b/html/includes/graphs/device/netstat_ip_frag.inc.php @@ -1,8 +1,8 @@ \ No newline at end of file diff --git a/html/includes/graphs/device/netstat_snmp.inc.php b/html/includes/graphs/device/netstat_snmp.inc.php index 0a0bd9704..513872d27 100644 --- a/html/includes/graphs/device/netstat_snmp.inc.php +++ b/html/includes/graphs/device/netstat_snmp.inc.php @@ -1,33 +1,31 @@ +require 'includes/graphs/generic_multi.inc.php'; diff --git a/html/includes/graphs/device/netstat_snmp_pkt.inc.php b/html/includes/graphs/device/netstat_snmp_pkt.inc.php index a87f8eb0f..40883d7be 100644 --- a/html/includes/graphs/device/netstat_snmp_pkt.inc.php +++ b/html/includes/graphs/device/netstat_snmp_pkt.inc.php @@ -1,21 +1,19 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/device/netstat_tcp.inc.php b/html/includes/graphs/device/netstat_tcp.inc.php index 37c76a6ef..7559f3bd7 100644 --- a/html/includes/graphs/device/netstat_tcp.inc.php +++ b/html/includes/graphs/device/netstat_tcp.inc.php @@ -1,27 +1,31 @@ +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/netstat_udp.inc.php b/html/includes/graphs/device/netstat_udp.inc.php index 3b8ca5388..e6ff11b1d 100644 --- a/html/includes/graphs/device/netstat_udp.inc.php +++ b/html/includes/graphs/device/netstat_udp.inc.php @@ -1,27 +1,28 @@ +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/nfsen_common.inc.php b/html/includes/graphs/device/nfsen_common.inc.php index fc36a36c6..774d47e3f 100644 --- a/html/includes/graphs/device/nfsen_common.inc.php +++ b/html/includes/graphs/device/nfsen_common.inc.php @@ -1,49 +1,55 @@ + // convert dots in filename to underscores + $nfsensuffix = ''; + if ($config['nfsen_suffix']) { + $nfsensuffix = $config['nfsen_suffix']; + } + + $basefilename_underscored = preg_replace('/\./', $config['nfsen_split_char'], $device['hostname']); + $nfsen_filename = (strstr($basefilename_underscored, $nfsensuffix, true)); + + if (is_file($nfsenrrds.$nfsen_filename.'.rrd')) { + $rrd_filename = $nfsenrrds.$nfsen_filename.'.rrd'; + + $flowtypes = array('tcp', 'udp', 'icmp', 'other'); + + $rrd_list = array(); + $nfsen_iter = 1; + foreach ($flowtypes as $flowtype) { + $rrd_list[$nfsen_iter]['filename'] = $rrd_filename; + $rrd_list[$nfsen_iter]['descr'] = $flowtype; + $rrd_list[$nfsen_iter]['ds'] = $dsprefix.$flowtype; + + // set a multiplier which in turn will create a CDEF if this var is set + if ($dsprefix == 'traffic_') { + $multiplier = '8'; + } + + $colours = 'blues'; + $nototal = 0; + $units = ''; + $unit_text = $dsdescr; + $scale_min = '0'; + + if ($_GET['debug']) { + print_r($rrd_list); + } + + $nfsen_iter++; + } + } +} + +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/device/nfsen_flows.inc.php b/html/includes/graphs/device/nfsen_flows.inc.php index e1579a988..42701705b 100644 --- a/html/includes/graphs/device/nfsen_flows.inc.php +++ b/html/includes/graphs/device/nfsen_flows.inc.php @@ -1,7 +1,5 @@ +require 'nfsen_common.inc.php'; diff --git a/html/includes/graphs/device/nfsen_packets.inc.php b/html/includes/graphs/device/nfsen_packets.inc.php index e10447e45..9e5ba07b2 100644 --- a/html/includes/graphs/device/nfsen_packets.inc.php +++ b/html/includes/graphs/device/nfsen_packets.inc.php @@ -1,8 +1,6 @@ +require 'nfsen_common.inc.php'; diff --git a/html/includes/graphs/device/nfsen_traffic.inc.php b/html/includes/graphs/device/nfsen_traffic.inc.php index 8210d2851..1f04c3b37 100644 --- a/html/includes/graphs/device/nfsen_traffic.inc.php +++ b/html/includes/graphs/device/nfsen_traffic.inc.php @@ -1,8 +1,6 @@ +require 'nfsen_common.inc.php'; diff --git a/html/includes/graphs/device/panos_sessions.inc.php b/html/includes/graphs/device/panos_sessions.inc.php index cbfe61587..b4d1311b7 100644 --- a/html/includes/graphs/device/panos_sessions.inc.php +++ b/html/includes/graphs/device/panos_sessions.inc.php @@ -1,18 +1,16 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/device/power.inc.php b/html/includes/graphs/device/power.inc.php index 3c320dda4..2a19fe0e0 100644 --- a/html/includes/graphs/device/power.inc.php +++ b/html/includes/graphs/device/power.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/processor.inc.php b/html/includes/graphs/device/processor.inc.php index 015a0c187..bc378e671 100644 --- a/html/includes/graphs/device/processor.inc.php +++ b/html/includes/graphs/device/processor.inc.php @@ -1,12 +1,10 @@ diff --git a/html/includes/graphs/device/processor_separate.inc.php b/html/includes/graphs/device/processor_separate.inc.php index c5bcb892f..2b5980256 100644 --- a/html/includes/graphs/device/processor_separate.inc.php +++ b/html/includes/graphs/device/processor_separate.inc.php @@ -2,33 +2,29 @@ $i = 0; -foreach ($procs as $proc) -{ - $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-" . $proc['processor_type'] . "-" . $proc['processor_index'] . ".rrd"); +foreach ($procs as $proc) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('processor-'.$proc['processor_type'].'-'.$proc['processor_index'].'.rrd'); - if (is_file($rrd_filename)) - { - $descr = short_hrDeviceDescr($proc['processor_descr']); + if (is_file($rrd_filename)) { + $descr = short_hrDeviceDescr($proc['processor_descr']); - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $descr; - $rrd_list[$i]['ds'] = "usage"; - $rrd_list[$i]['area'] = 1; - $i++; - } + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $descr; + $rrd_list[$i]['ds'] = 'usage'; + $rrd_list[$i]['area'] = 1; + $i++; + } } -$unit_text = "Load %"; +$unit_text = 'Load %'; -$units = '%'; +$units = '%'; $total_units = '%'; -$colours ='mixed'; +$colours = 'mixed'; -$scale_min = "0"; -$scale_max = "100"; +$scale_min = '0'; +$scale_max = '100'; $nototal = 1; -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/processor_stack.inc.php b/html/includes/graphs/device/processor_stack.inc.php index 7cdfa0780..dfbd4b355 100644 --- a/html/includes/graphs/device/processor_stack.inc.php +++ b/html/includes/graphs/device/processor_stack.inc.php @@ -2,34 +2,30 @@ $i = 0; -foreach ($procs as $proc) -{ - $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-" . $proc['processor_type'] . "-" . $proc['processor_index'] . ".rrd"); +foreach ($procs as $proc) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('processor-'.$proc['processor_type'].'-'.$proc['processor_index'].'.rrd'); - if (is_file($rrd_filename)) - { - $descr = short_hrDeviceDescr($proc['processor_descr']); + if (is_file($rrd_filename)) { + $descr = short_hrDeviceDescr($proc['processor_descr']); - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $descr; - $rrd_list[$i]['ds'] = "usage"; - $i++; - } + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $descr; + $rrd_list[$i]['ds'] = 'usage'; + $i++; + } } -$unit_text = "Load %"; +$unit_text = 'Load %'; -$units = '%'; +$units = '%'; $total_units = '%'; -$colours ='oranges'; +$colours = 'oranges'; -$scale_min = "0"; -$scale_max = "100"; +$scale_min = '0'; +$scale_max = '100'; -$divider = $i; +$divider = $i; $text_orig = 1; -$nototal = 1; +$nototal = 1; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/device/screenos_sessions.inc.php b/html/includes/graphs/device/screenos_sessions.inc.php index d15ce2aee..52ff2b3a3 100644 --- a/html/includes/graphs/device/screenos_sessions.inc.php +++ b/html/includes/graphs/device/screenos_sessions.inc.php @@ -1,26 +1,26 @@ +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/smokeping_all_common.inc.php b/html/includes/graphs/device/smokeping_all_common.inc.php index edff0d7e5..962ac8f51 100644 --- a/html/includes/graphs/device/smokeping_all_common.inc.php +++ b/html/includes/graphs/device/smokeping_all_common.inc.php @@ -3,89 +3,82 @@ // Dear Tobias. You write in Perl, this makes me hate you forever. // This is my translation of Smokeping's graphing. // Thanks to Bill Fenner for Perl->Human translation:> +$scale_min = 0; +$scale_rigid = true; -$scale_min = 0; -$scale_rigid = TRUE; +require 'includes/graphs/common.inc.php'; +require 'smokeping_common.inc.php'; -include("includes/graphs/common.inc.php"); -include("smokeping_common.inc.php"); +$i = 0; +$pings = 20; +$iter = 0; +$colourset = 'mixed'; -$i = 0; -$pings = 20; -$iter = 0; -$colourset = "mixed"; - -if($width > "500") -{ - $descr_len = 18; -} else { - $descr_len = 12 + round(($width - 275) / 8); +if ($width > '500') { + $descr_len = 18; +} +else { + $descr_len = (12 + round(($width - 275) / 8)); } -if($width > "500") -{ - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev\l'"; -} else { - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev\l'"; +if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." RTT Loss SDev RTT\:SDev\l'"; +} +else { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." RTT Loss SDev RTT\:SDev\l'"; } -foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filename) -{ +foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filename) { + if (!isset($config['graph_colours'][$colourset][$iter])) { + $iter = 0; + } - if (!isset($config['graph_colours'][$colourset][$iter])) { $iter = 0; } - $colour = $config['graph_colours'][$colourset][$iter]; - $iter++; + $colour = $config['graph_colours'][$colourset][$iter]; + $iter++; - $descr = rrdtool_escape($source, $descr_len); + $descr = rrdtool_escape($source, $descr_len); - $filename = $config['smokeping']['dir'] . $filename; - $rrd_options .= " DEF:median$i=".$filename.":median:AVERAGE "; - $rrd_options .= " DEF:loss$i=".$filename.":loss:AVERAGE"; - $rrd_options .= " CDEF:ploss$i=loss$i,$pings,/,100,*"; - $rrd_options .= " CDEF:dm$i=median$i"; -# $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT"; + $filename = $config['smokeping']['dir'].$filename; + $rrd_options .= " DEF:median$i=".$filename.':median:AVERAGE '; + $rrd_options .= " DEF:loss$i=".$filename.':loss:AVERAGE'; + $rrd_options .= " CDEF:ploss$i=loss$i,$pings,/,100,*"; + $rrd_options .= " CDEF:dm$i=median$i"; + // $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT"; + // start emulate Smokeping::calc_stddev + foreach (range(1, $pings) as $p) { + $rrd_options .= ' DEF:pin'.$i.'p'.$p.'='.$filename.':ping'.$p.':AVERAGE'; + $rrd_options .= ' CDEF:p'.$i.'p'.$p.'=pin'.$i.'p'.$p.',UN,0,pin'.$i.'p'.$p.',IF'; + } - // start emulate Smokeping::calc_stddev - foreach (range(1, $pings) as $p) - { - $rrd_options .= " DEF:pin".$i."p".$p."=".$filename.":ping".$p.":AVERAGE"; - $rrd_options .= " CDEF:p".$i."p".$p."=pin".$i."p".$p.",UN,0,pin".$i."p".$p.",IF"; - } + unset($pings_options, $m_options, $sdev_options); - unset($pings_options, $m_options, $sdev_options); + foreach (range(2, $pings) as $p) { + $pings_options .= ',p'.$i.'p'.$p.',UN,+'; + $m_options .= ',p'.$i.'p'.$p.',+'; + $sdev_options .= ',p'.$i.'p'.$p.',m'.$i.',-,DUP,*,+'; + } - foreach (range(2, $pings) as $p) - { - $pings_options .= ",p".$i."p".$p.",UN,+"; - $m_options .= ",p".$i."p".$p.",+"; - $sdev_options .= ",p".$i."p".$p.",m".$i.",-,DUP,*,+"; - } + $rrd_options .= ' CDEF:pings'.$i.'='.$pings.',p'.$i.'p1,UN'.$pings_options.',-'; + $rrd_options .= ' CDEF:m'.$i.'=p'.$i.'p1'.$m_options.',pings'.$i.',/'; + $rrd_options .= ' CDEF:sdev'.$i.'=p'.$i.'p1,m'.$i.',-,DUP,*'.$sdev_options.',pings'.$i.',/,SQRT'; + // end emulate Smokeping::calc_stddev + $rrd_options .= " CDEF:dmlow$i=dm$i,sdev$i,2,/,-"; + $rrd_options .= " CDEF:s2d$i=sdev$i"; + $rrd_options .= " AREA:dmlow$i"; + $rrd_options .= " AREA:s2d$i#".$colour.'30::STACK'; + $rrd_options .= " LINE1:dm$i#".$colour.":'$descr'"; - $rrd_options .= " CDEF:pings".$i."=".$pings .",p".$i."p1,UN". $pings_options . ",-"; - $rrd_options .= " CDEF:m".$i."=p".$i."p1".$m_options.",pings".$i.",/"; - $rrd_options .= " CDEF:sdev".$i."=p".$i."p1,m".$i.",-,DUP,*".$sdev_options.",pings".$i.",/,SQRT"; - // end emulate Smokeping::calc_stddev + // $rrd_options .= " LINE1:sdev$i#000000:$descr"; + $rrd_options .= " VDEF:avmed$i=median$i,AVERAGE"; + $rrd_options .= " VDEF:avsd$i=sdev$i,AVERAGE"; + $rrd_options .= " CDEF:msr$i=median$i,POP,avmed$i,avsd$i,/"; + $rrd_options .= " VDEF:avmsr$i=msr$i,AVERAGE"; - $rrd_options .= " CDEF:dmlow$i=dm$i,sdev$i,2,/,-"; - $rrd_options .= " CDEF:s2d$i=sdev$i"; - $rrd_options .= " AREA:dmlow$i"; - $rrd_options .= " AREA:s2d$i#".$colour."30::STACK"; - $rrd_options .= " LINE1:dm$i#".$colour.":'$descr'"; + $rrd_options .= " GPRINT:avmed$i:'%5.1lf%ss'"; + $rrd_options .= " GPRINT:ploss$i:AVERAGE:'%5.1lf%%'"; -# $rrd_options .= " LINE1:sdev$i#000000:$descr"; + $rrd_options .= " GPRINT:avsd$i:'%5.1lf%Ss'"; + $rrd_options .= " GPRINT:avmsr$i:'%5.1lf%s\\l'"; - $rrd_options .= " VDEF:avmed$i=median$i,AVERAGE"; - $rrd_options .= " VDEF:avsd$i=sdev$i,AVERAGE"; - $rrd_options .= " CDEF:msr$i=median$i,POP,avmed$i,avsd$i,/"; - $rrd_options .= " VDEF:avmsr$i=msr$i,AVERAGE"; - - $rrd_options .= " GPRINT:avmed$i:'%5.1lf%ss'"; - $rrd_options .= " GPRINT:ploss$i:AVERAGE:'%5.1lf%%'"; - - $rrd_options .= " GPRINT:avsd$i:'%5.1lf%Ss'"; - $rrd_options .= " GPRINT:avmsr$i:'%5.1lf%s\\l'"; - - $i++; -} - -?> + $i++; +}//end foreach diff --git a/html/includes/graphs/device/smokeping_all_common_avg.inc.php b/html/includes/graphs/device/smokeping_all_common_avg.inc.php index 12681140a..c77d51021 100644 --- a/html/includes/graphs/device/smokeping_all_common_avg.inc.php +++ b/html/includes/graphs/device/smokeping_all_common_avg.inc.php @@ -3,102 +3,95 @@ // Dear Tobias. You write in Perl, this makes me hate you forever. // This is my translation of Smokeping's graphing. // Thanks to Bill Fenner for Perl->Human translation:> +$scale_min = 0; +$scale_rigid = true; -$scale_min = 0; -$scale_rigid = TRUE; +require 'includes/graphs/common.inc.php'; +require 'smokeping_common.inc.php'; -include("includes/graphs/common.inc.php"); -include("smokeping_common.inc.php"); +$i = 0; +$pings = 20; +$iter = 0; +$colourset = 'mixed'; -$i = 0; -$pings = 20; -$iter = 0; -$colourset = "mixed"; - -if($width > "500") -{ - $descr_len = 18; -} else { - $descr_len = 12 + round(($width - 275) / 8); +if ($width > '500') { + $descr_len = 18; +} +else { + $descr_len = (12 + round(($width - 275) / 8)); } // FIXME str_pad really needs a "limit to length" so we can rid of all the substrs all over the code to limit the length as below... -if($width > "500") -{ - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev\l'"; -} else { - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev\l'"; +if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." RTT Loss SDev RTT\:SDev\l'"; +} +else { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." RTT Loss SDev RTT\:SDev\l'"; } -foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filename) -{ +foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filename) { + if (!isset($config['graph_colours'][$colourset][$iter])) { + $iter = 0; + } - if (!isset($config['graph_colours'][$colourset][$iter])) { $iter = 0; } - $colour = $config['graph_colours'][$colourset][$iter]; - $iter++; + $colour = $config['graph_colours'][$colourset][$iter]; + $iter++; - $descr = rrdtool_escape($source, $descr_len); + $descr = rrdtool_escape($source, $descr_len); - $filename = $config['smokeping']['dir'] . $filename; - $rrd_options .= " DEF:median$i=".$filename.":median:AVERAGE "; - $rrd_options .= " CDEF:dm$i=median$i,UN,0,median$i,IF"; - $rrd_options .= " DEF:loss$i=".$filename.":loss:AVERAGE"; - $rrd_options .= " CDEF:ploss$i=loss$i,$pings,/,100,*"; -# $rrd_options .= " CDEF:dm$i=median$i"; -# $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT"; + $filename = $config['smokeping']['dir'].$filename; + $rrd_options .= " DEF:median$i=".$filename.':median:AVERAGE '; + $rrd_options .= " CDEF:dm$i=median$i,UN,0,median$i,IF"; + $rrd_options .= " DEF:loss$i=".$filename.':loss:AVERAGE'; + $rrd_options .= " CDEF:ploss$i=loss$i,$pings,/,100,*"; + // $rrd_options .= " CDEF:dm$i=median$i"; + // $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT"; + // start emulate Smokeping::calc_stddev + foreach (range(1, $pings) as $p) { + $rrd_options .= ' DEF:pin'.$i.'p'.$p.'='.$filename.':ping'.$p.':AVERAGE'; + $rrd_options .= ' CDEF:p'.$i.'p'.$p.'=pin'.$i.'p'.$p.',UN,0,pin'.$i.'p'.$p.',IF'; + } - // start emulate Smokeping::calc_stddev - foreach (range(1, $pings) as $p) - { - $rrd_options .= " DEF:pin".$i."p".$p."=".$filename.":ping".$p.":AVERAGE"; - $rrd_options .= " CDEF:p".$i."p".$p."=pin".$i."p".$p.",UN,0,pin".$i."p".$p.",IF"; - } + unset($pings_options, $m_options, $sdev_options); - unset($pings_options, $m_options, $sdev_options); + foreach (range(2, $pings) as $p) { + $pings_options .= ',p'.$i.'p'.$p.',UN,+'; + $m_options .= ',p'.$i.'p'.$p.',+'; + $sdev_options .= ',p'.$i.'p'.$p.',m'.$i.',-,DUP,*,+'; + } - foreach (range(2, $pings) as $p) - { - $pings_options .= ",p".$i."p".$p.",UN,+"; - $m_options .= ",p".$i."p".$p.",+"; - $sdev_options .= ",p".$i."p".$p.",m".$i.",-,DUP,*,+"; - } + $rrd_options .= ' CDEF:pings'.$i.'='.$pings.',p'.$i.'p1,UN'.$pings_options.',-'; + $rrd_options .= ' CDEF:m'.$i.'=p'.$i.'p1'.$m_options.',pings'.$i.',/'; + $rrd_options .= ' CDEF:sdev'.$i.'=p'.$i.'p1,m'.$i.',-,DUP,*'.$sdev_options.',pings'.$i.',/,SQRT'; + // end emulate Smokeping::calc_stddev + $rrd_options .= " CDEF:dmlow$i=dm$i,sdev$i,2,/,-"; + $rrd_options .= " CDEF:s2d$i=sdev$i"; - $rrd_options .= " CDEF:pings".$i."=".$pings .",p".$i."p1,UN". $pings_options . ",-"; - $rrd_options .= " CDEF:m".$i."=p".$i."p1".$m_options.",pings".$i.",/"; - $rrd_options .= " CDEF:sdev".$i."=p".$i."p1,m".$i.",-,DUP,*".$sdev_options.",pings".$i.",/,SQRT"; - // end emulate Smokeping::calc_stddev + $dm_list .= ",dm$i,+"; + $sd_list .= ",s2d$i,+"; + $ploss_list .= ",ploss$i,+"; - $rrd_options .= " CDEF:dmlow$i=dm$i,sdev$i,2,/,-"; - $rrd_options .= " CDEF:s2d$i=sdev$i"; + $i++; +}//end foreach - $dm_list .= ",dm$i,+"; - $sd_list .= ",s2d$i,+"; - $ploss_list .= ",ploss$i,+"; +$descr = rrdtool_escape('Average', $descr_len); - $i++; +$rrd_options .= ' CDEF:ploss_all=0'.$ploss_list.",$i,/"; +$rrd_options .= ' CDEF:dm_all=0'.$dm_list.",$i,/"; +// $rrd_options .= " CDEF:dm_all_clean=dm_all,UN,NaN,dm_all,IF"; +$rrd_options .= ' CDEF:sd_all=0'.$sd_list.",$i,/"; +$rrd_options .= ' CDEF:dmlow_all=dm_all,sd_all,2,/,-'; -} - -$descr = rrdtool_escape("Average", $descr_len); - -$rrd_options .= " CDEF:ploss_all=0".$ploss_list.",$i,/"; -$rrd_options .= " CDEF:dm_all=0".$dm_list.",$i,/"; -# $rrd_options .= " CDEF:dm_all_clean=dm_all,UN,NaN,dm_all,IF"; -$rrd_options .= " CDEF:sd_all=0".$sd_list.",$i,/"; -$rrd_options .= " CDEF:dmlow_all=dm_all,sd_all,2,/,-"; - -$rrd_options .= " AREA:dmlow_all"; -$rrd_options .= " AREA:sd_all#AAAAAA::STACK"; +$rrd_options .= ' AREA:dmlow_all'; +$rrd_options .= ' AREA:sd_all#AAAAAA::STACK'; $rrd_options .= " LINE1:dm_all#CC0000:'$descr'"; -$rrd_options .= " VDEF:avmed=dm_all,AVERAGE"; -$rrd_options .= " VDEF:avsd=sd_all,AVERAGE"; -$rrd_options .= " CDEF:msr=dm_all,POP,avmed,avsd,/"; -$rrd_options .= " VDEF:avmsr=msr,AVERAGE"; +$rrd_options .= ' VDEF:avmed=dm_all,AVERAGE'; +$rrd_options .= ' VDEF:avsd=sd_all,AVERAGE'; +$rrd_options .= ' CDEF:msr=dm_all,POP,avmed,avsd,/'; +$rrd_options .= ' VDEF:avmsr=msr,AVERAGE'; $rrd_options .= " GPRINT:avmed:'%5.1lf%ss'"; $rrd_options .= " GPRINT:ploss_all:AVERAGE:'%5.1lf%%'"; $rrd_options .= " GPRINT:avsd:'%5.1lf%Ss'"; $rrd_options .= " GPRINT:avmsr:'%5.1lf%s\\l'"; - -?> diff --git a/html/includes/graphs/device/smokeping_common.inc.php b/html/includes/graphs/device/smokeping_common.inc.php index c158e8267..006eb4197 100644 --- a/html/includes/graphs/device/smokeping_common.inc.php +++ b/html/includes/graphs/device/smokeping_common.inc.php @@ -1,26 +1,25 @@ +} diff --git a/html/includes/graphs/device/smokeping_in_all.inc.php b/html/includes/graphs/device/smokeping_in_all.inc.php index aaee41706..e9c9ca4e5 100644 --- a/html/includes/graphs/device/smokeping_in_all.inc.php +++ b/html/includes/graphs/device/smokeping_in_all.inc.php @@ -1,7 +1,5 @@ +require 'smokeping_all_common.inc.php'; diff --git a/html/includes/graphs/device/smokeping_in_all_avg.inc.php b/html/includes/graphs/device/smokeping_in_all_avg.inc.php index 8344ba94c..fcc5539cf 100644 --- a/html/includes/graphs/device/smokeping_in_all_avg.inc.php +++ b/html/includes/graphs/device/smokeping_in_all_avg.inc.php @@ -1,7 +1,5 @@ +require 'smokeping_all_common_avg.inc.php'; diff --git a/html/includes/graphs/device/smokeping_out_all.inc.php b/html/includes/graphs/device/smokeping_out_all.inc.php index ef1d87f94..923c0bc74 100644 --- a/html/includes/graphs/device/smokeping_out_all.inc.php +++ b/html/includes/graphs/device/smokeping_out_all.inc.php @@ -1,7 +1,5 @@ +require 'smokeping_all_common.inc.php'; diff --git a/html/includes/graphs/device/smokeping_out_all_avg.inc.php b/html/includes/graphs/device/smokeping_out_all_avg.inc.php index 3d3c8645d..b36cb0eb5 100644 --- a/html/includes/graphs/device/smokeping_out_all_avg.inc.php +++ b/html/includes/graphs/device/smokeping_out_all_avg.inc.php @@ -1,7 +1,5 @@ +require 'smokeping_all_common_avg.inc.php'; diff --git a/html/includes/graphs/device/storage.inc.php b/html/includes/graphs/device/storage.inc.php index 211c98cc0..769e9ce91 100644 --- a/html/includes/graphs/device/storage.inc.php +++ b/html/includes/graphs/device/storage.inc.php @@ -1,31 +1,47 @@ + $descr = rrdtool_escape($storage['storage_descr'], 12); + $rrd = $config['rrd_dir'].'/'.$device['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 .= " 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'"; + $rrd_options .= " GPRINT:$storage[storage_id]size:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:$storage[storage_id]used:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\\\l"; + $iter++; +}//end foreach diff --git a/html/includes/graphs/device/temperature.inc.php b/html/includes/graphs/device/temperature.inc.php index bcc967485..b3f35c695 100644 --- a/html/includes/graphs/device/temperature.inc.php +++ b/html/includes/graphs/device/temperature.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/toner.inc.php b/html/includes/graphs/device/toner.inc.php index 06029c8b3..6a974b64a 100644 --- a/html/includes/graphs/device/toner.inc.php +++ b/html/includes/graphs/device/toner.inc.php @@ -1,59 +1,61 @@ + case '6': + $colour['left'] = '36393D'; + break; + + case '7': + default: + $colour['left'] = 'FF0000'; + unset($iter); + break; + }//end switch + }//end if + + $hostname = gethostbyid($toner['device_id']); + + $descr = substr(str_pad($toner['toner_descr'], 16), 0, 16); + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('toner-'.$toner['toner_index'].'.rrd'); + $toner_id = $toner['toner_id']; + + $rrd_options .= " DEF:toner$toner_id=$rrd_filename:toner:AVERAGE"; + $rrd_options .= " LINE2:toner$toner_id#".$colour['left'].":'".$descr."'"; + $rrd_options .= " GPRINT:toner$toner_id:LAST:'%5.0lf%%'"; + $rrd_options .= " GPRINT:toner$toner_id:MIN:'%5.0lf%%'"; + $rrd_options .= " GPRINT:toner$toner_id:MAX:%5.0lf%%\\\\l"; + + $iter++; +}//end foreach diff --git a/html/includes/graphs/device/ucd_io.inc.php b/html/includes/graphs/device/ucd_io.inc.php index 0a733f5bb..8b9c64f8c 100644 --- a/html/includes/graphs/device/ucd_io.inc.php +++ b/html/includes/graphs/device/ucd_io.inc.php @@ -1,12 +1,10 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/device/ucd_load.inc.php b/html/includes/graphs/device/ucd_load.inc.php index 9a0c45cc8..ccdf61ee5 100644 --- a/html/includes/graphs/device/ucd_load.inc.php +++ b/html/includes/graphs/device/ucd_load.inc.php @@ -1,21 +1,21 @@ diff --git a/html/includes/graphs/device/ucd_memory.inc.php b/html/includes/graphs/device/ucd_memory.inc.php index 992714aba..606fed717 100644 --- a/html/includes/graphs/device/ucd_memory.inc.php +++ b/html/includes/graphs/device/ucd_memory.inc.php @@ -1,8 +1,8 @@ diff --git a/html/includes/graphs/device/ucd_swap_io.inc.php b/html/includes/graphs/device/ucd_swap_io.inc.php index 6697ac8ae..002814538 100644 --- a/html/includes/graphs/device/ucd_swap_io.inc.php +++ b/html/includes/graphs/device/ucd_swap_io.inc.php @@ -1,12 +1,10 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/device/uptime.inc.php b/html/includes/graphs/device/uptime.inc.php index 20235f654..6c9c4ff88 100644 --- a/html/includes/graphs/device/uptime.inc.php +++ b/html/includes/graphs/device/uptime.inc.php @@ -1,17 +1,15 @@ diff --git a/html/includes/graphs/device/voltage.inc.php b/html/includes/graphs/device/voltage.inc.php index 3a2423fc7..efdf3350e 100644 --- a/html/includes/graphs/device/voltage.inc.php +++ b/html/includes/graphs/device/voltage.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/vpdn_sessions_l2tp.inc.php b/html/includes/graphs/device/vpdn_sessions_l2tp.inc.php index dd203415a..7e4ecc8e8 100644 --- a/html/includes/graphs/device/vpdn_sessions_l2tp.inc.php +++ b/html/includes/graphs/device/vpdn_sessions_l2tp.inc.php @@ -1,24 +1,21 @@ +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/vpdn_tunnels_l2tp.inc.php b/html/includes/graphs/device/vpdn_tunnels_l2tp.inc.php index 36d6c0fb1..9c4a9c01b 100644 --- a/html/includes/graphs/device/vpdn_tunnels_l2tp.inc.php +++ b/html/includes/graphs/device/vpdn_tunnels_l2tp.inc.php @@ -1,24 +1,21 @@ +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/wifi_clients.inc.php b/html/includes/graphs/device/wifi_clients.inc.php index 0ff024df4..1c45b1363 100644 --- a/html/includes/graphs/device/wifi_clients.inc.php +++ b/html/includes/graphs/device/wifi_clients.inc.php @@ -1,28 +1,24 @@ \ No newline at end of file diff --git a/html/includes/graphs/diskio/auth.inc.php b/html/includes/graphs/diskio/auth.inc.php index e9388680a..30b6271d7 100644 --- a/html/includes/graphs/diskio/auth.inc.php +++ b/html/includes/graphs/diskio/auth.inc.php @@ -1,19 +1,15 @@ diff --git a/html/includes/graphs/diskio/bits.inc.php b/html/includes/graphs/diskio/bits.inc.php index c61bf6d89..507e94cf1 100644 --- a/html/includes/graphs/diskio/bits.inc.php +++ b/html/includes/graphs/diskio/bits.inc.php @@ -1,10 +1,8 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/diskio/ops.inc.php b/html/includes/graphs/diskio/ops.inc.php index 1b0626757..eac593212 100644 --- a/html/includes/graphs/diskio/ops.inc.php +++ b/html/includes/graphs/diskio/ops.inc.php @@ -1,20 +1,18 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/generic_duplex.inc.php b/html/includes/graphs/generic_duplex.inc.php index 6a11166ef..bddfd09b0 100644 --- a/html/includes/graphs/generic_duplex.inc.php +++ b/html/includes/graphs/generic_duplex.inc.php @@ -2,131 +2,126 @@ // Draw generic bits graph // args: ds_in, ds_out, rrd_filename, bg, legend, from, to, width, height, inverse, $percentile +require 'includes/graphs/common.inc.php'; -include("includes/graphs/common.inc.php"); +$length = '10'; -$length = "10"; - -if (!isset($percentile)) { $length += "2"; } - -if (!isset($out_text)) { $out_text = "Out"; } -if (!isset($in_text)) { $in_text = "In"; } - -$unit_text = str_pad(truncate($unit_text,$length),$length); -$in_text = str_pad(truncate($in_text,$length),$length); -$out_text = str_pad(truncate($out_text,$length),$length); - -$rrd_options .= " DEF:".$out."=".$rrd_filename.":".$ds_out.":AVERAGE"; -$rrd_options .= " DEF:".$in."=".$rrd_filename.":".$ds_in.":AVERAGE"; -$rrd_options .= " DEF:".$out."_max=".$rrd_filename.":".$ds_out.":MAX"; -$rrd_options .= " DEF:".$in."_max=".$rrd_filename.":".$ds_in.":MAX"; -$rrd_options .= " CDEF:dout_max=out_max,-1,*"; -$rrd_options .= " CDEF:dout=out,-1,*"; -$rrd_options .= " CDEF:both=in,out,+"; -if ($print_total) -{ - $rrd_options .= " VDEF:totin=in,TOTAL"; - $rrd_options .= " VDEF:totout=out,TOTAL"; - $rrd_options .= " VDEF:tot=both,TOTAL"; -} -if ($percentile) -{ - $rrd_options .= " VDEF:percentile_in=in,".$percentile.",PERCENT"; - $rrd_options .= " VDEF:percentile_out=out,".$percentile.",PERCENT"; - $rrd_options .= " VDEF:dpercentile_out=dout,".$percentile.",PERCENT"; -} -if ($graph_max) -{ - $rrd_options .= " AREA:in_max#".$colour_area_in_max.":"; - $rrd_options .= " AREA:dout_max#".$colour_area_out_max.":"; +if (!isset($percentile)) { + $length += '2'; } -if($_GET['previous'] == "yes") -{ - $rrd_options .= " DEF:".$out."X=".$rrd_filename.":".$ds_out.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " DEF:".$in."X=".$rrd_filename.":".$ds_in.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " DEF:".$out."_maxX=".$rrd_filename.":".$ds_out.":MAX:start=".$prev_from.":end=".$from; - $rrd_options .= " DEF:".$in."_maxX=".$rrd_filename.":".$ds_in.":MAX:start=".$prev_from.":end=".$from; - $rrd_options .= " SHIFT:".$out."X:$period"; - $rrd_options .= " SHIFT:".$in."X:$period"; - $rrd_options .= " SHIFT:".$out."_maxX:$period"; - $rrd_options .= " SHIFT:".$in."_maxX:$period"; - $rrd_options .= " CDEF:dout_maxX=out_maxX,-1,*"; - $rrd_options .= " CDEF:doutX=outX,-1,*"; - $rrd_options .= " CDEF:bothX=inX,outX,+"; - if ($print_total) - { - $rrd_options .= " VDEF:totinX=inX,TOTAL"; - $rrd_options .= " VDEF:totoutX=outX,TOTAL"; - $rrd_options .= " VDEF:totX=bothX,TOTAL"; - } - if ($percentile) - { - $rrd_options .= " VDEF:percentile_inX=inX,".$percentile.",PERCENT"; - $rrd_options .= " VDEF:percentile_outX=outX,".$percentile.",PERCENT"; - $rrd_options .= " VDEF:dpercentile_outX=doutX,".$percentile.",PERCENT"; - } - if ($graph_max) - { - $rrd_options .= " AREA:in_max#".$colour_area_in_max.":"; - $rrd_options .= " AREA:dout_max#".$colour_area_out_max.":"; - } +if (!isset($out_text)) { + $out_text = 'Out'; } -$rrd_options .= " AREA:in#".$colour_area_in.":"; -$rrd_options .= " COMMENT:'".$unit_text." Now Ave Max"; +if (!isset($in_text)) { + $in_text = 'In'; +} -if ($percentile) -{ - $rrd_options .= " ".$percentile."th %"; +$unit_text = str_pad(truncate($unit_text, $length), $length); +$in_text = str_pad(truncate($in_text, $length), $length); +$out_text = str_pad(truncate($out_text, $length), $length); + +$rrd_options .= ' DEF:'.$out.'='.$rrd_filename.':'.$ds_out.':AVERAGE'; +$rrd_options .= ' DEF:'.$in.'='.$rrd_filename.':'.$ds_in.':AVERAGE'; +$rrd_options .= ' DEF:'.$out.'_max='.$rrd_filename.':'.$ds_out.':MAX'; +$rrd_options .= ' DEF:'.$in.'_max='.$rrd_filename.':'.$ds_in.':MAX'; +$rrd_options .= ' CDEF:dout_max=out_max,-1,*'; +$rrd_options .= ' CDEF:dout=out,-1,*'; +$rrd_options .= ' CDEF:both=in,out,+'; +if ($print_total) { + $rrd_options .= ' VDEF:totin=in,TOTAL'; + $rrd_options .= ' VDEF:totout=out,TOTAL'; + $rrd_options .= ' VDEF:tot=both,TOTAL'; +} + +if ($percentile) { + $rrd_options .= ' VDEF:percentile_in=in,'.$percentile.',PERCENT'; + $rrd_options .= ' VDEF:percentile_out=out,'.$percentile.',PERCENT'; + $rrd_options .= ' VDEF:dpercentile_out=dout,'.$percentile.',PERCENT'; +} + +if ($graph_max) { + $rrd_options .= ' AREA:in_max#'.$colour_area_in_max.':'; + $rrd_options .= ' AREA:dout_max#'.$colour_area_out_max.':'; +} + +if ($_GET['previous'] == 'yes') { + $rrd_options .= ' DEF:'.$out.'X='.$rrd_filename.':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' DEF:'.$in.'X='.$rrd_filename.':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' DEF:'.$out.'_maxX='.$rrd_filename.':'.$ds_out.':MAX:start='.$prev_from.':end='.$from; + $rrd_options .= ' DEF:'.$in.'_maxX='.$rrd_filename.':'.$ds_in.':MAX:start='.$prev_from.':end='.$from; + $rrd_options .= ' SHIFT:'.$out."X:$period"; + $rrd_options .= ' SHIFT:'.$in."X:$period"; + $rrd_options .= ' SHIFT:'.$out."_maxX:$period"; + $rrd_options .= ' SHIFT:'.$in."_maxX:$period"; + $rrd_options .= ' CDEF:dout_maxX=out_maxX,-1,*'; + $rrd_options .= ' CDEF:doutX=outX,-1,*'; + $rrd_options .= ' CDEF:bothX=inX,outX,+'; + if ($print_total) { + $rrd_options .= ' VDEF:totinX=inX,TOTAL'; + $rrd_options .= ' VDEF:totoutX=outX,TOTAL'; + $rrd_options .= ' VDEF:totX=bothX,TOTAL'; + } + + if ($percentile) { + $rrd_options .= ' VDEF:percentile_inX=inX,'.$percentile.',PERCENT'; + $rrd_options .= ' VDEF:percentile_outX=outX,'.$percentile.',PERCENT'; + $rrd_options .= ' VDEF:dpercentile_outX=doutX,'.$percentile.',PERCENT'; + } + + if ($graph_max) { + $rrd_options .= ' AREA:in_max#'.$colour_area_in_max.':'; + $rrd_options .= ' AREA:dout_max#'.$colour_area_out_max.':'; + } +}//end if + +$rrd_options .= ' AREA:in#'.$colour_area_in.':'; +$rrd_options .= " COMMENT:'".$unit_text.' Now Ave Max'; + +if ($percentile) { + $rrd_options .= ' '.$percentile.'th %'; } $rrd_options .= "\\n'"; -$rrd_options .= " LINE1.25:in#".$colour_line_in.":'".$in_text."'"; -$rrd_options .= " GPRINT:in:LAST:%6.2lf%s"; -$rrd_options .= " GPRINT:in:AVERAGE:%6.2lf%s"; -$rrd_options .= " GPRINT:in_max:MAX:%6.2lf%s"; +$rrd_options .= ' LINE1.25:in#'.$colour_line_in.":'".$in_text."'"; +$rrd_options .= ' GPRINT:in:LAST:%6.2lf%s'; +$rrd_options .= ' GPRINT:in:AVERAGE:%6.2lf%s'; +$rrd_options .= ' GPRINT:in_max:MAX:%6.2lf%s'; -if ($percentile) -{ - $rrd_options .= " GPRINT:percentile_in:%6.2lf%s"; +if ($percentile) { + $rrd_options .= ' GPRINT:percentile_in:%6.2lf%s'; } $rrd_options .= " COMMENT:'\\n'"; -$rrd_options .= " AREA:dout#".$colour_area_out.":"; -$rrd_options .= " LINE1.25:dout#".$colour_line_out.":'".$out_text."'"; -$rrd_options .= " GPRINT:out:LAST:%6.2lf%s"; -$rrd_options .= " GPRINT:out:AVERAGE:%6.2lf%s"; -$rrd_options .= " GPRINT:out_max:MAX:%6.2lf%s"; +$rrd_options .= ' AREA:dout#'.$colour_area_out.':'; +$rrd_options .= ' LINE1.25:dout#'.$colour_line_out.":'".$out_text."'"; +$rrd_options .= ' GPRINT:out:LAST:%6.2lf%s'; +$rrd_options .= ' GPRINT:out:AVERAGE:%6.2lf%s'; +$rrd_options .= ' GPRINT:out_max:MAX:%6.2lf%s'; -if ($percentile) -{ - $rrd_options .= " GPRINT:percentile_out:%6.2lf%s"; +if ($percentile) { + $rrd_options .= ' GPRINT:percentile_out:%6.2lf%s'; } $rrd_options .= " COMMENT:\\\\n"; -if ($print_total) -{ - $rrd_options .= " GPRINT:tot:'Total %6.2lf%s'"; - $rrd_options .= " GPRINT:totin:'(In %6.2lf%s'"; - $rrd_options .= " GPRINT:totout:'Out %6.2lf%s)\\\\l'"; +if ($print_total) { + $rrd_options .= " GPRINT:tot:'Total %6.2lf%s'"; + $rrd_options .= " GPRINT:totin:'(In %6.2lf%s'"; + $rrd_options .= " GPRINT:totout:'Out %6.2lf%s)\\\\l'"; } -if ($percentile) -{ - $rrd_options .= " LINE1:percentile_in#aa0000"; - $rrd_options .= " LINE1:dpercentile_out#aa0000"; +if ($percentile) { + $rrd_options .= ' LINE1:percentile_in#aa0000'; + $rrd_options .= ' LINE1:dpercentile_out#aa0000'; } -if($_GET['previous'] == "yes") -{ - $rrd_options .= " LINE1.25:in".$format."X#666666:'Prev In \\\\n'"; - $rrd_options .= " AREA:in".$format."X#99999966:"; - $rrd_options .= " LINE1.25:dout".$format."X#666666:'Prev Out'"; - $rrd_options .= " AREA:dout".$format."X#99999966:"; +if ($_GET['previous'] == 'yes') { + $rrd_options .= ' LINE1.25:in'.$format."X#666666:'Prev In \\\\n'"; + $rrd_options .= ' AREA:in'.$format.'X#99999966:'; + $rrd_options .= ' LINE1.25:dout'.$format."X#666666:'Prev Out'"; + $rrd_options .= ' AREA:dout'.$format.'X#99999966:'; } -$rrd_options .= " HRULE:0#999999"; - -?> +$rrd_options .= ' HRULE:0#999999'; diff --git a/html/includes/graphs/generic_multi.inc.php b/html/includes/graphs/generic_multi.inc.php index c9c1053f8..d02e82ebb 100644 --- a/html/includes/graphs/generic_multi.inc.php +++ b/html/includes/graphs/generic_multi.inc.php @@ -1,74 +1,78 @@ "500") -{ - $descr_len=24; -} else { - $descr_len=12; - $descr_len += round(($width - 250) / 8); +if ($width > '500') { + $descr_len = 24; +} +else { + $descr_len = 12; + $descr_len += round(($width - 250) / 8); } -if ($nototal) { $descrlen += "2"; $unitlen += "2";} - -if($width > "500") -{ - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)."Now Min Max Avg\l'"; - if (!$nototal) { $rrd_options .= " COMMENT:'Total '"; } - $rrd_options .= " COMMENT:'\l'"; -} else { - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)."Now Min Max Avg\l'"; - +if ($nototal) { + $descrlen += '2'; + $unitlen += '2'; } -$i = 0; +if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Now Min Max Avg\l'"; + if (!$nototal) { + $rrd_options .= " COMMENT:'Total '"; + } + + $rrd_options .= " COMMENT:'\l'"; +} +else { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Now Min Max Avg\l'"; +} + +$i = 0; $iter = 0; -foreach ($rrd_list as $rrd) -{ - if (!$config['graph_colours'][$colours][$iter]) { $iter = 0; } +foreach ($rrd_list as $rrd) { + if (!$config['graph_colours'][$colours][$iter]) { + $iter = 0; + } - $colour=$config['graph_colours'][$colours][$iter]; + $colour = $config['graph_colours'][$colours][$iter]; - $ds = $rrd['ds']; - $filename = $rrd['filename']; + $ds = $rrd['ds']; + $filename = $rrd['filename']; - $descr = rrdtool_escape($rrd['descr'], $descr_len); + $descr = rrdtool_escape($rrd['descr'], $descr_len); - $id = "ds".$i; + $id = 'ds'.$i; - $rrd_options .= " DEF:".$id."=$filename:$ds:AVERAGE"; + $rrd_options .= ' DEF:'.$id."=$filename:$ds:AVERAGE"; - if ($simple_rrd) - { - $rrd_options .= " CDEF:".$id."min=".$id." "; - $rrd_options .= " CDEF:".$id."max=".$id." "; - } else { - $rrd_options .= " DEF:".$id."min=$filename:$ds:MIN"; - $rrd_options .= " DEF:".$id."max=$filename:$ds:MAX"; - } + if ($simple_rrd) { + $rrd_options .= ' CDEF:'.$id.'min='.$id.' '; + $rrd_options .= ' CDEF:'.$id.'max='.$id.' '; + } + else { + $rrd_options .= ' DEF:'.$id."min=$filename:$ds:MIN"; + $rrd_options .= ' DEF:'.$id."max=$filename:$ds:MAX"; + } - if ($rrd['invert']) - { - $rrd_options .= " CDEF:".$id."i=".$id.",-1,*"; - $rrd_optionsc .= " AREA:".$id."i#".$colour.":'$descr':".$cstack; - $rrd_optionsc .= " GPRINT:".$id.":LAST:%5.1lf%s GPRINT:".$id."min:MIN:%5.1lf%s"; - $rrd_optionsc .= " GPRINT:".$id."max:MAX:%5.1lf%s GPRINT:".$id.":AVERAGE:'%5.1lf%s\\n'"; - $cstack = "STACK"; - } else { - $rrd_optionsb .= " AREA:".$id."#".$colour.":'$descr':".$bstack; - $rrd_optionsb .= " GPRINT:".$id.":LAST:%5.1lf%s GPRINT:".$id."min:MIN:%5.1lf%s"; - $rrd_optionsb .= " GPRINT:".$id."max:MAX:%5.1lf%s GPRINT:".$id.":AVERAGE:'%5.1lf%s\\n'"; - $bstack = "STACK"; - } + if ($rrd['invert']) { + $rrd_options .= ' CDEF:'.$id.'i='.$id.',-1,*'; + $rrd_optionsc .= ' AREA:'.$id.'i#'.$colour.":'$descr':".$cstack; + $rrd_optionsc .= ' GPRINT:'.$id.':LAST:%5.1lf%s GPRINT:'.$id.'min:MIN:%5.1lf%s'; + $rrd_optionsc .= ' GPRINT:'.$id.'max:MAX:%5.1lf%s GPRINT:'.$id.":AVERAGE:'%5.1lf%s\\n'"; + $cstack = 'STACK'; + } + else { + $rrd_optionsb .= ' AREA:'.$id.'#'.$colour.":'$descr':".$bstack; + $rrd_optionsb .= ' GPRINT:'.$id.':LAST:%5.1lf%s GPRINT:'.$id.'min:MIN:%5.1lf%s'; + $rrd_optionsb .= ' GPRINT:'.$id.'max:MAX:%5.1lf%s GPRINT:'.$id.":AVERAGE:'%5.1lf%s\\n'"; + $bstack = 'STACK'; + } - $i++; $iter++; - -} + $i++; + $iter++; +}//end foreach $rrd_options .= $rrd_optionsb; -$rrd_options .= " HRULE:0#555555"; +$rrd_options .= ' HRULE:0#555555'; $rrd_options .= $rrd_optionsc; - -?> diff --git a/html/includes/graphs/generic_multi_bits.inc.php b/html/includes/graphs/generic_multi_bits.inc.php index 5ea0dfaac..caa765e4d 100644 --- a/html/includes/graphs/generic_multi_bits.inc.php +++ b/html/includes/graphs/generic_multi_bits.inc.php @@ -2,97 +2,104 @@ // Draws aggregate bits graph from multiple RRDs // Variables : colour_[line|area]_[in|out], rrd_filenames +require 'includes/graphs/common.inc.php'; -include("includes/graphs/common.inc.php"); +$i = 0; -$i=0; +foreach ($rrd_filenames as $key => $rrd_filename) { + if ($rrd_inverted[$key]) { + $in = 'out'; + $out = 'in'; + } + else { + $in = 'in'; + $out = 'out'; + } -foreach ($rrd_filenames as $key => $rrd_filename) -{ - if ($rrd_inverted[$key]) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } + $rrd_options .= ' DEF:'.$in.'octets'.$i.'='.$rrd_filename.':'.$ds_in.':AVERAGE'; + $rrd_options .= ' DEF:'.$out.'octets'.$i.'='.$rrd_filename.':'.$ds_out.':AVERAGE'; + $in_thing .= $seperator.'inoctets'.$i.',UN,0,'.'inoctets'.$i.',IF'; + $out_thing .= $seperator.'outoctets'.$i.',UN,0,'.'outoctets'.$i.',IF'; + $pluses .= $plus; + $seperator = ','; + $plus = ',+'; - $rrd_options .= " DEF:".$in."octets" . $i . "=".$rrd_filename.":".$ds_in.":AVERAGE"; - $rrd_options .= " DEF:".$out."octets" . $i . "=".$rrd_filename.":".$ds_out.":AVERAGE"; - $in_thing .= $seperator . "inoctets" . $i . ",UN,0," . "inoctets" . $i . ",IF"; - $out_thing .= $seperator . "outoctets" . $i . ",UN,0," . "outoctets" . $i . ",IF"; - $pluses .= $plus; - $seperator = ","; - $plus = ",+"; + if ($_GET['previous']) { + $rrd_options .= ' DEF:'.$in.'octets'.$i.'X='.$rrd_filename.':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' DEF:'.$out.'octets'.$i.'X='.$rrd_filename.':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' SHIFT:'.$in.'octets'.$i."X:$period"; + $rrd_options .= ' SHIFT:'.$out.'octets'.$i."X:$period"; + $in_thingX .= $seperatorX.'inoctets'.$i.'X,UN,0,'.'inoctets'.$i.'X,IF'; + $out_thingX .= $seperatorX.'outoctets'.$i.'X,UN,0,'.'outoctets'.$i.'X,IF'; + $plusesX .= $plusX; + $seperatorX = ','; + $plusX = ',+'; + } - if ($_GET['previous']) - { - $rrd_options .= " DEF:".$in."octets" . $i . "X=".$rrd_filename.":".$ds_in.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " DEF:".$out."octets" . $i . "X=".$rrd_filename.":".$ds_out.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " SHIFT:".$in."octets" . $i . "X:$period"; - $rrd_options .= " SHIFT:".$out."octets" . $i . "X:$period"; - $in_thingX .= $seperatorX . "inoctets" . $i . "X,UN,0," . "inoctets" . $i . "X,IF"; - $out_thingX .= $seperatorX . "outoctets" . $i . "X,UN,0," . "outoctets" . $i . "X,IF"; - $plusesX .= $plusX; - $seperatorX = ","; - $plusX = ",+"; - } - $i++; -} + $i++; +}//end foreach -if ($i) -{ - if ($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } - $rrd_options .= " CDEF:".$in."octets=" . $in_thing . $pluses; - $rrd_options .= " CDEF:".$out."octets=" . $out_thing . $pluses; - $rrd_options .= " CDEF:doutoctets=outoctets,-1,*"; - $rrd_options .= " CDEF:inbits=inoctets,8,*"; - $rrd_options .= " CDEF:outbits=outoctets,8,*"; - $rrd_options .= " CDEF:doutbits=doutoctets,8,*"; - $rrd_options .= " VDEF:95thin=inbits,95,PERCENT"; - $rrd_options .= " VDEF:95thout=outbits,95,PERCENT"; - $rrd_options .= " VDEF:d95thout=doutbits,5,PERCENT"; +if ($i) { + if ($inverse) { + $in = 'out'; + $out = 'in'; + } + else { + $in = 'in'; + $out = 'out'; + } - if ($_GET['previous'] == "yes") - { - $rrd_options .= " CDEF:".$in."octetsX=" . $in_thingX . $pluses; - $rrd_options .= " CDEF:".$out."octetsX=" . $out_thingX . $pluses; - $rrd_options .= " CDEF:doutoctetsX=outoctetsX,-1,*"; - $rrd_options .= " CDEF:inbitsX=inoctetsX,8,*"; - $rrd_options .= " CDEF:outbitsX=outoctetsX,8,*"; - $rrd_options .= " CDEF:doutbitsX=doutoctetsX,8,*"; - $rrd_options .= " VDEF:95thinX=inbitsX,95,PERCENT"; - $rrd_options .= " VDEF:95thoutX=outbitsX,95,PERCENT"; - $rrd_options .= " VDEF:d95thoutX=doutbitsX,5,PERCENT"; - } + $rrd_options .= ' CDEF:'.$in.'octets='.$in_thing.$pluses; + $rrd_options .= ' CDEF:'.$out.'octets='.$out_thing.$pluses; + $rrd_options .= ' CDEF:doutoctets=outoctets,-1,*'; + $rrd_options .= ' CDEF:inbits=inoctets,8,*'; + $rrd_options .= ' CDEF:outbits=outoctets,8,*'; + $rrd_options .= ' CDEF:doutbits=doutoctets,8,*'; + $rrd_options .= ' VDEF:95thin=inbits,95,PERCENT'; + $rrd_options .= ' VDEF:95thout=outbits,95,PERCENT'; + $rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT'; - if ($legend == 'no' || $legend == '1') - { - $rrd_options .= " AREA:inbits#".$colour_area_in.":"; - $rrd_options .= " LINE1.25:inbits#".$colour_line_in.":"; - $rrd_options .= " AREA:doutbits#".$colour_area_out.":"; - $rrd_options .= " LINE1.25:doutbits#".$colour_line_out.":"; - } else { - $rrd_options .= " AREA:inbits#".$colour_area_in.":"; - $rrd_options .= " COMMENT:'bps Now Ave Max 95th %\\n'"; - $rrd_options .= " LINE1.25:inbits#".$colour_line_in.":In\ "; - $rrd_options .= " GPRINT:inbits:LAST:%6.2lf%s"; - $rrd_options .= " GPRINT:inbits:AVERAGE:%6.2lf%s"; - $rrd_options .= " GPRINT:inbits:MAX:%6.2lf%s"; - $rrd_options .= " GPRINT:95thin:%6.2lf%s\\\\n"; - $rrd_options .= " AREA:doutbits#".$colour_area_out.":"; - $rrd_options .= " LINE1.25:doutbits#".$colour_line_out.":Out"; - $rrd_options .= " GPRINT:outbits:LAST:%6.2lf%s"; - $rrd_options .= " GPRINT:outbits:AVERAGE:%6.2lf%s"; - $rrd_options .= " GPRINT:outbits:MAX:%6.2lf%s"; - $rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n"; - } + if ($_GET['previous'] == 'yes') { + $rrd_options .= ' CDEF:'.$in.'octetsX='.$in_thingX.$pluses; + $rrd_options .= ' CDEF:'.$out.'octetsX='.$out_thingX.$pluses; + $rrd_options .= ' CDEF:doutoctetsX=outoctetsX,-1,*'; + $rrd_options .= ' CDEF:inbitsX=inoctetsX,8,*'; + $rrd_options .= ' CDEF:outbitsX=outoctetsX,8,*'; + $rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*'; + $rrd_options .= ' VDEF:95thinX=inbitsX,95,PERCENT'; + $rrd_options .= ' VDEF:95thoutX=outbitsX,95,PERCENT'; + $rrd_options .= ' VDEF:d95thoutX=doutbitsX,5,PERCENT'; + } - $rrd_options .= " LINE1:95thin#aa0000"; - $rrd_options .= " LINE1:d95thout#aa0000"; + if ($legend == 'no' || $legend == '1') { + $rrd_options .= ' AREA:inbits#'.$colour_area_in.':'; + $rrd_options .= ' LINE1.25:inbits#'.$colour_line_in.':'; + $rrd_options .= ' AREA:doutbits#'.$colour_area_out.':'; + $rrd_options .= ' LINE1.25:doutbits#'.$colour_line_out.':'; + } + else { + $rrd_options .= ' AREA:inbits#'.$colour_area_in.':'; + $rrd_options .= " COMMENT:'bps Now Ave Max 95th %\\n'"; + $rrd_options .= ' LINE1.25:inbits#'.$colour_line_in.':In\ '; + $rrd_options .= ' GPRINT:inbits:LAST:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbits:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbits:MAX:%6.2lf%s'; + $rrd_options .= " GPRINT:95thin:%6.2lf%s\\\\n"; + $rrd_options .= ' AREA:doutbits#'.$colour_area_out.':'; + $rrd_options .= ' LINE1.25:doutbits#'.$colour_line_out.':Out'; + $rrd_options .= ' GPRINT:outbits:LAST:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbits:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbits:MAX:%6.2lf%s'; + $rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n"; + } - if ($_GET['previous'] == "yes") - { - $rrd_options .= " AREA:inbitsX#9999966:"; - $rrd_options .= " AREA:doutbitsX#99999966:"; - } + $rrd_options .= ' LINE1:95thin#aa0000'; + $rrd_options .= ' LINE1:d95thout#aa0000'; -} + if ($_GET['previous'] == 'yes') { + $rrd_options .= ' AREA:inbitsX#9999966:'; + $rrd_options .= ' AREA:doutbitsX#99999966:'; + } +}//end if -#$rrd_options .= " HRULE:0#999999"; - -?> +// $rrd_options .= " HRULE:0#999999"; diff --git a/html/includes/graphs/generic_multi_data.inc.php b/html/includes/graphs/generic_multi_data.inc.php index 93ee5b7cf..90f5c908e 100644 --- a/html/includes/graphs/generic_multi_data.inc.php +++ b/html/includes/graphs/generic_multi_data.inc.php @@ -2,108 +2,115 @@ // Draws aggregate bits graph from multiple RRDs // Variables : colour_[line|area]_[in|out], rrd_filenames +require 'includes/graphs/common.inc.php'; -include("includes/graphs/common.inc.php"); - -if($format == "octets" || $format == "bytes") -{ - $units = "Bps"; - $format = "octets"; -} else { - $units = "bps"; - $format = "bits"; +if ($format == 'octets' || $format == 'bytes') { + $units = 'Bps'; + $format = 'octets'; +} +else { + $units = 'bps'; + $format = 'bits'; } -$i=0; +$i = 0; -foreach ($rrd_filenames as $key => $rrd_filename) -{ - if ($rrd_inverted[$key]) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } +foreach ($rrd_filenames as $key => $rrd_filename) { + if ($rrd_inverted[$key]) { + $in = 'out'; + $out = 'in'; + } + else { + $in = 'in'; + $out = 'out'; + } - $rrd_options .= " DEF:".$in."octets" . $i . "=".$rrd_filename.":".$ds_in.":AVERAGE"; - $rrd_options .= " DEF:".$out."octets" . $i . "=".$rrd_filename.":".$ds_out.":AVERAGE"; - $in_thing .= $seperator . "inoctets" . $i . ",UN,0," . "inoctets" . $i . ",IF"; - $out_thing .= $seperator . "outoctets" . $i . ",UN,0," . "outoctets" . $i . ",IF"; - $pluses .= $plus; - $seperator = ","; - $plus = ",+"; + $rrd_options .= ' DEF:'.$in.'octets'.$i.'='.$rrd_filename.':'.$ds_in.':AVERAGE'; + $rrd_options .= ' DEF:'.$out.'octets'.$i.'='.$rrd_filename.':'.$ds_out.':AVERAGE'; + $in_thing .= $seperator.'inoctets'.$i.',UN,0,'.'inoctets'.$i.',IF'; + $out_thing .= $seperator.'outoctets'.$i.',UN,0,'.'outoctets'.$i.',IF'; + $pluses .= $plus; + $seperator = ','; + $plus = ',+'; - if ($_GET['previous']) - { - $rrd_options .= " DEF:".$in."octets" . $i . "X=".$rrd_filename.":".$ds_in.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " DEF:".$out."octets" . $i . "X=".$rrd_filename.":".$ds_out.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " SHIFT:".$in."octets" . $i . "X:$period"; - $rrd_options .= " SHIFT:".$out."octets" . $i . "X:$period"; - $in_thingX .= $seperatorX . "inoctets" . $i . "X,UN,0," . "inoctets" . $i . "X,IF"; - $out_thingX .= $seperatorX . "outoctets" . $i . "X,UN,0," . "outoctets" . $i . "X,IF"; - $plusesX .= $plusX; - $seperatorX = ","; - $plusX = ",+"; - } - $i++; -} + if ($_GET['previous']) { + $rrd_options .= ' DEF:'.$in.'octets'.$i.'X='.$rrd_filename.':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' DEF:'.$out.'octets'.$i.'X='.$rrd_filename.':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' SHIFT:'.$in.'octets'.$i."X:$period"; + $rrd_options .= ' SHIFT:'.$out.'octets'.$i."X:$period"; + $in_thingX .= $seperatorX.'inoctets'.$i.'X,UN,0,'.'inoctets'.$i.'X,IF'; + $out_thingX .= $seperatorX.'outoctets'.$i.'X,UN,0,'.'outoctets'.$i.'X,IF'; + $plusesX .= $plusX; + $seperatorX = ','; + $plusX = ',+'; + } -if ($i) -{ - if ($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } - $rrd_options .= " CDEF:".$in."octets=" . $in_thing . $pluses; - $rrd_options .= " CDEF:".$out."octets=" . $out_thing . $pluses; - $rrd_options .= " CDEF:doutoctets=outoctets,-1,*"; - $rrd_options .= " CDEF:inbits=inoctets,8,*"; - $rrd_options .= " CDEF:outbits=outoctets,8,*"; - $rrd_options .= " CDEF:doutbits=doutoctets,8,*"; - $rrd_options .= " VDEF:95thin=inbits,95,PERCENT"; - $rrd_options .= " VDEF:95thout=outbits,95,PERCENT"; - $rrd_options .= " VDEF:d95thout=doutbits,5,PERCENT"; + $i++; +}//end foreach - if ($_GET['previous'] == "yes") - { - $rrd_options .= " CDEF:".$in."octetsX=" . $in_thingX . $pluses; - $rrd_options .= " CDEF:".$out."octetsX=" . $out_thingX . $pluses; - $rrd_options .= " CDEF:doutoctetsX=outoctetsX,-1,*"; - $rrd_options .= " CDEF:inbitsX=inoctetsX,8,*"; - $rrd_options .= " CDEF:outbitsX=outoctetsX,8,*"; - $rrd_options .= " CDEF:doutbitsX=doutoctetsX,8,*"; - $rrd_options .= " VDEF:95thinX=inbitsX,95,PERCENT"; - $rrd_options .= " VDEF:95thoutX=outbitsX,95,PERCENT"; - $rrd_options .= " VDEF:d95thoutX=doutbitsX,5,PERCENT"; - } +if ($i) { + if ($inverse) { + $in = 'out'; + $out = 'in'; + } + else { + $in = 'in'; + $out = 'out'; + } - if ($legend == 'no' || $legend == '1') - { - $rrd_options .= " AREA:in".$format."#".$colour_area_in.":"; -# $rrd_options .= " LINE1.25:in".$format."#".$colour_line_in.":"; - $rrd_options .= " AREA:dout".$format."#".$colour_area_out.":"; -# $rrd_options .= " LINE1.25:dout".$format."#".$colour_line_out.":"; - } else { - $rrd_options .= " AREA:in".$format."#".$colour_area_in.":"; - $rrd_options .= " COMMENT:'bps Now Ave Max 95th %\\n'"; -# $rrd_options .= " LINE1.25:in".$format."#".$colour_line_in.":In\ "; - $rrd_options .= " GPRINT:in".$format.":LAST:%6.2lf%s"; - $rrd_options .= " GPRINT:in".$format.":AVERAGE:%6.2lf%s"; - $rrd_options .= " GPRINT:in".$format.":MAX:%6.2lf%s"; - $rrd_options .= " GPRINT:95thin:%6.2lf%s\\\\n"; - $rrd_options .= " AREA:dout".$format."#".$colour_area_out.":"; -# $rrd_options .= " LINE1.25:dout".$format."#".$colour_line_out.":Out"; - $rrd_options .= " GPRINT:out".$format.":LAST:%6.2lf%s"; - $rrd_options .= " GPRINT:out".$format.":AVERAGE:%6.2lf%s"; - $rrd_options .= " GPRINT:out".$format.":MAX:%6.2lf%s"; - $rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n"; - } + $rrd_options .= ' CDEF:'.$in.'octets='.$in_thing.$pluses; + $rrd_options .= ' CDEF:'.$out.'octets='.$out_thing.$pluses; + $rrd_options .= ' CDEF:doutoctets=outoctets,-1,*'; + $rrd_options .= ' CDEF:inbits=inoctets,8,*'; + $rrd_options .= ' CDEF:outbits=outoctets,8,*'; + $rrd_options .= ' CDEF:doutbits=doutoctets,8,*'; + $rrd_options .= ' VDEF:95thin=inbits,95,PERCENT'; + $rrd_options .= ' VDEF:95thout=outbits,95,PERCENT'; + $rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT'; - $rrd_options .= " LINE1:95thin#aa0000"; - $rrd_options .= " LINE1:d95thout#aa0000"; + if ($_GET['previous'] == 'yes') { + $rrd_options .= ' CDEF:'.$in.'octetsX='.$in_thingX.$pluses; + $rrd_options .= ' CDEF:'.$out.'octetsX='.$out_thingX.$pluses; + $rrd_options .= ' CDEF:doutoctetsX=outoctetsX,-1,*'; + $rrd_options .= ' CDEF:inbitsX=inoctetsX,8,*'; + $rrd_options .= ' CDEF:outbitsX=outoctetsX,8,*'; + $rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*'; + $rrd_options .= ' VDEF:95thinX=inbitsX,95,PERCENT'; + $rrd_options .= ' VDEF:95thoutX=outbitsX,95,PERCENT'; + $rrd_options .= ' VDEF:d95thoutX=doutbitsX,5,PERCENT'; + } - if ($_GET['previous'] == "yes") - { - $rrd_options .= " AREA:in".$format."X#99999999:"; - $rrd_options .= " AREA:dout".$format."X#99999999:"; - $rrd_options .= " LINE1:in".$format."X#666666:"; - $rrd_options .= " LINE1:dout".$format."X#666666:"; - } + if ($legend == 'no' || $legend == '1') { + $rrd_options .= ' AREA:in'.$format.'#'.$colour_area_in.':'; + // $rrd_options .= " LINE1.25:in".$format."#".$colour_line_in.":"; + $rrd_options .= ' AREA:dout'.$format.'#'.$colour_area_out.':'; + // $rrd_options .= " LINE1.25:dout".$format."#".$colour_line_out.":"; + } + else { + $rrd_options .= ' AREA:in'.$format.'#'.$colour_area_in.':'; + $rrd_options .= " COMMENT:'bps Now Ave Max 95th %\\n'"; + // $rrd_options .= " LINE1.25:in".$format."#".$colour_line_in.":In\ "; + $rrd_options .= ' GPRINT:in'.$format.':LAST:%6.2lf%s'; + $rrd_options .= ' GPRINT:in'.$format.':AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:in'.$format.':MAX:%6.2lf%s'; + $rrd_options .= " GPRINT:95thin:%6.2lf%s\\\\n"; + $rrd_options .= ' AREA:dout'.$format.'#'.$colour_area_out.':'; + // $rrd_options .= " LINE1.25:dout".$format."#".$colour_line_out.":Out"; + $rrd_options .= ' GPRINT:out'.$format.':LAST:%6.2lf%s'; + $rrd_options .= ' GPRINT:out'.$format.':AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:out'.$format.':MAX:%6.2lf%s'; + $rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n"; + } -} + $rrd_options .= ' LINE1:95thin#aa0000'; + $rrd_options .= ' LINE1:d95thout#aa0000'; -#$rrd_options .= " HRULE:0#999999"; + if ($_GET['previous'] == 'yes') { + $rrd_options .= ' AREA:in'.$format.'X#99999999:'; + $rrd_options .= ' AREA:dout'.$format.'X#99999999:'; + $rrd_options .= ' LINE1:in'.$format.'X#666666:'; + $rrd_options .= ' LINE1:dout'.$format.'X#666666:'; + } +}//end if -?> +// $rrd_options .= " HRULE:0#999999"; diff --git a/html/includes/graphs/generic_multi_data_separated.inc.php b/html/includes/graphs/generic_multi_data_separated.inc.php index 07d6ee6c0..7865d03de 100644 --- a/html/includes/graphs/generic_multi_data_separated.inc.php +++ b/html/includes/graphs/generic_multi_data_separated.inc.php @@ -1,117 +1,127 @@ "500") -{ - $descr_len=18; -} else { - $descr_len=8; - $descr_len += round(($width - 260) / 9.5); +if ($width > '500') { + $descr_len = 18; +} +else { + $descr_len = 8; + $descr_len += round(($width - 260) / 9.5); } -$unit_text = "Bits/sec"; +$unit_text = 'Bits/sec'; -if($width > "500") -{ - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." Current Average Maximum '"; - if (!$nototal) { $rrd_options .= " COMMENT:'Total '"; } - $rrd_options .= " COMMENT:'\l'"; -} else { - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." Now Ave Max\l'"; +if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." Current Average Maximum '"; + if (!$nototal) { + $rrd_options .= " COMMENT:'Total '"; + } + $rrd_options .= " COMMENT:'\l'"; +} +else { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." Now Ave Max\l'"; } -if(!isset($multiplier)) { $multiplier = "8"; } - -foreach ($rrd_list as $rrd) -{ - if (!$config['graph_colours'][$colours_in][$iter] || !$config['graph_colours'][$colours_out][$iter]) { $iter = 0; } - - $colour_in=$config['graph_colours'][$colours_in][$iter]; - $colour_out=$config['graph_colours'][$colours_out][$iter]; - - if (isset($rrd['descr_in'])) - { - $descr = rrdtool_escape($rrd['descr_in'], $descr_len) . " In"; - } else { - $descr = rrdtool_escape($rrd['descr'], $descr_len) . " In"; - } - $descr_out = rrdtool_escape($rrd['descr_out'], $descr_len) . " Out"; - $descr = str_replace("'", "", $descr); // FIXME does this mean ' should be filtered in rrdtool_escape? probably... - $descr_out = str_replace("'", "", $descr_out); - - $rrd_options .= " DEF:".$in.$i."=".$rrd['filename'].":".$ds_in.":AVERAGE "; - $rrd_options .= " DEF:".$out.$i."=".$rrd['filename'].":".$ds_out.":AVERAGE "; - $rrd_options .= " CDEF:inB".$i."=in".$i.",$multiplier,* "; - $rrd_options .= " CDEF:outB".$i."=out".$i.",$multiplier,*"; - $rrd_options .= " CDEF:outB".$i."_neg=outB".$i.",-1,*"; - $rrd_options .= " CDEF:octets".$i."=inB".$i.",outB".$i.",+"; - - if (!$args['nototal']) - { - - $in_thing .= $seperator . $in . $i . ",UN,0," . $in . $i . ",IF"; - $out_thing .= $seperator . $out . $i . ",UN,0," . $out . $i . ",IF"; - $pluses .= $plus; - $seperator = ","; - $plus = ",+"; - - $rrd_options .= " VDEF:totin".$i."=inB".$i.",TOTAL"; - $rrd_options .= " VDEF:totout".$i."=outB".$i.",TOTAL"; - $rrd_options .= " VDEF:tot".$i."=octets".$i.",TOTAL"; - } - - if ($i) { $stack="STACK"; } - - $rrd_options .= " AREA:inB".$i."#" . $colour_in . ":'" . $descr . "':$stack"; - $rrd_options .= " GPRINT:inB".$i.":LAST:%6.2lf%s$units"; - $rrd_options .= " GPRINT:inB".$i.":AVERAGE:%6.2lf%s$units"; - $rrd_options .= " GPRINT:inB".$i.":MAX:%6.2lf%s$units\l"; - - if (!$nototal) { $rrd_options .= " GPRINT:totin".$i.":%6.2lf%s$total_units"; } - - $rrd_options .= " 'HRULE:0#" . $colour_out.":".$descr_out."'"; - $rrd_optionsb .= " 'AREA:outB".$i."_neg#" . $colour_out . "::$stack'"; - $rrd_options .= " GPRINT:outB".$i.":LAST:%6.2lf%s$units"; - $rrd_options .= " GPRINT:outB".$i.":AVERAGE:%6.2lf%s$units"; - $rrd_options .= " GPRINT:outB".$i.":MAX:%6.2lf%s$units\l"; - - if (!$nototal) { $rrd_options .= " GPRINT:totout".$i.":%6.2lf%s$total_units"; } - - $rrd_options .= " 'COMMENT:\l'"; - $i++; $iter++; +if (!isset($multiplier)) { + $multiplier = '8'; } -if ($custom_graph) { $rrd_options .= $custom_graph; } +foreach ($rrd_list as $rrd) { + if (!$config['graph_colours'][$colours_in][$iter] || !$config['graph_colours'][$colours_out][$iter]) { + $iter = 0; + } -if(!$nototal) -{ - $rrd_options .= " CDEF:".$in."octets=" . $in_thing . $pluses; - $rrd_options .= " CDEF:".$out."octets=" . $out_thing . $pluses; - $rrd_options .= " CDEF:octets=inoctets,outoctets,+"; - $rrd_options .= " CDEF:doutoctets=outoctets,-1,*"; - $rrd_options .= " CDEF:inbits=inoctets,8,*"; - $rrd_options .= " CDEF:outbits=outoctets,8,*"; - $rrd_options .= " CDEF:doutbits=doutoctets,8,*"; + $colour_in = $config['graph_colours'][$colours_in][$iter]; + $colour_out = $config['graph_colours'][$colours_out][$iter]; - $rrd_options .= " VDEF:95thin=inbits,95,PERCENT"; - $rrd_options .= " VDEF:95thout=outbits,95,PERCENT"; - $rrd_options .= " VDEF:d95thout=doutbits,5,PERCENT"; + if (isset($rrd['descr_in'])) { + $descr = rrdtool_escape($rrd['descr_in'], $descr_len).' In'; + } + else { + $descr = rrdtool_escape($rrd['descr'], $descr_len).' In'; + } - $rrd_options .= " VDEF:totin=inoctets,TOTAL"; - $rrd_options .= " VDEF:totout=outoctets,TOTAL"; - $rrd_options .= " VDEF:tot=octets,TOTAL"; + $descr_out = rrdtool_escape($rrd['descr_out'], $descr_len).' Out'; + $descr = str_replace("'", '', $descr); + // FIXME does this mean ' should be filtered in rrdtool_escape? probably... + $descr_out = str_replace("'", '', $descr_out); -# $rrd_options .= " AREA:totin#" . $colour_in . ":'" . $descr . "':$stack"; -# $rrd_options .= " GPRINT:totin:LAST:%6.2lf%s$units"; -# $rrd_options .= " GPRINT:totin:AVERAGE:%6.2lf%s$units"; -# $rrd_options .= " GPRINT:totin:MAX:%6.2lf%s$units\l"; + $rrd_options .= ' DEF:'.$in.$i.'='.$rrd['filename'].':'.$ds_in.':AVERAGE '; + $rrd_options .= ' DEF:'.$out.$i.'='.$rrd['filename'].':'.$ds_out.':AVERAGE '; + $rrd_options .= ' CDEF:inB'.$i.'=in'.$i.",$multiplier,* "; + $rrd_options .= ' CDEF:outB'.$i.'=out'.$i.",$multiplier,*"; + $rrd_options .= ' CDEF:outB'.$i.'_neg=outB'.$i.',-1,*'; + $rrd_options .= ' CDEF:octets'.$i.'=inB'.$i.',outB'.$i.',+'; + if (!$args['nototal']) { + $in_thing .= $seperator.$in.$i.',UN,0,'.$in.$i.',IF'; + $out_thing .= $seperator.$out.$i.',UN,0,'.$out.$i.',IF'; + $pluses .= $plus; + $seperator = ','; + $plus = ',+'; + + $rrd_options .= ' VDEF:totin'.$i.'=inB'.$i.',TOTAL'; + $rrd_options .= ' VDEF:totout'.$i.'=outB'.$i.',TOTAL'; + $rrd_options .= ' VDEF:tot'.$i.'=octets'.$i.',TOTAL'; + } + + if ($i) { + $stack = 'STACK'; + } + + $rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."':$stack"; + $rrd_options .= ' GPRINT:inB'.$i.":LAST:%6.2lf%s$units"; + $rrd_options .= ' GPRINT:inB'.$i.":AVERAGE:%6.2lf%s$units"; + $rrd_options .= ' GPRINT:inB'.$i.":MAX:%6.2lf%s$units\l"; + + if (!$nototal) { + $rrd_options .= ' GPRINT:totin'.$i.":%6.2lf%s$total_units"; + } + + $rrd_options .= " 'HRULE:0#".$colour_out.':'.$descr_out."'"; + $rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out."::$stack'"; + $rrd_options .= ' GPRINT:outB'.$i.":LAST:%6.2lf%s$units"; + $rrd_options .= ' GPRINT:outB'.$i.":AVERAGE:%6.2lf%s$units"; + $rrd_options .= ' GPRINT:outB'.$i.":MAX:%6.2lf%s$units\l"; + + if (!$nototal) { + $rrd_options .= ' GPRINT:totout'.$i.":%6.2lf%s$total_units"; + } + + $rrd_options .= " 'COMMENT:\l'"; + $i++; + $iter++; +}//end foreach + +if ($custom_graph) { + $rrd_options .= $custom_graph; } +if (!$nototal) { + $rrd_options .= ' CDEF:'.$in.'octets='.$in_thing.$pluses; + $rrd_options .= ' CDEF:'.$out.'octets='.$out_thing.$pluses; + $rrd_options .= ' CDEF:octets=inoctets,outoctets,+'; + $rrd_options .= ' CDEF:doutoctets=outoctets,-1,*'; + $rrd_options .= ' CDEF:inbits=inoctets,8,*'; + $rrd_options .= ' CDEF:outbits=outoctets,8,*'; + $rrd_options .= ' CDEF:doutbits=doutoctets,8,*'; + + $rrd_options .= ' VDEF:95thin=inbits,95,PERCENT'; + $rrd_options .= ' VDEF:95thout=outbits,95,PERCENT'; + $rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT'; + + $rrd_options .= ' VDEF:totin=inoctets,TOTAL'; + $rrd_options .= ' VDEF:totout=outoctets,TOTAL'; + $rrd_options .= ' VDEF:tot=octets,TOTAL'; + + // $rrd_options .= " AREA:totin#" . $colour_in . ":'" . $descr . "':$stack"; + // $rrd_options .= " GPRINT:totin:LAST:%6.2lf%s$units"; + // $rrd_options .= " GPRINT:totin:AVERAGE:%6.2lf%s$units"; + // $rrd_options .= " GPRINT:totin:MAX:%6.2lf%s$units\l"; +}//end if + $rrd_options .= $rrd_optionsb; -$rrd_options .= " HRULE:0#999999"; - -?> +$rrd_options .= ' HRULE:0#999999'; diff --git a/html/includes/graphs/generic_multi_line.inc.php b/html/includes/graphs/generic_multi_line.inc.php index 7117f79e1..c34d78e77 100644 --- a/html/includes/graphs/generic_multi_line.inc.php +++ b/html/includes/graphs/generic_multi_line.inc.php @@ -1,72 +1,80 @@ "500") -{ - $descr_len=24; -} else { - $descr_len=12; - $descr_len += round(($width - 250) / 8); +if ($width > '500') { + $descr_len = 24; +} +else { + $descr_len = 12; + $descr_len += round(($width - 250) / 8); } -if ($nototal) { $descrlen += "2"; $unitlen += "2";} - -if($width > "500") -{ - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)."Now Min Max Avg\l'"; - if (!$nototal) { $rrd_options .= " COMMENT:'Total '"; } - $rrd_options .= " COMMENT:'\l'"; -} else { - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)."Now Min Max Avg\l'"; - +if ($nototal) { + $descrlen += '2'; + $unitlen += '2'; } -$i = 0; +if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Now Min Max Avg\l'"; + if (!$nototal) { + $rrd_options .= " COMMENT:'Total '"; + } + + $rrd_options .= " COMMENT:'\l'"; +} +else { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Now Min Max Avg\l'"; +} + +$i = 0; $iter = 0; -foreach ($rrd_list as $rrd) -{ - if (!$config['graph_colours'][$colours][$iter]) { $iter = 0; } +foreach ($rrd_list as $rrd) { + if (!$config['graph_colours'][$colours][$iter]) { + $iter = 0; + } - $colour=$config['graph_colours'][$colours][$iter]; + $colour = $config['graph_colours'][$colours][$iter]; - $ds = $rrd['ds']; - $filename = $rrd['filename']; + $ds = $rrd['ds']; + $filename = $rrd['filename']; - $descr = rrdtool_escape($rrd['descr'], $descr_len); + $descr = rrdtool_escape($rrd['descr'], $descr_len); - $id = "ds".$i; + $id = 'ds'.$i; - $rrd_options .= " DEF:".$id."=$filename:$ds:AVERAGE"; + $rrd_options .= ' DEF:'.$id."=$filename:$ds:AVERAGE"; - if ($simple_rrd) - { - $rrd_options .= " CDEF:".$id."min=".$id." "; - $rrd_options .= " CDEF:".$id."max=".$id." "; - } else { - $rrd_options .= " DEF:".$id."min=$filename:$ds:MIN"; - $rrd_options .= " DEF:".$id."max=$filename:$ds:MAX"; - } + if ($simple_rrd) { + $rrd_options .= ' CDEF:'.$id.'min='.$id.' '; + $rrd_options .= ' CDEF:'.$id.'max='.$id.' '; + } + else { + $rrd_options .= ' DEF:'.$id."min=$filename:$ds:MIN"; + $rrd_options .= ' DEF:'.$id."max=$filename:$ds:MAX"; + } - if ($rrd['invert']) - { - $rrd_options .= " CDEF:".$id."i=".$id.",-1,*"; - $rrd_optionsb .= " LINE1.25:".$id."i#".$colour.":'$descr'"; - if (!empty($rrd['areacolour'])) { $rrd_optionsb .= " AREA:".$id."i#" . $rrd['areacolour']; } - } else { - $rrd_optionsb .= " LINE1.25:".$id."#".$colour.":'$descr'"; - if (!empty($rrd['areacolour'])) { $rrd_optionsb .= " AREA:".$id."#" . $rrd['areacolour']; } - } + if ($rrd['invert']) { + $rrd_options .= ' CDEF:'.$id.'i='.$id.',-1,*'; + $rrd_optionsb .= ' LINE1.25:'.$id.'i#'.$colour.":'$descr'"; + if (!empty($rrd['areacolour'])) { + $rrd_optionsb .= ' AREA:'.$id.'i#'.$rrd['areacolour']; + } + } + else { + $rrd_optionsb .= ' LINE1.25:'.$id.'#'.$colour.":'$descr'"; + if (!empty($rrd['areacolour'])) { + $rrd_optionsb .= ' AREA:'.$id.'#'.$rrd['areacolour']; + } + } - $rrd_optionsb .= " GPRINT:".$id.":LAST:%5.2lf%s GPRINT:".$id."min:MIN:%5.2lf%s"; - $rrd_optionsb .= " GPRINT:".$id."max:MAX:%5.2lf%s GPRINT:".$id.":AVERAGE:'%5.2lf%s\\n'"; + $rrd_optionsb .= ' GPRINT:'.$id.':LAST:%5.2lf%s GPRINT:'.$id.'min:MIN:%5.2lf%s'; + $rrd_optionsb .= ' GPRINT:'.$id.'max:MAX:%5.2lf%s GPRINT:'.$id.":AVERAGE:'%5.2lf%s\\n'"; - $i++; $iter++; - -} + $i++; + $iter++; +}//end foreach $rrd_options .= $rrd_optionsb; -$rrd_options .= " HRULE:0#555555"; - -?> +$rrd_options .= ' HRULE:0#555555'; diff --git a/html/includes/graphs/generic_multi_simplex_seperated.inc.php b/html/includes/graphs/generic_multi_simplex_seperated.inc.php index adc08d957..18df802ae 100644 --- a/html/includes/graphs/generic_multi_simplex_seperated.inc.php +++ b/html/includes/graphs/generic_multi_simplex_seperated.inc.php @@ -1,127 +1,137 @@ "500") -{ - $descr_len = 24; // FIXME may even be more imo? -} else { - $descr_len = 12; - $descr_len += round(($width - 250) / 8); +if ($width > '500') { + $descr_len = 24; + // FIXME may even be more imo? +} +else { + $descr_len = 12; + $descr_len += round(($width - 250) / 8); } -if ($nototal) { $descrlen += "2"; $unitlen += "2";} -$unit_text = str_pad(truncate($unit_text,$unitlen),$unitlen); - -if($width > "500") -{ - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)."Now Min Max Avg\l'"; - if (!$nototal) { $rrd_options .= " COMMENT:'Total '"; } - $rrd_options .= " COMMENT:'\l'"; -} else { - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)."Now Min Max Avg\l'"; - +if ($nototal) { + $descrlen += '2'; + $unitlen += '2'; } -$unitlen = "10"; -if ($nototal) { $descrlen += "2"; $unitlen += "2";} -$unit_text = str_pad(truncate($unit_text,$unitlen),$unitlen); +$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen); -$colour_iter=0; -foreach ($rrd_list as $i => $rrd) -{ - if ($rrd['colour']) - { - $colour = $rrd['colour']; - } else { - if (!$config['graph_colours'][$colours][$colour_iter]) { $colour_iter = 0; } - $colour = $config['graph_colours'][$colours][$colour_iter]; - $colour_iter++; - } - - $descr = rrdtool_escape($rrd['descr'], $descr_len); - - $rrd_options .= " DEF:".$rrd['ds'].$i."=".$rrd['filename'].":".$rrd['ds'].":AVERAGE "; - - if ($simple_rrd) - { - $rrd_options .= " CDEF:".$rrd['ds'].$i."min=".$rrd['ds'].$i." "; - $rrd_options .= " CDEF:".$rrd['ds'].$i."max=".$rrd['ds'].$i." "; - } else { - $rrd_options .= " DEF:".$rrd['ds'].$i."min=".$rrd['filename'].":".$rrd['ds'].":MIN "; - $rrd_options .= " DEF:".$rrd['ds'].$i."max=".$rrd['filename'].":".$rrd['ds'].":MAX "; - } - - if ($_GET['previous']) - { - $rrd_options .= " DEF:".$i . "X=".$rrd['filename'].":".$rrd['ds'].":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " SHIFT:".$i . "X:$period"; - $thingX .= $seperatorX . $i . "X,UN,0," . $i . "X,IF"; - $plusesX .= $plusX; - $seperatorX = ","; - $plusX = ",+"; - } - - // Suppress totalling? - if (!$nototal) - { - $rrd_options .= " VDEF:tot".$rrd['ds'].$i."=".$rrd['ds'].$i.",TOTAL"; - } - - // This this not the first entry? - if ($i) { $stack="STACK"; } - # if we've been passed a multiplier we must make a CDEF based on it! - $g_defname = $rrd['ds']; - if (is_numeric($multiplier)) - { - $g_defname = $rrd['ds'] . "_cdef"; - $rrd_options .= " CDEF:" . $g_defname . $i . "=" . $rrd['ds'] . $i . "," . $multiplier . ",*"; - $rrd_options .= " CDEF:" . $g_defname . $i . "min=" . $rrd['ds'] . $i . "min," . $multiplier . ",*"; - $rrd_options .= " CDEF:" . $g_defname . $i . "max=" . $rrd['ds'] . $i . "max," . $multiplier . ",*"; - - // If we've been passed a divider (divisor!) we make a CDEF for it. - } elseif (is_numeric($divider)) - { - $g_defname = $rrd['ds'] . "_cdef"; - $rrd_options .= " CDEF:" . $g_defname . $i . "=" . $rrd['ds'] . $i . "," . $divider . ",/"; - $rrd_options .= " CDEF:" . $g_defname . $i . "min=" . $rrd['ds'] . $i . "min," . $divider . ",/"; - $rrd_options .= " CDEF:" . $g_defname . $i . "max=" . $rrd['ds'] . $i . "max," . $divider . ",/"; - } - - // Are our text values related to te multiplier/divisor or not? - if (isset($text_orig) && $text_orig) - { - $t_defname = $rrd['ds']; - } else { - $t_defname = $g_defname; - } - - $rrd_options .= " AREA:".$g_defname.$i."#".$colour.":'".$descr."':$stack"; - - $rrd_options .= " GPRINT:".$t_defname.$i.":LAST:%5.2lf%s GPRINT:".$t_defname.$i."min:MIN:%5.2lf%s"; - $rrd_options .= " GPRINT:".$t_defname.$i."max:MAX:%5.2lf%s GPRINT:".$t_defname.$i.":AVERAGE:'%5.2lf%s\\n'"; - - if (!$nototal) { $rrd_options .= " GPRINT:tot".$rrd['ds'].$i.":%6.2lf%s".rrdtool_escape($total_units).""; } - - $rrd_options .= " COMMENT:'\\n'"; -} - - if ($_GET['previous'] == "yes") - { - if (is_numeric($multiplier)) - { - $rrd_options .= " CDEF:X=" . $thingX . $plusesX.",".$multiplier. ",*"; - } elseif (is_numeric($divider)) - { - $rrd_options .= " CDEF:X=" . $thingX . $plusesX.",".$divider. ",/"; - } else - { - $rrd_options .= " CDEF:X=" . $thingX . $plusesX; +if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Now Min Max Avg\l'"; + if (!$nototal) { + $rrd_options .= " COMMENT:'Total '"; } - $rrd_options .= " AREA:X#99999999:"; - $rrd_options .= " LINE1.25:X#666666:"; + $rrd_options .= " COMMENT:'\l'"; +} +else { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Now Min Max Avg\l'"; +} - } +$unitlen = '10'; +if ($nototal) { + $descrlen += '2'; + $unitlen += '2'; +} -?> +$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen); + +$colour_iter = 0; +foreach ($rrd_list as $i => $rrd) { + if ($rrd['colour']) { + $colour = $rrd['colour']; + } + else { + if (!$config['graph_colours'][$colours][$colour_iter]) { + $colour_iter = 0; + } + + $colour = $config['graph_colours'][$colours][$colour_iter]; + $colour_iter++; + } + + $descr = rrdtool_escape($rrd['descr'], $descr_len); + + $rrd_options .= ' DEF:'.$rrd['ds'].$i.'='.$rrd['filename'].':'.$rrd['ds'].':AVERAGE '; + + if ($simple_rrd) { + $rrd_options .= ' CDEF:'.$rrd['ds'].$i.'min='.$rrd['ds'].$i.' '; + $rrd_options .= ' CDEF:'.$rrd['ds'].$i.'max='.$rrd['ds'].$i.' '; + } + else { + $rrd_options .= ' DEF:'.$rrd['ds'].$i.'min='.$rrd['filename'].':'.$rrd['ds'].':MIN '; + $rrd_options .= ' DEF:'.$rrd['ds'].$i.'max='.$rrd['filename'].':'.$rrd['ds'].':MAX '; + } + + if ($_GET['previous']) { + $rrd_options .= ' DEF:'.$i.'X='.$rrd['filename'].':'.$rrd['ds'].':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' SHIFT:'.$i."X:$period"; + $thingX .= $seperatorX.$i.'X,UN,0,'.$i.'X,IF'; + $plusesX .= $plusX; + $seperatorX = ','; + $plusX = ',+'; + } + + // Suppress totalling? + if (!$nototal) { + $rrd_options .= ' VDEF:tot'.$rrd['ds'].$i.'='.$rrd['ds'].$i.',TOTAL'; + } + + // This this not the first entry? + if ($i) { + $stack = 'STACK'; + } + + // if we've been passed a multiplier we must make a CDEF based on it! + $g_defname = $rrd['ds']; + if (is_numeric($multiplier)) { + $g_defname = $rrd['ds'].'_cdef'; + $rrd_options .= ' CDEF:'.$g_defname.$i.'='.$rrd['ds'].$i.','.$multiplier.',*'; + $rrd_options .= ' CDEF:'.$g_defname.$i.'min='.$rrd['ds'].$i.'min,'.$multiplier.',*'; + $rrd_options .= ' CDEF:'.$g_defname.$i.'max='.$rrd['ds'].$i.'max,'.$multiplier.',*'; + + // If we've been passed a divider (divisor!) we make a CDEF for it. + } + else if (is_numeric($divider)) { + $g_defname = $rrd['ds'].'_cdef'; + $rrd_options .= ' CDEF:'.$g_defname.$i.'='.$rrd['ds'].$i.','.$divider.',/'; + $rrd_options .= ' CDEF:'.$g_defname.$i.'min='.$rrd['ds'].$i.'min,'.$divider.',/'; + $rrd_options .= ' CDEF:'.$g_defname.$i.'max='.$rrd['ds'].$i.'max,'.$divider.',/'; + } + + // Are our text values related to te multiplier/divisor or not? + if (isset($text_orig) && $text_orig) { + $t_defname = $rrd['ds']; + } + else { + $t_defname = $g_defname; + } + + $rrd_options .= ' AREA:'.$g_defname.$i.'#'.$colour.":'".$descr."':$stack"; + + $rrd_options .= ' GPRINT:'.$t_defname.$i.':LAST:%5.2lf%s GPRINT:'.$t_defname.$i.'min:MIN:%5.2lf%s'; + $rrd_options .= ' GPRINT:'.$t_defname.$i.'max:MAX:%5.2lf%s GPRINT:'.$t_defname.$i.":AVERAGE:'%5.2lf%s\\n'"; + + if (!$nototal) { + $rrd_options .= ' GPRINT:tot'.$rrd['ds'].$i.':%6.2lf%s'.rrdtool_escape($total_units).''; + } + + $rrd_options .= " COMMENT:'\\n'"; +}//end foreach + +if ($_GET['previous'] == 'yes') { + if (is_numeric($multiplier)) { + $rrd_options .= ' CDEF:X='.$thingX.$plusesX.','.$multiplier.',*'; + } + else if (is_numeric($divider)) { + $rrd_options .= ' CDEF:X='.$thingX.$plusesX.','.$divider.',/'; + } + else { + $rrd_options .= ' CDEF:X='.$thingX.$plusesX; + } + + $rrd_options .= ' AREA:X#99999999:'; + $rrd_options .= ' LINE1.25:X#666666:'; +} diff --git a/html/includes/graphs/generic_simplex.inc.php b/html/includes/graphs/generic_simplex.inc.php index ddc45ba2a..186cc80a0 100644 --- a/html/includes/graphs/generic_simplex.inc.php +++ b/html/includes/graphs/generic_simplex.inc.php @@ -1,128 +1,117 @@ + if ($percentile) { + $rrd_options .= ' GPRINT:'.$ds.'_percentile:%6.2lf%s'; + } + + $rrd_options .= "\\\\n"; + $rrd_options .= " COMMENT:\\\\n"; + + if ($print_total) { + $rrd_options .= ' GPRINT:'.$ds.'_tot:Total\ %6.2lf%s\)\\\\l'; + } + + if ($percentile) { + $rrd_options .= ' LINE1:'.$ds.'_percentile#aa0000'; + } + + if ($_GET['previous'] == 'yes') { + $rrd_options .= ' LINE1.25:'.$ds."X#666666:'Prev \\\\n'"; + $rrd_options .= ' AREA:'.$ds.'X#99999966:'; + } +}//end if diff --git a/html/includes/graphs/global/auth.inc.php b/html/includes/graphs/global/auth.inc.php index b0ad7e578..c364820b4 100644 --- a/html/includes/graphs/global/auth.inc.php +++ b/html/includes/graphs/global/auth.inc.php @@ -1,8 +1,5 @@ = "5") -{ - $auth = 1; +if ($_SESSION['userlevel'] >= '5') { + $auth = 1; } - -?> diff --git a/html/includes/graphs/global/bits.inc.php b/html/includes/graphs/global/bits.inc.php index 862b39e50..674229ecf 100644 --- a/html/includes/graphs/global/bits.inc.php +++ b/html/includes/graphs/global/bits.inc.php @@ -1,66 +1,58 @@ +require 'includes/graphs/generic_multi_bits_separated.inc.php'; diff --git a/html/includes/graphs/global/processor_separate.inc.php b/html/includes/graphs/global/processor_separate.inc.php index 74b80b923..3afd67250 100644 --- a/html/includes/graphs/global/processor_separate.inc.php +++ b/html/includes/graphs/global/processor_separate.inc.php @@ -2,33 +2,29 @@ $i = 0; -foreach (dbFetchRows("SELECT * FROM `processors` AS P, devices AS D WHERE D.device_id = P.device_id") as $proc) -{ - $rrd_filename = $config['rrd_dir'] . "/".$proc['hostname']."/" . safename("processor-" . $proc['processor_type'] . "-" . $proc['processor_index'] . ".rrd"); +foreach (dbFetchRows('SELECT * FROM `processors` AS P, devices AS D WHERE D.device_id = P.device_id') as $proc) { + $rrd_filename = $config['rrd_dir'].'/'.$proc['hostname'].'/'.safename('processor-'.$proc['processor_type'].'-'.$proc['processor_index'].'.rrd'); - if (is_file($rrd_filename)) - { - $descr = short_hrDeviceDescr($proc['processor_descr']); + if (is_file($rrd_filename)) { + $descr = short_hrDeviceDescr($proc['processor_descr']); - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $descr; - $rrd_list[$i]['ds'] = "usage"; - $rrd_list[$i]['area'] = 1; - $i++; - } + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $descr; + $rrd_list[$i]['ds'] = 'usage'; + $rrd_list[$i]['area'] = 1; + $i++; + } } -$unit_text = "Load %"; +$unit_text = 'Load %'; -$units = '%'; +$units = '%'; $total_units = '%'; -$colours ='mixed'; +$colours = 'mixed'; -$scale_min = "0"; -$scale_max = "100"; +$scale_min = '0'; +$scale_max = '100'; $nototal = 1; -include("includes/graphs/generic_multi_line.inc.php"); - -?> +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/global/processor_stack.inc.php b/html/includes/graphs/global/processor_stack.inc.php index ffe3d6225..9c205f144 100644 --- a/html/includes/graphs/global/processor_stack.inc.php +++ b/html/includes/graphs/global/processor_stack.inc.php @@ -2,34 +2,30 @@ $i = 0; -foreach (dbFetchRows("SELECT * FROM `processors` AS P, devices AS D WHERE D.device_id = P.device_id") as $proc) -{ - $rrd_filename = $config['rrd_dir'] . "/".$proc['hostname']."/" . safename("processor-" . $proc['processor_type'] . "-" . $proc['processor_index'] . ".rrd"); +foreach (dbFetchRows('SELECT * FROM `processors` AS P, devices AS D WHERE D.device_id = P.device_id') as $proc) { + $rrd_filename = $config['rrd_dir'].'/'.$proc['hostname'].'/'.safename('processor-'.$proc['processor_type'].'-'.$proc['processor_index'].'.rrd'); - if (is_file($rrd_filename)) - { - $descr = short_hrDeviceDescr($proc['processor_descr']); + if (is_file($rrd_filename)) { + $descr = short_hrDeviceDescr($proc['processor_descr']); - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $descr; - $rrd_list[$i]['ds'] = "usage"; - $i++; - } + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $descr; + $rrd_list[$i]['ds'] = 'usage'; + $i++; + } } -$unit_text = "Load %"; +$unit_text = 'Load %'; -$units = '%'; +$units = '%'; $total_units = '%'; -$colours ='oranges'; +$colours = 'oranges'; -$scale_min = "0"; -$scale_max = "100"; +$scale_min = '0'; +$scale_max = '100'; -$divider = $i; +$divider = $i; $text_orig = 1; -$nototal = 1; +$nototal = 1; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/ipsectunnel/auth.inc.php b/html/includes/graphs/ipsectunnel/auth.inc.php index f780ac87a..f5aebe2d3 100644 --- a/html/includes/graphs/ipsectunnel/auth.inc.php +++ b/html/includes/graphs/ipsectunnel/auth.inc.php @@ -1,19 +1,15 @@ diff --git a/html/includes/graphs/ipsectunnel/bits.inc.php b/html/includes/graphs/ipsectunnel/bits.inc.php index cd0fa91fd..ce3e84d36 100644 --- a/html/includes/graphs/ipsectunnel/bits.inc.php +++ b/html/includes/graphs/ipsectunnel/bits.inc.php @@ -1,10 +1,8 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/ipsectunnel/pkts.inc.php b/html/includes/graphs/ipsectunnel/pkts.inc.php index d90d03482..48daf4788 100644 --- a/html/includes/graphs/ipsectunnel/pkts.inc.php +++ b/html/includes/graphs/ipsectunnel/pkts.inc.php @@ -1,19 +1,17 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/location/auth.inc.php b/html/includes/graphs/location/auth.inc.php index 1cb224e28..d3229e413 100644 --- a/html/includes/graphs/location/auth.inc.php +++ b/html/includes/graphs/location/auth.inc.php @@ -1,13 +1,9 @@ diff --git a/html/includes/graphs/location/bits.inc.php b/html/includes/graphs/location/bits.inc.php index 99e51c14c..501b39c74 100644 --- a/html/includes/graphs/location/bits.inc.php +++ b/html/includes/graphs/location/bits.inc.php @@ -1,67 +1,60 @@ +require 'includes/graphs/generic_multi_bits_separated.inc.php'; diff --git a/html/includes/graphs/macaccounting/auth.inc.php b/html/includes/graphs/macaccounting/auth.inc.php index dc1a7e84b..971874116 100644 --- a/html/includes/graphs/macaccounting/auth.inc.php +++ b/html/includes/graphs/macaccounting/auth.inc.php @@ -1,43 +1,45 @@ '; + print_r($acc); + echo ''; + } - if ($debug) { - echo("
    ");
    -    print_r($acc);
    -    echo("
    "); - } + if (is_array($acc)) { + if ($auth || port_permitted($acc['port_id'])) { + if ($debug) { + echo $config['rrd_dir'].'/'.$acc['hostname'].'/'.safename('cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'); + } - if (is_array($acc)) - { + if (is_file($config['rrd_dir'].'/'.$acc['hostname'].'/'.safename('cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'))) { + if ($debug) { + echo 'exists'; + } - if ($auth || port_permitted($acc['port_id'])) - { - if ($debug) { echo($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")); } - - if (is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"))) - { - if ($debug) { echo("exists"); } - $rrd_filename = $config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"); - $port = get_port_by_id($acc['port_id']); - $device = device_by_id_cache($port['device_id']); - $title = generate_device_link($device); - $title .= " :: Port ".generate_port_link($port); - $title .= " :: " . formatMac($acc['mac']); - $auth = TRUE; - } else { - graph_error("file not found"); - } - } else { - graph_error("unauthenticated"); + $rrd_filename = $config['rrd_dir'].'/'.$acc['hostname'].'/'.safename('cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'); + $port = get_port_by_id($acc['port_id']); + $device = device_by_id_cache($port['device_id']); + $title = generate_device_link($device); + $title .= ' :: Port '.generate_port_link($port); + $title .= ' :: '.formatMac($acc['mac']); + $auth = true; + } + else { + graph_error('file not found'); + } + } + else { + graph_error('unauthenticated'); + } + } + else { + graph_error('entry not found'); } - } else { - graph_error("entry not found"); - } -} else { - graph_error("invalid id"); } -?> +else { + graph_error('invalid id'); +} diff --git a/html/includes/graphs/macaccounting/bits.inc.php b/html/includes/graphs/macaccounting/bits.inc.php index e0f0f5e0a..7b650081b 100644 --- a/html/includes/graphs/macaccounting/bits.inc.php +++ b/html/includes/graphs/macaccounting/bits.inc.php @@ -1,8 +1,6 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/macaccounting/pkts.inc.php b/html/includes/graphs/macaccounting/pkts.inc.php index 2a9457642..b0f0eb6c7 100644 --- a/html/includes/graphs/macaccounting/pkts.inc.php +++ b/html/includes/graphs/macaccounting/pkts.inc.php @@ -1,19 +1,17 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/mempool/usage.inc.php b/html/includes/graphs/mempool/usage.inc.php index 6fec6aa98..e3bde5516 100644 --- a/html/includes/graphs/mempool/usage.inc.php +++ b/html/includes/graphs/mempool/usage.inc.php @@ -1,33 +1,33 @@ "500") -{ - $descr_len=13; -} else { - $descr_len=8; - $descr_len += round(($width - 250) / 8); +if ($width > '500') { + $descr_len = 13; +} +else { + $descr_len = 8; + $descr_len += round(($width - 250) / 8); } -if($width > "500") -{ - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)."Total Used Free( Min Max Ave)'"; - $rrd_options .= " COMMENT:'\l'"; -} else { - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)."Total Used Free\l'"; +if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Total Used Free( Min Max Ave)'"; + $rrd_options .= " COMMENT:'\l'"; +} +else { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Total Used Free\l'"; } $descr = rrdtool_escape(short_hrDeviceDescr($mempool['mempool_descr']), $descr_len); -$perc = round($mempool['mempool_perc'], 0); +$perc = round($mempool['mempool_perc'], 0); $background = get_percentage_colours($perc); $rrd_options .= " DEF:$mempool[mempool_id]used=$rrd_filename:used:AVERAGE"; @@ -35,33 +35,31 @@ $rrd_options .= " DEF:$mempool[mempool_id]free=$rrd_filename:free:AVERAGE"; $rrd_options .= " CDEF:$mempool[mempool_id]size=$mempool[mempool_id]used,$mempool[mempool_id]free,+"; $rrd_options .= " CDEF:$mempool[mempool_id]perc=$mempool[mempool_id]used,$mempool[mempool_id]size,/,100,*"; $rrd_options .= " CDEF:$mempool[mempool_id]percx=100,$mempool[mempool_id]perc,-"; -$rrd_options .= " AREA:$mempool[mempool_id]perc#" . $background['right'] . ":"; +$rrd_options .= " AREA:$mempool[mempool_id]perc#".$background['right'].':'; -if($width > "500") -{ - $rrd_options .= " LINE1.25:$mempool[mempool_id]perc#" . $background['left'] . ":'$descr'"; - $rrd_options .= " GPRINT:$mempool[mempool_id]size:LAST:%6.2lf%sB"; - $rrd_options .= " GPRINT:$mempool[mempool_id]used:LAST:%6.2lf%sB"; - $rrd_options .= " GPRINT:$mempool[mempool_id]free:LAST:%6.2lf%sB"; - $rrd_options .= " GPRINT:$mempool[mempool_id]free:MIN:%5.2lf%sB"; - $rrd_options .= " GPRINT:$mempool[mempool_id]free:MAX:%5.2lf%sB"; - $rrd_options .= " GPRINT:$mempool[mempool_id]free:AVERAGE:%5.2lf%sB\\\\n"; - $rrd_options .= " COMMENT:'".substr(str_pad('', $descr_len+12),0,$descr_len+12)." '"; - $rrd_options .= " GPRINT:$mempool[mempool_id]perc:LAST:'%5.2lf%% '"; - $rrd_options .= " GPRINT:$mempool[mempool_id]percx:LAST:'%5.2lf%% '"; - $rrd_options .= " GPRINT:$mempool[mempool_id]perc:MIN:'%5.2lf%% '"; - $rrd_options .= " GPRINT:$mempool[mempool_id]perc:MAX:'%5.2lf%% '"; - $rrd_options .= " GPRINT:$mempool[mempool_id]perc:AVERAGE:%5.2lf%%\\\\n"; -} else { - $rrd_options .= " LINE1.25:$mempool[mempool_id]perc#" . $background['left'] . ":'$descr'"; - $rrd_options .= " GPRINT:$mempool[mempool_id]size:LAST:%6.2lf%sB"; - $rrd_options .= " GPRINT:$mempool[mempool_id]used:LAST:%6.2lf%sB"; - $rrd_options .= " GPRINT:$mempool[mempool_id]free:LAST:%6.2lf%sB"; - $rrd_options .= " COMMENT:'\l'"; - $rrd_options .= " COMMENT:'".substr(str_pad('', $descr_len+12),0,$descr_len+12)." '"; - $rrd_options .= " GPRINT:$mempool[mempool_id]perc:LAST:'%5.2lf%% '"; - $rrd_options .= " GPRINT:$mempool[mempool_id]percx:LAST:'%5.2lf%% '"; - $rrd_options .= " COMMENT:'\l'"; +if ($width > '500') { + $rrd_options .= " LINE1.25:$mempool[mempool_id]perc#".$background['left'].":'$descr'"; + $rrd_options .= " GPRINT:$mempool[mempool_id]size:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:$mempool[mempool_id]used:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:$mempool[mempool_id]free:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:$mempool[mempool_id]free:MIN:%5.2lf%sB"; + $rrd_options .= " GPRINT:$mempool[mempool_id]free:MAX:%5.2lf%sB"; + $rrd_options .= " GPRINT:$mempool[mempool_id]free:AVERAGE:%5.2lf%sB\\\\n"; + $rrd_options .= " COMMENT:'".substr(str_pad('', ($descr_len + 12)), 0, ($descr_len + 12))." '"; + $rrd_options .= " GPRINT:$mempool[mempool_id]perc:LAST:'%5.2lf%% '"; + $rrd_options .= " GPRINT:$mempool[mempool_id]percx:LAST:'%5.2lf%% '"; + $rrd_options .= " GPRINT:$mempool[mempool_id]perc:MIN:'%5.2lf%% '"; + $rrd_options .= " GPRINT:$mempool[mempool_id]perc:MAX:'%5.2lf%% '"; + $rrd_options .= " GPRINT:$mempool[mempool_id]perc:AVERAGE:%5.2lf%%\\\\n"; } - -?> +else { + $rrd_options .= " LINE1.25:$mempool[mempool_id]perc#".$background['left'].":'$descr'"; + $rrd_options .= " GPRINT:$mempool[mempool_id]size:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:$mempool[mempool_id]used:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:$mempool[mempool_id]free:LAST:%6.2lf%sB"; + $rrd_options .= " COMMENT:'\l'"; + $rrd_options .= " COMMENT:'".substr(str_pad('', ($descr_len + 12)), 0, ($descr_len + 12))." '"; + $rrd_options .= " GPRINT:$mempool[mempool_id]perc:LAST:'%5.2lf%% '"; + $rrd_options .= " GPRINT:$mempool[mempool_id]percx:LAST:'%5.2lf%% '"; + $rrd_options .= " COMMENT:'\l'"; +}//end if diff --git a/html/includes/graphs/multiport/auth.inc.php b/html/includes/graphs/multiport/auth.inc.php index 3ffe44929..603c6a945 100644 --- a/html/includes/graphs/multiport/auth.inc.php +++ b/html/includes/graphs/multiport/auth.inc.php @@ -1,21 +1,11 @@ +$title = 'Multi Port :: '; diff --git a/html/includes/graphs/multiport/bits.inc.php b/html/includes/graphs/multiport/bits.inc.php index 907bd06ad..de3206c23 100644 --- a/html/includes/graphs/multiport/bits.inc.php +++ b/html/includes/graphs/multiport/bits.inc.php @@ -2,30 +2,25 @@ $i = 1; -foreach (explode(",", $vars['id']) as $ifid) -{ - if (strstr($ifid, "!")) - { - $rrd_inverted[$i] = TRUE; - $ifid = str_replace("!", "", $ifid); - } +foreach (explode(',', $vars['id']) as $ifid) { + if (strstr($ifid, '!')) { + $rrd_inverted[$i] = true; + $ifid = str_replace('!', '', $ifid); + } - $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid)); - if (is_file($config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . safename($int['ifIndex'] . ".rrd"))) - { - $rrd_filenames[$i] = $config['rrd_dir'] . "/" . $int['hostname'] . "/port-" . safename($int['ifIndex'] . ".rrd"); - $i++; - } + $int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); + if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.safename($int['ifIndex'].'.rrd'))) { + $rrd_filenames[$i] = $config['rrd_dir'].'/'.$int['hostname'].'/port-'.safename($int['ifIndex'].'.rrd'); + $i++; + } } -$ds_in = "INOCTETS"; -$ds_out = "OUTOCTETS"; +$ds_in = 'INOCTETS'; +$ds_out = 'OUTOCTETS'; -$colour_line_in = "006600"; -$colour_line_out = "000099"; -$colour_area_in = "CDEB8B"; -$colour_area_out = "C3D9FF"; +$colour_line_in = '006600'; +$colour_line_out = '000099'; +$colour_area_in = 'CDEB8B'; +$colour_area_out = 'C3D9FF'; -include("includes/graphs/generic_multi_data.inc.php"); - -?> +require 'includes/graphs/generic_multi_data.inc.php'; diff --git a/html/includes/graphs/multiport/bits_duo.inc.php b/html/includes/graphs/multiport/bits_duo.inc.php index 8393ece82..205ca3834 100644 --- a/html/includes/graphs/multiport/bits_duo.inc.php +++ b/html/includes/graphs/multiport/bits_duo.inc.php @@ -1,122 +1,133 @@ +$rrd_options .= ' CDEF:'.$in.'octets='.$in_thing.$pluses; +$rrd_options .= ' CDEF:'.$out.'octets='.$out_thing.$pluses; +$rrd_options .= ' CDEF:'.$in.'octetsb='.$in_thingb.$plusesb; +$rrd_options .= ' CDEF:'.$out.'octetsb='.$out_thingb.$plusesb; +$rrd_options .= ' CDEF:doutoctets=outoctets,-1,*'; +$rrd_options .= ' CDEF:inbits=inoctets,8,*'; +$rrd_options .= ' CDEF:outbits=outoctets,8,*'; +$rrd_options .= ' CDEF:doutbits=doutoctets,8,*'; +$rrd_options .= ' CDEF:doutoctetsb=outoctetsb,-1,*'; +$rrd_options .= ' CDEF:inbitsb=inoctetsb,8,*'; +$rrd_options .= ' CDEF:outbitsb=outoctetsb,8,*'; +$rrd_options .= ' CDEF:doutbitsb=doutoctetsb,8,*'; +$rrd_options .= ' CDEF:inbits_tot=inbits,inbitsb,+'; +$rrd_options .= ' CDEF:outbits_tot=outbits,outbitsb,+'; +$rrd_options .= ' CDEF:doutbits_tot=outbits_tot,-1,*'; +$rrd_options .= ' CDEF:nothing=outbits_tot,outbits_tot,-'; + +if ($legend == 'no') { + $rrd_options .= ' AREA:inbits_tot#cdeb8b:'; + $rrd_options .= ' AREA:inbits#ffcc99:'; + $rrd_options .= ' AREA:doutbits_tot#C3D9FF:'; + $rrd_options .= ' AREA:doutbits#ffcc99:'; + $rrd_options .= ' LINE1:inbits#aa9966:'; + $rrd_options .= ' LINE1:doutbits#aa9966:'; + // $rrd_options .= " LINE1:inbitsb#006600:"; + // $rrd_options .= " LINE1:doutbitsb#000066:"; + $rrd_options .= ' LINE1.25:inbits_tot#006600:'; + $rrd_options .= ' LINE1.25:doutbits_tot#000099:'; + $rrd_options .= ' LINE0.5:nothing#555555:'; +} +else { + $rrd_options .= " COMMENT:bps\ \ \ \ \ \ \ \ \ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Min\ \ \ \ \ \ Max\\\\n"; + $rrd_options .= ' AREA:inbits_tot#cdeb8b:Peering\ In\ '; + $rrd_options .= ' GPRINT:inbitsb:LAST:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbitsb:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbitsb:MIN:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbitsb:MAX:%6.2lf%s\\\\l'; + $rrd_options .= ' AREA:doutbits_tot#C3D9FF:'; + $rrd_options .= ' COMMENT:\ \ \ \ \ \ \ \ \ \ Out'; + $rrd_options .= ' GPRINT:outbitsb:LAST:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbitsb:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbitsb:MIN:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbitsb:MAX:%6.2lf%s\\\\l'; + + $rrd_options .= ' AREA:inbits#ffcc99:Transit\ In\ '; + $rrd_options .= ' GPRINT:inbits:LAST:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbits:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbits:MIN:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbits:MAX:%6.2lf%s\\\\l'; + $rrd_options .= ' AREA:doutbits#ffcc99:'; + $rrd_options .= ' COMMENT:\ \ \ \ \ \ \ \ \ \ Out'; + $rrd_options .= ' GPRINT:outbits:LAST:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbits:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbits:MIN:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbits:MAX:%6.2lf%s\\\\l'; + + $rrd_options .= ' COMMENT:Total\ \ \ \ \ In\ '; + $rrd_options .= ' GPRINT:inbits_tot:LAST:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbits_tot:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbits_tot:MIN:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbits_tot:MAX:%6.2lf%s\\\\l'; + $rrd_options .= ' COMMENT:\ \ \ \ \ \ \ \ \ \ Out'; + $rrd_options .= ' GPRINT:outbits_tot:LAST:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbits_tot:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbits_tot:MIN:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbits_tot:MAX:%6.2lf%s\\\\l'; + + $rrd_options .= ' LINE1:inbits#aa9966:'; + $rrd_options .= ' LINE1:doutbits#aa9966:'; + // $rrd_options .= " LINE1.25:inbitsb#006600:"; + // $rrd_options .= " LINE1.25:doutbitsb#006600:"; + $rrd_options .= ' LINE1.25:inbits_tot#006600:'; + $rrd_options .= ' LINE1.25:doutbits_tot#000099:'; + $rrd_options .= ' LINE0.5:nothing#555555:'; +}//end if + +if ($width <= '300') { + $rrd_options .= ' --font LEGEND:7:'.$config['mono_font'].' --font AXIS:6:'.$config['mono_font'].' --font-render-mode normal'; +} diff --git a/html/includes/graphs/multiport/bits_separate.inc.php b/html/includes/graphs/multiport/bits_separate.inc.php index 3419078ad..d54259d02 100644 --- a/html/includes/graphs/multiport/bits_separate.inc.php +++ b/html/includes/graphs/multiport/bits_separate.inc.php @@ -2,30 +2,26 @@ $i = 0; -foreach (explode(",", $vars['id']) as $ifid) -{ - $port = dbFetchRow("SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid)); - if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) - { - $port = ifLabel($port); - $rrd_list[$i]['filename'] = $config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"); - $rrd_list[$i]['descr'] = $port['hostname'] . " " . $port['ifDescr']; - $rrd_list[$i]['descr_in'] = $port['hostname']; - $rrd_list[$i]['descr_out'] = makeshortif($port['label']); - $i++; - } +foreach (explode(',', $vars['id']) as $ifid) { + $port = dbFetchRow('SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); + if (is_file($config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'))) { + $port = ifLabel($port); + $rrd_list[$i]['filename'] = $config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'); + $rrd_list[$i]['descr'] = $port['hostname'].' '.$port['ifDescr']; + $rrd_list[$i]['descr_in'] = $port['hostname']; + $rrd_list[$i]['descr_out'] = makeshortif($port['label']); + $i++; + } } -$units = 'bps'; -$total_units='B'; -$colours_in='greens'; -$multiplier = "8"; +$units = 'bps'; +$total_units = 'B'; +$colours_in = 'greens'; +$multiplier = '8'; $colours_out = 'blues'; $nototal = 1; -$ds_in = "INOCTETS"; -$ds_out = "OUTOCTETS"; +$ds_in = 'INOCTETS'; +$ds_out = 'OUTOCTETS'; -include("includes/graphs/generic_multi_bits_separated.inc.php"); - -?> +require 'includes/graphs/generic_multi_bits_separated.inc.php'; diff --git a/html/includes/graphs/multiport/bits_trio.inc.php b/html/includes/graphs/multiport/bits_trio.inc.php index 4506c67b2..a1112a677 100644 --- a/html/includes/graphs/multiport/bits_trio.inc.php +++ b/html/includes/graphs/multiport/bits_trio.inc.php @@ -1,172 +1,197 @@ diff --git a/html/includes/graphs/munin/graph.inc.php b/html/includes/graphs/munin/graph.inc.php index 1d6be7dc9..21521c60a 100644 --- a/html/includes/graphs/munin/graph.inc.php +++ b/html/includes/graphs/munin/graph.inc.php @@ -2,63 +2,59 @@ // Attempt to draw a graph out of DSes we've collected from Munin plugins. // Reverse engineering ftw! - $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -if($width > "500") -{ - $descr_len=24; -} else { - $descr_len=14; - $descr_len += round(($width - 230) / 8.2); +if ($width > '500') { + $descr_len = 24; +} +else { + $descr_len = 14; + $descr_len += round(($width - 230) / 8.2); } -if($width > "500") -{ - $rrd_options .= " COMMENT:'".substr(str_pad($mplug['mplug_vlabel'], $descr_len),0,$descr_len)." Current Average Maximum\l'"; - $rrd_options .= " COMMENT:'\l'"; -} else { - $rrd_options .= " COMMENT:'".substr(str_pad($mplug['mplug_vlabel'], $descr_len),0,$descr_len)." Current Average Maximum\l'"; +if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($mplug['mplug_vlabel'], $descr_len), 0, $descr_len)." Current Average Maximum\l'"; + $rrd_options .= " COMMENT:'\l'"; +} +else { + $rrd_options .= " COMMENT:'".substr(str_pad($mplug['mplug_vlabel'], $descr_len), 0, $descr_len)." Current Average Maximum\l'"; } $c_i = 0; -$dbq = dbFetchRows("SELECT * FROM `munin_plugins_ds` WHERE `mplug_id` = ?", array($mplug['mplug_id'])); -foreach ($dbq as $ds) -{ - $ds_filename = $plugfile."_".$ds['ds_name'].".rrd"; - $ds_name = $ds['ds_name']; +$dbq = dbFetchRows('SELECT * FROM `munin_plugins_ds` WHERE `mplug_id` = ?', array($mplug['mplug_id'])); +foreach ($dbq as $ds) { + $ds_filename = $plugfile.'_'.$ds['ds_name'].'.rrd'; + $ds_name = $ds['ds_name']; - $cmd_def .= " DEF:".$ds['ds_name']."=".$ds_filename.":val:AVERAGE"; + $cmd_def .= ' DEF:'.$ds['ds_name'].'='.$ds_filename.':val:AVERAGE'; - if (!empty($ds['ds_cdef'])) - { - $cmd_cdef .= ""; - $ds_name = $ds['ds_name']."_cdef"; - } - - if ($ds['ds_graph'] == "yes") - { - if (empty($ds['colour'])) - { - if (!$config['graph_colours']['mixed'][$c_i]) { $c_i = 0; } - $colour=$config['graph_colours']['mixed'][$c_i]; $c_i++; - } else { - $colour = $ds['colour']; + if (!empty($ds['ds_cdef'])) { + $cmd_cdef .= ''; + $ds_name = $ds['ds_name'].'_cdef'; } - $descr = rrdtool_escape($ds['ds_label'], $descr_len); + if ($ds['ds_graph'] == 'yes') { + if (empty($ds['colour'])) { + if (!$config['graph_colours']['mixed'][$c_i]) { + $c_i = 0; + } - $cmd_graph .= ' '.$ds['ds_draw'].':'.$ds_name.'#'.$colour.':"'.$descr.'"'; - $cmd_graph .= ' GPRINT:'.$ds_name.':LAST:"%6.2lf%s"'; - $cmd_graph .= ' GPRINT:'.$ds_name.':AVERAGE:"%6.2lf%s"'; - $cmd_graph .= ' GPRINT:'.$ds_name.':MAX:"%6.2lf%s\\n"'; + $colour = $config['graph_colours']['mixed'][$c_i]; + $c_i++; + } + else { + $colour = $ds['colour']; + } - } + $descr = rrdtool_escape($ds['ds_label'], $descr_len); -} + $cmd_graph .= ' '.$ds['ds_draw'].':'.$ds_name.'#'.$colour.':"'.$descr.'"'; + $cmd_graph .= ' GPRINT:'.$ds_name.':LAST:"%6.2lf%s"'; + $cmd_graph .= ' GPRINT:'.$ds_name.':AVERAGE:"%6.2lf%s"'; + $cmd_graph .= ' GPRINT:'.$ds_name.':MAX:"%6.2lf%s\\n"'; + } +}//end foreach -$rrd_options .= $cmd_def . $cmd_cdef . $cmd_graph; - -?> +$rrd_options .= $cmd_def.$cmd_cdef.$cmd_graph; diff --git a/html/includes/graphs/netscalervsvr/auth.inc.php b/html/includes/graphs/netscalervsvr/auth.inc.php index 6b90b0632..dbeb11450 100644 --- a/html/includes/graphs/netscalervsvr/auth.inc.php +++ b/html/includes/graphs/netscalervsvr/auth.inc.php @@ -1,20 +1,15 @@ diff --git a/html/includes/graphs/netscalervsvr/bits.inc.php b/html/includes/graphs/netscalervsvr/bits.inc.php index 17707bbb3..58ef562b6 100644 --- a/html/includes/graphs/netscalervsvr/bits.inc.php +++ b/html/includes/graphs/netscalervsvr/bits.inc.php @@ -1,8 +1,6 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/netscalervsvr/conns.inc.php b/html/includes/graphs/netscalervsvr/conns.inc.php index 9f17d874a..38927dc18 100644 --- a/html/includes/graphs/netscalervsvr/conns.inc.php +++ b/html/includes/graphs/netscalervsvr/conns.inc.php @@ -1,22 +1,20 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/netscalervsvr/hitmiss.inc.php b/html/includes/graphs/netscalervsvr/hitmiss.inc.php index 31e557dcb..cc4e63395 100644 --- a/html/includes/graphs/netscalervsvr/hitmiss.inc.php +++ b/html/includes/graphs/netscalervsvr/hitmiss.inc.php @@ -1,23 +1,23 @@ +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/netscalervsvr/pkts.inc.php b/html/includes/graphs/netscalervsvr/pkts.inc.php index 988e0c2f0..dd5ccec32 100644 --- a/html/includes/graphs/netscalervsvr/pkts.inc.php +++ b/html/includes/graphs/netscalervsvr/pkts.inc.php @@ -1,19 +1,17 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/netscalervsvr/reqs.inc.php b/html/includes/graphs/netscalervsvr/reqs.inc.php index d39c6f9cb..758536538 100644 --- a/html/includes/graphs/netscalervsvr/reqs.inc.php +++ b/html/includes/graphs/netscalervsvr/reqs.inc.php @@ -1,22 +1,20 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/old_generic_simplex.inc.php b/html/includes/graphs/old_generic_simplex.inc.php index bbf6f9e02..24a93147c 100644 --- a/html/includes/graphs/old_generic_simplex.inc.php +++ b/html/includes/graphs/old_generic_simplex.inc.php @@ -2,97 +2,90 @@ // Draw generic bits graph // args: ds_in, ds_out, rrd_filename, bg, legend, from, to, width, height, inverse, percentile +require 'includes/graphs/common.inc.php'; -include("includes/graphs/common.inc.php"); +$unit_text = str_pad(truncate($unit_text, 18, ''), 18); +$line_text = str_pad(truncate($line_text, 12, ''), 12); -$unit_text = str_pad(truncate($unit_text,18,''),18); -$line_text = str_pad(truncate($line_text,12,''),12); - -if ($multiplier) -{ - if (empty($multiplier_action)) { - $multiplier_action = "*"; - } - $rrd_options .= " DEF:".$ds."_o=".$rrd_filename.":".$ds.":AVERAGE"; - $rrd_options .= " CDEF:".$ds."=".$ds."_o,$multiplier,$multiplier_action"; -} else { - $rrd_options .= " DEF:".$ds."=".$rrd_filename.":".$ds.":AVERAGE"; -} -if ($print_total) -{ - $rrd_options .= " VDEF:".$ds."_total=ds,TOTAL"; -} - -if ($percentile) -{ - $rrd_options .= " VDEF:".$ds."_percentile=".$ds.",".$percentile.",PERCENT"; -} - -if($_GET['previous'] == "yes") -{ - if ($multiplier) - { +if ($multiplier) { if (empty($multiplier_action)) { - $multiplier_action = "*"; + $multiplier_action = '*'; } - $rrd_options .= " DEF:".$ds."_oX=".$rrd_filename.":".$ds.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " SHIFT:".$ds."_oX:$period"; - $rrd_options .= " CDEF:".$ds."X=".$ds."_oX,$multiplier,*"; - } else { - $rrd_options .= " DEF:".$ds."X=".$rrd_filename.":".$ds.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " SHIFT:".$ds."X:$period"; - } - if ($print_total) - { - $rrd_options .= " VDEF:".$ds."_totalX=ds,TOTAL"; - } - if ($percentile) - { - $rrd_options .= " VDEF:".$ds."_percentileX=".$ds.",".$percentile.",PERCENT"; - } -# if ($graph_max) -# { -# $rrd_options .= " AREA:".$ds."_max#".$colour_area_max.":"; -# } + + $rrd_options .= ' DEF:'.$ds.'_o='.$rrd_filename.':'.$ds.':AVERAGE'; + $rrd_options .= ' CDEF:'.$ds.'='.$ds."_o,$multiplier,$multiplier_action"; +} +else { + $rrd_options .= ' DEF:'.$ds.'='.$rrd_filename.':'.$ds.':AVERAGE'; } -$rrd_options .= " AREA:".$ds."#".$colour_area.":"; +if ($print_total) { + $rrd_options .= ' VDEF:'.$ds.'_total=ds,TOTAL'; +} -$rrd_options .= " COMMENT:'".$unit_text."Now Ave Max"; +if ($percentile) { + $rrd_options .= ' VDEF:'.$ds.'_percentile='.$ds.','.$percentile.',PERCENT'; +} -if ($percentile) -{ - $rrd_options .= " ".$percentile."th %"; +if ($_GET['previous'] == 'yes') { + if ($multiplier) { + if (empty($multiplier_action)) { + $multiplier_action = '*'; + } + + $rrd_options .= ' DEF:'.$ds.'_oX='.$rrd_filename.':'.$ds.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' SHIFT:'.$ds."_oX:$period"; + $rrd_options .= ' CDEF:'.$ds.'X='.$ds."_oX,$multiplier,*"; + } + else { + $rrd_options .= ' DEF:'.$ds.'X='.$rrd_filename.':'.$ds.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' SHIFT:'.$ds."X:$period"; + } + + if ($print_total) { + $rrd_options .= ' VDEF:'.$ds.'_totalX=ds,TOTAL'; + } + + if ($percentile) { + $rrd_options .= ' VDEF:'.$ds.'_percentileX='.$ds.','.$percentile.',PERCENT'; + } + + // if ($graph_max) + // { + // $rrd_options .= " AREA:".$ds."_max#".$colour_area_max.":"; + // } +}//end if + +$rrd_options .= ' AREA:'.$ds.'#'.$colour_area.':'; + +$rrd_options .= " COMMENT:'".$unit_text.'Now Ave Max'; + +if ($percentile) { + $rrd_options .= ' '.$percentile.'th %'; } $rrd_options .= "\\n'"; -$rrd_options .= " LINE1.25:".$ds."#".$colour_line.":'".$line_text."'"; -$rrd_options .= " GPRINT:".$ds.":LAST:%6.2lf%s"; -$rrd_options .= " GPRINT:".$ds.":AVERAGE:%6.2lf%s"; -$rrd_options .= " GPRINT:".$ds.":MAX:%6.2lf%s"; +$rrd_options .= ' LINE1.25:'.$ds.'#'.$colour_line.":'".$line_text."'"; +$rrd_options .= ' GPRINT:'.$ds.':LAST:%6.2lf%s'; +$rrd_options .= ' GPRINT:'.$ds.':AVERAGE:%6.2lf%s'; +$rrd_options .= ' GPRINT:'.$ds.':MAX:%6.2lf%s'; -if ($percentile) -{ - $rrd_options .= " GPRINT:".$ds."_percentile:%6.2lf%s"; +if ($percentile) { + $rrd_options .= ' GPRINT:'.$ds.'_percentile:%6.2lf%s'; } $rrd_options .= "\\\\n"; $rrd_options .= " COMMENT:\\\\n"; -if ($print_total) -{ - $rrd_options .= " GPRINT:".$ds."_tot:Total\ %6.2lf%s\)\\\\l"; +if ($print_total) { + $rrd_options .= ' GPRINT:'.$ds.'_tot:Total\ %6.2lf%s\)\\\\l'; } -if ($percentile) -{ - $rrd_options .= " LINE1:".$ds."_percentile#aa0000"; +if ($percentile) { + $rrd_options .= ' LINE1:'.$ds.'_percentile#aa0000'; } -if($_GET['previous'] == "yes") -{ - $rrd_options .= " LINE1.25:".$ds."X#666666:'Prev \\\\n'"; - $rrd_options .= " AREA:".$ds."X#99999966:"; +if ($_GET['previous'] == 'yes') { + $rrd_options .= ' LINE1.25:'.$ds."X#666666:'Prev \\\\n'"; + $rrd_options .= ' AREA:'.$ds.'X#99999966:'; } - -?> diff --git a/html/includes/graphs/port/adsl_attainable.inc.php b/html/includes/graphs/port/adsl_attainable.inc.php index 8ca0186f2..ad84314a0 100644 --- a/html/includes/graphs/port/adsl_attainable.inc.php +++ b/html/includes/graphs/port/adsl_attainable.inc.php @@ -1,28 +1,25 @@ \ No newline at end of file diff --git a/html/includes/graphs/port/adsl_attenuation.inc.php b/html/includes/graphs/port/adsl_attenuation.inc.php index 1c30b4a48..74cb1e2d3 100644 --- a/html/includes/graphs/port/adsl_attenuation.inc.php +++ b/html/includes/graphs/port/adsl_attenuation.inc.php @@ -1,28 +1,25 @@ \ No newline at end of file diff --git a/html/includes/graphs/port/adsl_power.inc.php b/html/includes/graphs/port/adsl_power.inc.php index eb5fd36dc..5b7d8957a 100644 --- a/html/includes/graphs/port/adsl_power.inc.php +++ b/html/includes/graphs/port/adsl_power.inc.php @@ -1,28 +1,25 @@ \ No newline at end of file diff --git a/html/includes/graphs/port/adsl_snr.inc.php b/html/includes/graphs/port/adsl_snr.inc.php index adf8f325e..9c369cda6 100644 --- a/html/includes/graphs/port/adsl_snr.inc.php +++ b/html/includes/graphs/port/adsl_snr.inc.php @@ -1,28 +1,25 @@ diff --git a/html/includes/graphs/port/adsl_speed.inc.php b/html/includes/graphs/port/adsl_speed.inc.php index da0c4b20b..25a080980 100644 --- a/html/includes/graphs/port/adsl_speed.inc.php +++ b/html/includes/graphs/port/adsl_speed.inc.php @@ -1,28 +1,25 @@ \ No newline at end of file diff --git a/html/includes/graphs/port/bits.inc.php b/html/includes/graphs/port/bits.inc.php index 8101cb933..c24f376dd 100644 --- a/html/includes/graphs/port/bits.inc.php +++ b/html/includes/graphs/port/bits.inc.php @@ -1,8 +1,6 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/port/errors.inc.php b/html/includes/graphs/port/errors.inc.php index 8f26b14b4..bb9e8b0a2 100644 --- a/html/includes/graphs/port/errors.inc.php +++ b/html/includes/graphs/port/errors.inc.php @@ -1,30 +1,28 @@ \ No newline at end of file +require 'includes/graphs/generic_multi_seperated.inc.php'; diff --git a/html/includes/graphs/port/etherlike.inc.php b/html/includes/graphs/port/etherlike.inc.php index c021b1e73..b997b3050 100644 --- a/html/includes/graphs/port/etherlike.inc.php +++ b/html/includes/graphs/port/etherlike.inc.php @@ -1,34 +1,39 @@ +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/port/mac_acc_total.inc.php b/html/includes/graphs/port/mac_acc_total.inc.php index c00d5ade7..eb9f0622a 100644 --- a/html/includes/graphs/port/mac_acc_total.inc.php +++ b/html/includes/graphs/port/mac_acc_total.inc.php @@ -1,108 +1,134 @@ +$rrd_options .= ' HRULE:0#999999'; diff --git a/html/includes/graphs/port/nupkts.inc.php b/html/includes/graphs/port/nupkts.inc.php index 1614b5f5e..e26f5e449 100644 --- a/html/includes/graphs/port/nupkts.inc.php +++ b/html/includes/graphs/port/nupkts.inc.php @@ -1,63 +1,58 @@ + include 'includes/graphs/generic_duplex.inc.php'; +}//end if diff --git a/html/includes/graphs/port/pagp_bits.inc.php b/html/includes/graphs/port/pagp_bits.inc.php index 43e715ad6..6c5663b08 100644 --- a/html/includes/graphs/port/pagp_bits.inc.php +++ b/html/includes/graphs/port/pagp_bits.inc.php @@ -1,28 +1,23 @@ +require 'includes/graphs/generic_multi_bits_separated.inc.php'; diff --git a/html/includes/graphs/port/upkts.inc.php b/html/includes/graphs/port/upkts.inc.php index e8cf22bdc..b0578c323 100644 --- a/html/includes/graphs/port/upkts.inc.php +++ b/html/includes/graphs/port/upkts.inc.php @@ -1,19 +1,17 @@ \ No newline at end of file +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/graphs/rserver/auth.inc.php b/html/includes/graphs/rserver/auth.inc.php index 6f0a1e274..d179370bc 100644 --- a/html/includes/graphs/rserver/auth.inc.php +++ b/html/includes/graphs/rserver/auth.inc.php @@ -1,20 +1,16 @@ diff --git a/html/includes/graphs/screenos_sessions.inc.php b/html/includes/graphs/screenos_sessions.inc.php index e33da7f34..24117d9d0 100644 --- a/html/includes/graphs/screenos_sessions.inc.php +++ b/html/includes/graphs/screenos_sessions.inc.php @@ -1,30 +1,29 @@ \ No newline at end of file +require 'generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/sensor/auth.inc.php b/html/includes/graphs/sensor/auth.inc.php index d24d1d229..c86920ecf 100644 --- a/html/includes/graphs/sensor/auth.inc.php +++ b/html/includes/graphs/sensor/auth.inc.php @@ -1,21 +1,17 @@ diff --git a/html/includes/graphs/sensor/current.inc.php b/html/includes/graphs/sensor/current.inc.php index 381d1e270..b496c002a 100644 --- a/html/includes/graphs/sensor/current.inc.php +++ b/html/includes/graphs/sensor/current.inc.php @@ -1,20 +1,23 @@ +if (is_numeric($sensor['sensor_limit_low'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; +} diff --git a/html/includes/graphs/sensor/dbm.inc.php b/html/includes/graphs/sensor/dbm.inc.php index a4ea9191f..5880ddafc 100644 --- a/html/includes/graphs/sensor/dbm.inc.php +++ b/html/includes/graphs/sensor/dbm.inc.php @@ -1,20 +1,23 @@ +if (is_numeric($sensor['sensor_limit_low'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; +} diff --git a/html/includes/graphs/sensor/fanspeed.inc.php b/html/includes/graphs/sensor/fanspeed.inc.php index 82ec16cc9..c1fad583c 100644 --- a/html/includes/graphs/sensor/fanspeed.inc.php +++ b/html/includes/graphs/sensor/fanspeed.inc.php @@ -1,17 +1,20 @@ +if (is_numeric($sensor['sensor_limit_low'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; +} diff --git a/html/includes/graphs/sensor/frequency.inc.php b/html/includes/graphs/sensor/frequency.inc.php index 27629e65c..16dfe8ac5 100644 --- a/html/includes/graphs/sensor/frequency.inc.php +++ b/html/includes/graphs/sensor/frequency.inc.php @@ -1,19 +1,22 @@ +if (is_numeric($sensor['sensor_limit_low'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; +} diff --git a/html/includes/graphs/sensor/humidity.inc.php b/html/includes/graphs/sensor/humidity.inc.php index 153d435dd..37ee96d63 100644 --- a/html/includes/graphs/sensor/humidity.inc.php +++ b/html/includes/graphs/sensor/humidity.inc.php @@ -1,29 +1,32 @@ +if (is_numeric($sensor['sensor_limit_low'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; +} diff --git a/html/includes/graphs/sensor/power.inc.php b/html/includes/graphs/sensor/power.inc.php index 1731a3d09..c279bb80a 100644 --- a/html/includes/graphs/sensor/power.inc.php +++ b/html/includes/graphs/sensor/power.inc.php @@ -1,25 +1,28 @@ +if (is_numeric($sensor['sensor_limit_low'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; +} diff --git a/html/includes/graphs/sensor/temperature.inc.php b/html/includes/graphs/sensor/temperature.inc.php index 39b0381a5..c8ffb312d 100644 --- a/html/includes/graphs/sensor/temperature.inc.php +++ b/html/includes/graphs/sensor/temperature.inc.php @@ -1,27 +1,30 @@ +if (is_numeric($sensor['sensor_limit_low'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; +} diff --git a/html/includes/graphs/sensor/voltage.inc.php b/html/includes/graphs/sensor/voltage.inc.php index ca3ea023d..634c7a54e 100644 --- a/html/includes/graphs/sensor/voltage.inc.php +++ b/html/includes/graphs/sensor/voltage.inc.php @@ -1,25 +1,28 @@ +if (is_numeric($sensor['sensor_limit_low'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; +} diff --git a/html/includes/graphs/service/auth.inc.php b/html/includes/graphs/service/auth.inc.php index 0d66f6946..eb30d023a 100644 --- a/html/includes/graphs/service/auth.inc.php +++ b/html/includes/graphs/service/auth.inc.php @@ -1,20 +1,16 @@ diff --git a/html/includes/graphs/smokeping/auth.inc.php b/html/includes/graphs/smokeping/auth.inc.php index 55e9f80ee..a82cfd71d 100644 --- a/html/includes/graphs/smokeping/auth.inc.php +++ b/html/includes/graphs/smokeping/auth.inc.php @@ -1,11 +1,8 @@ diff --git a/html/includes/graphs/smokeping/in.inc.php b/html/includes/graphs/smokeping/in.inc.php index 5488422ad..ecd63a2e3 100644 --- a/html/includes/graphs/smokeping/in.inc.php +++ b/html/includes/graphs/smokeping/in.inc.php @@ -1,94 +1,89 @@ Human translation:> +$scale_min = 0; +$scale_rigid = true; -$scale_min = 0; -$scale_rigid = TRUE; +require 'includes/graphs/common.inc.php'; +require 'smokeping_common.inc.php'; -include("includes/graphs/common.inc.php"); -include("smokeping_common.inc.php"); +$i = 0; +$pings = 20; +$iter = 0; +$colourset = 'mixed'; -$i = 0; -$pings = 20; -$iter = 0; -$colourset = "mixed"; - -if($width > "500") -{ - $descr_len = 18; -} else { - $descr_len = 12 + round(($width - 275) / 8); +if ($width > '500') { + $descr_len = 18; +} +else { + $descr_len = (12 + round(($width - 275) / 8)); } -if($width > "500") -{ - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev \l'"; -} else { - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev \l'"; +if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." RTT Loss SDev RTT\:SDev \l'"; +} +else { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." RTT Loss SDev RTT\:SDev \l'"; } -if($src['hostname'] == $config['own_hostname']) -{ - $filename = $config['smokeping']['dir'] . $device['hostname'].'.rrd'; - if (!file_exists($filename)) - { - // Try with dots in hostname replaced by underscores - $filename = $config['smokeping']['dir'] . str_replace(".", "_", $device['hostname']).'.rrd'; - } -} else { - $filename = $config['smokeping']['dir'] . $device['hostname'] .'~'.$src['hostname'].'.rrd'; - if (!file_exists($filename)) - { - // Try with dots in hostname replaced by underscores - $filename = $config['smokeping']['dir'] . str_replace(".", "-", $device['hostname']) .'~'.$src['hostname'].'.rrd'; - } +if ($src['hostname'] == $config['own_hostname']) { + $filename = $config['smokeping']['dir'].$device['hostname'].'.rrd'; + if (!file_exists($filename)) { + // Try with dots in hostname replaced by underscores + $filename = $config['smokeping']['dir'].str_replace('.', '_', $device['hostname']).'.rrd'; + } +} +else { + $filename = $config['smokeping']['dir'].$device['hostname'].'~'.$src['hostname'].'.rrd'; + if (!file_exists($filename)) { + // Try with dots in hostname replaced by underscores + $filename = $config['smokeping']['dir'].str_replace('.', '-', $device['hostname']).'~'.$src['hostname'].'.rrd'; + } +} + +if (!isset($config['graph_colours'][$colourset][$iter])) { + $iter = 0; } - if (!isset($config['graph_colours'][$colourset][$iter])) { $iter = 0; } $colour = $config['graph_colours'][$colourset][$iter]; $iter++; - $descr = rrdtool_escape($source,$descr_len); + $descr = rrdtool_escape($source, $descr_len); - $rrd_options .= " DEF:median$i=".$filename.":median:AVERAGE "; - $rrd_options .= " DEF:loss$i=".$filename.":loss:AVERAGE"; + $rrd_options .= " DEF:median$i=".$filename.':median:AVERAGE '; + $rrd_options .= " DEF:loss$i=".$filename.':loss:AVERAGE'; $rrd_options .= " CDEF:ploss$i=loss$i,$pings,/,100,*"; $rrd_options .= " CDEF:dm$i=median$i"; -# $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT"; - +// $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT"; // start emulate Smokeping::calc_stddev - foreach (range(1, $pings) as $p) - { - $rrd_options .= " DEF:pin".$i."p".$p."=".$filename.":ping".$p.":AVERAGE"; - $rrd_options .= " CDEF:p".$i."p".$p."=pin".$i."p".$p.",UN,0,pin".$i."p".$p.",IF"; - } +foreach (range(1, $pings) as $p) { + $rrd_options .= ' DEF:pin'.$i.'p'.$p.'='.$filename.':ping'.$p.':AVERAGE'; + $rrd_options .= ' CDEF:p'.$i.'p'.$p.'=pin'.$i.'p'.$p.',UN,0,pin'.$i.'p'.$p.',IF'; +} unset($pings_options, $m_options, $sdev_options); - foreach (range(2, $pings) as $p) - { - $pings_options .= ",p".$i."p".$p.",UN,+"; - $m_options .= ",p".$i."p".$p.",+"; - $sdev_options .= ",p".$i."p".$p.",m".$i.",-,DUP,*,+"; - } +foreach (range(2, $pings) as $p) { + $pings_options .= ',p'.$i.'p'.$p.',UN,+'; + $m_options .= ',p'.$i.'p'.$p.',+'; + $sdev_options .= ',p'.$i.'p'.$p.',m'.$i.',-,DUP,*,+'; +} - $rrd_options .= " CDEF:pings".$i."=".$pings .",p".$i."p1,UN". $pings_options . ",-"; - $rrd_options .= " CDEF:m".$i."=p".$i."p1".$m_options.",pings".$i.",/"; - $rrd_options .= " CDEF:sdev".$i."=p".$i."p1,m".$i.",-,DUP,*".$sdev_options.",pings".$i.",/,SQRT"; + $rrd_options .= ' CDEF:pings'.$i.'='.$pings.',p'.$i.'p1,UN'.$pings_options.',-'; + $rrd_options .= ' CDEF:m'.$i.'=p'.$i.'p1'.$m_options.',pings'.$i.',/'; + $rrd_options .= ' CDEF:sdev'.$i.'=p'.$i.'p1,m'.$i.',-,DUP,*'.$sdev_options.',pings'.$i.',/,SQRT'; // end emulate Smokeping::calc_stddev - $rrd_options .= " CDEF:dmlow$i=dm$i,sdev$i,2,/,-"; $rrd_options .= " CDEF:s2d$i=sdev$i"; $rrd_options .= " AREA:dmlow$i"; - $rrd_options .= " AREA:s2d$i#".$colour."30::STACK"; + $rrd_options .= " AREA:s2d$i#".$colour.'30::STACK'; $rrd_options .= " LINE1:dm$i#".$colour.":'$descr'"; -# $rrd_options .= " LINE1:sdev$i#000000:$descr"; - +// $rrd_options .= " LINE1:sdev$i#000000:$descr"; $rrd_options .= " VDEF:avmed$i=median$i,AVERAGE"; $rrd_options .= " VDEF:avsd$i=sdev$i,AVERAGE"; $rrd_options .= " CDEF:msr$i=median$i,POP,avmed$i,avsd$i,/"; @@ -101,5 +96,3 @@ if($src['hostname'] == $config['own_hostname']) $rrd_options .= " GPRINT:avmsr$i:'%5.1lf%s\\l'"; $i++; - -?> diff --git a/html/includes/graphs/smokeping/out.inc.php b/html/includes/graphs/smokeping/out.inc.php index 6ebfdc9e0..714aa9064 100644 --- a/html/includes/graphs/smokeping/out.inc.php +++ b/html/includes/graphs/smokeping/out.inc.php @@ -1,94 +1,89 @@ Human translation:> +$scale_min = 0; +$scale_rigid = true; -$scale_min = 0; -$scale_rigid = TRUE; +require 'includes/graphs/common.inc.php'; +require 'smokeping_common.inc.php'; -include("includes/graphs/common.inc.php"); -include("smokeping_common.inc.php"); +$i = 0; +$pings = 20; +$iter = 0; +$colourset = 'mixed'; -$i = 0; -$pings = 20; -$iter = 0; -$colourset = "mixed"; - -if($width > "500") -{ - $descr_len = 18; -} else { - $descr_len = 12 + round(($width - 275) / 8); +if ($width > '500') { + $descr_len = 18; +} +else { + $descr_len = (12 + round(($width - 275) / 8)); } -if($width > "500") -{ - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev \l'"; -} else { - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev \l'"; +if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." RTT Loss SDev RTT\:SDev \l'"; +} +else { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." RTT Loss SDev RTT\:SDev \l'"; } -if($device['hostname'] == $config['own_hostname']) -{ - $filename = $config['smokeping']['dir'] . $dest['hostname'].'.rrd'; - if (!file_exists($filename)) - { - // Try with dots in hostname replaced by underscores - $filename = $config['smokeping']['dir'] . str_replace(".", "_", $dest['hostname']).'.rrd'; - } -} else { - $filename = $config['smokeping']['dir'] . $dest['hostname'] .'~'.$device['hostname'].'.rrd'; - if (!file_exists($filename)) - { - // Try with dots in hostname replaced by underscores - $filename = $config['smokeping']['dir'] . str_replace(".", "_", $dest['hostname']) .'~'.$device['hostname'].'.rrd'; - } +if ($device['hostname'] == $config['own_hostname']) { + $filename = $config['smokeping']['dir'].$dest['hostname'].'.rrd'; + if (!file_exists($filename)) { + // Try with dots in hostname replaced by underscores + $filename = $config['smokeping']['dir'].str_replace('.', '_', $dest['hostname']).'.rrd'; + } +} +else { + $filename = $config['smokeping']['dir'].$dest['hostname'].'~'.$device['hostname'].'.rrd'; + if (!file_exists($filename)) { + // Try with dots in hostname replaced by underscores + $filename = $config['smokeping']['dir'].str_replace('.', '_', $dest['hostname']).'~'.$device['hostname'].'.rrd'; + } +} + +if (!isset($config['graph_colours'][$colourset][$iter])) { + $iter = 0; } - if (!isset($config['graph_colours'][$colourset][$iter])) { $iter = 0; } $colour = $config['graph_colours'][$colourset][$iter]; $iter++; - $descr = rrdtool_escape($source,$descr_len); + $descr = rrdtool_escape($source, $descr_len); - $rrd_options .= " DEF:median$i=".$filename.":median:AVERAGE "; - $rrd_options .= " DEF:loss$i=".$filename.":loss:AVERAGE"; + $rrd_options .= " DEF:median$i=".$filename.':median:AVERAGE '; + $rrd_options .= " DEF:loss$i=".$filename.':loss:AVERAGE'; $rrd_options .= " CDEF:ploss$i=loss$i,$pings,/,100,*"; $rrd_options .= " CDEF:dm$i=median$i"; -# $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT"; - +// $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT"; // start emulate Smokeping::calc_stddev - foreach (range(1, $pings) as $p) - { - $rrd_options .= " DEF:pin".$i."p".$p."=".$filename.":ping".$p.":AVERAGE"; - $rrd_options .= " CDEF:p".$i."p".$p."=pin".$i."p".$p.",UN,0,pin".$i."p".$p.",IF"; - } +foreach (range(1, $pings) as $p) { + $rrd_options .= ' DEF:pin'.$i.'p'.$p.'='.$filename.':ping'.$p.':AVERAGE'; + $rrd_options .= ' CDEF:p'.$i.'p'.$p.'=pin'.$i.'p'.$p.',UN,0,pin'.$i.'p'.$p.',IF'; +} unset($pings_options, $m_options, $sdev_options); - foreach (range(2, $pings) as $p) - { - $pings_options .= ",p".$i."p".$p.",UN,+"; - $m_options .= ",p".$i."p".$p.",+"; - $sdev_options .= ",p".$i."p".$p.",m".$i.",-,DUP,*,+"; - } +foreach (range(2, $pings) as $p) { + $pings_options .= ',p'.$i.'p'.$p.',UN,+'; + $m_options .= ',p'.$i.'p'.$p.',+'; + $sdev_options .= ',p'.$i.'p'.$p.',m'.$i.',-,DUP,*,+'; +} - $rrd_options .= " CDEF:pings".$i."=".$pings .",p".$i."p1,UN". $pings_options . ",-"; - $rrd_options .= " CDEF:m".$i."=p".$i."p1".$m_options.",pings".$i.",/"; - $rrd_options .= " CDEF:sdev".$i."=p".$i."p1,m".$i.",-,DUP,*".$sdev_options.",pings".$i.",/,SQRT"; + $rrd_options .= ' CDEF:pings'.$i.'='.$pings.',p'.$i.'p1,UN'.$pings_options.',-'; + $rrd_options .= ' CDEF:m'.$i.'=p'.$i.'p1'.$m_options.',pings'.$i.',/'; + $rrd_options .= ' CDEF:sdev'.$i.'=p'.$i.'p1,m'.$i.',-,DUP,*'.$sdev_options.',pings'.$i.',/,SQRT'; // end emulate Smokeping::calc_stddev - $rrd_options .= " CDEF:dmlow$i=dm$i,sdev$i,2,/,-"; $rrd_options .= " CDEF:s2d$i=sdev$i"; $rrd_options .= " AREA:dmlow$i"; - $rrd_options .= " AREA:s2d$i#".$colour."30::STACK"; + $rrd_options .= " AREA:s2d$i#".$colour.'30::STACK'; $rrd_options .= " LINE1:dm$i#".$colour.":'$descr'"; -# $rrd_options .= " LINE1:sdev$i#000000:$descr"; - +// $rrd_options .= " LINE1:sdev$i#000000:$descr"; $rrd_options .= " VDEF:avmed$i=median$i,AVERAGE"; $rrd_options .= " VDEF:avsd$i=sdev$i,AVERAGE"; $rrd_options .= " CDEF:msr$i=median$i,POP,avmed$i,avsd$i,/"; @@ -101,5 +96,3 @@ if($device['hostname'] == $config['own_hostname']) $rrd_options .= " GPRINT:avmsr$i:'%5.1lf%s\\l'"; $i++; - -?> diff --git a/html/includes/graphs/storage/usage.inc.php b/html/includes/graphs/storage/usage.inc.php index c42d339e6..60b01e418 100644 --- a/html/includes/graphs/storage/usage.inc.php +++ b/html/includes/graphs/storage/usage.inc.php @@ -1,20 +1,20 @@ diff --git a/html/includes/graphs/vserver/auth.inc.php b/html/includes/graphs/vserver/auth.inc.php index 3f400c1fd..2d16279db 100644 --- a/html/includes/graphs/vserver/auth.inc.php +++ b/html/includes/graphs/vserver/auth.inc.php @@ -1,20 +1,16 @@ diff --git a/html/includes/graphs/vserver/bits.inc.php b/html/includes/graphs/vserver/bits.inc.php index 28d4ac4c9..edafe2186 100644 --- a/html/includes/graphs/vserver/bits.inc.php +++ b/html/includes/graphs/vserver/bits.inc.php @@ -1,8 +1,6 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/vserver/pkts.inc.php b/html/includes/graphs/vserver/pkts.inc.php index be538a926..8590633ac 100644 --- a/html/includes/graphs/vserver/pkts.inc.php +++ b/html/includes/graphs/vserver/pkts.inc.php @@ -1,19 +1,17 @@ +require 'includes/graphs/generic_duplex.inc.php'; diff --git a/html/includes/port-edit.inc.php b/html/includes/port-edit.inc.php index a0348c785..abfba6053 100644 --- a/html/includes/port-edit.inc.php +++ b/html/includes/port-edit.inc.php @@ -1,78 +1,65 @@ $val) -{ - if (strncmp($key,"oldign_",7) == 0) - { - # Interface identifier passed as part of the field name +foreach ($_POST as $key => $val) { + if (strncmp($key, 'oldign_', 7) == 0) { + // Interface identifier passed as part of the field name + $port_id = intval(substr($key, 7)); - $port_id = intval(substr($key,7)); + $oldign = intval($val) ? 1 : 0; + $newign = $_POST['ignore_'.$port_id] ? 1 : 0; - $oldign = intval($val) ? 1 : 0; - $newign = $_POST['ignore_'.$port_id] ? 1 : 0; + // As checkboxes are not posted when unset - we effectively need to do a diff to work + // out a set->unset case. + if ($oldign == $newign) { + continue; + } - # As checkboxes are not posted when unset - we effectively need to do a diff to work - # out a set->unset case. + $n = dbUpdate(array('ignore' => $newign), 'ports', '`device_id` = ? AND `port_id` = ?', array($device_id, $port_id)); - if ($oldign == $newign) - { - continue; + if ($n < 0) { + $rows_updated = -1; + break; + } + + $rows_updated += $n; } + else if (strncmp($key, 'olddis_', 7) == 0) { + // Interface identifier passed as part of the field name + $port_id = intval(substr($key, 7)); - $n = dbUpdate(array('ignore' => $newign), 'ports', '`device_id` = ? AND `port_id` = ?', array($device_id, $port_id)); + $olddis = intval($val) ? 1 : 0; + $newdis = $_POST['disabled_'.$port_id] ? 1 : 0; - if ($n <0) - { - $rows_updated = -1; - break; - } + // As checkboxes are not posted when unset - we effectively need to do a diff to work + // out a set->unset case. + if ($olddis == $newdis) { + continue; + } - $rows_updated += $n; - } - elseif (strncmp($key,"olddis_",7) == 0) - { - # Interface identifier passed as part of the field name + $n = dbUpdate(array('disabled' => $newdis), 'ports', '`device_id` = ? AND `port_id` = ?', array($device_id, $port_id)); - $port_id = intval(substr($key,7)); + if ($n < 0) { + $rows_updated = -1; + break; + } - $olddis = intval($val) ? 1 : 0; - $newdis = $_POST['disabled_'.$port_id] ? 1 : 0; + $rows_updated += $n; + }//end if +}//end foreach - # As checkboxes are not posted when unset - we effectively need to do a diff to work - # out a set->unset case. - - if ($olddis == $newdis) - { - continue; - } - - $n = dbUpdate(array('disabled' => $newdis), 'ports', '`device_id` = ? AND `port_id` = ?', array($device_id, $port_id)); - - if ($n <0) - { - $rows_updated = -1; - break; - } - - $rows_updated += $n; - } +if ($rows_updated > 0) { + $update_message = $rows_updated.' Device record updated.'; + $updated = 1; } - -if ($rows_updated > 0) -{ - $update_message = $rows_updated . " 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; +else if ($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/includes/print-accesspoint-graphs.inc.php b/html/includes/print-accesspoint-graphs.inc.php index 28960cfd5..cb0498d09 100644 --- a/html/includes/print-accesspoint-graphs.inc.php +++ b/html/includes/print-accesspoint-graphs.inc.php @@ -2,12 +2,10 @@ global $config; -$graph_array['height'] = "100"; -$graph_array['width'] = "215"; +$graph_array['height'] = '100'; +$graph_array['width'] = '215'; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $ap['accesspoint_id']; $graph_array['type'] = $graph_type; -include("includes/print-graphrow.inc.php"); - -?> +require 'includes/print-graphrow.inc.php'; diff --git a/html/includes/print-accesspoint.inc.php b/html/includes/print-accesspoint.inc.php index e41e6dd69..a3a1dcbe6 100644 --- a/html/includes/print-accesspoint.inc.php +++ b/html/includes/print-accesspoint.inc.php @@ -1,92 +1,92 @@ - "); -echo(" " . generate_ap_link($ap, " $text
    ")); -echo(""); -echo("$break".$ap['mac_addr']."
    ".$ap['type']. " - channel ".$ap['channel']); -echo("
    txpow $ap[txpow]"); -echo("
    "); -echo(""); +echo " + "; +echo ' '.generate_ap_link($ap, " $text
    "); +echo ''; +echo "$break".$ap['mac_addr'].'
    '.$ap['type'].' - channel '.$ap['channel']; +echo "
    txpow $ap[txpow]"; +echo '
    '; +echo ''; -echo(""); -$ap['graph_type'] = "accesspoints_numasoclients"; -echo(generate_ap_link($ap, "")); -echo("
    \n"); -$ap['graph_type'] = "accesspoints_radioutil"; -echo(generate_ap_link($ap, "")); -echo("
    \n"); -$ap['graph_type'] = "accesspoints_interference"; -echo(generate_ap_link($ap, "")); -echo("
    \n"); +echo ''; +$ap['graph_type'] = 'accesspoints_numasoclients'; +echo generate_ap_link($ap, ""); +echo "
    \n"; +$ap['graph_type'] = 'accesspoints_radioutil'; +echo generate_ap_link($ap, ""); +echo "
    \n"; +$ap['graph_type'] = 'accesspoints_interference'; +echo generate_ap_link($ap, ""); +echo "
    \n"; -echo(""); +echo ''; -echo(" ".format_bi($ap[numasoclients])." Clients
    "); -echo(" ".format_bi($ap[radioutil])." % busy
    "); -echo(" ".format_bi($ap[interference])." interference index
    "); +echo " ".format_bi($ap[numasoclients]).' Clients
    '; +echo " ".format_bi($ap[radioutil]).' % busy
    '; +echo " ".format_bi($ap[interference]).' interference index
    '; -echo(""); +echo ''; -if ($vars['tab'] == "accesspoint") { +if ($vars['tab'] == 'accesspoint') { + $graph_type = 'accesspoints_numasoclients'; + echo ""; + echo "
    Associated Clients
    "; + include 'includes/print-accesspoint-graphs.inc.php'; + echo ''; + $graph_type = 'accesspoints_interference'; + echo ""; + echo "
    Interference
    "; + include 'includes/print-accesspoint-graphs.inc.php'; + echo ''; - $graph_type='accesspoints_numasoclients'; - echo(""); - echo("
    Associated Clients
    "); - include("includes/print-accesspoint-graphs.inc.php"); - echo(""); + $graph_type = 'accesspoints_channel'; + echo ""; + echo "
    Channel
    "; + include 'includes/print-accesspoint-graphs.inc.php'; + echo ''; - $graph_type='accesspoints_interference'; - echo(""); - echo("
    Interference
    "); - include("includes/print-accesspoint-graphs.inc.php"); - echo(""); + $graph_type = 'accesspoints_txpow'; + echo ""; + echo "
    Transmit Power
    "; + include 'includes/print-accesspoint-graphs.inc.php'; + echo ''; - $graph_type='accesspoints_channel'; - echo(""); - echo("
    Channel
    "); - include("includes/print-accesspoint-graphs.inc.php"); - echo(""); + $graph_type = 'accesspoints_radioutil'; + echo ""; + echo "
    Radio Utilization
    "; + include 'includes/print-accesspoint-graphs.inc.php'; + echo ''; - $graph_type='accesspoints_txpow'; - echo(""); - echo("
    Transmit Power
    "); - include("includes/print-accesspoint-graphs.inc.php"); - echo(""); + $graph_type = 'accesspoints_nummonclients'; + echo ""; + echo "
    Monitored Clients
    "; + include 'includes/print-accesspoint-graphs.inc.php'; + echo ''; - $graph_type='accesspoints_radioutil'; - echo(""); - echo("
    Radio Utilization
    "); - include("includes/print-accesspoint-graphs.inc.php"); - echo(""); - - $graph_type='accesspoints_nummonclients'; - echo(""); - echo("
    Monitored Clients
    "); - include("includes/print-accesspoint-graphs.inc.php"); - echo(""); - - $graph_type='accesspoints_nummonbssid'; - echo(""); - echo("
    Number of monitored BSSIDs
    "); - include("includes/print-accesspoint-graphs.inc.php"); - echo(""); - - } - -?> + $graph_type = 'accesspoints_nummonbssid'; + echo ""; + echo "
    Number of monitored BSSIDs
    "; + include 'includes/print-accesspoint-graphs.inc.php'; + echo ''; +}//end if diff --git a/html/includes/print-device-graph.php b/html/includes/print-device-graph.php index aeda550da..cf629b884 100644 --- a/html/includes/print-device-graph.php +++ b/html/includes/print-device-graph.php @@ -1,19 +1,26 @@ '); -echo('
    '.$graph_title.'
    '); +echo '
    '; +echo '
    '.$graph_title.'
    '; -include("includes/print-graphrow.inc.php"); +require 'includes/print-graphrow.inc.php'; -echo('
    '); +echo ''; $g_i++; - -?> - diff --git a/html/includes/print-interface-adsl.inc.php b/html/includes/print-interface-adsl.inc.php index a53d2fc1b..fa891bbbc 100644 --- a/html/includes/print-interface-adsl.inc.php +++ b/html/includes/print-interface-adsl.inc.php @@ -1,106 +1,115 @@ 0 || $port['ifOutErrors_delta'] > 0) -{ - $error_img = generate_port_link($port,"Interface Errors","port_errors"); -} else { - $error_img = ""; +if (!is_integer($i / 2)) { + $row_colour = $list_colour_a; +} +else { + $row_colour = $list_colour_b; } -echo(" - "); -echo(" - " . generate_port_link($port, $port['ifIndex'] . ". ".$port['label']) . " -
    ".$port['ifAlias'].""); - -if ($port['ifAlias']) { echo("
    "); } - -unset ($break); -if ($port_details) -{ - foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip) - { - echo("$break ".$ip['ipv4_address']."/".$ip['ipv4_prefixlen'].""); - $break = ","; - } - foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip6); - { - echo("$break ".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen'].""); - $break = ","; - } +if ($port['ifInErrors_delta'] > 0 || $port['ifOutErrors_delta'] > 0) { + $error_img = generate_port_link($port, "Interface Errors", 'port_errors'); +} +else { + $error_img = ''; } -echo(""); +echo " + "; +echo ' + '.generate_port_link($port, $port['ifIndex'].'. '.$port['label']).' +
    '.$port['ifAlias'].''; -$width="120"; $height="40"; $from = $config['time']['day']; +if ($port['ifAlias']) { + echo '
    '; +} -echo(""); -echo(formatRates($port['ifInOctets_rate'] * 8)." ".formatRates($port['ifOutOctets_rate'] * 8)); -echo("
    "); -$port['graph_type'] = "port_bits"; -echo(generate_port_link($port, "", $port['graph_type'])); +unset($break); +if ($port_details) { + foreach (dbFetchRows('SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?', array($port['port_id'])) as $ip) { + echo "$break ".$ip['ipv4_address'].'/'.$ip['ipv4_prefixlen'].''; + $break = ','; + } -echo(""); -echo("".formatRates($port['adslAturChanCurrTxRate']) . "/". formatRates($port['adslAtucChanCurrTxRate'])); -echo("
    "); -$port['graph_type'] = "port_adsl_speed"; -echo(generate_port_link($port, "", $port['graph_type'])); + foreach (dbFetchRows('SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?', array($port['port_id'])) as $ip6) { ; + echo "$break ".Net_IPv6::compress($ip6['ipv6_address']).'/'.$ip6['ipv6_prefixlen'].''; + $break = ','; + } +} -echo(""); -echo("".formatRates($port['adslAturCurrAttainableRate']) . "/". formatRates($port['adslAtucCurrAttainableRate'])); -echo("
    "); -$port['graph_type'] = "port_adsl_attainable"; -echo(generate_port_link($port, "", $port['graph_type'])); +echo ''; -echo(""); -echo("".$port['adslAturCurrAtn'] . "dB/". $port['adslAtucCurrAtn'] . "dB"); -echo("
    "); -$port['graph_type'] = "port_adsl_attenuation"; -echo(generate_port_link($port, "", $port['graph_type'])); +$width = '120'; +$height = '40'; +$from = $config['time']['day']; -echo(""); -echo("".$port['adslAturCurrSnrMgn'] . "dB/". $port['adslAtucCurrSnrMgn'] . "dB"); -echo("
    "); -$port['graph_type'] = "port_adsl_snr"; -echo(generate_port_link($port, "", $port['graph_type'])); +echo ''; +echo (formatRates(($port['ifInOctets_rate'] * 8))." ".formatRates(($port['ifOutOctets_rate'] * 8))); +echo '
    '; +$port['graph_type'] = 'port_bits'; +echo generate_port_link( + $port, + "", + $port['graph_type'] +); -echo(""); -echo("".$port['adslAturCurrOutputPwr'] . "dBm/". $port['adslAtucCurrOutputPwr'] . "dBm"); -echo("
    "); -$port['graph_type'] = "port_adsl_power"; -echo(generate_port_link($port, "", $port['graph_type'])); +echo ''; +echo ''.formatRates($port['adslAturChanCurrTxRate']).'/'.formatRates($port['adslAtucChanCurrTxRate']); +echo '
    '; +$port['graph_type'] = 'port_adsl_speed'; +echo generate_port_link( + $port, + "", + $port['graph_type'] +); -# if ($port[ifDuplex] != unknown) { echo("Duplex " . $port['ifDuplex'] . ""); } else { echo("-"); } +echo ''; +echo ''.formatRates($port['adslAturCurrAttainableRate']).'/'.formatRates($port['adslAtucCurrAttainableRate']); +echo '
    '; +$port['graph_type'] = 'port_adsl_attainable'; +echo generate_port_link( + $port, + "", + $port['graph_type'] +); -# echo(""); -# echo($port_adsl['adslLineCoding']."/".$port_adsl['adslLineType']); -# echo("
    "); -# echo("Sync:".formatRates($port_adsl['adslAtucChanCurrTxRate']) . "/". formatRates($port_adsl['adslAturChanCurrTxRate'])); -# echo("
    "); -# echo("Max:".formatRates($port_adsl['adslAtucCurrAttainableRate']) . "/". formatRates($port_adsl['adslAturCurrAttainableRate'])); -# echo(""); -# echo("Atten:".$port_adsl['adslAtucCurrAtn'] . "dB/". $port_adsl['adslAturCurrAtn'] . "dB"); -# echo("
    "); -# echo("SNR:".$port_adsl['adslAtucCurrSnrMgn'] . "dB/". $port_adsl['adslAturCurrSnrMgn']. "dB"); +echo ''; +echo ''.$port['adslAturCurrAtn'].'dB/'.$port['adslAtucCurrAtn'].'dB'; +echo '
    '; +$port['graph_type'] = 'port_adsl_attenuation'; +echo generate_port_link( + $port, + "", + $port['graph_type'] +); -echo(""); +echo ''; +echo ''.$port['adslAturCurrSnrMgn'].'dB/'.$port['adslAtucCurrSnrMgn'].'dB'; +echo '
    '; +$port['graph_type'] = 'port_adsl_snr'; +echo generate_port_link( + $port, + "", + $port['graph_type'] +); -?> +echo ''; +echo ''.$port['adslAturCurrOutputPwr'].'dBm/'.$port['adslAtucCurrOutputPwr'].'dBm'; +echo '
    '; +$port['graph_type'] = 'port_adsl_power'; +echo generate_port_link( + $port, + "", + $port['graph_type'] +); + +echo ''; diff --git a/html/includes/print-interface-graphs.inc.php b/html/includes/print-interface-graphs.inc.php index 1049c7d80..7971fccff 100644 --- a/html/includes/print-interface-graphs.inc.php +++ b/html/includes/print-interface-graphs.inc.php @@ -2,12 +2,10 @@ global $config; -$graph_array['height'] = "100"; -$graph_array['width'] = "215"; +$graph_array['height'] = '100'; +$graph_array['width'] = '215'; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $port['port_id']; $graph_array['type'] = $graph_type; -include("includes/print-graphrow.inc.php"); - -?> +require 'includes/print-graphrow.inc.php'; diff --git a/html/includes/print-service.inc.php b/html/includes/print-service.inc.php index 8d776cd7d..e91535d79 100644 --- a/html/includes/print-service.inc.php +++ b/html/includes/print-service.inc.php @@ -1,48 +1,59 @@ $service_type"; } -elseif ($service[service_status] == '1') { $status = "$service_type"; } -elseif ($service[service_status] == '2') { $status = "$service_type"; } - -$message = trim($service['service_message']); -$message = str_replace("\n", "
    ", $message); - -$since = time() - $service['service_changed']; -$since = formatUptime($since); - -if ($service['service_checked']) -{ - $checked = time() - $service['service_checked']; - $checked = formatUptime($checked); -} else { $checked = "Never"; } - -$mini_url = "graph.php?id=".$service['service_id']."&type=service_availability&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=efefef"; - -$popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$service['service_type']; -$popup .= "
    "; -$popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - -echo(" - "); - -if ($device_id) -{ - if (!$samehost) - { - echo("" . generate_device_link($device) . ""); - } else { - echo(""); - } +if ($service[service_status] == '0') { + $status = "$service_type"; +} +else if ($service[service_status] == '1') { + $status = "$service_type"; +} +else if ($service[service_status] == '2') { + $status = "$service_type"; } -echo(" +$message = trim($service['service_message']); +$message = str_replace("\n", '
    ', $message); + +$since = (time() - $service['service_changed']); +$since = formatUptime($since); + +if ($service['service_checked']) { + $checked = (time() - $service['service_checked']); + $checked = formatUptime($checked); +} +else { + $checked = 'Never'; +} + +$mini_url = 'graph.php?id='.$service['service_id'].'&type=service_availability&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=efefef'; + +$popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$service['service_type']; +$popup .= "
    "; +$popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; + +echo " + "; + +if ($device_id) { + if (!$samehost) { + echo "".generate_device_link($device).''; + } + else { + echo ''; + } +} + +echo " $status @@ -53,8 +64,6 @@ echo(" $message - "); + "; $i++; - -?> diff --git a/html/includes/print-vlan.inc.php b/html/includes/print-vlan.inc.php index 9b496035c..6fa489411 100644 --- a/html/includes/print-vlan.inc.php +++ b/html/includes/print-vlan.inc.php @@ -1,52 +1,52 @@ "); - -echo(" Vlan " . $vlan['vlan_vlan'] . ""); -echo("" . $vlan['vlan_name'] . ""); -echo(""); - - $vlan_ports = array(); - $otherports = dbFetchRows("SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id", array($device['device_id'], $vlan['vlan_vlan'])); - foreach ($otherports as $otherport) - { - $vlan_ports[$otherport[ifIndex]] = $otherport; - } - $otherports = dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?", array($device['device_id'], $vlan['vlan_vlan'])); - foreach ($otherports as $otherport) - { - $vlan_ports[$otherport[ifIndex]] = array_merge($otherport, array('untagged' => '1')); - } - ksort($vlan_ports); - -foreach ($vlan_ports as $port) -{ - $port = ifLabel($port, $device); - if ($vars['view'] == "graphs") - { - echo("
    -
    ".makeshortif($port['ifDescr'])."
    - ".$device['hostname']." - ".$port['ifDescr']."
    \ - ".$port['ifAlias']." \ - \ - ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " - -
    ".truncate(short_port_descr($port['ifAlias']), 22, '')."
    - "); - } - else - { - echo($vlan['port_sep'] . generate_port_link($port, makeshortif($port['label']))); - $vlan['port_sep'] = ", "; - if ($port['untagged']) { echo("(U)"); } - - } +if (!is_integer($i / 2)) { + $bg_colour = $list_colour_a; +} +else { + $bg_colour = $list_colour_b; } -echo(''); +echo ""; -?> +echo ' Vlan '.$vlan['vlan_vlan'].''; +echo ''.$vlan['vlan_name'].''; +echo ''; + + $vlan_ports = array(); + $otherports = dbFetchRows('SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id', array($device['device_id'], $vlan['vlan_vlan'])); +foreach ($otherports as $otherport) { + $vlan_ports[$otherport[ifIndex]] = $otherport; +} + + $otherports = dbFetchRows('SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?', array($device['device_id'], $vlan['vlan_vlan'])); +foreach ($otherports as $otherport) { + $vlan_ports[$otherport[ifIndex]] = array_merge($otherport, array('untagged' => '1')); +} + + ksort($vlan_ports); + +foreach ($vlan_ports as $port) { + $port = ifLabel($port, $device); + if ($vars['view'] == 'graphs') { + echo "
    +
    ".makeshortif($port['ifDescr'])."
    + ".$device['hostname'].' - '.$port['ifDescr'].'
    \ + '.$port['ifAlias']." \ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"." + +
    ".truncate(short_port_descr($port['ifAlias']), 22, '').'
    + '; + } + else { + echo $vlan['port_sep'].generate_port_link($port, makeshortif($port['label'])); + $vlan['port_sep'] = ', '; + if ($port['untagged']) { + echo '(U)'; + } + } +}//end foreach + +echo ''; diff --git a/html/includes/print-vm.inc.php b/html/includes/print-vm.inc.php index c75866a39..e69730001 100644 --- a/html/includes/print-vm.inc.php +++ b/html/includes/print-vm.inc.php @@ -1,43 +1,37 @@ '); +echo ''; -echo(''); +echo ''; -if (getidbyname($vm['vmwVmDisplayName'])) -{ - echo(generate_device_link(device_by_name($vm['vmwVmDisplayName']))); -} else { - echo $vm['vmwVmDisplayName']; +if (getidbyname($vm['vmwVmDisplayName'])) { + echo generate_device_link(device_by_name($vm['vmwVmDisplayName'])); +} +else { + echo $vm['vmwVmDisplayName']; } -echo(""); -echo('' . $vm['vmwVmState'] . ""); +echo ''; +echo ''.$vm['vmwVmState'].''; -if ($vm['vmwVmGuestOS'] == "E: tools not installed") -{ - echo('Unknown (VMware Tools not installed)'); +if ($vm['vmwVmGuestOS'] == 'E: tools not installed') { + echo 'Unknown (VMware Tools not installed)'; } -else if ($vm['vmwVmGuestOS'] == "") -{ - echo('(Unknown)'); +else if ($vm['vmwVmGuestOS'] == '') { + echo '(Unknown)'; } -elseif (isset($config['vmware_guestid'][$vm['vmwVmGuestOS']])) -{ - echo('' . $config['vmware_guestid'][$vm['vmwVmGuestOS']] . ""); +else if (isset($config['vmware_guestid'][$vm['vmwVmGuestOS']])) { + echo ''.$config['vmware_guestid'][$vm['vmwVmGuestOS']].''; } -else -{ - echo('' . $vm['vmwVmGuestOS'] . ""); +else { + echo ''.$vm['vmwVmGuestOS'].''; } -if ($vm['vmwVmMemSize'] >= 1024) -{ - echo("" . sprintf("%.2f",$vm['vmwVmMemSize']/1024) . " GB"); -} else { - echo("" . sprintf("%.2f",$vm['vmwVmMemSize']) . " MB"); +if ($vm['vmwVmMemSize'] >= 1024) { + echo (''.sprintf('%.2f', ($vm['vmwVmMemSize'] / 1024)).' GB'); +} +else { + echo ''.sprintf('%.2f', $vm['vmwVmMemSize']).' MB'; } -echo('' . $vm['vmwVmCpus'] . " CPU"); - -?> +echo ''.$vm['vmwVmCpus'].' CPU'; diff --git a/html/includes/print-vrf.inc.php b/html/includes/print-vrf.inc.php index abc680eb8..1fe1afb87 100644 --- a/html/includes/print-vrf.inc.php +++ b/html/includes/print-vrf.inc.php @@ -1,39 +1,39 @@ "); - -echo("" . $vrf['vrf_name'] . ""); -echo("" . $vrf['mplsVpnVrfDescription'] . ""); -echo("" . $vrf['mplsVpnVrfRouteDistinguisher'] . ""); - -echo(''); -foreach (dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVrf` = ?", array($device['device_id'], $vrf['vrf_id'])) as $port) -{ - if ($vars['view'] == "graphs") - { - $graph_type = "port_" . $vars['graph']; - echo("
    -
    ".makeshortif($port['ifDescr'])."
    - ".$device['hostname']." - ".$port['ifDescr']."
    \ - ".$port['ifAlias']." \ - \ - ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " - -
    ".truncate(short_port_descr($port['ifAlias']), 22, '')."
    - "); - } else { - echo($vrf['port_sep'] . generate_port_link($port, makeshortif($port['ifDescr']))); - $vrf['port_sep'] = ", "; - } +if (is_integer($i / 2)) { + $bg_colour = $list_colour_a; +} +else { + $bg_colour = $list_colour_b; } -echo(""); -echo(""); +echo ""; -?> +echo "".$vrf['vrf_name'].''; +echo ''.$vrf['mplsVpnVrfDescription'].''; +echo ''.$vrf['mplsVpnVrfRouteDistinguisher'].''; + +echo ''; +foreach (dbFetchRows('SELECT * FROM ports WHERE `device_id` = ? AND `ifVrf` = ?', array($device['device_id'], $vrf['vrf_id'])) as $port) { + if ($vars['view'] == 'graphs') { + $graph_type = 'port_'.$vars['graph']; + echo "
    +
    ".makeshortif($port['ifDescr'])."
    + ".$device['hostname'].' - '.$port['ifDescr'].'
    \ + '.$port['ifAlias']." \ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"." + +
    ".truncate(short_port_descr($port['ifAlias']), 22, '').'
    + '; + } + else { + echo $vrf['port_sep'].generate_port_link($port, makeshortif($port['ifDescr'])); + $vrf['port_sep'] = ', '; + } +} + +echo ''; +echo ''; diff --git a/html/includes/service-delete.inc.php b/html/includes/service-delete.inc.php index 2cf580c2d..9ea114dc5 100644 --- a/html/includes/service-delete.inc.php +++ b/html/includes/service-delete.inc.php @@ -4,10 +4,7 @@ $affected = dbDelete('services', '`service_id` = ?', array($_POST['service'])); - if ($affected) - { - $message .= $message_break . $rows . " service deleted!"; - $message_break .= "
    "; - } - -?> +if ($affected) { + $message .= $message_break.$rows.' service deleted!'; + $message_break .= '
    '; +} diff --git a/html/pages/apps/overview.inc.php b/html/pages/apps/overview.inc.php index 69d898375..029ded341 100644 --- a/html/pages/apps/overview.inc.php +++ b/html/pages/apps/overview.inc.php @@ -1,53 +1,50 @@ '); - echo('

    '.generate_link(nicecase($app['app_type']),array('page'=>'apps','app'=>$app['app_type'])).'

    '); - $app_devices = dbFetchRows("SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?", array($app['app_type'])); +foreach ($app_list as $app) { + echo '
    '; + echo '

    '.generate_link(nicecase($app['app_type']), array('page' => 'apps', 'app' => $app['app_type'])).'

    '; + $app_devices = dbFetchRows('SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?', array($app['app_type'])); - foreach ($app_devices as $app_device) - { + foreach ($app_devices as $app_device) { $graph_type = $graphs[$app['app_type']][0]; - $graph_array['type'] = "application_".$app['app_type']."_".$graph_type; - $graph_array['id'] = $app_device['app_id']; - $graph_array_zoom['type'] = "application_".$app['app_type']."_".$graph_type; - $graph_array_zoom['id'] = $app_device['app_id']; + $graph_array['type'] = 'application_'.$app['app_type'].'_'.$graph_type; + $graph_array['id'] = $app_device['app_id']; + $graph_array_zoom['type'] = 'application_'.$app['app_type'].'_'.$graph_type; + $graph_array_zoom['id'] = $app_device['app_id']; - $link_array = $graph_array; - $link_array['page'] = "device"; - $link_array['device'] = $app_device['device_id']; - $link_array['tab'] = "apps"; - $link_array['app'] = $app['app_type']; - unset($link_array['height'], $link_array['width']); - $overlib_url = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'device'; + $link_array['device'] = $app_device['device_id']; + $link_array['tab'] = 'apps'; + $link_array['app'] = $app['app_type']; + unset($link_array['height'], $link_array['width']); + $overlib_url = generate_url($link_array); - $overlib_link = ''.shorthost($app_device['hostname']).""; - if (!empty($app_device['app_instance'])) - { - $overlib_link .= ''.$app_device['app_instance'].""; - $app_device['content_add'] = '('.$app_device['app_instance'].')'; - } - $overlib_link .= "
    "; - $overlib_link .= generate_graph_tag($graph_array); - $overlib_content = generate_overlib_content($graph_array, $app_device['hostname'] . " - ". $app_device['app_type'] . $app_device['content_add']); + $overlib_link = ''.shorthost($app_device['hostname']).''; + if (!empty($app_device['app_instance'])) { + $overlib_link .= ''.$app_device['app_instance'].''; + $app_device['content_add'] = '('.$app_device['app_instance'].')'; + } - echo("
    "); - echo(overlib_link($overlib_url, $overlib_link, $overlib_content)); - echo("
    "); - } - echo('
    '); -} + $overlib_link .= '
    '; + $overlib_link .= generate_graph_tag($graph_array); + $overlib_content = generate_overlib_content($graph_array, $app_device['hostname'].' - '.$app_device['app_type'].$app_device['content_add']); -?> + echo "
    "; + echo overlib_link($overlib_url, $overlib_link, $overlib_content); + echo '
    '; + }//end foreach + + echo ''; +}//end foreach diff --git a/html/pages/bill/actions.inc.php b/html/pages/bill/actions.inc.php index b63038cf3..d55c2944c 100644 --- a/html/pages/bill/actions.inc.php +++ b/html/pages/bill/actions.inc.php @@ -1,86 +1,107 @@ Bill Deleted. Redirecting to Bills list."); - - echo(""); -} - -if ($_POST['action'] == "reset_bill" && ($_POST['confirm'] == "rrd" || $_POST['confirm'] == "mysql")) -{ - if ($_POST['confirm'] == "mysql") { - foreach (dbFetchRows("SELECT * FROM `bill_ports` WHERE `bill_id` = ?", array($bill_id)) as $port_data) +if ($_POST['action'] == 'delete_bill' && $_POST['confirm'] == 'confirm') { + foreach (dbFetchRows('SELECT * FROM `bill_ports` WHERE `bill_id` = ?', array($bill_id)) as $port_data) { - dbDelete('port_in_measurements', '`port_id` = ?', array($port_data['bill_id'])); - dbDelete('port_out_measurements', '`port_id` = ?', array($port_data['bill_id'])); + dbDelete('port_in_measurements', '`port_id` = ?', array($port_data['bill_id'])); + dbDelete('port_out_measurements', '`port_id` = ?', array($port_data['bill_id'])); } + dbDelete('bill_hist', '`bill_id` = ?', array($bill_id)); + dbDelete('bill_ports', '`bill_id` = ?', array($bill_id)); dbDelete('bill_data', '`bill_id` = ?', array($bill_id)); - } - if ($_POST['confirm'] == "rrd") { - // Stil todo - } + dbDelete('bill_perms', '`bill_id` = ?', array($bill_id)); + dbDelete('bills', '`bill_id` = ?', array($bill_id)); - echo("
    Bill Reseting. Redirecting to Bills list.
    "); + echo '
    Bill Deleted. Redirecting to Bills list.
    '; - echo(""); + echo ""; } -if ($_POST['action'] == "add_bill_port") -{ - dbInsert(array('bill_id' => $_POST['bill_id'], 'port_id' => $_POST['port_id']), 'bill_ports'); -} -if ($_POST['action'] == "delete_bill_port") -{ - dbDelete('bill_ports', "`bill_id` = ? AND `port_id` = ?", array($bill_id, $_POST['port_id'])); -} -if ($_POST['action'] == "update_bill") -{ - if (isset($_POST['bill_quota']) or isset($_POST['bill_cdr'])) - { - if ($_POST['bill_type'] == "quota") - { - if (isset($_POST['bill_quota_type'])) - { - if ($_POST['bill_quota_type'] == "MB") { $multiplier = 1 * $config['billing']['base']; } - if ($_POST['bill_quota_type'] == "GB") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base']; } - if ($_POST['bill_quota_type'] == "TB") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base'] * $config['billing']['base']; } - $bill_quota = (is_numeric($_POST['bill_quota']) ? $_POST['bill_quota'] * $config['billing']['base'] * $multiplier : 0); - $bill_cdr = 0; - } +if ($_POST['action'] == 'reset_bill' && ($_POST['confirm'] == 'rrd' || $_POST['confirm'] == 'mysql')) { + if ($_POST['confirm'] == 'mysql') { + foreach (dbFetchRows('SELECT * FROM `bill_ports` WHERE `bill_id` = ?', array($bill_id)) as $port_data) { + dbDelete('port_in_measurements', '`port_id` = ?', array($port_data['bill_id'])); + dbDelete('port_out_measurements', '`port_id` = ?', array($port_data['bill_id'])); + } + + dbDelete('bill_hist', '`bill_id` = ?', array($bill_id)); + dbDelete('bill_data', '`bill_id` = ?', array($bill_id)); } - if ($_POST['bill_type'] == "cdr") - { - if (isset($_POST['bill_cdr_type'])) - { - if ($_POST['bill_cdr_type'] == "Kbps") { $multiplier = 1 * $config['billing']['base']; } - if ($_POST['bill_cdr_type'] == "Mbps") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base']; } - if ($_POST['bill_cdr_type'] == "Gbps") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base'] * $config['billing']['base']; } - $bill_cdr = (is_numeric($_POST['bill_cdr']) ? $_POST['bill_cdr'] * $multiplier : 0); - $bill_quota = 0; - } - } - } - if (dbUpdate(array('bill_name' => $_POST['bill_name'], 'bill_day' => $_POST['bill_day'], 'bill_quota' => $bill_quota, - 'bill_cdr' => $bill_cdr, 'bill_type' => $_POST['bill_type'], 'bill_custid' => $_POST['bill_custid'], - 'bill_ref' => $_POST['bill_ref'], 'bill_notes' => $_POST['bill_notes']), 'bills', '`bill_id` = ?', array($bill_id))) - { - print_message("Bill Properties Updated"); - } + if ($_POST['confirm'] == 'rrd') { + // Stil todo + } + + echo '
    Bill Reseting. Redirecting to Bills list.
    '; + + echo ""; } -?> +if ($_POST['action'] == 'add_bill_port') { + dbInsert(array('bill_id' => $_POST['bill_id'], 'port_id' => $_POST['port_id']), 'bill_ports'); +} + +if ($_POST['action'] == 'delete_bill_port') { + dbDelete('bill_ports', '`bill_id` = ? AND `port_id` = ?', array($bill_id, $_POST['port_id'])); +} + +if ($_POST['action'] == 'update_bill') { + if (isset($_POST['bill_quota']) or isset($_POST['bill_cdr'])) { + if ($_POST['bill_type'] == 'quota') { + if (isset($_POST['bill_quota_type'])) { + if ($_POST['bill_quota_type'] == 'MB') { + $multiplier = (1 * $config['billing']['base']); + } + + if ($_POST['bill_quota_type'] == 'GB') { + $multiplier = (1 * $config['billing']['base'] * $config['billing']['base']); + } + + if ($_POST['bill_quota_type'] == 'TB') { + $multiplier = (1 * $config['billing']['base'] * $config['billing']['base'] * $config['billing']['base']); + } + + $bill_quota = (is_numeric($_POST['bill_quota']) ? $_POST['bill_quota'] * $config['billing']['base'] * $multiplier : 0); + $bill_cdr = 0; + } + } + + if ($_POST['bill_type'] == 'cdr') { + if (isset($_POST['bill_cdr_type'])) { + if ($_POST['bill_cdr_type'] == 'Kbps') { + $multiplier = (1 * $config['billing']['base']); + } + + if ($_POST['bill_cdr_type'] == 'Mbps') { + $multiplier = (1 * $config['billing']['base'] * $config['billing']['base']); + } + + if ($_POST['bill_cdr_type'] == 'Gbps') { + $multiplier = (1 * $config['billing']['base'] * $config['billing']['base'] * $config['billing']['base']); + } + + $bill_cdr = (is_numeric($_POST['bill_cdr']) ? $_POST['bill_cdr'] * $multiplier : 0); + $bill_quota = 0; + } + } + }//end if + + if (dbUpdate( + array( + 'bill_name' => $_POST['bill_name'], + 'bill_day' => $_POST['bill_day'], + 'bill_quota' => $bill_quota, + 'bill_cdr' => $bill_cdr, + 'bill_type' => $_POST['bill_type'], + 'bill_custid' => $_POST['bill_custid'], + 'bill_ref' => $_POST['bill_ref'], + 'bill_notes' => $_POST['bill_notes'], + ), + 'bills', + '`bill_id` = ?', + array($bill_id) + )) { + print_message('Bill Properties Updated'); + } +}//end if diff --git a/html/pages/bill/pdf_css.inc.php b/html/pages/bill/pdf_css.inc.php index 05ac3ed37..24b12c2c8 100644 --- a/html/pages/bill/pdf_css.inc.php +++ b/html/pages/bill/pdf_css.inc.php @@ -75,5 +75,3 @@ $css = << EOF; - -?> \ No newline at end of file diff --git a/html/pages/deleted-ports.inc.php b/html/pages/deleted-ports.inc.php index d0d6c3479..373557b58 100644 --- a/html/pages/deleted-ports.inc.php +++ b/html/pages/deleted-ports.inc.php @@ -1,40 +1,37 @@ Deleted ".generate_device_link($interface)." - ".generate_port_link($interface).""); + if (port_permitted($interface['port_id'], $interface['device_id'])) { + delete_port($interface['port_id']); + echo '
    Deleted '.generate_device_link($interface).' - '.generate_port_link($interface).'
    '; + } } - } -} elseif ($vars['purge']) { - $interface = dbFetchRow("SELECT * from `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id", array($vars['purge'])); - if (port_permitted($interface['port_id'], $interface['device_id'])) - delete_port($interface['port_id']); - echo("
    Deleted ".generate_device_link($interface)." - ".generate_port_link($interface)."
    "); +} +else if ($vars['purge']) { + $interface = dbFetchRow('SELECT * from `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id', array($vars['purge'])); + if (port_permitted($interface['port_id'], $interface['device_id'])) { + delete_port($interface['port_id']); + } + + echo '
    Deleted '.generate_device_link($interface).' - '.generate_port_link($interface).'
    '; } -echo(""); -echo(""); +echo '
    Purge All
    '; +echo ""; -foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) -{ - $interface = ifLabel($interface, $interface); - if (port_permitted($interface['port_id'], $interface['device_id'])) - { - echo(""); - echo(""); - echo(""); - echo(""); - echo(""); - } +foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { + $interface = ifLabel($interface, $interface); + if (port_permitted($interface['port_id'], $interface['device_id'])) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ""; + } } -echo("
    Purge All
    ".generate_device_link($interface)."".generate_port_link($interface)." Purge
    '.generate_device_link($interface).''.generate_port_link($interface).' Purge
    "); - -?> +echo ''; diff --git a/html/pages/device/accesspoint.inc.php b/html/pages/device/accesspoint.inc.php index ee4c46a3a..39463069c 100644 --- a/html/pages/device/accesspoint.inc.php +++ b/html/pages/device/accesspoint.inc.php @@ -1,20 +1,13 @@ "); +echo "
    "; -$i = "1"; +$i = '1'; -$ap = dbFetchRow("SELECT * FROM `accesspoint` WHERE `device_id` = ? AND `accesspoint_id` = ? AND `deleted` = '0' ORDER BY `name`,`radio_number` ASC", array($device['device_id'],$vars['ap'])); +$ap = dbFetchRow("SELECT * FROM `accesspoint` WHERE `device_id` = ? AND `accesspoint_id` = ? AND `deleted` = '0' ORDER BY `name`,`radio_number` ASC", array($device['device_id'], $vars['ap'])); -echo("
    "); +echo "
    "; -include("includes/print-accesspoint.inc.php"); +require 'includes/print-accesspoint.inc.php'; -echo("
    "); - - - - - - -?> +echo ''; diff --git a/html/pages/device/apps.inc.php b/html/pages/device/apps.inc.php index 5bf5a21d6..7d1412ebb 100644 --- a/html/pages/device/apps.inc.php +++ b/html/pages/device/apps.inc.php @@ -2,55 +2,61 @@ print_optionbar_start(); -echo("Apps » "); +echo "Apps » "; unset($sep); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'apps'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'apps', +); -foreach (dbFetchRows("SELECT * FROM `applications` WHERE `device_id` = ?", array($device['device_id'])) as $app) -{ - echo($sep); +foreach (dbFetchRows('SELECT * FROM `applications` WHERE `device_id` = ?', array($device['device_id'])) as $app) { + echo $sep; - if (!$vars['app']) { $vars['app'] = $app['app_type']; } + if (!$vars['app']) { + $vars['app'] = $app['app_type']; + } - if ($vars['app'] == $app['app_type']) - { - echo(""); - #echo(''); - } else { - #echo(''); - } - $link_add = array('app'=>$app['app_type']); - $text = nicecase($app['app_type']); - if (!empty($app['app_instance'])) - { - $text .= "(".$app['app_instance'].")"; - $link_add['instance'] = $app['app_id']; - } - echo(generate_link($text,$link_array,$link_add)); - if ($vars['app'] == $app['app_type']) { echo(""); } - $sep = " | "; + if ($vars['app'] == $app['app_type']) { + echo ""; + // echo(''); + } + else { + // echo(''); + } + + $link_add = array('app' => $app['app_type']); + $text = nicecase($app['app_type']); + if (!empty($app['app_instance'])) { + $text .= '('.$app['app_instance'].')'; + $link_add['instance'] = $app['app_id']; + } + + echo generate_link($text, $link_array, $link_add); + if ($vars['app'] == $app['app_type']) { + echo ''; + } + + $sep = ' | '; } print_optionbar_end(); -$where_array = array($device['device_id'], $vars['app']); -if($vars['instance']) -{ - $where = " AND `app_id` = ?"; - $where_array[] = $vars['instance']; +$where_array = array( + $device['device_id'], + $vars['app'], +); +if ($vars['instance']) { + $where = ' AND `app_id` = ?'; + $where_array[] = $vars['instance']; } -$app = dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?".$where, $where_array); +$app = dbFetchRow('SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?'.$where, $where_array); -if (is_file("pages/device/apps/".mres($vars['app']).".inc.php")) -{ - include("pages/device/apps/".mres($vars['app']).".inc.php"); +if (is_file('pages/device/apps/'.mres($vars['app']).'.inc.php')) { + include 'pages/device/apps/'.mres($vars['app']).'.inc.php'; } -$pagetitle[] = "Apps"; - -?> +$pagetitle[] = 'Apps'; diff --git a/html/pages/device/apps/apache.inc.php b/html/pages/device/apps/apache.inc.php index 7715051e2..c5975ea5b 100644 --- a/html/pages/device/apps/apache.inc.php +++ b/html/pages/device/apps/apache.inc.php @@ -2,28 +2,27 @@ global $config; -$graphs = array('apache_bits' => 'Traffic', - 'apache_hits' => 'Hits', - 'apache_cpu' => 'CPU Utilisation', - 'apache_scoreboard' => 'Scoreboard Statistics'); +$graphs = array( + 'apache_bits' => 'Traffic', + 'apache_hits' => 'Hits', + 'apache_cpu' => 'CPU Utilisation', + 'apache_scoreboard' => 'Scoreboard Statistics', +); -foreach ($graphs as $key => $text) -{ - $graph_type = "apache_scoreboard"; +foreach ($graphs as $key => $text) { + $graph_type = 'apache_scoreboard'; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; - echo('

    '.$text.'

    '); + echo '

    '.$text.'

    '; - echo(""); + echo ""; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(""); + echo ''; } - -?> diff --git a/html/pages/device/apps/drbd.inc.php b/html/pages/device/apps/drbd.inc.php index 36af19ddf..842e27440 100644 --- a/html/pages/device/apps/drbd.inc.php +++ b/html/pages/device/apps/drbd.inc.php @@ -1,28 +1,26 @@ '.$app['app_instance'].''); +echo '

    '.$app['app_instance'].'

    '; -$graphs = array('drbd_network_bits' => 'Network Traffic', - 'drbd_disk_bits' => 'Disk Traffic', - 'drbd_unsynced' => 'Unsynced Data', - 'drbd_queue' => 'Queues'); +$graphs = array( + 'drbd_network_bits' => 'Network Traffic', + 'drbd_disk_bits' => 'Disk Traffic', + 'drbd_unsynced' => 'Unsynced Data', + 'drbd_queue' => 'Queues', +); -foreach ($graphs as $key => $text) -{ +foreach ($graphs as $key => $text) { + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; + echo '

    '.$text.'

    '; - echo('

    '.$text.'

    '); + echo ""; - echo(""); + include 'includes/print-graphrow.inc.php'; - include("includes/print-graphrow.inc.php"); - - echo(""); + echo ''; } - -?> diff --git a/html/pages/device/apps/mailscanner.inc.php b/html/pages/device/apps/mailscanner.inc.php index 231886f9c..5a6bd6f34 100644 --- a/html/pages/device/apps/mailscanner.inc.php +++ b/html/pages/device/apps/mailscanner.inc.php @@ -2,25 +2,24 @@ global $config; -$graphs = array('mailscanner_sent' => 'Mailscanner - Sent / Received', - 'mailscanner_spam' => 'Mailscanner - Spam / Virus', - 'mailscanner_reject' => 'Mailscanner - Rejected / Waiting / Relayed'); +$graphs = array( + 'mailscanner_sent' => 'Mailscanner - Sent / Received', + 'mailscanner_spam' => 'Mailscanner - Spam / Virus', + 'mailscanner_reject' => 'Mailscanner - Rejected / Waiting / Relayed', +); -foreach ($graphs as $key => $text) -{ - $graph_type = $key; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; +foreach ($graphs as $key => $text) { + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; - echo('

    '.$text.'

    '); - echo(""); + echo '

    '.$text.'

    '; + echo ""; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(""); + echo ''; } - -?> \ No newline at end of file diff --git a/html/pages/device/apps/memcached.inc.php b/html/pages/device/apps/memcached.inc.php index 7b7c71540..d17b23d53 100644 --- a/html/pages/device/apps/memcached.inc.php +++ b/html/pages/device/apps/memcached.inc.php @@ -2,31 +2,28 @@ global $config; -$graphs = array('memcached_bits' => 'Traffic', - 'memcached_commands' => 'Commands', - 'memcached_data' => 'Data Size', - 'memcached_items' => 'Items', - 'memcached_uptime' => 'Uptime', - 'memcached_threads' => 'Threads', +$graphs = array( + 'memcached_bits' => 'Traffic', + 'memcached_commands' => 'Commands', + 'memcached_data' => 'Data Size', + 'memcached_items' => 'Items', + 'memcached_uptime' => 'Uptime', + 'memcached_threads' => 'Threads', ); -foreach ($graphs as $key => $text) -{ +foreach ($graphs as $key => $text) { + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; + echo '

    '.$text.'

    '; - echo('

    '.$text.'

    '); + echo ""; - echo(""); + include 'includes/print-graphrow.inc.php'; - include("includes/print-graphrow.inc.php"); - - echo(""); + echo ''; } - -?> diff --git a/html/pages/device/apps/mysql.inc.php b/html/pages/device/apps/mysql.inc.php index 511edf3cd..851498787 100644 --- a/html/pages/device/apps/mysql.inc.php +++ b/html/pages/device/apps/mysql.inc.php @@ -3,74 +3,78 @@ global $config; print_optionbar_start(); -echo("".nicecase($app['app_type'])." » "); +echo "".nicecase($app['app_type']).' » '; -$app_sections = array('system' => "System", - 'queries' => "Queries", - 'innodb' => "InnoDB"); +$app_sections = array( + 'system' => 'System', + 'queries' => 'Queries', + 'innodb' => 'InnoDB', +); unset($sep); -foreach ($app_sections as $app_section => $app_section_text) -{ - echo($sep); +foreach ($app_sections as $app_section => $app_section_text) { + echo $sep; - if (!$vars['app_section']) { $vars['app_section'] = $app_section; } + if (!$vars['app_section']) { + $vars['app_section'] = $app_section; + } - if ($vars['app_section'] == $app_section) - { - echo(""); - } - echo(generate_link($app_section_text,$vars,array('app_section'=>$app_section))); - if ($vars['app_section'] == $app_section) { echo(""); } - $sep = " | "; + if ($vars['app_section'] == $app_section) { + echo ""; + } + + echo generate_link($app_section_text, $vars, array('app_section' => $app_section)); + if ($vars['app_section'] == $app_section) { + echo ''; + } + + $sep = ' | '; } + print_optionbar_end(); $graphs['system'] = array( - 'mysql_connections' => 'Connections', - 'mysql_files_tables' => 'Files and Tables', - 'mysql_myisam_indexes' => 'MyISAM Indexes', - 'mysql_network_traffic' => 'Network Traffic', - 'mysql_table_locks' => 'Table Locks', - 'mysql_temporary_objects' => 'Temporary Objects' - ); + 'mysql_connections' => 'Connections', + 'mysql_files_tables' => 'Files and Tables', + 'mysql_myisam_indexes' => 'MyISAM Indexes', + 'mysql_network_traffic' => 'Network Traffic', + 'mysql_table_locks' => 'Table Locks', + 'mysql_temporary_objects' => 'Temporary Objects', +); $graphs['queries'] = array( - 'mysql_command_counters' => 'Command Counters', - 'mysql_query_cache' => 'Query Cache', - 'mysql_query_cache_memory' => 'Query Cache Memory', - 'mysql_select_types' => 'Select Types', - 'mysql_slow_queries' => 'Slow Queries', - 'mysql_sorts' => 'Sorts', - ); + 'mysql_command_counters' => 'Command Counters', + 'mysql_query_cache' => 'Query Cache', + 'mysql_query_cache_memory' => 'Query Cache Memory', + 'mysql_select_types' => 'Select Types', + 'mysql_slow_queries' => 'Slow Queries', + 'mysql_sorts' => 'Sorts', +); $graphs['innodb'] = array( - 'mysql_innodb_buffer_pool' => 'InnoDB Buffer Pool', - 'mysql_innodb_buffer_pool_activity' => 'InnoDB Buffer Pool Activity', - 'mysql_innodb_insert_buffer' => 'InnoDB Insert Buffer', - 'mysql_innodb_io' => 'InnoDB IO', - 'mysql_innodb_io_pending' => 'InnoDB IO Pending', - 'mysql_innodb_log' => 'InnoDB Log', - 'mysql_innodb_row_operations' => 'InnoDB Row Operations', - 'mysql_innodb_semaphores' => 'InnoDB semaphores', - 'mysql_innodb_transactions' => 'InnoDB Transactions', - ); + 'mysql_innodb_buffer_pool' => 'InnoDB Buffer Pool', + 'mysql_innodb_buffer_pool_activity' => 'InnoDB Buffer Pool Activity', + 'mysql_innodb_insert_buffer' => 'InnoDB Insert Buffer', + 'mysql_innodb_io' => 'InnoDB IO', + 'mysql_innodb_io_pending' => 'InnoDB IO Pending', + 'mysql_innodb_log' => 'InnoDB Log', + 'mysql_innodb_row_operations' => 'InnoDB Row Operations', + 'mysql_innodb_semaphores' => 'InnoDB semaphores', + 'mysql_innodb_transactions' => 'InnoDB Transactions', +); -foreach ($graphs[$vars['app_section']] as $key => $text) -{ - $graph_type = $key; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; - echo('

    '.$text.'

    '); +foreach ($graphs[$vars['app_section']] as $key => $text) { + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; + echo '

    '.$text.'

    '; - echo(""); + echo ""; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(""); + echo ''; } - -?> diff --git a/html/pages/device/apps/nginx.inc.php b/html/pages/device/apps/nginx.inc.php index a1d3d2506..f78ba4d1b 100644 --- a/html/pages/device/apps/nginx.inc.php +++ b/html/pages/device/apps/nginx.inc.php @@ -2,24 +2,23 @@ global $config; -$graphs = array('nginx_connections' => 'nginx Connections', - 'nginx_req' => 'nginx requests'); +$graphs = array( + 'nginx_connections' => 'nginx Connections', + 'nginx_req' => 'nginx requests', +); -foreach ($graphs as $key => $text) -{ - $graph_type = $key; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; - echo('

    '.$text.'

    '); +foreach ($graphs as $key => $text) { + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; + echo '

    '.$text.'

    '; - echo(""); + echo ""; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(""); + echo ''; } - -?> \ No newline at end of file diff --git a/html/pages/device/apps/ntp-client.inc.php b/html/pages/device/apps/ntp-client.inc.php index 881b27c82..11980b420 100644 --- a/html/pages/device/apps/ntp-client.inc.php +++ b/html/pages/device/apps/ntp-client.inc.php @@ -2,22 +2,22 @@ global $config; -$graphs = array('ntpclient_stats' => 'NTP Client - Statistics', - 'ntpclient_freq' => 'NTP Client - Frequency'); +$graphs = array( + 'ntpclient_stats' => 'NTP Client - Statistics', + 'ntpclient_freq' => 'NTP Client - Frequency', +); foreach ($graphs as $key => $text) { - $graph_type = $key; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; - echo('

    '.$text.'

    '); - echo(""); + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; + echo '

    '.$text.'

    '; + echo ""; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(""); + echo ''; } - -?> \ No newline at end of file diff --git a/html/pages/device/apps/ntpd-server.inc.php b/html/pages/device/apps/ntpd-server.inc.php index 26875d6cc..1b4adaf86 100644 --- a/html/pages/device/apps/ntpd-server.inc.php +++ b/html/pages/device/apps/ntpd-server.inc.php @@ -2,27 +2,27 @@ global $config; -$graphs = array('ntpdserver_stats' => 'NTPD Server - Statistics', - 'ntpdserver_freq' => 'NTPD Server - Frequency', - 'ntpdserver_stratum' => 'NTPD Server - Stratum', - 'ntpdserver_buffer' => 'NTPD Server - Buffer', - 'ntpdserver_bits' => 'NTPD Server - Packets Sent/Received', - 'ntpdserver_packets' => 'NTPD Server - Packets Dropped/Ignored', - 'ntpdserver_uptime' => 'NTPD Server - Uptime'); +$graphs = array( + 'ntpdserver_stats' => 'NTPD Server - Statistics', + 'ntpdserver_freq' => 'NTPD Server - Frequency', + 'ntpdserver_stratum' => 'NTPD Server - Stratum', + 'ntpdserver_buffer' => 'NTPD Server - Buffer', + 'ntpdserver_bits' => 'NTPD Server - Packets Sent/Received', + 'ntpdserver_packets' => 'NTPD Server - Packets Dropped/Ignored', + 'ntpdserver_uptime' => 'NTPD Server - Uptime', +); foreach ($graphs as $key => $text) { - $graph_type = $key; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; - echo('

    '.$text.'

    '); - echo(""); + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; + echo '

    '.$text.'

    '; + echo ""; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(""); + echo ''; } - -?> \ No newline at end of file diff --git a/html/pages/device/apps/powerdns.inc.php b/html/pages/device/apps/powerdns.inc.php index 4aa7f2b3d..774b9af2a 100644 --- a/html/pages/device/apps/powerdns.inc.php +++ b/html/pages/device/apps/powerdns.inc.php @@ -2,30 +2,29 @@ global $config; -$graphs = array('powerdns_latency' => 'PowerDNS - Latency', - 'powerdns_fail' => 'PowerDNS - Corrupt / Failed / Timed out', - 'powerdns_packetcache' => 'PowerDNS - Packet Cache', - 'powerdns_querycache' => 'PowerDNS - Query Cache', - 'powerdns_recursing' => 'PowerDNS - Recursing Queries and Answers', - 'powerdns_queries' => 'PowerDNS - Total UDP/TCP Queries and Answers', - 'powerdns_queries_udp' => 'PowerDNS - Detail UDP IPv4/IPv6 Queries and Answers'); +$graphs = array( + 'powerdns_latency' => 'PowerDNS - Latency', + 'powerdns_fail' => 'PowerDNS - Corrupt / Failed / Timed out', + 'powerdns_packetcache' => 'PowerDNS - Packet Cache', + 'powerdns_querycache' => 'PowerDNS - Query Cache', + 'powerdns_recursing' => 'PowerDNS - Recursing Queries and Answers', + 'powerdns_queries' => 'PowerDNS - Total UDP/TCP Queries and Answers', + 'powerdns_queries_udp' => 'PowerDNS - Detail UDP IPv4/IPv6 Queries and Answers', +); -foreach ($graphs as $key => $text) -{ - $graph_type = $key; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; +foreach ($graphs as $key => $text) { + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; - echo('

    '.$text.'

    '); + echo '

    '.$text.'

    '; - echo(""); + echo ""; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(""); + echo ''; } - -?> \ No newline at end of file diff --git a/html/pages/device/apps/shoutcast.inc.php b/html/pages/device/apps/shoutcast.inc.php index cceb5ffc1..1dea2fdd5 100644 --- a/html/pages/device/apps/shoutcast.inc.php +++ b/html/pages/device/apps/shoutcast.inc.php @@ -2,75 +2,67 @@ global $config; -$total = true; +$total = true; -$rrddir = $config['rrd_dir']."/".$device['hostname']; -$files = array(); +$rrddir = $config['rrd_dir'].'/'.$device['hostname']; +$files = array(); -if ($handle = opendir($rrddir)) -{ - while (false !== ($file = readdir($handle))) - { - if ($file != "." && $file != "..") +if ($handle = opendir($rrddir)) { + while (false !== ($file = readdir($handle))) { - if (eregi("app-shoutcast-".$app['app_id'], $file)) - { - array_push($files, $file); - } + if ($file != '.' && $file != '..') { + if (eregi('app-shoutcast-'.$app['app_id'], $file)) { + array_push($files, $file); + } + } } - } } -if (isset($total) && $total == true) -{ - $graphs = array( - 'shoutcast_multi_bits' => 'Traffic Statistics - Total of all Shoutcast servers', - 'shoutcast_multi_stats' => 'Shoutcast Statistics - Total of all Shoutcast servers' - ); +if (isset($total) && $total == true) { + $graphs = array( + 'shoutcast_multi_bits' => 'Traffic Statistics - Total of all Shoutcast servers', + 'shoutcast_multi_stats' => 'Shoutcast Statistics - Total of all Shoutcast servers', + ); - foreach ($graphs as $key => $text) - { - $graph_type = $key; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; - echo('

    '.$text.'

    '); - echo(""); + foreach ($graphs as $key => $text) + { + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; + echo '

    '.$text.'

    '; + echo ""; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(""); - } + echo ''; + } } -foreach ($files as $id => $file) -{ - $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); - $hostname = eregi_replace('.rrd', '', $hostname); - list($host, $port) = split('_', $hostname, 2); - $graphs = array( - 'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')', - 'shoutcast_stats' => 'Shoutcast Statistics - '.$host.' (Port: '.$port.')' - ); +foreach ($files as $id => $file) { + $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); + $hostname = eregi_replace('.rrd', '', $hostname); + list($host, $port) = split('_', $hostname, 2); + $graphs = array( + 'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')', + 'shoutcast_stats' => 'Shoutcast Statistics - '.$host.' (Port: '.$port.')', + ); - foreach ($graphs as $key => $text) - { - $graph_type = $key; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; - $graph_array['type'] = "application_".$key; - $graph_array['hostname'] = $hostname; - echo('

    '.$text.'

    '); - echo(""); + foreach ($graphs as $key => $text) { + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; + $graph_array['hostname'] = $hostname; + echo '

    '.$text.'

    '; + echo ""; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(""); - } + echo ''; + } } - -?> \ No newline at end of file diff --git a/html/pages/device/collectd.inc.php b/html/pages/device/collectd.inc.php index 11be70a95..dabbb7d52 100644 --- a/html/pages/device/collectd.inc.php +++ b/html/pages/device/collectd.inc.php @@ -1,4 +1,4 @@ - * @@ -16,97 +16,115 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02150-1301, USA. */ -error_reporting(E_ALL | E_NOTICE | E_WARNING); +error_reporting((E_ALL | E_NOTICE | E_WARNING)); -require('includes/collectd/config.php'); -require('includes/collectd/functions.php'); -require('includes/collectd/definitions.php'); - -#require('config.php'); -#require('functions.php'); -#require('definitions.php'); +require 'includes/collectd/config.php'; +require 'includes/collectd/functions.php'; +require 'includes/collectd/definitions.php'; load_graph_definitions(); + /** * Send back new list content * @items Array of options values to return to browser * @method Name of Javascript method that will be called to process data */ -function dhtml_response_list(&$items, $method) { - header("Content-Type: text/xml"); +function dhtml_response_list(&$items, $method) +{ + header('Content-Type: text/xml'); + + print (''."\n"); + print ("\n"); + printf(" %s\n", htmlspecialchars($method)); + print (" \n"); + foreach ($items as &$item) { + printf(' '."\n", htmlspecialchars($item)); + } + + print (" \n"); + print (''); + +}//end dhtml_response_list() - print(''."\n"); - print("\n"); - printf(" %s\n", htmlspecialchars($method)); - print(" \n"); - foreach ($items as &$item) - printf(' '."\n", htmlspecialchars($item)); - print(" \n"); - print(""); -} print_optionbar_start(); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'collectd'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'collectd', +); - $plugins = collectd_list_plugins($device['hostname']); - unset($sep); - foreach ($plugins as &$plugin) { - if (!$vars['plugin']) { $vars['plugin'] = $plugin; } - echo($sep); - if ($vars['plugin'] == $plugin) { echo(""); } - echo(generate_link(htmlspecialchars($plugin),$link_array,array('plugin'=>$plugin))); - if ($vars['plugin'] == $plugin) { echo(""); } - $sep = ' | '; +$plugins = collectd_list_plugins($device['hostname']); +unset($sep); +foreach ($plugins as &$plugin) { + if (!$vars['plugin']) { + $vars['plugin'] = $plugin; } - unset ($sep); + + echo $sep; + if ($vars['plugin'] == $plugin) { + echo ""; + } + + echo generate_link(htmlspecialchars($plugin), $link_array, array('plugin' => $plugin)); + if ($vars['plugin'] == $plugin) { + echo ''; + } + + $sep = ' | '; +} + +unset($sep); print_optionbar_end(); - $i=0; +$i = 0; - $pinsts = collectd_list_pinsts($device['hostname'], $vars['plugin']); - foreach ($pinsts as &$instance) { +$pinsts = collectd_list_pinsts($device['hostname'], $vars['plugin']); +foreach ($pinsts as &$instance) { + $types = collectd_list_types($device['hostname'], $vars['plugin'], $instance); + foreach ($types as &$type) { + $typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type); - $types = collectd_list_types($device['hostname'], $vars['plugin'], $instance); - foreach ($types as &$type) { + if ($MetaGraphDefs[$type]) { + $typeinstances = array($MetaGraphDefs[$type]); + } - $typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type); + foreach ($typeinstances as &$tinst) { + $i++; + if (!is_integer($i / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - if ($MetaGraphDefs[$type]) { $typeinstances = array($MetaGraphDefs[$type]); } + echo '
    '; + echo '
    '; + if ($tinst) { + echo $vars['plugin']." $instance - $type - $tinst"; + } + else { + echo $vars['plugin']." $instance - $type"; + } - foreach ($typeinstances as &$tinst) { - $i++; - if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + echo '
    '; - echo('
    '); - echo('
    '); - if ($tinst) { - echo($vars['plugin']." $instance - $type - $tinst"); - } else { - echo($vars['plugin']." $instance - $type"); - } - echo("
    "); + $graph_array['type'] = 'device_collectd'; + $graph_array['device'] = $device['device_id']; - $graph_array['type'] = "device_collectd"; - $graph_array['device'] = $device['device_id']; + $graph_array['c_plugin'] = $vars['plugin']; + $graph_array['c_plugin_instance'] = $instance; + $graph_array['c_type'] = $type; + $graph_array['c_type_instance'] = $tinst; - $graph_array['c_plugin'] = $vars['plugin']; - $graph_array['c_plugin_instance'] = $instance; - $graph_array['c_type'] = $type; - $graph_array['c_type_instance'] = $tinst; - - include("includes/print-graphrow.inc.php"); - - echo("
    "); - - } - } + include 'includes/print-graphrow.inc.php'; + echo '
    '; + } } +} -$pagetitle[] = "CollectD"; -?> +$pagetitle[] = 'CollectD'; diff --git a/html/pages/device/edit/icon.inc.php b/html/pages/device/edit/icon.inc.php index 62184c94a..3adb7d915 100644 --- a/html/pages/device/edit/icon.inc.php +++ b/html/pages/device/edit/icon.inc.php @@ -1,36 +1,34 @@ "7") - { - $param = array('icon' => $_POST['icon']); +if ($_POST['editing']) { + if ($_SESSION['userlevel'] > '7') { + $param = array('icon' => $_POST['icon']); - $rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id'])); + $rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id'])); - if ($rows_updated > 0 || $updated) - { - $update_message = "Device icon updated."; - $updated = 1; - $device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id'])); - } elseif ($rows_updated = '-1') { - $update_message = "Device icon unchanged. No update necessary."; - $updated = -1; - } else { - $update_message = "Device icon update error."; + if ($rows_updated > 0 || $updated) { + $update_message = 'Device icon updated.'; + $updated = 1; + $device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id'])); + } + else if ($rows_updated = '-1') { + $update_message = 'Device icon unchanged. No update necessary.'; + $updated = -1; + } + else { + $update_message = 'Device icon update error.'; + } + } + else { + include 'includes/error-no-perm.inc.php'; } - } - else - { - include("includes/error-no-perm.inc.php"); - } } -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +if ($updated && $update_message) { + print_message($update_message); +} +else if ($update_message) { + print_error($update_message); } ?> @@ -44,26 +42,23 @@ if ($updated && $update_message) \n"); +echo " \n"; -# Default icon +// Default icon $icon = $config['os'][$device['os']]['icon']; -echo(' ' . "\n"); +echo ' '."\n"; -for ($i = 0;$i < count($config['os'][$device['os']]['icons']);$i++) -{ - $icon = $config['os'][$device['os']]['icons'][$i]; - echo(' ' . "\n"); +for ($i = 0; $i < count($config['os'][$device['os']]['icons']); $i++) { + $icon = $config['os'][$device['os']]['icons'][$i]; + echo ' '."\n"; } -if ($numicons %10 == 0) -{ - echo(" \n"); - echo(" \n"); +if (($numicons % 10) == 0) { + echo " \n"; + echo " \n"; } ?> diff --git a/html/pages/device/entphysical.inc.php b/html/pages/device/entphysical.inc.php index dc34aae56..af167b4dd 100644 --- a/html/pages/device/entphysical.inc.php +++ b/html/pages/device/entphysical.inc.php @@ -1,92 +1,113 @@ "); - - if ($ent['entPhysicalClass'] == "chassis") { echo(" "); } - if ($ent['entPhysicalClass'] == "module") { echo(" "); } - if ($ent['entPhysicalClass'] == "port") { echo(" "); } - if ($ent['entPhysicalClass'] == "container") { echo(" "); } - if ($ent['entPhysicalClass'] == "sensor") + $ents = dbFetchRows('SELECT * FROM `entPhysical` WHERE device_id = ? AND entPhysicalContainedIn = ? ORDER BY entPhysicalContainedIn,entPhysicalIndex', array($device['device_id'], $ent)); + foreach ($ents as $ent) { - echo(" "); - $sensor = dbFetchRow("SELECT * FROM `sensors` WHERE `device_id` = ? AND (`entPhysicalIndex` = ? OR `sensor_index` = ?)", array($device['device_id'], $ent['entPhysicalIndex'], $ent['entPhysicalIndex'])); - if (count($sensor)) - { - $link = " href='device/device=".$device['device_id']."/tab=health/metric=".$sensor['sensor_class']."/' onmouseover=\"return overlib('', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\""; - } - } else { unset ($link); } + echo " +
  • "; - if ($ent['entPhysicalClass'] == "backplane") { echo(" "); } - if ($ent['entPhysicalParentRelPos'] > '-1') {echo("".$ent['entPhysicalParentRelPos'].". "); } + if ($ent['entPhysicalClass'] == 'chassis') { + echo " "; + } - if ($link) {echo(""); } + if ($ent['entPhysicalClass'] == 'module') { + echo " "; + } - if ($ent['ifIndex']) - { - $interface = dbFetchRow("SELECT * FROM `ports` WHERE ifIndex = ? AND device_id = ?", array($ent['ifIndex'], $device['device_id'])); - $ent['entPhysicalName'] = generate_port_link($interface); - } + if ($ent['entPhysicalClass'] == 'port') { + echo " "; + } - if ($ent['entPhysicalModelName'] && $ent['entPhysicalName']) - { - echo("".$ent['entPhysicalModelName'] . " (".$ent['entPhysicalName'].")"); - } elseif ($ent['entPhysicalModelName']) { - echo("".$ent['entPhysicalModelName'] . ""); - } elseif (is_numeric($ent['entPhysicalName']) && $ent['entPhysicalVendorType']) { - echo("".$ent['entPhysicalName']." ".$ent['entPhysicalVendorType'].""); - } elseif ($ent['entPhysicalName']) { - echo("".$ent['entPhysicalName'].""); - } elseif ($ent['entPhysicalDescr']) { - echo("".$ent['entPhysicalDescr'].""); - } + if ($ent['entPhysicalClass'] == 'container') { + echo " "; + } - if ($ent['entPhysicalClass'] == "sensor") - { - echo(" (".$ent['entSensorValue'] ." ". $ent['entSensorType'].")"); - } + if ($ent['entPhysicalClass'] == 'sensor') { + echo " "; + $sensor = dbFetchRow('SELECT * FROM `sensors` WHERE `device_id` = ? AND (`entPhysicalIndex` = ? OR `sensor_index` = ?)', array($device['device_id'], $ent['entPhysicalIndex'], $ent['entPhysicalIndex'])); + if (count($sensor)) { + $link = " href='device/device=".$device['device_id'].'/tab=health/metric='.$sensor['sensor_class']."/' onmouseover=\"return overlib('', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\""; + } + } else { + unset($link); + } - echo("
    " . $ent['entPhysicalDescr']); + if ($ent['entPhysicalClass'] == 'backplane') { + echo " "; + } - if ($link) { echo(""); } + if ($ent['entPhysicalParentRelPos'] > '-1') { + echo ''.$ent['entPhysicalParentRelPos'].'. '; + } - if ($ent['entPhysicalSerialNum']) - { - echo("
    Serial No. ".$ent['entPhysicalSerialNum']." "); - } + if ($link) { + echo ""; + } - echo("
    "); + if ($ent['ifIndex']) { + $interface = dbFetchRow('SELECT * FROM `ports` WHERE ifIndex = ? AND device_id = ?', array($ent['ifIndex'], $device['device_id'])); + $ent['entPhysicalName'] = generate_port_link($interface); + } - $count = dbFetchCell("SELECT COUNT(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entPhysicalContainedIn = '".$ent['entPhysicalIndex']."'"); - if ($count) - { - echo("
      "); - printEntPhysical($ent['entPhysicalIndex'], $level+1, ''); - echo("
    "); - } + if ($ent['entPhysicalModelName'] && $ent['entPhysicalName']) { + echo ''.$ent['entPhysicalModelName'].' ('.$ent['entPhysicalName'].')'; + } + else if ($ent['entPhysicalModelName']) { + echo ''.$ent['entPhysicalModelName'].''; + } + else if (is_numeric($ent['entPhysicalName']) && $ent['entPhysicalVendorType']) { + echo ''.$ent['entPhysicalName'].' '.$ent['entPhysicalVendorType'].''; + } + else if ($ent['entPhysicalName']) { + echo ''.$ent['entPhysicalName'].''; + } + else if ($ent['entPhysicalDescr']) { + echo ''.$ent['entPhysicalDescr'].''; + } - echo("
  • "); - } -} + if ($ent['entPhysicalClass'] == 'sensor') { + echo ' ('.$ent['entSensorValue'].' '.$ent['entSensorType'].')'; + } -echo("
    + echo "
    ".$ent['entPhysicalDescr']; + + if ($link) { + echo ''; + } + + if ($ent['entPhysicalSerialNum']) { + echo "
    Serial No. ".$ent['entPhysicalSerialNum'].' '; + } + + echo '
    '; + + $count = dbFetchCell("SELECT COUNT(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entPhysicalContainedIn = '".$ent['entPhysicalIndex']."'"); + if ($count) { + echo '
      '; + printEntPhysical($ent['entPhysicalIndex'], ($level + 1), ''); + echo '
    '; + } + + echo ''; + }//end foreach + +}//end printEntPhysical() + + +echo ""); +
    "; -echo("
      "); -$level = "0"; -$ent['entPhysicalIndex'] = "0"; -printEntPhysical($ent['entPhysicalIndex'], $level, "liOpen"); -echo("
    "); +echo "
      "; +$level = '0'; +$ent['entPhysicalIndex'] = '0'; +printEntPhysical($ent['entPhysicalIndex'], $level, 'liOpen'); +echo '
    '; -$pagetitle = "Inventory"; - -?> +$pagetitle = 'Inventory'; diff --git a/html/pages/device/graphs/cpu.inc.php b/html/pages/device/graphs/cpu.inc.php index e9b870bce..10b1086d0 100644 --- a/html/pages/device/graphs/cpu.inc.php +++ b/html/pages/device/graphs/cpu.inc.php @@ -1,11 +1,8 @@ diff --git a/html/pages/device/graphs/fortigate-sessions.inc.php b/html/pages/device/graphs/fortigate-sessions.inc.php index 6af7229bf..e0167873a 100644 --- a/html/pages/device/graphs/fortigate-sessions.inc.php +++ b/html/pages/device/graphs/fortigate-sessions.inc.php @@ -1,11 +1,8 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/hrprocesses.inc.php b/html/pages/device/graphs/hrprocesses.inc.php index 5e7eb9dd9..a90776b5f 100644 --- a/html/pages/device/graphs/hrprocesses.inc.php +++ b/html/pages/device/graphs/hrprocesses.inc.php @@ -1,11 +1,8 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/hrusers.inc.php b/html/pages/device/graphs/hrusers.inc.php index ff5acb4a4..8bb5fef3e 100644 --- a/html/pages/device/graphs/hrusers.inc.php +++ b/html/pages/device/graphs/hrusers.inc.php @@ -1,11 +1,8 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/ipSytemStats.inc.php b/html/pages/device/graphs/ipSytemStats.inc.php index 5666b5311..34873a3d1 100644 --- a/html/pages/device/graphs/ipSytemStats.inc.php +++ b/html/pages/device/graphs/ipSytemStats.inc.php @@ -1,24 +1,20 @@ diff --git a/html/pages/device/graphs/memory.inc.php b/html/pages/device/graphs/memory.inc.php index f4830a668..3b1f7a477 100644 --- a/html/pages/device/graphs/memory.inc.php +++ b/html/pages/device/graphs/memory.inc.php @@ -1,11 +1,8 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/netstats.inc.php b/html/pages/device/graphs/netstats.inc.php index 16b36750d..2e47aeb75 100644 --- a/html/pages/device/graphs/netstats.inc.php +++ b/html/pages/device/graphs/netstats.inc.php @@ -1,79 +1,70 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/netstats_icmp_info.inc.php b/html/pages/device/graphs/netstats_icmp_info.inc.php index 9e798d2c7..827b1694a 100644 --- a/html/pages/device/graphs/netstats_icmp_info.inc.php +++ b/html/pages/device/graphs/netstats_icmp_info.inc.php @@ -1,11 +1,8 @@ diff --git a/html/pages/device/graphs/netstats_icmp_stat.inc.php b/html/pages/device/graphs/netstats_icmp_stat.inc.php index ddb758b68..2ba52c4b1 100644 --- a/html/pages/device/graphs/netstats_icmp_stat.inc.php +++ b/html/pages/device/graphs/netstats_icmp_stat.inc.php @@ -1,11 +1,8 @@ diff --git a/html/pages/device/graphs/netstats_ip.inc.php b/html/pages/device/graphs/netstats_ip.inc.php index 516f5732b..46b5831e4 100644 --- a/html/pages/device/graphs/netstats_ip.inc.php +++ b/html/pages/device/graphs/netstats_ip.inc.php @@ -1,16 +1,13 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/netstats_snmp.inc.php b/html/pages/device/graphs/netstats_snmp.inc.php index 453b9a7b9..e8da71c5f 100644 --- a/html/pages/device/graphs/netstats_snmp.inc.php +++ b/html/pages/device/graphs/netstats_snmp.inc.php @@ -1,16 +1,13 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/netstats_tcp.inc.php b/html/pages/device/graphs/netstats_tcp.inc.php index fa4fa0575..686fc5193 100644 --- a/html/pages/device/graphs/netstats_tcp.inc.php +++ b/html/pages/device/graphs/netstats_tcp.inc.php @@ -1,11 +1,8 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/netstats_udp.inc.php b/html/pages/device/graphs/netstats_udp.inc.php index 2ef2d9603..5eb134e04 100644 --- a/html/pages/device/graphs/netstats_udp.inc.php +++ b/html/pages/device/graphs/netstats_udp.inc.php @@ -1,11 +1,8 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/screenos-sessions.inc.php b/html/pages/device/graphs/screenos-sessions.inc.php index 080c5b470..66e25a701 100644 --- a/html/pages/device/graphs/screenos-sessions.inc.php +++ b/html/pages/device/graphs/screenos-sessions.inc.php @@ -1,11 +1,8 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/screenos.inc.php b/html/pages/device/graphs/screenos.inc.php index 4cd4cdb19..8065e8c0c 100644 --- a/html/pages/device/graphs/screenos.inc.php +++ b/html/pages/device/graphs/screenos.inc.php @@ -1,11 +1,8 @@ \ No newline at end of file diff --git a/html/pages/device/graphs/uptime.inc.php b/html/pages/device/graphs/uptime.inc.php index c025b413c..0beb16403 100644 --- a/html/pages/device/graphs/uptime.inc.php +++ b/html/pages/device/graphs/uptime.inc.php @@ -1,8 +1,6 @@ \ No newline at end of file +require 'includes/print-device-graph.php'; diff --git a/html/pages/device/graphs/wireless.inc.php b/html/pages/device/graphs/wireless.inc.php index 98afa48d7..699b07d17 100644 --- a/html/pages/device/graphs/wireless.inc.php +++ b/html/pages/device/graphs/wireless.inc.php @@ -1,11 +1,8 @@ diff --git a/html/pages/device/health/dbm.inc.php b/html/pages/device/health/dbm.inc.php index 4d264d98f..7da8dc68a 100644 --- a/html/pages/device/health/dbm.inc.php +++ b/html/pages/device/health/dbm.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/diskio.inc.php b/html/pages/device/health/diskio.inc.php index 03e151662..dd425d273 100644 --- a/html/pages/device/health/diskio.inc.php +++ b/html/pages/device/health/diskio.inc.php @@ -1,51 +1,54 @@ '); - -#echo(" -# -# -# -# -# "); +echo '

    ' . nicecase($icon) . '

    '); -echo('


    '.nicecase($icon).'

    '; +echo '


    ' . nicecase($icon) . '

    '); - echo('


    '.nicecase($icon).'

    '; + echo '

    DriveUsageFree
    '; +// echo(" +// +// +// +// +// "); $row = 1; -foreach (dbFetchRows("SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr", array($device['device_id'])) as $drive) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } +foreach (dbFetchRows('SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr', array($device['device_id'])) as $drive) { + if (is_integer($row / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - $fs_url = "device/device=".$device['device_id']."/tab=health/metric=diskio/"; + $fs_url = 'device/device='.$device['device_id'].'/tab=health/metric=diskio/'; - $graph_array_zoom['id'] = $drive['diskio_id']; - $graph_array_zoom['type'] = "diskio_ops"; - $graph_array_zoom['width'] = "400"; - $graph_array_zoom['height'] = "125"; - $graph_array_zoom['from'] = $config['time']['twoday']; - $graph_array_zoom['to'] = $config['time']['now']; + $graph_array_zoom['id'] = $drive['diskio_id']; + $graph_array_zoom['type'] = 'diskio_ops'; + $graph_array_zoom['width'] = '400'; + $graph_array_zoom['height'] = '125'; + $graph_array_zoom['from'] = $config['time']['twoday']; + $graph_array_zoom['to'] = $config['time']['now']; - echo(""); + echo "'; - $types = array("diskio_bits", "diskio_ops"); + $types = array( + 'diskio_bits', + 'diskio_ops', + ); - foreach ($types as $graph_type) - { - echo('"); - } + echo ''; + } - $row++; + $row++; } -echo("
    DriveUsageFree
    "); - echo(overlib_link($fs_url, $drive['diskio_descr'], generate_graph_tag($graph_array_zoom), NULL)); - echo("
    "; + echo overlib_link($fs_url, $drive['diskio_descr'], generate_graph_tag($graph_array_zoom), null); + echo '
    '); + foreach ($types as $graph_type) { + echo '
    '; - $graph_array = array(); - $graph_array['id'] = $drive['diskio_id']; - $graph_array['type'] = $graph_type; + $graph_array = array(); + $graph_array['id'] = $drive['diskio_id']; + $graph_array['type'] = $graph_type; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    "); - -?> +echo ''; diff --git a/html/pages/device/health/fanspeed.inc.php b/html/pages/device/health/fanspeed.inc.php index accf2d896..62c385ebf 100644 --- a/html/pages/device/health/fanspeed.inc.php +++ b/html/pages/device/health/fanspeed.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/frequency.inc.php b/html/pages/device/health/frequency.inc.php index 4ad62f40d..280a76e49 100644 --- a/html/pages/device/health/frequency.inc.php +++ b/html/pages/device/health/frequency.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/power.inc.php b/html/pages/device/health/power.inc.php index ab246055e..e0354e564 100644 --- a/html/pages/device/health/power.inc.php +++ b/html/pages/device/health/power.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/sensors.inc.php b/html/pages/device/health/sensors.inc.php index 36f85bb59..7e38a58f9 100644 --- a/html/pages/device/health/sensors.inc.php +++ b/html/pages/device/health/sensors.inc.php @@ -1,32 +1,34 @@ "); +echo ''; $row = 1; -foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_descr`", array($class, $device['device_id'])) as $sensor) -{ - if (!is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } +foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_descr`', array($class, $device['device_id'])) as $sensor) { + if (!is_integer($row / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - echo(" - - - - - - \n"); - echo(" + + + + + + \n"; + echo ""); + echo ''; - $row++; + $row++; } -echo("
    " . $sensor['sensor_descr'] . "" . $sensor['sensor_type'] . "" . format_si($sensor['sensor_current']) .$unit. "" . format_si($sensor['sensor_limit']) . $unit . "" . format_si($sensor['sensor_limit_low']) . $unit ."
    "); + echo "
    ".$sensor['sensor_descr'].''.$sensor['sensor_type'].''.format_si($sensor['sensor_current']).$unit.''.format_si($sensor['sensor_limit']).$unit.''.format_si($sensor['sensor_limit_low']).$unit."
    "; - $graph_array['id'] = $sensor['sensor_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $sensor['sensor_id']; + $graph_array['type'] = $graph_type; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    "); - -?> +echo ''; diff --git a/html/pages/device/health/temperature.inc.php b/html/pages/device/health/temperature.inc.php index dd2c8878b..b13856f47 100644 --- a/html/pages/device/health/temperature.inc.php +++ b/html/pages/device/health/temperature.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/voltage.inc.php b/html/pages/device/health/voltage.inc.php index 900db5c18..6ff7cdb7b 100644 --- a/html/pages/device/health/voltage.inc.php +++ b/html/pages/device/health/voltage.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/latency.inc.php b/html/pages/device/latency.inc.php index 72f882be6..571916fc0 100644 --- a/html/pages/device/latency.inc.php +++ b/html/pages/device/latency.inc.php @@ -2,134 +2,123 @@ print_optionbar_start(); -echo("Latency » "); +echo "Latency » "; -if(count($smokeping_files['in'][$device['hostname']])) - $menu_options['incoming'] = 'Incoming'; +if (count($smokeping_files['in'][$device['hostname']])) { + $menu_options['incoming'] = 'Incoming'; +} -if(count($smokeping_files['out'][$device['hostname']])) - $menu_options['outgoing'] = 'Outgoing'; +if (count($smokeping_files['out'][$device['hostname']])) { + $menu_options['outgoing'] = 'Outgoing'; +} -$sep = ""; -foreach ($menu_options as $option => $text) -{ - if (!$vars['view']) { $vars['view'] = $option; } - echo($sep); - if ($vars['view'] == $option) - { - echo(""); - } - echo(generate_link($text,$vars,array('view'=>$option))); - if ($vars['view'] == $option) - { - echo(""); - } - $sep = " | "; +$sep = ''; +foreach ($menu_options as $option => $text) { + if (!$vars['view']) { + $vars['view'] = $option; + } + + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $vars, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); print_optionbar_end(); -echo(''); +echo '
    '; -if($vars['view'] == "incoming") -{ +if ($vars['view'] == 'incoming') { + if (count($smokeping_files['in'][$device['hostname']])) { + $graph_array['type'] = 'device_smokeping_in_all_avg'; + $graph_array['device'] = $device['device_id']; + echo ''; - include("includes/print-graphrow.inc.php"); + $graph_array['type'] = 'device_smokeping_in_all'; + $graph_array['legend'] = no; + echo ''); + include 'includes/print-graphrow.inc.php'; - $graph_array['type'] = "device_smokeping_in_all"; - $graph_array['legend'] = no; - echo(''; - include("includes/print-graphrow.inc.php"); + unset($graph_array['legend']); - echo(''); + ksort($smokeping_files['in'][$device['hostname']]); + foreach ($smokeping_files['in'][$device['hostname']] as $src => $host) { + $hostname = str_replace('.rrd', '', $host); + $host = device_by_name($src); + if (is_numeric($host['device_id'])) { + echo ''); - } - } - - } - -} elseif ($vars['view'] == "outgoing") { - - if (count($smokeping_files['out'][$device['hostname']])) - { - - $graph_array['type'] = "device_smokeping_out_all_avg"; - $graph_array['device'] = $device['device_id']; - echo(''); - - $graph_array['type'] = "device_smokeping_out_all"; - $graph_array['legend'] = no; - echo(''); - - unset($graph_array['legend']); - - asort($smokeping_files['out'][$device['hostname']]); - foreach ($smokeping_files['out'][$device['hostname']] AS $host) - { - $hostname = str_replace(".rrd", "", $host); - list($hostname) = explode("~", $hostname); - $host = device_by_name($hostname); - if (is_numeric($host['device_id'])) - { - echo(''); - } - } - - } + echo ''; + } + } + }//end if } +else if ($vars['view'] == 'outgoing') { + if (count($smokeping_files['out'][$device['hostname']])) { + $graph_array['type'] = 'device_smokeping_out_all_avg'; + $graph_array['device'] = $device['device_id']; + echo '
    '; + echo '

    Average

    '; - if (count($smokeping_files['in'][$device['hostname']])) - { + include 'includes/print-graphrow.inc.php'; - $graph_array['type'] = "device_smokeping_in_all_avg"; - $graph_array['device'] = $device['device_id']; - echo('
    '); - echo('

    Average

    '); + echo '
    '; + echo '

    Aggregate

    '; - echo('
    '); - echo('

    Aggregate

    '); + echo '
    '; + echo '

    '.generate_device_link($host).'

    '; + $graph_array['type'] = 'smokeping_in'; + $graph_array['device'] = $device['device_id']; + $graph_array['src'] = $host['device_id']; - unset($graph_array['legend']); + include 'includes/print-graphrow.inc.php'; - ksort($smokeping_files['in'][$device['hostname']]); - foreach ($smokeping_files['in'][$device['hostname']] AS $src => $host) - { - $hostname = str_replace(".rrd", "", $host); - $host = device_by_name($src); - if (is_numeric($host['device_id'])) - { - echo('
    '); - echo('

    '.generate_device_link($host).'

    '); - $graph_array['type'] = "smokeping_in"; - $graph_array['device'] = $device['device_id']; - $graph_array['src'] = $host['device_id']; - - include("includes/print-graphrow.inc.php"); - - echo('
    '); - echo('

    Aggregate

    '); - - include("includes/print-graphrow.inc.php"); - - echo('
    '); - echo('

    Aggregate

    '); - - include("includes/print-graphrow.inc.php"); - - echo('
    '); - echo('

    '.generate_device_link($host).'

    '); - $graph_array['type'] = "smokeping_out"; - $graph_array['device'] = $device['device_id']; - $graph_array['dest'] = $host['device_id']; - - include("includes/print-graphrow.inc.php"); - - echo('
    '; + echo '

    Aggregate

    '; -echo('
    '); + include 'includes/print-graphrow.inc.php'; -$pagetitle[] = "Latency"; + echo ''; -?> + $graph_array['type'] = 'device_smokeping_out_all'; + $graph_array['legend'] = no; + echo ''; + echo '

    Aggregate

    '; + + include 'includes/print-graphrow.inc.php'; + + echo ''; + + unset($graph_array['legend']); + + asort($smokeping_files['out'][$device['hostname']]); + foreach ($smokeping_files['out'][$device['hostname']] as $host) { + $hostname = str_replace('.rrd', '', $host); + list($hostname) = explode('~', $hostname); + $host = device_by_name($hostname); + if (is_numeric($host['device_id'])) { + echo ''; + echo '

    '.generate_device_link($host).'

    '; + $graph_array['type'] = 'smokeping_out'; + $graph_array['device'] = $device['device_id']; + $graph_array['dest'] = $host['device_id']; + + include 'includes/print-graphrow.inc.php'; + + echo ''; + } + } + }//end if +}//end if + +echo ''; + +$pagetitle[] = 'Latency'; diff --git a/html/pages/device/loadbalancer.inc.php b/html/pages/device/loadbalancer.inc.php index 26e96923c..ab624a873 100644 --- a/html/pages/device/loadbalancer.inc.php +++ b/html/pages/device/loadbalancer.inc.php @@ -1,70 +1,75 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'loadbalancer'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'loadbalancer', +); // Cisco ACE -$type_text['loadbalancer_rservers'] = "Rservers"; -$type_text['loadbalancer_vservers'] = "Serverfarms"; +$type_text['loadbalancer_rservers'] = 'Rservers'; +$type_text['loadbalancer_vservers'] = 'Serverfarms'; // Citrix Netscaler -$type_text['netscaler_vsvr'] = "VServers"; +$type_text['netscaler_vsvr'] = 'VServers'; print_optionbar_start(); -$pagetitle[] = "Load Balancer"; +$pagetitle[] = 'Load Balancer'; -echo("Load Balancer » "); +echo "Load Balancer » "; unset($sep); -foreach ($loadbalancer_tabs as $type) -{ +foreach ($loadbalancer_tabs as $type) { + if (!$vars['type']) { + $vars['type'] = $type; + } - if (!$vars['type']) { $vars['type'] = $type; } + echo $sep; - echo($sep); + if ($vars['type'] == $type) { + echo ''; + } - if ($vars['type'] == $type) - { - echo(''); - } + echo generate_link($type_text[$type].' ('.$device_loadbalancer_count[$type].')', $link_array, array('type' => $type)); + if ($vars['type'] == $type) { + echo ''; + } - echo(generate_link($type_text[$type] ." (".$device_loadbalancer_count[$type].")",$link_array,array('type'=>$type))); - if ($vars['type'] == $type) { echo(""); } - $sep = " | "; + $sep = ' | '; } print_optionbar_end(); -if (is_file("pages/device/loadbalancer/".mres($vars['type']).".inc.php")) -{ - include("pages/device/loadbalancer/".mres($vars['type']).".inc.php"); -} else { - foreach ($loadbalancer_tabs as $type) - { - if ($type != "overview") - { - if (is_file("pages/device/loadbalancer/overview/".mres($type).".inc.php")) { - - $g_i++; - if (!is_integer($g_i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - - echo('
    '); - echo('
    '.$type_text[$type].''); - - include("pages/device/loadbalancer/overview/".mres($type).".inc.php"); - - echo('
    '); - echo('
    '); - } else { - $graph_title = $type_text[$type]; - $graph_type = "device_".$type; - - include("includes/print-device-graph.php"); - } - } - } +if (is_file('pages/device/loadbalancer/'.mres($vars['type']).'.inc.php')) { + include 'pages/device/loadbalancer/'.mres($vars['type']).'.inc.php'; } +else { + foreach ($loadbalancer_tabs as $type) { + if ($type != 'overview') { + if (is_file('pages/device/loadbalancer/overview/'.mres($type).'.inc.php')) { + $g_i++; + if (!is_integer($g_i / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } -?> + echo '
    '; + echo '
    '.$type_text[$type].''; + + include 'pages/device/loadbalancer/overview/'.mres($type).'.inc.php'; + + echo '
    '; + echo '
    '; + } + else { + $graph_title = $type_text[$type]; + $graph_type = 'device_'.$type; + + include 'includes/print-device-graph.php'; + }//end if + }//end if + }//end foreach +}//end if diff --git a/html/pages/device/loadbalancer/ace_rservers.inc.php b/html/pages/device/loadbalancer/ace_rservers.inc.php index 08ee06c47..52f1773c7 100644 --- a/html/pages/device/loadbalancer/ace_rservers.inc.php +++ b/html/pages/device/loadbalancer/ace_rservers.inc.php @@ -2,90 +2,103 @@ print_optionbar_start(); -echo("Serverfarm Rservers » "); +echo "Serverfarm Rservers » "; -#$auth = TRUE; +// $auth = TRUE; +$menu_options = array('basic' => 'Basic'); -$menu_options = array('basic' => 'Basic', - ); +if (!$_GET['opta']) { + $_GET['opta'] = 'basic'; +} -if (!$_GET['opta']) { $_GET['opta'] = "basic"; } +$sep = ''; +foreach ($menu_options as $option => $text) { + if ($_GET['optd'] == $option) { + echo ""; + } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - if ($_GET['optd'] == $option) { echo(""); } - echo('' . $text - . ''); - if ($_GET['optd'] == $option) { echo(""); } - echo(" | "); + echo ''.$text .''; + if ($_GET['optd'] == $option) { + echo ''; + } + + echo ' | '; } unset($sep); -echo(' Graphs: '); +echo ' Graphs: '; -#$graph_types = array("bits" => "Bits", -# "pkts" => "Packets", -# "errors" => "Errors"); +// $graph_types = array("bits" => "Bits", +// "pkts" => "Packets", +// "errors" => "Errors"); +$graph_types = array( + 'curr' => 'CurrentConns', + 'failed' => 'FailedConns', + 'total' => 'TotalConns', + ); -$graph_types = array("curr" => "CurrentConns", - "failed" => "FailedConns", - "total" => "TotalConns"); +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($_GET['opte'] == $type) { + echo ""; + } -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($_GET['opte'] == $type) { echo(""); } - echo(''.$descr.''); - if ($_GET['opte'] == $type) { echo(""); } + echo ''.$descr.''; + if ($_GET['opte'] == $type) { + echo ''; + } - $type_sep = " | "; + $type_sep = ' | '; } print_optionbar_end(); -echo("
    "); -$i = "0"; -foreach (dbFetchRows("SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = ? ORDER BY `farm_id`", array($device['device_id'])) as $rserver) -{ -if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } +echo "
    "; +$i = '0'; +foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = ? ORDER BY `farm_id`', array($device['device_id'])) as $rserver) { + if (is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } -if($rserver['StateDescr'] == "Server is now operational") { $rserver_class="green"; } else { $rserver_class="red"; } + if ($rserver['StateDescr'] == 'Server is now operational') { + $rserver_class = 'green'; + } else { + $rserver_class = 'red'; + } -echo(""); -#echo(""); -echo(""); -#echo(""); -echo(""); -echo(""); - if ($_GET['optd'] == "graphs") - { - echo(''); - echo(""; + // echo(""); + echo ''; + // echo(""); + echo "'; + echo ''; + if ($_GET['optd'] == 'graphs') { + echo ''; + echo ' - "); - } + '; + } -echo(""); -echo(""); + echo ''; + echo ''; - $i++; + $i++; } -echo("
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "" . $rserver['farm_id'] . "" . $rserver['farm_id'] . "" . $rserver['StateDescr'] . "
    "); - $graph_type = "rserver_" . $_GET['opte']; + echo "
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "'.$rserver['farm_id'].'" . $rserver['farm_id'] . "".$rserver['StateDescr'].'
    '; + $graph_type = 'rserver_'.$_GET['opte']; -$graph_array['height'] = "100"; -$graph_array['width'] = "215"; -$graph_array['to'] = $config['time']['now']; -$graph_array['id'] = $rserver['rserver_id']; -$graph_array['type'] = $graph_type; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $rserver['rserver_id']; + $graph_array['type'] = $graph_type; -include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; -#include("includes/print-interface-graphs.inc.php"); - - echo(" + // include("includes/print-interface-graphs.inc.php"); + echo '
    "); - -?> +echo ''; diff --git a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php index aaaa437a8..a67d755b9 100644 --- a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php +++ b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php @@ -1,141 +1,164 @@ VServer » "); + // echo('All'); + // print_optionbar_end(); + $graph_types = array( + 'bits' => 'Bits', + 'pkts' => 'Packets', + 'conns' => 'Connections', + 'reqs' => 'Requests', + 'hitmiss' => 'Hit/Miss', + ); -#print_optionbar_start(); -#echo("VServer » "); -#echo('All'); -#print_optionbar_end(); + $i = 0; -$graph_types = array("bits" => "Bits", - "pkts" => "Packets", - "conns" => "Connections", - "reqs" => "Requests", - "hitmiss" => "Hit/Miss"); + echo "
    "; + foreach (dbFetchRows('SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? AND `vsvr_id` = ? ORDER BY `vsvr_name`', array($device['device_id'], $vars['vsvr'])) as $vsvr) { + if (is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } -$i=0; + if ($vsvr['vsvr_state'] == 'up') { + $vsvr_class = 'green'; + } + else { + $vsvr_class = 'red'; + } -echo("
    "); -foreach (dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? AND `vsvr_id` = ? ORDER BY `vsvr_name`", array($device['device_id'], $vars['vsvr'])) as $vsvr) -{ + echo ""; + echo ''; + echo ''; + echo "'; + echo (''); + echo (''); + echo ''; - if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } + foreach ($graph_types as $graph_type => $graph_text) { + $i++; + echo ''; + echo '"); - echo(''); - echo(""); - echo(""); - echo(""); - echo(""); - echo(""); + include 'includes/print-graphrow.inc.php'; - foreach ($graph_types as $graph_type => $graph_text) - { - $i++; - echo(''); - echo(' - "); - } + '; + } + }//end foreach + + echo '
    '.$vsvr['vsvr_name'].''.$vsvr['vsvr_ip'].':'.$vsvr['vsvr_port'].'".$vsvr['vsvr_state'].''.format_si(($vsvr['vsvr_bps_in'] * 8)).'bps'.format_si(($vsvr['vsvr_bps_out'] * 8)).'bps
    '; + $graph_type = 'netscalervsvr_'.$graph_type; + $graph_array['height'] = '100'; + $graph_array['width'] = '213'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $vsvr['vsvr_id']; + $graph_array['type'] = $graph_type; - if ($vsvr['vsvr_state'] == "up") { $vsvr_class="green"; } else { $vsvr_class="red"; } + echo '

    '.$graph_text.'

    '; - echo("
    ' . $vsvr['vsvr_name'] . '" . $vsvr['vsvr_ip'] . ":" . $vsvr['vsvr_port'] . "" . $vsvr['vsvr_state'] . "" . format_si($vsvr['vsvr_bps_in']*8) . "bps" . format_si($vsvr['vsvr_bps_out']*8) . "bps
    '); - $graph_type = "netscalervsvr_" . $graph_type; - $graph_array['height'] = "100"; - $graph_array['width'] = "213"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $vsvr['vsvr_id']; - $graph_array['type'] = $graph_type; - - echo('

    '.$graph_text.'

    '); - - include("includes/print-graphrow.inc.php"); - - echo(" + echo '
    '; } +else { + print_optionbar_start(); -echo(""); + echo "VServers » "; -} else { + $menu_options = array('basic' => 'Basic'); -print_optionbar_start(); + if (!$vars['view']) { + $vars['view'] = 'basic'; + } -echo("VServers » "); + $sep = ''; + foreach ($menu_options as $option => $text) { + if ($vars['view'] == $option) { + echo ""; + } -$menu_options = array('basic' => 'Basic', - ); + echo ''.$text.''; + if ($vars['view'] == $option) { + echo ''; + } -if (!$vars['view']) { $vars['view'] = "basic"; } + echo ' | '; + } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - if ($vars['view'] == $option) { echo(""); } - echo(''.$text.''); - if ($vars['view'] == $option) { echo(""); } - echo(" | "); -} + unset($sep); + echo ' Graphs: '; + $graph_types = array( + 'bits' => 'Bits', + 'pkts' => 'Packets', + 'conns' => 'Connections', + 'reqs' => 'Requests', + 'hitmiss' => 'Hit/Miss', + ); -unset($sep); -echo(' Graphs: '); -$graph_types = array("bits" => "Bits", - "pkts" => "Packets", - "conns" => "Connections", - "reqs" => "Requests", - "hitmiss" => "Hit/Miss"); + foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($vars['graph'] == $type) { + echo ""; + } -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($vars['graph'] == $type) { echo(""); } - echo(''.$descr.''); - if ($vars['graph'] == $type) { echo(""); } - $type_sep = " | "; -} + echo ''.$descr.''; + if ($vars['graph'] == $type) { + echo ''; + } -print_optionbar_end(); + $type_sep = ' | '; + } -echo("
    "); -$i = "0"; -foreach (dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_name`", array($device['device_id'])) as $vsvr) -{ - if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } + print_optionbar_end(); - if ($vsvr['vsvr_state'] == "up") { $vsvr_class="green"; } else { $vsvr_class="red"; } + echo "
    "; + $i = '0'; + foreach (dbFetchRows('SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_name`', array($device['device_id'])) as $vsvr) { + if (is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } - echo(""); - echo(''); - echo(""); - echo(""); - echo(""); - echo(""); - echo(""); - if ($vars['view'] == "graphs") - { - echo(''); - echo('"; + echo ''; + echo ''; + echo "'; + echo (''); + echo (''); + echo ''; + if ($vars['view'] == 'graphs') { + echo ''; + echo ' - "); - } + '; + } -echo(""); -echo(""); + echo ''; + echo ''; - $i++; -} + $i++; + }//end foreach -echo("
    ' . $vsvr['vsvr_name'] . '" . $vsvr['vsvr_ip'] . ":" . $vsvr['vsvr_port'] . "" . $vsvr['vsvr_state'] . "" . format_si($vsvr['vsvr_bps_in']*8) . "bps" . format_si($vsvr['vsvr_bps_out']*8) . "bps
    '); - $graph_type = "netscalervsvr_" . $vars['graph']; - $graph_array['height'] = "100"; - $graph_array['width'] = "213"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $vsvr['vsvr_id']; - $graph_array['type'] = $graph_type; + if ($vsvr['vsvr_state'] == 'up') { + $vsvr_class = 'green'; + } + else { + $vsvr_class = 'red'; + } - include("includes/print-graphrow.inc.php"); + echo "
    '.$vsvr['vsvr_name'].''.$vsvr['vsvr_ip'].':'.$vsvr['vsvr_port'].'".$vsvr['vsvr_state'].''.format_si(($vsvr['vsvr_bps_in'] * 8)).'bps'.format_si(($vsvr['vsvr_bps_out'] * 8)).'bps
    '; + $graph_type = 'netscalervsvr_'.$vars['graph']; + $graph_array['height'] = '100'; + $graph_array['width'] = '213'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $vsvr['vsvr_id']; + $graph_array['type'] = $graph_type; - echo(" + include 'includes/print-graphrow.inc.php'; + + echo '
    "); - -} - -?> + echo ''; +}//end if diff --git a/html/pages/device/nfsen.inc.php b/html/pages/device/nfsen.inc.php index d3552efd5..53e3c1ef4 100644 --- a/html/pages/device/nfsen.inc.php +++ b/html/pages/device/nfsen.inc.php @@ -1,19 +1,16 @@ 'nfsen_flows', - 'Packets' => 'nfsen_packets', - 'Traffic' => 'nfsen_traffic' -); + 'Flows' => 'nfsen_flows', + 'Packets' => 'nfsen_packets', + 'Traffic' => 'nfsen_traffic', + ); -foreach ($datas as $name=>$type) -{ - $graph_title = $name; - $graph_type = "device_".$type; +foreach ($datas as $name => $type) { + $graph_title = $name; + $graph_type = 'device_'.$type; - include("includes/print-device-graph.php"); + include 'includes/print-device-graph.php'; } -$pagetitle[] = "Netflow"; - -?> +$pagetitle[] = 'Netflow'; diff --git a/html/pages/device/overview/sensors/dbm.inc.php b/html/pages/device/overview/sensors/dbm.inc.php index 81646d32c..dab9874c2 100644 --- a/html/pages/device/overview/sensors/dbm.inc.php +++ b/html/pages/device/overview/sensors/dbm.inc.php @@ -1,10 +1,8 @@ +require 'pages/device/overview/generic/sensor.inc.php'; diff --git a/html/pages/device/overview/sensors/fanspeeds.inc.php b/html/pages/device/overview/sensors/fanspeeds.inc.php index 5e522f4bc..f044edcbf 100644 --- a/html/pages/device/overview/sensors/fanspeeds.inc.php +++ b/html/pages/device/overview/sensors/fanspeeds.inc.php @@ -1,10 +1,8 @@ +require 'pages/device/overview/generic/sensor.inc.php'; diff --git a/html/pages/device/overview/sensors/frequencies.inc.php b/html/pages/device/overview/sensors/frequencies.inc.php index 077e51bb9..b49adbe28 100644 --- a/html/pages/device/overview/sensors/frequencies.inc.php +++ b/html/pages/device/overview/sensors/frequencies.inc.php @@ -1,10 +1,8 @@ +require 'pages/device/overview/generic/sensor.inc.php'; diff --git a/html/pages/device/overview/sensors/power.inc.php b/html/pages/device/overview/sensors/power.inc.php index 7bd262b7f..98a026d15 100644 --- a/html/pages/device/overview/sensors/power.inc.php +++ b/html/pages/device/overview/sensors/power.inc.php @@ -1,10 +1,8 @@ +require 'pages/device/overview/generic/sensor.inc.php'; diff --git a/html/pages/device/overview/sensors/temperatures.inc.php b/html/pages/device/overview/sensors/temperatures.inc.php index 111d046ab..c198f37c8 100644 --- a/html/pages/device/overview/sensors/temperatures.inc.php +++ b/html/pages/device/overview/sensors/temperatures.inc.php @@ -1,10 +1,8 @@ +require 'pages/device/overview/generic/sensor.inc.php'; diff --git a/html/pages/device/overview/sensors/voltages.inc.php b/html/pages/device/overview/sensors/voltages.inc.php index 11d40ccc3..69afcb1c6 100644 --- a/html/pages/device/overview/sensors/voltages.inc.php +++ b/html/pages/device/overview/sensors/voltages.inc.php @@ -1,10 +1,8 @@ +require 'pages/device/overview/generic/sensor.inc.php'; diff --git a/html/pages/device/packages.inc.php b/html/pages/device/packages.inc.php index db517b438..20cd7ff91 100644 --- a/html/pages/device/packages.inc.php +++ b/html/pages/device/packages.inc.php @@ -1,22 +1,25 @@ '); +echo ''; -$i=0; -foreach (dbFetchRows("SELECT * FROM `packages` WHERE `device_id` = ? ORDER BY `name`", array($device['device_id'])) as $entry) -{ - echo(''); - echo(''); - if ($build != '') { $dbuild = '-'.$entry['build']; } else { $dbuild = ''; } - echo(""); - echo(""); - echo(""); - echo(""); - echo(""); +$i = 0; +foreach (dbFetchRows('SELECT * FROM `packages` WHERE `device_id` = ? ORDER BY `name`', array($device['device_id'])) as $entry) { + echo ''; + echo ''; + if ($build != '') { + $dbuild = '-'.$entry['build']; + } + else { + $dbuild = ''; + } - $i++; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $i++; } -echo("
    '.$entry['name'].'".$entry['version'].$dbuild."".$entry['arch']."".$entry['manager']."".format_si($entry['size'])."
    '.$entry['name'].''.$entry['version'].$dbuild.''.$entry['arch'].''.$entry['manager'].''.format_si($entry['size']).'
    "); - -?> +echo ''; diff --git a/html/pages/device/port/adsl.inc.php b/html/pages/device/port/adsl.inc.php index 44813e685..170f2a2c5 100644 --- a/html/pages/device/port/adsl.inc.php +++ b/html/pages/device/port/adsl.inc.php @@ -1,27 +1,24 @@ ADSL Line Speed"); - $graph_type = "port_adsl_speed"; +if (file_exists($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-adsl.rrd')) { + $iid = $id; + echo '
    ADSL Line Speed
    '; + $graph_type = 'port_adsl_speed'; - include("includes/print-interface-graphs.inc.php"); + include 'includes/print-interface-graphs.inc.php'; - echo("
    ADSL Line Attenuation
    "); - $graph_type = "port_adsl_attenuation"; + echo '
    ADSL Line Attenuation
    '; + $graph_type = 'port_adsl_attenuation'; - include("includes/print-interface-graphs.inc.php"); + include 'includes/print-interface-graphs.inc.php'; - echo("
    ADSL Line SNR Margin
    "); - $graph_type = "port_adsl_snr"; + echo '
    ADSL Line SNR Margin
    '; + $graph_type = 'port_adsl_snr'; - include("includes/print-interface-graphs.inc.php"); + include 'includes/print-interface-graphs.inc.php'; - echo("
    ADSL Output Powers
    "); - $graph_type = "port_adsl_power"; + echo '
    ADSL Output Powers
    '; + $graph_type = 'port_adsl_power'; - include("includes/print-interface-graphs.inc.php"); + include 'includes/print-interface-graphs.inc.php'; } - -?> diff --git a/html/pages/device/port/arp.inc.php b/html/pages/device/port/arp.inc.php index f9898a363..821787543 100644 --- a/html/pages/device/port/arp.inc.php +++ b/html/pages/device/port/arp.inc.php @@ -1,29 +1,48 @@ '); -$i = "1"; +echo ''; +$i = '1'; -foreach (dbFetchRows("SELECT * FROM ipv4_mac WHERE port_id = ?", array($port['port_id'])) as $arp) -{ - if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($arp['ipv4_address'])); +foreach (dbFetchRows('SELECT * FROM ipv4_mac WHERE port_id = ?', array($port['port_id'])) as $arp) { + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } - if ($arp_host) { $arp_name = generate_device_link($arp_host); } else { unset($arp_name); } - if ($arp_host) { $arp_if = generate_port_link($arp_host); } else { unset($arp_if); } + $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($arp['ipv4_address'])); - if ($arp_host['device_id'] == $device['device_id']) { $arp_name = "Localhost"; } - if ($arp_host['port_id'] == $arp['port_id']) { $arp_if = "Local Port"; } + if ($arp_host) { + $arp_name = generate_device_link($arp_host); + } + else { + unset($arp_name); + } - echo(' - + if ($arp_host) { + $arp_if = generate_port_link($arp_host); + } + else { + unset($arp_if); + } + + if ($arp_host['device_id'] == $device['device_id']) { + $arp_name = 'Localhost'; + } + + if ($arp_host['port_id'] == $arp['port_id']) { + $arp_if = 'Local Port'; + } + + echo ' + - '); - $i++; -} + '; + $i++; +}//end foreach -echo('
    '.formatmac($arp['mac_address']).' '.$arp['ipv4_address'].' '.$arp_name.' '.$arp_if.'
    '); - -?> +echo ''; diff --git a/html/pages/device/port/graphs.inc.php b/html/pages/device/port/graphs.inc.php index 8a38915f3..a323197de 100644 --- a/html/pages/device/port/graphs.inc.php +++ b/html/pages/device/port/graphs.inc.php @@ -1,35 +1,31 @@ Interface Traffic"); - $graph_type = "port_bits"; +if (file_exists($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'.rrd')) { + $iid = $id; + echo '
    Interface Traffic
    '; + $graph_type = 'port_bits'; - include("includes/print-interface-graphs.inc.php"); + include 'includes/print-interface-graphs.inc.php'; - echo("
    Interface Packets
    "); - $graph_type = "port_upkts"; + echo '
    Interface Packets
    '; + $graph_type = 'port_upkts'; - include("includes/print-interface-graphs.inc.php"); + include 'includes/print-interface-graphs.inc.php'; - echo("
    Interface Non Unicast
    "); - $graph_type = "port_nupkts"; + echo '
    Interface Non Unicast
    '; + $graph_type = 'port_nupkts'; - include("includes/print-interface-graphs.inc.php"); + include 'includes/print-interface-graphs.inc.php'; - echo("
    Interface Errors
    "); - $graph_type = "port_errors"; + echo '
    Interface Errors
    '; + $graph_type = 'port_errors'; - include("includes/print-interface-graphs.inc.php"); + include 'includes/print-interface-graphs.inc.php'; - if (is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . $port['ifIndex'] . "-dot3.rrd")) - { - echo("
    Ethernet Errors
    "); - $graph_type = "port_etherlike"; + if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-dot3.rrd')) { + echo '
    Ethernet Errors
    '; + $graph_type = 'port_etherlike'; - include("includes/print-interface-graphs.inc.php"); - } + include 'includes/print-interface-graphs.inc.php'; + } } - -?> diff --git a/html/pages/device/port/junose-atm-vp.inc.php b/html/pages/device/port/junose-atm-vp.inc.php index 0c57c75d6..70ea47d54 100644 --- a/html/pages/device/port/junose-atm-vp.inc.php +++ b/html/pages/device/port/junose-atm-vp.inc.php @@ -2,40 +2,54 @@ $row = 0; -if ($_GET['optc']) { $graph_type = "atmvp_".$_GET['optc']; } -if (!$graph_type) { $graph_type = "atmvp_bits"; } - -echo(''); - -foreach (dbFetchRows("SELECT * FROM juniAtmVp WHERE port_id = ?", array($interface['port_id'])) as $vp) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - echo(''); - echo(''); - echo(''); - - $graph_array['height'] = "100"; - $graph_array['width'] = "214"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $vp['juniAtmVp_id']; - $graph_array['type'] = $graph_type; - - $periods = array('day', 'week', 'month', 'year'); - - echo(''); - - $row++; +if ($_GET['optc']) { + $graph_type = 'atmvp_'.$_GET['optc']; } -echo('
    '.$row.'. VP'.$vp['vp_id'].' '.$vp['vp_descr'].'
    '); - - foreach ($periods as $period) - { - $graph_array['from'] = $$period; - $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; - echo(overlib_link("#", generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); - } - - echo('
    '); +if (!$graph_type) { + $graph_type = 'atmvp_bits'; +} -?> +echo ''; + +foreach (dbFetchRows('SELECT * FROM juniAtmVp WHERE port_id = ?', array($interface['port_id'])) as $vp) { + if (is_integer($row / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } + + echo ''; + echo ''; + echo ''; + + $graph_array['height'] = '100'; + $graph_array['width'] = '214'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $vp['juniAtmVp_id']; + $graph_array['type'] = $graph_type; + + $periods = array( + 'day', + 'week', + 'month', + 'year', + ); + + echo ''; + + $row++; +}//end foreach + +echo '
    '.$row.'. VP'.$vp['vp_id'].' '.$vp['vp_descr'].'
    '; + + foreach ($periods as $period) { + $graph_array['from'] = $$period; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; + echo overlib_link('#', generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + } + + echo '
    '; diff --git a/html/pages/device/port/macaccounting.inc.php b/html/pages/device/port/macaccounting.inc.php index 29b4ad148..e82861c31 100644 --- a/html/pages/device/port/macaccounting.inc.php +++ b/html/pages/device/port/macaccounting.inc.php @@ -1,196 +1,218 @@ Disabled"; } -if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } -if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } +$color = 'black'; +if ($port['ifAdminStatus'] == 'down') { + $status = "Disabled"; +} -$i = 1; +if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { + $status = "Enabled / Disconnected"; +} + +if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { + $status = "Enabled / Connected"; +} + +$i = 1; $inf = fixifName($ifname); -echo("
    "); +echo "
    "; -if ($vars['subview'] == "top10") -{ +if ($vars['subview'] == 'top10') { + if (!isset($vars['sort'])) { + $vars['sort'] = 'in'; + } - if (!isset($vars['sort'])) { $vars['sort'] = "in"; } - if (!isset($vars['period'])) { $vars['period'] = "1day"; } - $from = "-" . $vars['period']; + if (!isset($vars['period'])) { + $vars['period'] = '1day'; + } - echo("
    + $from = '-'.$vars['period']; + + echo "
    - +
    -"); - unset($query); - } - else - { +"; + unset($query); +} +else { + $query = 'SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) as bps FROM `mac_accounting` AS M, + `ports` AS I, `devices` AS D WHERE M.port_id = ? AND I.port_id = M.port_id AND I.device_id = D.device_id ORDER BY bps DESC'; + $param = array($port['port_id']); - $query = "SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) as bps FROM `mac_accounting` AS M, - `ports` AS I, `devices` AS D WHERE M.port_id = ? AND I.port_id = M.port_id AND I.device_id = D.device_id ORDER BY bps DESC"; - $param = array($port['port_id']); + foreach (dbFetchRows($query, $param) as $acc) { + if (!is_integer($i / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - foreach (dbFetchRows($query, $param) as $acc) - { - if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - $addy = dbFetchRow("SELECT * FROM ipv4_mac where mac_address = ?", array($acc['mac'])); - #$name = gethostbyaddr($addy['ipv4_address']); FIXME - Maybe some caching for this? - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($addy['ipv4_address'])); - if ($arp_host) { $arp_name = generate_device_link($arp_host); $arp_name .= " ".generate_port_link($arp_host); } else { unset($arp_if); } + $addy = dbFetchRow('SELECT * FROM ipv4_mac where mac_address = ?', array($acc['mac'])); + // $name = gethostbyaddr($addy['ipv4_address']); FIXME - Maybe some caching for this? + $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($addy['ipv4_address'])); + if ($arp_host) { + $arp_name = generate_device_link($arp_host); + $arp_name .= ' '.generate_port_link($arp_host); + } + else { + unset($arp_if); + } - if ($name == $addy['ipv4_address']) { unset ($name); } - if (dbFetchCell("SELECT count(*) FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($acc['device_id'], $addy['ipv4_address']))) - { - $peer_info = dbFetchRow("SELECT * FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($acc['device_id'], $addy['ipv4_address'])); - } else { unset ($peer_info); } + if ($name == $addy['ipv4_address']) { + unset($name); + } - if ($peer_info) - { - $asn = "AS".$peer_info['bgpPeerRemoteAs']; $astext = $peer_info['astext']; - } else { - unset ($as); unset ($astext); unset($asn); - } + if (dbFetchCell('SELECT count(*) FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?', array($acc['device_id'], $addy['ipv4_address']))) { + $peer_info = dbFetchRow('SELECT * FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?', array($acc['device_id'], $addy['ipv4_address'])); + } + else { + unset($peer_info); + } - if ($vars['graph']) - { - $graph_type = "macaccounting_" . $vars['graph']; - } else { - $graph_type = "macaccounting_bits"; - } + if ($peer_info) { + $asn = 'AS'.$peer_info['bgpPeerRemoteAs']; + $astext = $peer_info['astext']; + } + else { + unset($as); + unset($astext); + unset($asn); + } - if ($vars['subview'] == "minigraphs") - { - if (!$asn) { $asn = "No Session"; } + if ($vars['graph']) { + $graph_type = 'macaccounting_'.$vars['graph']; + } + else { + $graph_type = 'macaccounting_bits'; + } - echo("
    - ".$addy['ipv4_address']." - ".$asn." + if ($vars['subview'] == 'minigraphs') { + if (!$asn) { + $asn = 'No Session'; + } + + echo "
    + ".$addy['ipv4_address'].' - '.$asn." ".$name." - ".$addy['ipv4_address']." - ".$asn."
    \ - \ +
    ".$name.' - '.$addy['ipv4_address'].' - '.$asn."
    \ + \ ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" > -
    + - ".$name." -
    "); + ".$name.' +
    '; + } + else { + echo "
    "; - } - else - { - echo("
    "); - - echo(" + echo (' - - - - - + + + + +
    ".mac_clean_to_readable($acc['mac'])."".$addy['ipv4_address']."".$name." ".$arp_name . "".formatRates($acc['cipMacHCSwitchedBytes_input_rate'] / 8)."".formatRates($acc['cipMacHCSwitchedBytes_output_rate'] / 8)."'.mac_clean_to_readable($acc['mac']).''.$addy['ipv4_address'].''.$name.' '.$arp_name.''.formatRates(($acc['cipMacHCSwitchedBytes_input_rate'] / 8)).''.formatRates(($acc['cipMacHCSwitchedBytes_output_rate'] / 8)).'
    - "); + '); - $peer_info['astext']; + $peer_info['astext']; - $graph_array['type'] = $graph_type; - $graph_array['id'] = $acc['ma_id']; - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - echo(''); + $graph_array['type'] = $graph_type; + $graph_array['id'] = $acc['ma_id']; + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + echo ''; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(""); + echo ''; - $i++; - } - } -} - -?> + $i++; + }//end if + }//end foreach +}//end if diff --git a/html/pages/device/port/realtime.inc.php b/html/pages/device/port/realtime.inc.php index 28585faca..41311917f 100644 --- a/html/pages/device/port/realtime.inc.php +++ b/html/pages/device/port/realtime.inc.php @@ -1,26 +1,31 @@ "); } - echo(generate_link($interval."s",$link_array,array('view'=>'realtime','interval'=>$interval))); - if ($vars['interval'] == $interval) { echo(""); } - $thinger = " | "; +foreach (array(0.25, 1, 2, 5, 15, 60) as $interval) { + echo $thinger; + if ($vars['interval'] == $interval) { + echo ""; + } + + echo generate_link($interval.'s', $link_array, array('view' => 'realtime', 'interval' => $interval)); + if ($vars['interval'] == $interval) { + echo ''; + } + + $thinger = ' | '; } print_optionbar_end(); @@ -28,8 +33,8 @@ print_optionbar_end(); ?>
    - - + + Your browser does not support the type SVG! You need to either use Firefox or download the Adobe SVG plugin. diff --git a/html/pages/device/port/vlans.inc.php b/html/pages/device/port/vlans.inc.php index d96071c6a..d36139ddf 100644 --- a/html/pages/device/port/vlans.inc.php +++ b/html/pages/device/port/vlans.inc.php @@ -2,49 +2,63 @@ $vlans = dbFetchRows("SELECT * FROM `ports_vlans` AS PV, vlans AS V WHERE PV.`port_id` = '".$port['port_id']."' and PV.`device_id` = '".$device['device_id']."' AND V.`vlan_vlan` = PV.vlan AND V.device_id = PV.device_id"); -echo(''); +echo '
    '; -echo(""); +echo ''; -$row=0; -foreach ($vlans as $vlan) -{ - $row++; - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - echo(''); +$row = 0; +foreach ($vlans as $vlan) { + $row++; + if (is_integer($row / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - echo(""); - echo(""); + echo ''; - if ($vlan['state'] == "blocking") { $class="red"; } elseif ($vlan['state'] == "forwarding" ) { $class="green"; } else { $class = "none"; } + echo ''; + echo ''; - echo(""); + if ($vlan['state'] == 'blocking') { + $class = 'red'; + } + else if ($vlan['state'] == 'forwarding') { + $class = 'green'; + } + else { + $class = 'none'; + } - $vlan_ports = array(); - $otherports = dbFetchRows("SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id", array($device['device_id'], $vlan['vlan'])); - foreach ($otherports as $otherport) - { - $vlan_ports[$otherport[ifIndex]] = $otherport; - } - $otherports = dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?", array($device['device_id'], $vlan['vlan'])); - foreach ($otherports as $otherport) - { - $vlan_ports[$otherport[ifIndex]] = array_merge($otherport, array('untagged' => '1')); - } - ksort($vlan_ports); + echo ''; - echo(""); - echo(""); -} + $vlan_ports = array(); + $otherports = dbFetchRows('SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id', array($device['device_id'], $vlan['vlan'])); + foreach ($otherports as $otherport) { + $vlan_ports[$otherport[ifIndex]] = $otherport; + } -echo("
    VLANDescriptionCostPriorityStateOther Ports
    VLANDescriptionCostPriorityStateOther Ports
    Vlan " . $vlan['vlan'] . "" . $vlan['vlan_descr'] . "
    Vlan '.$vlan['vlan'].''.$vlan['vlan_descr'].'".$vlan['cost']."".$vlan['priority']."".$vlan['state']."'.$vlan['cost'].''.$vlan['priority']."".$vlan['state'].'"); - $vsep=''; - foreach ($vlan_ports as $otherport) - { - echo($vsep.generate_port_link($otherport, makeshortif($otherport['ifDescr']))); - if ($otherport['untagged']) { echo("(U)"); } - $vsep=", "; - } - echo("
    "); + $otherports = dbFetchRows('SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?', array($device['device_id'], $vlan['vlan'])); + foreach ($otherports as $otherport) { + $vlan_ports[$otherport[ifIndex]] = array_merge($otherport, array('untagged' => '1')); + } -?> + ksort($vlan_ports); + + echo ''; + $vsep = ''; + foreach ($vlan_ports as $otherport) { + echo $vsep.generate_port_link($otherport, makeshortif($otherport['ifDescr'])); + if ($otherport['untagged']) { + echo '(U)'; + } + + $vsep = ', '; + } + + echo ''; + echo ''; +}//end foreach + +echo ''; diff --git a/html/pages/device/ports/adsl.inc.php b/html/pages/device/ports/adsl.inc.php index cb75fa4df..ba19fae99 100644 --- a/html/pages/device/ports/adsl.inc.php +++ b/html/pages/device/ports/adsl.inc.php @@ -1,17 +1,15 @@ "); +echo "
    "; - echo(""); - $i = "0"; - $ports = dbFetchRows("select * from `ports` AS P, `ports_adsl` AS A WHERE P.device_id = ? AND A.port_id = P.port_id AND P.deleted = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); - foreach ($ports as $port) - { - include("includes/print-interface-adsl.inc.php"); +echo ''; +$i = '0'; +$ports = dbFetchRows("select * from `ports` AS P, `ports_adsl` AS A WHERE P.device_id = ? AND A.port_id = P.port_id AND P.deleted = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); - $i++; - } - echo("
    PortTrafficSync SpeedAttainable SpeedAttenuationSNR MarginOutput Powers
    PortTrafficSync SpeedAttainable SpeedAttenuationSNR MarginOutput Powers
    "); - echo("
    "); +foreach ($ports as $port) { + include 'includes/print-interface-adsl.inc.php'; + $i++; +} -?> +echo ''; +echo "
    "; diff --git a/html/pages/device/ports/arp.inc.php b/html/pages/device/ports/arp.inc.php index e4a9b19d2..20417201c 100644 --- a/html/pages/device/ports/arp.inc.php +++ b/html/pages/device/ports/arp.inc.php @@ -1,33 +1,51 @@ '); -echo('PortMAC addressIPv4 addressRemote deviceRemote port'); +echo ''; +echo ''; -$i = "1"; +$i = '1'; -foreach (dbFetchRows("SELECT * FROM ipv4_mac AS M, ports AS I WHERE I.port_id = M.port_id AND I.device_id = ?", array($device['device_id'])) as $arp) -{ - if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } +foreach (dbFetchRows('SELECT * FROM ipv4_mac AS M, ports AS I WHERE I.port_id = M.port_id AND I.device_id = ?', array($device['device_id'])) as $arp) { + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($arp['ipv4_address'])); + $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($arp['ipv4_address'])); - if ($arp_host) { $arp_name = generate_device_link($arp_host); } else { unset($arp_name); } - if ($arp_host) { $arp_if = generate_port_link($arp_host); } else { unset($arp_if); } + if ($arp_host) { + $arp_name = generate_device_link($arp_host); + } + else { + unset($arp_name); + } - if ($arp_host['device_id'] == $device['device_id']) { $arp_name = "Localhost"; } - if ($arp_host['port_id'] == $arp['port_id']) { $arp_if = "Local Port"; } + if ($arp_host) { + $arp_if = generate_port_link($arp_host); + } + else { + unset($arp_if); + } - echo(" + if ($arp_host['device_id'] == $device['device_id']) { + $arp_name = 'Localhost'; + } + + if ($arp_host['port_id'] == $arp['port_id']) { + $arp_if = 'Local Port'; + } + + echo " - - - + + + - "); - $i++; -} + "; + $i++; +}//end foreach -echo("
    PortMAC addressIPv4 addressRemote deviceRemote port
    ".generate_port_link(array_merge($arp, $device))."".formatmac($arp['mac_address'])."".$arp['ipv4_address']."".generate_port_link(array_merge($arp, $device)).''.formatmac($arp['mac_address']).''.$arp['ipv4_address']." $arp_name $arp_if
    "); - -?> +echo ''; diff --git a/html/pages/device/ports/neighbours.inc.php b/html/pages/device/ports/neighbours.inc.php index 02a5091dd..5e417eb99 100644 --- a/html/pages/device/ports/neighbours.inc.php +++ b/html/pages/device/ports/neighbours.inc.php @@ -1,39 +1,42 @@ '); +echo ''; -$i = "1"; +$i = '1'; -echo(' +echo ' - '); + '; -foreach (dbFetchRows("SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id", array($device['device_id'])) as $neighbour) +foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) { + if ($bg_colour == $list_colour_b) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } - if ($bg_colour == $list_colour_b) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } + echo ''; + echo ''; - echo(''); - echo(''); + if (is_numeric($neighbour['remote_port_id']) && $neighbour['remote_port_id']) { + $remote_port = get_port_by_id($neighbour['remote_port_id']); + $remote_device = device_by_id_cache($remote_port['device_id']); + echo ''; + echo ''; + } + else { + echo ''; + echo ''; + } - if (is_numeric($neighbour['remote_port_id']) && $neighbour['remote_port_id']) - { - $remote_port = get_port_by_id($neighbour['remote_port_id']); - $remote_device = device_by_id_cache($remote_port['device_id']); - echo(""); - echo(""); - } else { - echo(""); - echo(""); - } - echo(""); - echo(""); - $i++; -} + echo ''; + echo ''; + $i++; +}//end foreach -echo("
    Local Port
    Local Port Remote Port Remote Device Protocol
    '.generate_port_link($neighbour).'
    '.$neighbour['ifAlias'].'
    '.generate_port_link($neighbour).'
    '.$neighbour['ifAlias'].'
    '.generate_port_link($remote_port).'
    '.$remote_port['ifAlias'].'
    '.generate_device_link($remote_device).'
    '.$remote_device['hardware'].'
    '.$neighbour['remote_port'].''.$neighbour['remote_hostname'].' +
    '.$neighbour['remote_platform'].'
    ".generate_port_link($remote_port)."
    ".$remote_port['ifAlias']."
    ".generate_device_link($remote_device)."
    ".$remote_device['hardware']."
    ".$neighbour['remote_port']."".$neighbour['remote_hostname']." -
    ".$neighbour['remote_platform']."
    ".strtoupper($neighbour['protocol'])."
    '.strtoupper($neighbour['protocol']).'
    "); - -?> +echo ''; diff --git a/html/pages/device/pseudowires.inc.php b/html/pages/device/pseudowires.inc.php index a981e5cc4..c134c8b66 100644 --- a/html/pages/device/pseudowires.inc.php +++ b/html/pages/device/pseudowires.inc.php @@ -1,97 +1,121 @@ 'pseudowires'); print_optionbar_start(); -echo('Pseudowires » '); +echo 'Pseudowires » '; -if ($vars['view'] == "detail") { echo(''); } -echo(generate_link("Details",$link_array,array('view'=> 'detail'))); -if ($vars['view'] == "detail") { echo(''); } +if ($vars['view'] == 'detail') { + echo ''; +} -echo(" | "); +echo generate_link('Details', $link_array, array('view' => 'detail')); +if ($vars['view'] == 'detail') { + echo ''; +} -if ($vars['view'] == "minigraphs") { echo(''); } -echo(generate_link("Mini Graphs",$link_array,array('view' => "minigraphs"))); -if ($vars['view'] == "minigraphs") { echo(''); } +echo ' | '; + +if ($vars['view'] == 'minigraphs') { + echo ''; +} + +echo generate_link('Mini Graphs', $link_array, array('view' => 'minigraphs')); +if ($vars['view'] == 'minigraphs') { + echo ''; +} print_optionbar_end(); -echo(""); +echo '
    '; -foreach (dbFetchRows("SELECT * FROM pseudowires AS P, ports AS I WHERE P.port_id = I.port_id AND I.device_id = ? ORDER BY I.ifDescr", array($device['device_id'])) as $pw_a) -{ - $i = 0; - while ($i < count($linkdone)) - { - $thislink = $pw_a['device_id'] . $pw_a['port_id']; - if ($linkdone[$i] == $thislink) { $skip = "yes"; } - $i++; - } - - $pw_b = dbFetchRow("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id - AND P.cpwVcID = ? AND P.port_id = I.port_id", array($pw_a['peer_device_id'], $pw_a['cpwVcID'])); - - if (!port_permitted($pw_a['port_id'])) { $skip = "yes"; } - if (!port_permitted($pw_b['port_id'])) { $skip = "yes"; } - - if ($skip) - { - unset($skip); - } else { - if ($bg == "ffffff") { $bg = "e5e5e5"; } else { $bg="ffffff"; } - echo(" - - "); - echo(""); - - if ($vars['view'] == "minigraphs") - { - echo(""); + $i++; } - $linkdone[] = $pw_b['device_id'] . $pw_b['port_id']; - } + $pw_b = dbFetchRow( + 'SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id + AND P.cpwVcID = ? AND P.port_id = I.port_id', array( $pw_a['peer_device_id'], $pw_a['cpwVcID'],)); + + if (!port_permitted($pw_a['port_id'])) { + $skip = 'yes'; + } + + if (!port_permitted($pw_b['port_id'])) { + $skip = 'yes'; + } + + if ($skip) { + unset($skip); + } + else { + if ($bg == 'ffffff') { + $bg = 'e5e5e5'; + } + else { + $bg = 'ffffff'; + } + + echo " + + '; + echo "'; + + if ($vars['view'] == 'minigraphs') { + echo "'; + } + + $linkdone[] = $pw_b['device_id'].$pw_b['port_id']; + } } -echo("
    ".$pw_a['cpwVcID']."".generate_port_link($pw_a)." ".generate_device_link($pw_b)."".generate_port_link($pw_b)."
    ".$pw_a['ifAlias']."".$pw_b['ifAlias']."
    "); - - if ($pw_a) - { - $pw_a['width'] = "150"; - $pw_a['height'] = "30"; - $pw_a['from'] = $config['time']['day']; - $pw_a['to'] = $config['time']['now']; - $pw_a['bg'] = $bg; - $types = array('bits','upkts','errors'); - foreach ($types as $graph_type) - { - $pw_a['graph_type'] = "port_".$graph_type; - print_port_thumbnail($pw_a); +foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I WHERE P.port_id = I.port_id AND I.device_id = ? ORDER BY I.ifDescr', array($device['device_id'])) as $pw_a) { + $i = 0; + while ($i < count($linkdone)) { + $thislink = $pw_a['device_id'].$pw_a['port_id']; + if ($linkdone[$i] == $thislink) { + $skip = 'yes'; } - } - echo(""); - if ($pw_b) - { - $pw_b['width'] = "150"; - $pw_b['height'] = "30"; - $pw_b['from'] = $config['time']['day']; - $pw_b['to'] = $config['time']['now']; - $pw_b['bg'] = $bg; - $types = array('bits','upkts','errors'); - foreach ($types as $graph_type) - { - $pw_b['graph_type'] = "port_".$graph_type; - print_port_thumbnail($pw_b); - } - } - - echo("
    ".$pw_a['cpwVcID'].''.generate_port_link($pw_a)." ".generate_device_link($pw_b).''.generate_port_link($pw_b).'
    ".$pw_a['ifAlias'].''.$pw_b['ifAlias'].'
    "; + + if ($pw_a) { + $pw_a['width'] = '150'; + $pw_a['height'] = '30'; + $pw_a['from'] = $config['time']['day']; + $pw_a['to'] = $config['time']['now']; + $pw_a['bg'] = $bg; + $types = array( + 'bits', + 'upkts', + 'errors', + ); + foreach ($types as $graph_type) + { + $pw_a['graph_type'] = 'port_'.$graph_type; + print_port_thumbnail($pw_a); + } + } + + echo ''; + + if ($pw_b) { + $pw_b['width'] = '150'; + $pw_b['height'] = '30'; + $pw_b['from'] = $config['time']['day']; + $pw_b['to'] = $config['time']['now']; + $pw_b['bg'] = $bg; + $types = array('bits', 'upkts', 'errors'); + foreach ($types as $graph_type) { + $pw_b['graph_type'] = 'port_'.$graph_type; + print_port_thumbnail($pw_b); + } + } + + echo '
    "); - -?> +echo ''; diff --git a/html/pages/device/routing.inc.php b/html/pages/device/routing.inc.php index ebd8c62a7..e4be54617 100644 --- a/html/pages/device/routing.inc.php +++ b/html/pages/device/routing.inc.php @@ -1,78 +1,83 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'routing'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'routing', +); -#$type_text['overview'] = "Overview"; -$type_text['ipsec_tunnels'] = "IPSEC Tunnels"; +// $type_text['overview'] = "Overview"; +$type_text['ipsec_tunnels'] = 'IPSEC Tunnels'; // Cisco ACE -$type_text['loadbalancer_rservers'] = "Rservers"; -$type_text['loadbalancer_vservers'] = "Serverfarms"; +$type_text['loadbalancer_rservers'] = 'Rservers'; +$type_text['loadbalancer_vservers'] = 'Serverfarms'; // Citrix Netscaler -$type_text['netscaler_vsvr'] = "VServers"; +$type_text['netscaler_vsvr'] = 'VServers'; -$type_text['bgp'] = "BGP"; -$type_text['cef'] = "CEF"; -$type_text['ospf'] = "OSPF"; -$type_text['vrf'] = "VRFs"; +$type_text['bgp'] = 'BGP'; +$type_text['cef'] = 'CEF'; +$type_text['ospf'] = 'OSPF'; +$type_text['vrf'] = 'VRFs'; print_optionbar_start(); -$pagetitle[] = "Routing"; +$pagetitle[] = 'Routing'; -echo("Routing » "); +echo "Routing » "; unset($sep); -foreach ($routing_tabs as $type) -{ +foreach ($routing_tabs as $type) { + if (!$vars['proto']) { + $vars['proto'] = $type; + } - if (!$vars['proto']) { $vars['proto'] = $type; } + echo $sep; - echo($sep); + if ($vars['proto'] == $type) { + echo ''; + } - if ($vars['proto'] == $type) - { - echo(''); - } + echo generate_link($type_text[$type].' ('.$device_routing_count[$type].')', $link_array, array('proto' => $type)); + if ($vars['proto'] == $type) { + echo ''; + } - echo(generate_link($type_text[$type] ." (".$device_routing_count[$type].")",$link_array,array('proto'=>$type))); - if ($vars['proto'] == $type) { echo(""); } - $sep = " | "; + $sep = ' | '; } print_optionbar_end(); -if (is_file("pages/device/routing/".mres($vars['proto']).".inc.php")) -{ - include("pages/device/routing/".mres($vars['proto']).".inc.php"); -} else { - foreach ($routing_tabs as $type) - { - if ($type != "overview") - { - if (is_file("pages/device/routing/overview/".mres($type).".inc.php")) { - - $g_i++; - if (!is_integer($g_i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - - echo('
    '); - echo('
    '.$type_text[$type].''); - - include("pages/device/routing/overview/".mres($type).".inc.php"); - - echo('
    '); - echo('
    '); - } else { - $graph_title = $type_text[$type]; - $graph_type = "device_".$type; - - include("includes/print-device-graph.php"); - } - } - } +if (is_file('pages/device/routing/'.mres($vars['proto']).'.inc.php')) { + include 'pages/device/routing/'.mres($vars['proto']).'.inc.php'; } +else { + foreach ($routing_tabs as $type) { + if ($type != 'overview') { + if (is_file('pages/device/routing/overview/'.mres($type).'.inc.php')) { + $g_i++; + if (!is_integer($g_i / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } -?> + echo '
    '; + echo '
    '.$type_text[$type].''; + + include 'pages/device/routing/overview/'.mres($type).'.inc.php'; + + echo '
    '; + echo '
    '; + } + else { + $graph_title = $type_text[$type]; + $graph_type = 'device_'.$type; + + include 'includes/print-device-graph.php'; + }//end if + }//end if + }//end foreach +}//end if diff --git a/html/pages/device/routing/cef.inc.php b/html/pages/device/routing/cef.inc.php index 785b0f653..d4a31416f 100644 --- a/html/pages/device/routing/cef.inc.php +++ b/html/pages/device/routing/cef.inc.php @@ -2,107 +2,133 @@ print_optionbar_start(); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'routing', - 'proto' => 'cef'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'routing', + 'proto' => 'cef', +); -if(!isset($vars['view'])) { $vars['view'] = "basic"; } +if (!isset($vars['view'])) { + $vars['view'] = 'basic'; +} -echo('CEF » '); +echo 'CEF » '; -if ($vars['view'] == "basic") { echo(""); } -echo(generate_link("Basic", $link_array,array('view'=>'basic'))); -if ($vars['view'] == "basic") { echo(""); } +if ($vars['view'] == 'basic') { + echo ""; +} -echo(" | "); +echo generate_link('Basic', $link_array, array('view' => 'basic')); +if ($vars['view'] == 'basic') { + echo ''; +} -if ($vars['view'] == "graphs") { echo(""); } -echo(generate_link("Graphs", $link_array,array('view'=>'graphs'))); -if ($vars['view'] == "graphs") { echo(""); } +echo ' | '; + +if ($vars['view'] == 'graphs') { + echo ""; +} + +echo generate_link('Graphs', $link_array, array('view' => 'graphs')); +if ($vars['view'] == 'graphs') { + echo ''; +} print_optionbar_end(); -echo('
    - '); +echo '
    +
    '; -echo(' - - - - - - '); +echo ' + + + + + + '; -$i=0; +$i = 0; -foreach (dbFetchRows("SELECT * FROM `cef_switching` WHERE `device_id` = ? ORDER BY `entPhysicalIndex`, `afi`, `cef_index`", array($device['device_id'])) as $cef) -{ +foreach (dbFetchRows('SELECT * FROM `cef_switching` WHERE `device_id` = ? ORDER BY `entPhysicalIndex`, `afi`, `cef_index`', array($device['device_id'])) as $cef) { + $entity = dbFetchRow('SELECT * FROM `entPhysical` WHERE device_id = ? AND `entPhysicalIndex` = ?', array($device['device_id'], $cef['entPhysicalIndex'])); - $entity = dbFetchRow("SELECT * FROM `entPhysical` WHERE device_id = ? AND `entPhysicalIndex` = ?", array($device['device_id'], $cef['entPhysicalIndex'])); + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } - if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } + $interval = ($cef['updated'] - $cef['updated_prev']); - $interval = $cef['updated'] - $cef['updated_prev']; + if (!$entity['entPhysicalModelName'] && $entity['entPhysicalContainedIn']) { + $parent_entity = dbFetchRow('SELECT * FROM `entPhysical` WHERE device_id = ? AND `entPhysicalIndex` = ?', array($device['device_id'], $entity['entPhysicalContainedIn'])); + $entity_descr = $entity['entPhysicalName'].' ('.$parent_entity['entPhysicalModelName'].')'; + } + else { + $entity_descr = $entity['entPhysicalName'].' ('.$entity['entPhysicalModelName'].')'; + } - if (!$entity['entPhysicalModelName'] && $entity['entPhysicalContainedIn']) - { - $parent_entity = dbFetchRow("SELECT * FROM `entPhysical` WHERE device_id = ? AND `entPhysicalIndex` = ?", array($device['device_id'], $entity['entPhysicalContainedIn'])); - $entity_descr = $entity['entPhysicalName'] . " (" . $parent_entity['entPhysicalModelName'] .")"; - } else { - $entity_descr = $entity['entPhysicalName'] . " (" . $entity['entPhysicalModelName'] .")"; - } + echo " + + - - "); - echo(""); - echo(""); - echo(""); + echo ''; + echo ' - "); + echo ''; + echo ''; + echo ''; - include("includes/print-graphrow.inc.php"); + echo ' + '; - echo(""); - } + if ($vars['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $cef['cef_switching_id']; + $graph_array['type'] = 'cefswitching_graph'; - $i++; + echo "'; + } + + $i++; } -echo("
    EntityAFIPathDropPuntPunt2Host
    EntityAFIPathDropPuntPunt2Host
    ".$entity_descr.''.$cef['afi'].''; - echo("
    ".$entity_descr."".$cef['afi'].""); + switch ($cef['cef_path']) { + case 'RP RIB': + echo 'RP RIB'; + break; + + case 'RP LES': + echo 'RP LES'; + break; + + case 'RP PAS': + echo 'RP PAS'; + break; - switch ($cef['cef_path']) { - case "RP RIB": - echo 'RP RIB'; - break; - case "RP LES": - echo 'RP LES'; - break; - case "RP PAS": - echo 'RP PAS'; - break; default: - echo $cef['cef_path']; - } + echo $cef['cef_path']; + } - echo("".format_si($cef['drop'])); - if ($cef['drop'] > $cef['drop_prev']) { echo(" (".round(($cef['drop']-$cef['drop_prev'])/$interval,2)."/sec)"); } - echo("".format_si($cef['punt'])); - if ($cef['punt'] > $cef['punt_prev']) { echo(" (".round(($cef['punt']-$cef['punt_prev'])/$interval,2)."/sec)"); } - echo("".format_si($cef['punt2host'])); - if ($cef['punt2host'] > $cef['punt2host_prev']) { echo(" (".round(($cef['punt2host']-$cef['punt2host_prev'])/$interval,2)."/sec)"); } - echo("'.format_si($cef['drop']); + if ($cef['drop'] > $cef['drop_prev']) { + echo (" (".round((($cef['drop'] - $cef['drop_prev']) / $interval), 2).'/sec)'); + } - echo("
    '.format_si($cef['punt']); + if ($cef['punt'] > $cef['punt_prev']) { + echo (" (".round((($cef['punt'] - $cef['punt_prev']) / $interval), 2).'/sec)'); + } - if ($vars['view'] == "graphs") - { - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $cef['cef_switching_id']; - $graph_array['type'] = "cefswitching_graph"; + echo ''.format_si($cef['punt2host']); + if ($cef['punt2host'] > $cef['punt2host_prev']) { + echo (" (".round((($cef['punt2host'] - $cef['punt2host_prev']) / $interval), 2).'/sec)'); + } - echo("
    "); + echo '
    "; + + include 'includes/print-graphrow.inc.php'; + + echo '
    "); - -?> +echo ''; diff --git a/html/pages/device/routing/ipsec_tunnels.inc.php b/html/pages/device/routing/ipsec_tunnels.inc.php index 2cde88559..5a360169a 100644 --- a/html/pages/device/routing/ipsec_tunnels.inc.php +++ b/html/pages/device/routing/ipsec_tunnels.inc.php @@ -1,93 +1,114 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'routing', - 'proto' => 'ipsec_tunnels'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'routing', + 'proto' => 'ipsec_tunnels', + ); print_optionbar_start(); -echo("IPSEC Tunnels » "); +echo "IPSEC Tunnels » "; -$menu_options = array('basic' => 'Basic', - ); +$menu_options = array('basic' => 'Basic'); -if(!isset($vars['view'])) { $vars['view'] = "basic"; } - -echo("VRFs » "); - -$menu_options = array('basic' => 'Basic', -# 'detail' => 'Detail', - ); - -if (!$_GET['opta']) { $_GET['opta'] = "basic"; } - -$sep = ""; -foreach ($menu_options as $option => $text) -{ - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text, $link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - echo(" | "); +if (!isset($vars['view'])) { + $vars['view'] = 'basic'; } -echo(' Graphs: '); +echo "VRFs » "; -$graph_types = array("bits" => "Bits", - "pkts" => "Packets"); +$menu_options = array('basic' => 'Basic', +// 'detail' => 'Detail', +); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($vars['graph'] == $type) { echo(""); } - echo(generate_link($descr, $link_array,array('view'=>'graphs','graph'=>$type))); - if ($vars['graph'] == $type) { echo(""); } +if (!$_GET['opta']) { + $_GET['opta'] = 'basic'; +} - $type_sep = " | "; +$sep = ''; +foreach ($menu_options as $option => $text) { + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + echo ' | '; +} + +echo ' Graphs: '; + +$graph_types = array( + 'bits' => 'Bits', + 'pkts' => 'Packets', + ); + +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($vars['graph'] == $type) { + echo ""; + } + + echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type)); + if ($vars['graph'] == $type) { + echo ''; + } + + $type_sep = ' | '; } print_optionbar_end(); -echo("
    "); -$i = "0"; -foreach (dbFetchRows("SELECT * FROM `ipsec_tunnels` WHERE `device_id` = ? ORDER BY `peer_addr`", array($device['device_id'])) as $tunnel) -{ +echo "
    "; +$i = '0'; +foreach (dbFetchRows('SELECT * FROM `ipsec_tunnels` WHERE `device_id` = ? ORDER BY `peer_addr`', array($device['device_id'])) as $tunnel) { + if (is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } -if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } + if ($tunnel['tunnel_status'] == 'active') { + $tunnel_class = 'green'; + } + else { + $tunnel_class = 'red'; + } -if($tunnel['tunnel_status'] == "active") { $tunnel_class="green"; } else { $tunnel_class="red"; } + echo ""; + echo ''; + echo ''; + echo "'; + echo ''; + if (isset($vars['graph'])) { + echo ''; + echo '"); -echo(""); -echo(""); -echo(""); -echo(""); - if (isset($vars['graph'])) - { - echo(''); - echo(" - "); - } + '; + } -echo(""); -echo(""); + echo ''; + echo ''; - $i++; -} + $i++; +}//end foreach -echo("
    '.$tunnel['local_addr'].' » '.$tunnel['peer_addr'].''.$tunnel['tunnel_name'].'".$tunnel['tunnel_status'].'
    '; + $graph_type = 'ipsectunnel_'.$vars['graph']; -echo("
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "" . $tunnel['tunnel_name'] . "" . $tunnel['tunnel_status'] . "
    "); - $graph_type = "ipsectunnel_" . $vars['graph']; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $tunnel['tunnel_id']; + $graph_array['type'] = $graph_type; - $graph_array['height'] = "100"; - $graph_array['width'] = "215"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $tunnel['tunnel_id']; - $graph_array['type'] = $graph_type; + include 'includes/print-graphrow.inc.php'; - include("includes/print-graphrow.inc.php"); - - echo(" + echo '
    "); - -?> +echo ''; diff --git a/html/pages/device/routing/ospf.inc.php b/html/pages/device/routing/ospf.inc.php index 8b17078e3..ed126a7fe 100644 --- a/html/pages/device/routing/ospf.inc.php +++ b/html/pages/device/routing/ospf.inc.php @@ -1,148 +1,193 @@ '); +echo ''; // Loop Instances - -foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", array($device['device_id'])) as $instance) -{ - if (!is_integer($i_i/2)) { $instance_bg = $list_colour_a; } else { $instance_bg = $list_colour_b; } - - $area_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id'])); - $port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ?", array($device['device_id'])); - $port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id'])); - $nbr_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ?", array($device['device_id'])); - - $query = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE "; - $query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; - $query .= " AND I.device_id = ?"; - $ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'], $device['device_id'])); - - if ($instance['ospfAdminStat'] == "enabled") { $enabled = 'enabled'; } else { $enabled = 'disabled'; } - if ($instance['ospfAreaBdrRtrStatus'] == "true") { $abr = 'yes'; } else { $abr = 'no'; } - if ($instance['ospfASBdrRtrStatus'] == "true") { $asbr = 'yes'; } else { $asbr = 'no'; } - - echo(''); - echo(''); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(''); - - echo(''); - echo(''); - echo(''); + echo ''; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; - $i_i++; -} // End loop instances + echo ''; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + + echo ''; + echo ''; + echo ''; + + $i_a++; + } //end foreach + + echo ''; + + // Loop Neigbours + $i_n = 1; + foreach (dbFetchRows('SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?', array($device['device_id'])) as $nbr) { + if (!is_integer($i_n / 2)) { + $nbr_bg = $list_colour_b_a; + } + else { + $nbr_bg = $list_colour_b_b; + } + + $host = @dbFetchRow( + 'SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? + AND I.port_id = A.port_id AND D.device_id = I.device_id', + array($nbr['ospfNbrRtrId']) + ); + + if (is_array($host)) { + $rtr_id = generate_device_link($host); + } + else { + $rtr_id = 'unknown'; + } + + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + + $i_n++; + }//end foreach + + echo '
    Router IdStatusABRASBRAreasPortsNeighbours
    '.$instance['ospfRouterId'] . '' . $enabled . '' . $abr . '' . $asbr . '' . $area_count . '' . $port_count . '('.$port_count_enabled.')' . $nbr_count . '
    '); - echo(''); - echo(''); - - ///# Loop Areas - $i_a = 0; - foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id'])) as $area) - { - if (!is_integer($i_a/2)) { $area_bg = $list_colour_b_a; } else { $area_bg = $list_colour_b_b; } - - $area_port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId'])); - $area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId'])); - - echo(''); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(''); - - echo(''); - echo(''); - echo(''); + $area_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ?', array($device['device_id'])); + $port_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ?', array($device['device_id'])); + $port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id'])); + $nbr_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ?', array($device['device_id'])); - $i_a++; - } // End loop areas + $query = 'SELECT * FROM ipv4_addresses AS A, ports AS I WHERE '; + $query .= '(A.ipv4_address = ? AND I.port_id = A.port_id)'; + $query .= ' AND I.device_id = ?'; + $ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'], $device['device_id'])); - echo(''); - - // Loop Neigbours - $i_n = 1; - foreach (dbFetchRows("SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?", array($device['device_id'])) as $nbr) - { - if (!is_integer($i_n/2)) { $nbr_bg = $list_colour_b_a; } else { $nbr_bg = $list_colour_b_b; } - - $host = @dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? - AND I.port_id = A.port_id AND D.device_id = I.device_id", array($nbr['ospfNbrRtrId'])); - - if (is_array($host)) { $rtr_id = generate_device_link($host); } else { $rtr_id = "unknown"; } - - echo(''); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(''); - $i_n++; + if ($instance['ospfAreaBdrRtrStatus'] == 'true') { + $abr = 'yes'; + } + else { + $abr = 'no'; + } - } + if ($instance['ospfASBdrRtrStatus'] == 'true') { + $asbr = 'yes'; + } + else { + $asbr = 'no'; + } - echo('
    Area IdStatusPorts
    '.$area['ospfAreaId'] . '' . $enabled . '' . $area_port_count . '('.$area_port_count_enabled.')
    '); - echo(''); - echo(''); - - ///# Loop Ports - $i_p = $i_a + 1; - $p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id"; - foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) - { - if (!is_integer($i_a/2)) - { - if (!is_integer($i_p/2)) { $port_bg = $list_colour_b_b; } else { $port_bg = $list_colour_b_a; } - } else { - if (!is_integer($i_p/2)) { $port_bg = $list_colour_a_b; } else { $port_bg = $list_colour_a_a; } - } - - if ($ospfport['ospfIfAdminStat'] == "enabled") - { - $port_enabled = 'enabled'; - } else { - $port_enabled = 'disabled'; - } - - echo(''); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(''); - - $i_p++; +foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', array($device['device_id'])) as $instance) { + if (!is_integer($i_i / 2)) { + $instance_bg = $list_colour_a; + } + else { + $instance_bg = $list_colour_b; } - echo('
    PortStatusPort TypePort State
    '. generate_port_link($ospfport) . '' . $port_enabled . '' . $ospfport['ospfIfType'] . '' . $ospfport['ospfIfState'] . '
    '); - echo('
    Router IdDeviceIP AddressStatus
    ' . $nbr['ospfNbrRtrId'] . '' . $rtr_id . '' . $nbr['ospfNbrIpAddr'] . ''); - switch ($nbr['ospfNbrState']) - { - case 'full': - echo(''.$nbr['ospfNbrState'].''); - break; - case 'down': - echo(''.$nbr['ospfNbrState'].''); - break; - default: - echo(''.$nbr['ospfNbrState'].''); - break; + if ($instance['ospfAdminStat'] == 'enabled') { + $enabled = 'enabled'; + } + else { + $enabled = 'disabled'; } - echo('
    '); - echo('
    Router IdStatusABRASBRAreasPortsNeighbours
    '.$instance['ospfRouterId'].''.$enabled.''.$abr.''.$asbr.''.$area_count.''.$port_count.'('.$port_count_enabled.')'.$nbr_count.'
    '; + echo ''; + echo ''; -echo('
    Area IdStatusPorts
    '); + // # Loop Areas + $i_a = 0; + foreach (dbFetchRows('SELECT * FROM `ospf_areas` WHERE `device_id` = ?', array($device['device_id'])) as $area) { + if (!is_integer($i_a / 2)) { + $area_bg = $list_colour_b_a; + } + else { + $area_bg = $list_colour_b_b; + } -?> + $area_port_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospfIfAreaId` = ?', array($device['device_id'], $area['ospfAreaId'])); + $area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId'])); + + echo '
    '.$area['ospfAreaId'].''.$enabled.''.$area_port_count.'('.$area_port_count_enabled.')
    '; + echo ''; + echo ''; + + // # Loop Ports + $i_p = ($i_a + 1); + $p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id"; + foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) + { + if (!is_integer($i_a / 2)) { + if (!is_integer($i_p / 2)) { + $port_bg = $list_colour_b_b; + } + else { + $port_bg = $list_colour_b_a; + } + } + else { + if (!is_integer($i_p / 2)) { + $port_bg = $list_colour_a_b; + } + else { + $port_bg = $list_colour_a_a; + } + } + + if ($ospfport['ospfIfAdminStat'] == 'enabled') { + $port_enabled = 'enabled'; + } + else { + $port_enabled = 'disabled'; + } + + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + + $i_p++; + }//end foreach + + echo '
    PortStatusPort TypePort State
    '.generate_port_link($ospfport).''.$port_enabled.''.$ospfport['ospfIfType'].''.$ospfport['ospfIfState'].'
    '; + echo '
    Router IdDeviceIP AddressStatus
    '.$nbr['ospfNbrRtrId'].''.$rtr_id.''.$nbr['ospfNbrIpAddr'].''; + switch ($nbr['ospfNbrState']) { + case 'full': + echo ''.$nbr['ospfNbrState'].''; + break; + + case 'down': + echo ''.$nbr['ospfNbrState'].''; + break; + + default: + echo ''.$nbr['ospfNbrState'].''; + break; + } + + echo '
    '; + echo ''; + echo ''; + + $i_i++; +} //end foreach + +echo ''; diff --git a/html/pages/device/routing/vrf.inc.php b/html/pages/device/routing/vrf.inc.php index ae52da8e6..59bfc6648 100644 --- a/html/pages/device/routing/vrf.inc.php +++ b/html/pages/device/routing/vrf.inc.php @@ -1,64 +1,77 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'routing', - 'proto' => 'vrf'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'routing', + 'proto' => 'vrf', + ); -#echo(generate_link("Basic", $link_array,array('view'=>'basic'))); - -if(!isset($vars['view'])) { $vars['view'] = "basic"; } +// echo(generate_link("Basic", $link_array,array('view'=>'basic'))); +if (!isset($vars['view'])) { + $vars['view'] = 'basic'; +} print_optionbar_start(); -echo("VRFs » "); +echo "VRFs » "; $menu_options = array('basic' => 'Basic', -# 'detail' => 'Detail', - ); +// 'detail' => 'Detail', + ); -if (!$_GET['opta']) { $_GET['opta'] = "basic"; } +if (!$_GET['opta']) { + $_GET['opta'] = 'basic'; +} -$sep = ""; -foreach ($menu_options as $option => $text) -{ - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text, $link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - echo(" | "); +$sep = ''; +foreach ($menu_options as $option => $text) { + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + echo ' | '; } unset($sep); -echo(' Graphs: '); +echo ' Graphs: '; -$graph_types = array("bits" => "Bits", - "upkts" => "Unicast Packets", - "nupkts" => "Non-Unicast Packets", - "errors" => "Errors", - "etherlike" => "Etherlike"); +$graph_types = array( + 'bits' => 'Bits', + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors', + 'etherlike' => 'Etherlike', + ); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($vars['graph'] == $type) { echo(""); } - echo(generate_link($descr, $link_array,array('view'=>'graphs','graph'=>$type))); - if ($vars['graph'] == $type) { echo(""); } +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($vars['graph'] == $type) { + echo ""; + } - $type_sep = " | "; + echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type)); + if ($vars['graph'] == $type) { + echo ''; + } + + $type_sep = ' | '; } print_optionbar_end(); -echo("
    "); -$i = "0"; -foreach (dbFetchRows("SELECT * FROM `vrfs` WHERE `device_id` = ? ORDER BY `vrf_name`", array($device['device_id'])) as $vrf) -{ - include("includes/print-vrf.inc.php"); +echo "
    "; +$i = '0'; +foreach (dbFetchRows('SELECT * FROM `vrfs` WHERE `device_id` = ? ORDER BY `vrf_name`', array($device['device_id'])) as $vrf) { + include 'includes/print-vrf.inc.php'; - $i++; + $i++; } -echo("
    "); - -?> +echo ''; diff --git a/html/pages/device/services.inc.php b/html/pages/device/services.inc.php index d4bb3b1da..300043928 100644 --- a/html/pages/device/services.inc.php +++ b/html/pages/device/services.inc.php @@ -1,59 +1,71 @@ Services » "); +echo "Services » "; -$menu_options = array('basic' => 'Basic', - 'details' => 'Details'); +$menu_options = array( + 'basic' => 'Basic', + 'details' => 'Details', +); -if (!$vars['view']) { $vars['view'] = "basic"; } +if (!$vars['view']) { + $vars['view'] = 'basic'; +} -$sep = ""; -foreach ($menu_options as $option => $text) -{ - if (empty($vars['view'])) { $vars['view'] = $option; } - echo($sep); - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text, $vars, array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - $sep = " | "; +$sep = ''; +foreach ($menu_options as $option => $text) { + if (empty($vars['view'])) { + $vars['view'] = $option; + } + + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $vars, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); print_optionbar_end(); -if (dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE device_id = ?", array($device['device_id'])) > '0') -{ - echo("
    "); - $i = "1"; - foreach (dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ? ORDER BY `service_type`", array($device['device_id'])) as $service) - { - include("includes/print-service.inc.php"); +if (dbFetchCell('SELECT COUNT(service_id) FROM `services` WHERE device_id = ?', array($device['device_id'])) > '0') { + echo "
    "; + $i = '1'; + foreach (dbFetchRows('SELECT * FROM `services` WHERE `device_id` = ? ORDER BY `service_type`', array($device['device_id'])) as $service) { + include 'includes/print-service.inc.php'; - if ($vars['view'] == "details") - { - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $service['service_id']; - $graph_array['type'] = "service_availability"; + if ($vars['view'] == 'details') { + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $service['service_id']; + $graph_array['type'] = 'service_availability'; - $periods = array('day', 'week', 'month', 'year'); + $periods = array( + 'day', + 'week', + 'month', + 'year', + ); - echo('"); - } - } - echo("
    '); + echo '
    '; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    "); + echo ''; + } + } + + echo ''; } -else -{ - echo("No Services"); +else { + echo 'No Services'; } -$pagetitle[] = "Services"; - -?> +$pagetitle[] = 'Services'; diff --git a/html/pages/device/slas.inc.php b/html/pages/device/slas.inc.php index aec523110..3cc6cbf11 100644 --- a/html/pages/device/slas.inc.php +++ b/html/pages/device/slas.inc.php @@ -2,76 +2,78 @@ print_optionbar_start(); -echo("SLA » "); +echo "SLA » "; -$slas = dbFetchRows("SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0 ORDER BY `sla_nr`", array($device['device_id'])); +$slas = dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0 ORDER BY `sla_nr`', array($device['device_id'])); // Collect types $sla_types = array('all' => 'All'); -foreach ($slas as $sla) -{ - $sla_type = $sla['rtt_type']; +foreach ($slas as $sla) { + $sla_type = $sla['rtt_type']; - if (!in_array($sla_type, $sla_types)) - if (isset($config['sla_type_labels'][$sla_type])) - { - $text = $config['sla_type_labels'][$sla_type]; + if (!in_array($sla_type, $sla_types)) { + if (isset($config['sla_type_labels'][$sla_type])) { + $text = $config['sla_type_labels'][$sla_type]; + } } - else - { - $text = ucfirst($sla_type); + else { + $text = ucfirst($sla_type); } $sla_types[$sla_type] = $text; } + asort($sla_types); -$sep = ""; -foreach ($sla_types as $sla_type => $text) -{ - if (!$vars['view']) { $vars['view'] = $sla_type; } +$sep = ''; +foreach ($sla_types as $sla_type => $text) { + if (!$vars['view']) { + $vars['view'] = $sla_type; + } - echo($sep); - if ($vars['view'] == $sla_type) - { - echo(""); - } - echo(generate_link($text,$vars,array('view'=>$sla_type))); - if ($vars['view'] == $sla_type) - { - echo(""); - } - $sep = " | "; + echo $sep; + if ($vars['view'] == $sla_type) { + echo ""; + } + + echo generate_link($text, $vars, array('view' => $sla_type)); + if ($vars['view'] == $sla_type) { + echo ''; + } + + $sep = ' | '; } + unset($sep); print_optionbar_end(); -echo(''); +echo '
    '; -foreach ($slas as $sla) -{ - if ($vars['view'] != 'all' && $vars['view'] != $sla['rtt_type']) - continue; +foreach ($slas as $sla) { + if ($vars['view'] != 'all' && $vars['view'] != $sla['rtt_type']) { + continue; + } - $name = "SLA #". $sla['sla_nr'] ." - ". $sla_types[$sla['rtt_type']]; - if ($sla['tag']) - $name .= ": ".$sla['tag']; - if ($sla['owner']) - $name .= " (Owner: ". $sla['owner'] .")"; + $name = 'SLA #'.$sla['sla_nr'].' - '.$sla_types[$sla['rtt_type']]; + if ($sla['tag']) { + $name .= ': '.$sla['tag']; + } - $graph_array['type'] = "device_sla"; - $graph_array['id'] = $sla['sla_id']; - echo(''); + include 'includes/print-graphrow.inc.php'; + + echo ''; } -echo('
    '); - echo('

    '.htmlentities($name).'

    '); + if ($sla['owner']) { + $name .= ' (Owner: '.$sla['owner'].')'; + } - include("includes/print-graphrow.inc.php"); + $graph_array['type'] = 'device_sla'; + $graph_array['id'] = $sla['sla_id']; + echo '
    '; + echo '

    '.htmlentities($name).'

    '; - echo('
    '); +echo ''; -$pagetitle[] = "SLAs"; - -?> +$pagetitle[] = 'SLAs'; diff --git a/html/pages/device/toner.inc.php b/html/pages/device/toner.inc.php index 130b84d0b..7fe35144f 100644 --- a/html/pages/device/toner.inc.php +++ b/html/pages/device/toner.inc.php @@ -1,11 +1,8 @@ +require 'includes/print-device-graph.php'; +$pagetitle[] = 'Toner'; diff --git a/html/pages/device/vlans.inc.php b/html/pages/device/vlans.inc.php index 13d7f4c35..9adca0834 100644 --- a/html/pages/device/vlans.inc.php +++ b/html/pages/device/vlans.inc.php @@ -1,74 +1,89 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'vlans'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'vlans', + ); print_optionbar_start(); -echo("VLANs » "); +echo "VLANs » "; -if ($vars['view'] == 'graphs' || $vars['view'] == 'minigraphs') -{ - if (isset($vars['graph'])) { $graph_type = "port_" . $vars['graph']; } else { $graph_type = "port_bits"; } +if ($vars['view'] == 'graphs' || $vars['view'] == 'minigraphs') { + if (isset($vars['graph'])) { + $graph_type = 'port_'.$vars['graph']; + } + else { + $graph_type = 'port_bits'; + } } -if (!$vars['view']) { $vars['view'] = "basic"; } +if (!$vars['view']) { + $vars['view'] = 'basic'; +} -$menu_options['basic'] = 'Basic'; -#$menu_options['details'] = 'Details'; +$menu_options['basic'] = 'Basic'; +// $menu_options['details'] = 'Details'; +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text,$link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - $sep = " | "; + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); -echo(' | Graphs: '); +echo ' | Graphs: '; -$graph_types = array("bits" => "Bits", - "upkts" => "Unicast Packets", - "nupkts" => "Non-Unicast Packets", - "errors" => "Errors"); +$graph_types = array( + 'bits' => 'Bits', + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors', + ); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } - echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type))); - if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($vars['graph'] == $type && $vars['view'] == 'graphs') { + echo ""; + } -/* - echo(' ('); - if ($vars['graph'] == $type && $vars['type'] == "minigraphs") { echo(""); } - echo(generate_link('Mini',$link_array,array('type'=>'minigraphs','graph'=>$type))); - if ($vars['graph'] == $type && $vars['type'] == "minigraphs") { echo(""); } - echo(')'); -*/ - $type_sep = " | "; + echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type)); + if ($vars['graph'] == $type && $vars['view'] == 'graphs') { + echo ''; + } + + /* + echo(' ('); + if ($vars['graph'] == $type && $vars['type'] == "minigraphs") { echo(""); } + echo(generate_link('Mini',$link_array,array('type'=>'minigraphs','graph'=>$type))); + if ($vars['graph'] == $type && $vars['type'] == "minigraphs") { echo(""); } + echo(')'); + */ + $type_sep = ' | '; } print_optionbar_end(); -echo(''); +echo '
    '; -$i = "1"; +$i = '1'; -foreach (dbFetchRows("SELECT * FROM `vlans` WHERE `device_id` = ? ORDER BY 'vlan_vlan'", array($device['device_id'])) as $vlan) -{ - include("includes/print-vlan.inc.php"); +foreach (dbFetchRows("SELECT * FROM `vlans` WHERE `device_id` = ? ORDER BY 'vlan_vlan'", array($device['device_id'])) as $vlan) { + include 'includes/print-vlan.inc.php'; - $i++; + $i++; } -echo("
    "); +echo ''; -$pagetitle[] = "VLANs"; - -?> +$pagetitle[] = 'VLANs'; diff --git a/html/pages/device/vm.inc.php b/html/pages/device/vm.inc.php index f85c55319..5dee674a5 100644 --- a/html/pages/device/vm.inc.php +++ b/html/pages/device/vm.inc.php @@ -1,18 +1,15 @@ Server NamePower StatusOperating SystemMemoryCPU'); +echo ''; -$i = "1"; +$i = '1'; -foreach (dbFetchRows("SELECT * FROM vminfo WHERE device_id = ? ORDER BY vmwVmDisplayName", array($device['device_id'])) as $vm) -{ - include("includes/print-vm.inc.php"); +foreach (dbFetchRows('SELECT * FROM vminfo WHERE device_id = ? ORDER BY vmwVmDisplayName', array($device['device_id'])) as $vm) { + include 'includes/print-vm.inc.php'; - $i++; + $i++; } -echo("
    Server NamePower StatusOperating SystemMemoryCPU
    "); +echo ''; -$pagetitle[] = "Virtual Machines"; - -?> +$pagetitle[] = 'Virtual Machines'; diff --git a/html/pages/health/current.inc.php b/html/pages/health/current.inc.php index 074afecfe..28de0a214 100644 --- a/html/pages/health/current.inc.php +++ b/html/pages/health/current.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/dbm.inc.php b/html/pages/health/dbm.inc.php index 9d7f49c83..57da8ced5 100644 --- a/html/pages/health/dbm.inc.php +++ b/html/pages/health/dbm.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/fanspeed.inc.php b/html/pages/health/fanspeed.inc.php index f8aae0665..cbb3d5632 100644 --- a/html/pages/health/fanspeed.inc.php +++ b/html/pages/health/fanspeed.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/frequency.inc.php b/html/pages/health/frequency.inc.php index 4e52297a0..45a66986b 100644 --- a/html/pages/health/frequency.inc.php +++ b/html/pages/health/frequency.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/humidity.inc.php b/html/pages/health/humidity.inc.php index 68fcbec3b..e59efb5a9 100644 --- a/html/pages/health/humidity.inc.php +++ b/html/pages/health/humidity.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/power.inc.php b/html/pages/health/power.inc.php index 6256158b4..ca7c95b35 100644 --- a/html/pages/health/power.inc.php +++ b/html/pages/health/power.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/temperature.inc.php b/html/pages/health/temperature.inc.php index f6cd40cfd..06f784380 100644 --- a/html/pages/health/temperature.inc.php +++ b/html/pages/health/temperature.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/toner.inc.php b/html/pages/health/toner.inc.php index 4008fbee2..f9907b6f7 100644 --- a/html/pages/health/toner.inc.php +++ b/html/pages/health/toner.inc.php @@ -1,62 +1,57 @@ - "); +echo "
    +
    "; -echo(" +echo ' - "); + '; -foreach (dbFetchRows("SELECT * FROM `toner` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY D.hostname, S.toner_descr") as $toner) -{ - if (device_permitted($toner['device_id'])) - { - $total = $toner['toner_capacity']; - $perc = $toner['toner_current']; +foreach (dbFetchRows('SELECT * FROM `toner` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY D.hostname, S.toner_descr') as $toner) { + if (device_permitted($toner['device_id'])) { + $total = $toner['toner_capacity']; + $perc = $toner['toner_current']; - $graph_array['type'] = $graph_type; - $graph_array['id'] = $toner['toner_id']; - $graph_array['from'] = $config['time']['day']; - $graph_array['to'] = $config['time']['now']; - $graph_array['height'] = "20"; - $graph_array['width'] = "80"; - $graph_array_zoom = $graph_array; - $graph_array_zoom['height'] = "150"; - $graph_array_zoom['width'] = "400"; - $link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/"; - $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); + $graph_array['type'] = $graph_type; + $graph_array['id'] = $toner['toner_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = '20'; + $graph_array['width'] = '80'; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; + $link = 'graphs/id='.$graph_array['id'].'/type='.$graph_array['type'].'/from='.$graph_array['from'].'/to='.$graph_array['to'].'/'; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); - $background = get_percentage_colours(100 - $perc); + $background = get_percentage_colours(100 - $perc); - echo(" + echo ""); + ".print_percentage_bar(400, 20, $perc, "$perc%", 'ffffff', $background['left'], $free, 'ffffff', $background['right'])." + '; - if ($vars['view'] == "graphs") - { - echo(""); - } # endif graphs - } + echo ''; + } + } } -echo("
    Device Toner Usage Used
    " . generate_device_link($toner) . "" . $toner['toner_descr'] . "
    ".generate_device_link($toner).''.$toner['toner_descr']." $mini_graph - ".print_percentage_bar (400, 20, $perc, "$perc%", "ffffff", $background['left'], $free, "ffffff", $background['right'])." - $perc"."%
    $perc".'%
    "); + if ($vars['view'] == 'graphs') { + echo "
    "; - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $toner['toner_id']; - $graph_array['type'] = $graph_type; + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $toner['toner_id']; + $graph_array['type'] = $graph_type; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    "); - -?> +echo ''; diff --git a/html/pages/health/voltage.inc.php b/html/pages/health/voltage.inc.php index 57d8a6886..cca91aa3c 100644 --- a/html/pages/health/voltage.inc.php +++ b/html/pages/health/voltage.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/packages.inc.php b/html/pages/packages.inc.php index dccddf75f..c3e79c8cf 100644 --- a/html/pages/packages.inc.php +++ b/html/pages/packages.inc.php @@ -1,62 +1,61 @@ $value) -{ - if ($value != "") - { - switch ($var) - { - case 'name': - $where .= " AND `$var` = ?"; - $param[] = $value; - break; +foreach ($vars as $var => $value) { + if ($value != '') { + switch ($var) + { + case 'name': + $where .= " AND `$var` = ?"; + $param[] = $value; + break; + } } - } } -echo(''); +echo '
    '; -foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", $param) as $entry) -{ - echo(''); - echo(''); +foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", $param) as $entry) { + echo ''; + echo ''; - echo(""); -} + foreach ($entry['blah'] as $version => $bleu) { + $content = '
    '; -echo("
    '.$entry['name'].'
    '.$entry['name'].'"); - foreach (dbFetchRows("SELECT * FROM `packages` WHERE `name` = ? ORDER BY version, build", array($entry['name'])) as $entry_v) - { - $entry['blah'][$entry_v['version']][$entry_v['build']][$entry_v['device_id']] = 1; - } - - foreach ($entry['blah'] as $version => $bleu) - { - - $content = '
    '; - - foreach ($bleu as $build => $bloo) - { - if ($build) { $dbuild = '-' . $build; } else { $dbuild = ''; } - $content .= '
    '.$version.$dbuild.''; - foreach ($bloo as $device_id => $no) - { - $this_device = device_by_id_cache($device_id); - $content .= ''.$this_device['hostname'].' '; - - } - $content .= "
    "; + echo '
    '; + foreach (dbFetchRows('SELECT * FROM `packages` WHERE `name` = ? ORDER BY version, build', array($entry['name'])) as $entry_v) { + $entry['blah'][$entry_v['version']][$entry_v['build']][$entry_v['device_id']] = 1; } - $content .= ""; - if (empty($vars['name'])) - { - echo("".overlib_link("", $version, $content, NULL).""); - } else { - echo("$version $content"); - } - } - echo(""); - echo("
    "); + foreach ($bleu as $build => $bloo) + { + if ($build) { + $dbuild = '-'.$build; + } + else { + $dbuild = ''; + } -?> + $content .= '
    '.$version.$dbuild.''; + foreach ($bloo as $device_id => $no) + { + $this_device = device_by_id_cache($device_id); + $content .= ''.$this_device['hostname'].' '; + } + + $content .= '
    '; + } + + $content .= ''; + if (empty($vars['name'])) { + echo "".overlib_link('', $version, $content, null).''; + } + else { + echo "$version $content"; + } + }//end foreach + + echo ''; + echo ''; +}//end foreach + +echo ''; diff --git a/html/pages/ports/graph.inc.php b/html/pages/ports/graph.inc.php index 90455b2d1..c582a3209 100644 --- a/html/pages/ports/graph.inc.php +++ b/html/pages/ports/graph.inc.php @@ -1,59 +1,75 @@ 0 || $port['out_errors'] > 0) - { - $error_img = generate_port_link($port,"Interface Errors",errors); - } else { $error_img = ""; } + if ($port['in_errors'] > 0 || $port['out_errors'] > 0) { + $error_img = generate_port_link($port, "Interface Errors", errors); + } + else { + $error_img = ''; + } - if (port_permitted($port['port_id'], $port['device_id'])) - { - $port = ifLabel($port, $device); + if (port_permitted($port['port_id'], $port['device_id'])) { + $port = ifLabel($port, $device); - $graph_type = "port_" . $subformat; + $graph_type = 'port_'.$subformat; - if ($_SESSION['widescreen']) { $width=357; } else { $width=315; } - if ($_SESSION['widescreen']) { $width_div=438; } else { $width_div=393; } + if ($_SESSION['widescreen']) { + $width = 357; + } + else { + $width = 315; + } - $graph_array = array(); - $graph_array['height'] = 100; - $graph_array['width'] = 210; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $port['port_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + if ($_SESSION['widescreen']) { + $width_div = 438; + } + else { + $width_div = 393; + } - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $port['hostname'] . " - " . $port['label']); - $graph_array['title'] = "yes"; - $graph_array['width'] = $width; $graph_array['height'] = 119; - $graph = generate_graph_tag($graph_array); + $graph_array = array(); + $graph_array['height'] = 100; + $graph_array['width'] = 210; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $port['port_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - echo("
    "); - echo(overlib_link($link, $graph, $overlib_content)); - echo("
    "); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); + $overlib_content = generate_overlib_content($graph_array, $port['hostname'].' - '.$port['label']); + $graph_array['title'] = 'yes'; + $graph_array['width'] = $width; + $graph_array['height'] = 119; + $graph = generate_graph_tag($graph_array); -# echo("\ -# \ -# ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". -# " -# -# "); - } -} -?> + echo "
    "; + echo overlib_link($link, $graph, $overlib_content); + echo '
    '; + + // echo("\ + // \ + // ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". + // " + // + // "); + }//end if +}//end foreach diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index 275d472d5..5dd77f468 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -1,97 +1,122 @@ 'pseudowires'); print_optionbar_start(); -echo('Pseudowires » '); +echo 'Pseudowires » '; -if ($vars['view'] == "detail") { echo(''); } -echo(generate_link("Details",$link_array,array('view'=> 'detail'))); -if ($vars['view'] == "detail") { echo(''); } +if ($vars['view'] == 'detail') { + echo ''; +} -echo(" | "); +echo generate_link('Details', $link_array, array('view' => 'detail')); +if ($vars['view'] == 'detail') { + echo ''; +} -if ($vars['view'] == "minigraphs") { echo(''); } -echo(generate_link("Mini Graphs",$link_array,array('view' => "minigraphs"))); -if ($vars['view'] == "minigraphs") { echo(''); } +echo ' | '; + +if ($vars['view'] == 'minigraphs') { + echo ''; +} + +echo generate_link('Mini Graphs', $link_array, array('view' => 'minigraphs')); +if ($vars['view'] == 'minigraphs') { + echo ''; +} print_optionbar_end(); -echo(""); +echo '
    '; -foreach (dbFetchRows("SELECT * FROM pseudowires AS P, ports AS I, devices AS D WHERE P.port_id = I.port_id AND I.device_id = D.device_id ORDER BY D.hostname,I.ifDescr") as $pw_a) -{ - $i = 0; - while ($i < count($linkdone)) - { - $thislink = $pw_a['device_id'] . $pw_a['port_id']; - if ($linkdone[$i] == $thislink) { $skip = "yes"; } - $i++; - } - - $pw_b = dbFetchRow("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id - AND P.cpwVcID = ? AND P.port_id = I.port_id", array($pw_a['peer_device_id'], $pw_a['cpwVcID'])); - - if (!port_permitted($pw_a['port_id'])) { $skip = "yes"; } - if (!port_permitted($pw_b['port_id'])) { $skip = "yes"; } - - if ($skip) - { - unset($skip); - } else { - if ($bg == "ffffff") { $bg = "e5e5e5"; } else { $bg="ffffff"; } - echo(" - - "); - echo(""); - - if ($vars['view'] == "minigraphs") - { - echo(""); + $i++; } - $linkdone[] = $pw_b['device_id'] . $pw_b['port_id']; - } -} + $pw_b = dbFetchRow( + 'SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id + AND P.cpwVcID = ? AND P.port_id = I.port_id', + array( + $pw_a['peer_device_id'], + $pw_a['cpwVcID'], + ) + ); -echo("
    ".$pw_a['cpwVcID']."".generate_device_link($pw_a)."".generate_port_link($pw_a)." ".generate_device_link($pw_b)."".generate_port_link($pw_b)."
    ".$pw_a['ifAlias']."".$pw_b['ifAlias']."
    "); - - if ($pw_a) - { - $pw_a['width'] = "150"; - $pw_a['height'] = "30"; - $pw_a['from'] = $config['time']['day']; - $pw_a['to'] = $config['time']['now']; - $pw_a['bg'] = $bg; - $types = array('bits','upkts','errors'); - foreach ($types as $graph_type) - { - $pw_a['graph_type'] = "port_".$graph_type; - print_port_thumbnail($pw_a); +foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I, devices AS D WHERE P.port_id = I.port_id AND I.device_id = D.device_id ORDER BY D.hostname,I.ifDescr') as $pw_a) { + $i = 0; + while ($i < count($linkdone)) { + $thislink = $pw_a['device_id'].$pw_a['port_id']; + if ($linkdone[$i] == $thislink) { + $skip = 'yes'; } - } - echo(""); - if ($pw_b) - { - $pw_b['width'] = "150"; - $pw_b['height'] = "30"; - $pw_b['from'] = $config['time']['day']; - $pw_b['to'] = $config['time']['now']; - $pw_b['bg'] = $bg; - $types = array('bits','upkts','errors'); - foreach ($types as $graph_type) - { - $pw_b['graph_type'] = "port_".$graph_type; - print_port_thumbnail($pw_b); - } - } - - echo("
    "); + if (!port_permitted($pw_a['port_id'])) { + $skip = 'yes'; + } -?> + if (!port_permitted($pw_b['port_id'])) { + $skip = 'yes'; + } + + if ($skip) { + unset($skip); + } + else { + if ($bg == 'ffffff') { + $bg = 'e5e5e5'; + } + else { + $bg = 'ffffff'; + } + + echo "".$pw_a['cpwVcID'].''.generate_device_link($pw_a).''.generate_port_link($pw_a)." + + ".generate_device_link($pw_b).''.generate_port_link($pw_b).''; + echo "".$pw_a['ifAlias'].''.$pw_b['ifAlias'].''; + + if ($vars['view'] == 'minigraphs') { + echo ""; + + if ($pw_a) { + $pw_a['width'] = '150'; + $pw_a['height'] = '30'; + $pw_a['from'] = $config['time']['day']; + $pw_a['to'] = $config['time']['now']; + $pw_a['bg'] = $bg; + $types = array('bits', 'upkts', 'errors'); + foreach ($types as $graph_type) + { + $pw_a['graph_type'] = 'port_'.$graph_type; + print_port_thumbnail($pw_a); + } + } + + echo ''; + + if ($pw_b) { + $pw_b['width'] = '150'; + $pw_b['height'] = '30'; + $pw_b['from'] = $config['time']['day']; + $pw_b['to'] = $config['time']['now']; + $pw_b['bg'] = $bg; + $types = array('bits', 'upkts', 'errors'); + foreach ($types as $graph_type) { + $pw_b['graph_type'] = 'port_'.$graph_type; + print_port_thumbnail($pw_b); + } + } + + echo ''; + }//end if + + $linkdone[] = $pw_b['device_id'].$pw_b['port_id']; + }//end if +}//end foreach + +echo ''; diff --git a/html/pages/purgeports.inc.php b/html/pages/purgeports.inc.php index 3bd98e20e..0b3d3639e 100644 --- a/html/pages/purgeports.inc.php +++ b/html/pages/purgeports.inc.php @@ -1,10 +1,7 @@ Deleting port " . $port['port_id'] . " - " . $port['ifDescr']); - delete_port($port['port_id']); - echo(""); +foreach (dbFetchRows("SELECT * FROM `ports` WHERE `deleted` = '1'") as $port) { + echo "
    Deleting port ".$port['port_id'].' - '.$port['ifDescr']; + delete_port($port['port_id']); + echo '
    '; } - -?> diff --git a/html/pages/routing.inc.php b/html/pages/routing.inc.php index 9c0bfb272..0a7fcb335 100644 --- a/html/pages/routing.inc.php +++ b/html/pages/routing.inc.php @@ -1,59 +1,62 @@ Routing » "); +// if (!$vars['protocol']) { $vars['protocol'] = "overview"; } +echo "Routing » "; unset($sep); -foreach ($routing_count as $type => $value) -{ - if (!$vars['protocol']) { $vars['protocol'] = $type; } +foreach ($routing_count as $type => $value) { + if (!$vars['protocol']) { + $vars['protocol'] = $type; + } - echo($sep); unset($sep); + echo $sep; + unset($sep); - if ($vars['protocol'] == $type) - { - echo(''); - } - if ($routing_count[$type]) - { - echo(generate_link($type_text[$type] ." (".$routing_count[$type].")",array('page'=> 'routing', 'protocol' => $type))); - $sep = " | "; - } + if ($vars['protocol'] == $type) { + echo ''; + } - if ($vars['protocol'] == $type) { echo(""); } -} + if ($routing_count[$type]) { + echo generate_link($type_text[$type].' ('.$routing_count[$type].')', array('page' => 'routing', 'protocol' => $type)); + $sep = ' | '; + } + + if ($vars['protocol'] == $type) { + echo ''; + } +}//end foreach print_optionbar_end(); -switch ($vars['protocol']) -{ - case 'overview': - case 'bgp': - case 'vrf': - case 'cef': - case 'ospf': - include('pages/routing/'.$vars['protocol'].'.inc.php'); +switch ($vars['protocol']) { + case 'overview': + case 'bgp': + case 'vrf': + case 'cef': + case 'ospf': + include 'pages/routing/'.$vars['protocol'].'.inc.php'; break; - default: - echo(report_this('Unknown protocol '.$vars['protocol'])); + + default: + echo report_this('Unknown protocol '.$vars['protocol']); break; } - -?> diff --git a/html/pages/routing/ospf.inc.php b/html/pages/routing/ospf.inc.php index f60312704..e3d779bfe 100644 --- a/html/pages/routing/ospf.inc.php +++ b/html/pages/routing/ospf.inc.php @@ -1,47 +1,65 @@ '); -echo('DeviceRouter IdStatusABRASBRAreasPortsNeighbours'); +echo ''; +echo ''; // Loop Instances +foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `ospfAdminStat` = 'enabled'") as $instance) { + if (!is_integer($i_i / 2)) { + $instance_bg = $list_colour_a; + } + else { + $instance_bg = $list_colour_b; + } -foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `ospfAdminStat` = 'enabled'") as $instance) -{ - if (!is_integer($i_i/2)) { $instance_bg = $list_colour_a; } else { $instance_bg = $list_colour_b; } + $device = device_by_id_cache($instance['device_id']); - $device = device_by_id_cache($instance['device_id']); + $area_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'"); + $port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."'"); + $port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = '".$device['device_id']."'"); + $neighbour_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = '".$device['device_id']."'"); - $area_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'"); - $port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."'"); - $port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = '".$device['device_id']."'"); - $neighbour_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = '".$device['device_id']."'"); + $ip_query = 'SELECT * FROM ipv4_addresses AS A, ports AS I WHERE '; + $ip_query .= '(A.ipv4_address = ? AND I.port_id = A.port_id)'; + $ip_query .= ' AND I.device_id = ?'; - $ip_query = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE "; - $ip_query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; - $ip_query .= " AND I.device_id = ?"; + $ipv4_host = dbFetchRow($ip_query, array($peer['bgpPeerIdentifier'], $device['device_id'])); - $ipv4_host = dbFetchRow($ip_query, array($peer['bgpPeerIdentifier'], $device['device_id'])); + if ($instance['ospfAdminStat'] == 'enabled') { + $enabled = 'enabled'; + } + else { + $enabled = 'disabled'; + } - if ($instance['ospfAdminStat'] == "enabled") { $enabled = 'enabled'; } else { $enabled = 'disabled'; } - if ($instance['ospfAreaBdrRtrStatus'] == "true") { $abr = 'yes'; } else { $abr = 'no'; } - if ($instance['ospfASBdrRtrStatus'] == "true") { $asbr = 'yes'; } else { $asbr = 'no'; } + if ($instance['ospfAreaBdrRtrStatus'] == 'true') { + $abr = 'yes'; + } + else { + $abr = 'no'; + } - echo(''); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(' '); - echo(''); + if ($instance['ospfASBdrRtrStatus'] == 'true') { + $asbr = 'yes'; + } + else { + $asbr = 'no'; + } - $i_i++; -} // End loop instances + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; -echo('
    DeviceRouter IdStatusABRASBRAreasPortsNeighbours
    '.generate_device_link($device, 0, array('tab' => 'routing', 'proto' => 'ospf')). ''.$instance['ospfRouterId'] . '' . $enabled . '' . $abr . '' . $asbr . '' . $area_count . '' . $port_count . '('.$port_count_enabled.')' . $neighbour_count . '
    '.generate_device_link($device, 0, array('tab' => 'routing', 'proto' => 'ospf')).''.$instance['ospfRouterId'].''.$enabled.''.$abr.''.$asbr.''.$area_count.''.$port_count.'('.$port_count_enabled.')'.$neighbour_count.'
    '); + $i_i++; +} //end foreach -?> +echo ''; diff --git a/html/pages/routing/overview.inc.php b/html/pages/routing/overview.inc.php index ff49c70ff..bd9a9e63e 100644 --- a/html/pages/routing/overview.inc.php +++ b/html/pages/routing/overview.inc.php @@ -1,28 +1,29 @@ '; + echo '
    '.$type_text[$type].''; - echo('
    '); - echo('
    '.$type_text[$type].''); + include 'pages/routing/overview/'.mres($type).'.inc.php'; - include("pages/routing/overview/".mres($type).".inc.php"); + echo '
    '; + echo '
    '; + } + else { + $graph_title = $type_text[$type]; + $graph_type = 'device_'.$type; - echo('
    '); - echo(''); - } else { - $graph_title = $type_text[$type]; - $graph_type = "device_".$type; - - include("includes/print-device-graph.php"); - } + include 'includes/print-device-graph.php'; + } } - } - -?> +} diff --git a/html/pages/routing/vrf.inc.php b/html/pages/routing/vrf.inc.php index 530c6b7f2..4d428cb1c 100644 --- a/html/pages/routing/vrf.inc.php +++ b/html/pages/routing/vrf.inc.php @@ -1,182 +1,257 @@ = '5') { - - if (!isset($_GET['optb'])) { $_GET['optb'] = "all"; } - if (!isset($_GET['optc'])) { $_GET['optc'] = "basic"; } - - print_optionbar_start(); - - echo('VRF » '); - - if ($_GET['opta'] == "vrf" && $_GET['optb'] == "all") { echo(""); } - echo('All'); - if ($_GET['opta'] == "vrf" && $_GET['optb'] == "all") { echo(""); } - echo(' | '); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "basic") { echo(""); } - echo('Basic'); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "basic") { echo(""); } - echo(" | "); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "details") { echo(""); } - echo('Details'); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "details") { echo(""); } - echo(" | Graphs: ( "); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "bits") { echo(""); } - echo('Bits'); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "bits") { echo(""); } - echo(" | "); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "upkts") { echo(""); } - echo('Packets'); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "upkts") { echo(""); } - echo(" | "); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "nupkts") { echo(""); } - echo('NU Packets'); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "nupkts") { echo(""); } - echo(" | "); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "errors") { echo(""); } - echo('Errors'); - if ($_GET['opta'] == "vrf" && $_GET['optc'] == "errors") { echo(""); } - - echo(" )"); - - print_optionbar_end(); - -if($_GET['optb'] == "all" ) { - - // Pre-Cache in arrays - // That's heavier on RAM, but much faster on CPU (1:40) - - // Specifying the fields reduces a lot the RAM used (1:4) . - $vrf_fields = "vrf_id, mplsVpnVrfRouteDistinguisher, mplsVpnVrfDescription, vrf_name"; - $dev_fields = "D.device_id as device_id, hostname, os, hardware, version, features, location, status, `ignore`, disabled"; - $port_fields = "port_id, ifvrf, device_id, ifDescr, ifAlias, ifName"; - - foreach (dbFetchRows("SELECT $vrf_fields, $dev_fields FROM `vrfs` AS V, `devices` AS D WHERE D.device_id = V.device_id") as $vrf_device) - { - if (empty($vrf_devices[$vrf_device['mplsVpnVrfRouteDistinguisher']])) { $vrf_devices[$vrf_device['mplsVpnVrfRouteDistinguisher']][0] = $vrf_device; } - else { array_push ($vrf_devices[$vrf_device['mplsVpnVrfRouteDistinguisher']], $vrf_device); } - } - - foreach (dbFetchRows("SELECT $port_fields FROM `ports` WHERE ifVrf<>0") as $port) - { - if (empty($ports[$port['ifvrf']][$port['device_id']])) { $ports[$port['ifvrf']][$port['device_id']][0] = $port; } - else { array_push ($ports[$port['ifvrf']][$port['device_id']], $port); } - } - - echo("
    "); - $i = "1"; - foreach (dbFetchRows("SELECT * FROM `vrfs` GROUP BY `mplsVpnVrfRouteDistinguisher`") as $vrf) - { - if ($i % 2) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - echo(""); - echo(""); - echo(""); - #echo(""); - echo(""); - - $i++; - } - echo("
    " . $vrf['vrf_name'] . "
    " . $vrf['mplsVpnVrfDescription'] . "
    " . $vrf['mplsVpnVrfRouteDistinguisher'] . "" . $vrf['mplsVpnVrfDescription'] . ""); - $x=1; - foreach ($vrf_devices[$vrf['mplsVpnVrfRouteDistinguisher']] as $device) - { - if ($i % 2) - { - if ($x % 2) { $dev_colour = $list_colour_a_a; } else { $dev_colour = $list_colour_a_b; } - } else { - if ($x % 2) { $dev_colour = $list_colour_b_b; } else { $dev_colour = $list_colour_b_a; } - } - echo(""); - $x++; - } // End While - - echo("
    ".generate_device_link($device, shorthost($device['hostname']))); - - if ($device['vrf_name'] != $vrf['vrf_name']) { echo("Configured : ".$device['vrf_name']."', CAPTION, 'VRF Inconsistency' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> "); } - echo(""); - unset($seperator); - - foreach ($ports[$device['vrf_id']][$device['device_id']] as $port) - { - $port = array_merge ($device, $port); - - switch ($_GET['optc']) - { - case 'bits': - case 'upkts': - case 'nupkts': - case 'errors': - $port['width'] = "130"; - $port['height'] = "30"; - $port['from'] = $config['time']['day']; - $port['to'] = $config['time']['now']; - $port['bg'] = "#".$bg; - $port['graph_type'] = "port_".$_GET['optc']; - echo("
    -
    ".makeshortif($port['ifDescr'])."
    "); - print_port_thumbnail($port); - echo("
    ".truncate(short_port_descr($port['ifAlias']), 22, '')."
    -
    "); - break; - - default: - echo($seperator.generate_port_link($port,makeshortif($port['ifDescr']))); - $seperator = ", "; - break; - } - } - echo("
    "); - -} else { - - echo("
    "); - $vrf = dbFetchRow("SELECT * FROM `vrfs` WHERE mplsVpnVrfRouteDistinguisher = ?", array($_GET['optb'])); - echo(""); - echo(""); - echo(""); - echo(""); - echo("
    " . $vrf['vrf_name'] . "" . $vrf['mplsVpnVrfRouteDistinguisher'] . "" . $vrf['mplsVpnVrfDescription'] . "
    "); - - $x=0; - - $devices = dbFetchRows("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = ? AND D.device_id = V.device_id", array($vrf['mplsVpnVrfRouteDistinguisher'])); - foreach ($devices as $device) - { - $hostname = $device['hostname']; - if ($x % 2) { $device_colour = $list_colour_a; } else { $device_colour = $list_colour_b; } - echo(""); - - include("includes/device-header.inc.php"); - - echo("
    "); - unset($seperator); - echo('
    '); - $i=1; - foreach (dbFetchRows("SELECT * FROM `ports` WHERE `ifVrf` = ? AND `device_id` = ?", array($device['vrf_id'], $device['device_id'])) as $interface) - { - if ($x % 2) - { - if ($i % 2 === 0) { $int_colour = $list_colour_a_b; } else { $int_colour = $list_colour_a_a; } - } else { - if ($i % 2 === 0) { $int_colour = $list_colour_b_a; } else { $int_colour = $list_colour_b_b; } - } - - include("includes/print-interface.inc.php"); - - $i++; + if (!isset($_GET['optb'])) { + $_GET['optb'] = 'all'; } - $x++; - echo("
    "); - echo("
    "); - } + if (!isset($_GET['optc'])) { + $_GET['optc'] = 'basic'; + } + + print_optionbar_start(); + + echo 'VRF » '; + + if ($_GET['opta'] == 'vrf' && $_GET['optb'] == 'all') { + echo ""; + } + + echo 'All'; + if ($_GET['opta'] == 'vrf' && $_GET['optb'] == 'all') { + echo ''; + } + + echo ' | '; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'basic') { + echo ""; + } + + echo 'Basic'; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'basic') { + echo ''; + } + + echo ' | '; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'details') { + echo ""; + } + + echo 'Details'; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'details') { + echo ''; + } + + echo ' | Graphs: ( '; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'bits') { + echo ""; + } + + echo 'Bits'; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'upkts') { + echo ""; + } + + echo 'Packets'; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'upkts') { + echo ''; + } + + echo ' | '; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'nupkts') { + echo ""; + } + + echo 'NU Packets'; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'nupkts') { + echo ''; + } + + echo ' | '; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'errors') { + echo ""; + } + + echo 'Errors'; + if ($_GET['opta'] == 'vrf' && $_GET['optc'] == 'errors') { + echo ''; + } + + echo ' )'; + + print_optionbar_end(); + + if ($_GET['optb'] == 'all') { + // Pre-Cache in arrays + // That's heavier on RAM, but much faster on CPU (1:40) + // Specifying the fields reduces a lot the RAM used (1:4) . + $vrf_fields = 'vrf_id, mplsVpnVrfRouteDistinguisher, mplsVpnVrfDescription, vrf_name'; + $dev_fields = 'D.device_id as device_id, hostname, os, hardware, version, features, location, status, `ignore`, disabled'; + $port_fields = 'port_id, ifvrf, device_id, ifDescr, ifAlias, ifName'; + + foreach (dbFetchRows("SELECT $vrf_fields, $dev_fields FROM `vrfs` AS V, `devices` AS D WHERE D.device_id = V.device_id") as $vrf_device) { + if (empty($vrf_devices[$vrf_device['mplsVpnVrfRouteDistinguisher']])) { + $vrf_devices[$vrf_device['mplsVpnVrfRouteDistinguisher']][0] = $vrf_device; + } + else { + array_push($vrf_devices[$vrf_device['mplsVpnVrfRouteDistinguisher']], $vrf_device); + } + } + + foreach (dbFetchRows("SELECT $port_fields FROM `ports` WHERE ifVrf<>0") as $port) { + if (empty($ports[$port['ifvrf']][$port['device_id']])) { + $ports[$port['ifvrf']][$port['device_id']][0] = $port; + } + else { + array_push($ports[$port['ifvrf']][$port['device_id']], $port); + } + } + + echo "
    "; + $i = '1'; + foreach (dbFetchRows('SELECT * FROM `vrfs` GROUP BY `mplsVpnVrfRouteDistinguisher`') as $vrf) { + if (($i % 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } + + echo ""; + echo "'; + echo ''; + // echo(""); + echo ''; + $i++; + }//end foreach + + echo '
    ".$vrf['vrf_name'].'
    '.$vrf['mplsVpnVrfDescription'].'
    '.$vrf['mplsVpnVrfRouteDistinguisher'].'" . $vrf['mplsVpnVrfDescription'] . "'; + $x = 1; + foreach ($vrf_devices[$vrf['mplsVpnVrfRouteDistinguisher']] as $device) { + if (($i % 2)) { + if (($x % 2)) { + $dev_colour = $list_colour_a_a; + } + else { + $dev_colour = $list_colour_a_b; + } + } + else { + if (($x % 2)) { + $dev_colour = $list_colour_b_b; + } + else { + $dev_colour = $list_colour_b_a; + } + } + + echo "'; + $x++; + } //end foreach + + echo '
    ".generate_device_link($device, shorthost($device['hostname'])); + + if ($device['vrf_name'] != $vrf['vrf_name']) { + echo "Configured : '.$device['vrf_name']."', CAPTION, 'VRF Inconsistency' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> "; + } + + echo ''; + unset($seperator); + + foreach ($ports[$device['vrf_id']][$device['device_id']] as $port) { + $port = array_merge($device, $port); + + switch ($_GET['optc']) { + case 'bits': + case 'upkts': + case 'nupkts': + case 'errors': + $port['width'] = '130'; + $port['height'] = '30'; + $port['from'] = $config['time']['day']; + $port['to'] = $config['time']['now']; + $port['bg'] = '#'.$bg; + $port['graph_type'] = 'port_'.$_GET['optc']; + echo "
    +
    ".makeshortif($port['ifDescr']).'
    '; + print_port_thumbnail($port); + echo "
    ".truncate(short_port_descr($port['ifAlias']), 22, '').'
    +
    '; + break; + + default: + echo $seperator.generate_port_link($port, makeshortif($port['ifDescr'])); + $seperator = ', '; + break; + }//end switch + }//end foreach + + echo '
    '; + } + else { + echo "
    "; + $vrf = dbFetchRow('SELECT * FROM `vrfs` WHERE mplsVpnVrfRouteDistinguisher = ?', array($_GET['optb'])); + echo ""; + echo "'; + echo ''; + echo ''; + echo '
    ".$vrf['vrf_name'].''.$vrf['mplsVpnVrfRouteDistinguisher'].''.$vrf['mplsVpnVrfDescription'].'
    '; + + $x = 0; + + $devices = dbFetchRows('SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = ? AND D.device_id = V.device_id', array($vrf['mplsVpnVrfRouteDistinguisher'])); + foreach ($devices as $device) { + $hostname = $device['hostname']; + if (($x % 2)) { + $device_colour = $list_colour_a; + } + else { + $device_colour = $list_colour_b; + } + + echo ''; + + include 'includes/device-header.inc.php'; + + echo '
    '; + unset($seperator); + echo '
    '; + $i = 1; + foreach (dbFetchRows('SELECT * FROM `ports` WHERE `ifVrf` = ? AND `device_id` = ?', array($device['vrf_id'], $device['device_id'])) as $interface) { + if (($x % 2)) { + if (($i % 2) === 0) { + $int_colour = $list_colour_a_b; + } + else { + $int_colour = $list_colour_a_a; + } + } + else { + if (($i % 2) === 0) { + $int_colour = $list_colour_b_a; + } + else { + $int_colour = $list_colour_b_b; + } + } + + include 'includes/print-interface.inc.php'; + + $i++; + }//end foreach + + $x++; + echo '
    '; + echo "
    "; + }//end foreach + }//end if } - -} else { - - include("includes/error-no-perm.inc.php"); - -} // End Permission if - -?> +else { + include 'includes/error-no-perm.inc.php'; +} //end if diff --git a/includes/discovery/cisco-entity-sensor.inc.php b/includes/discovery/cisco-entity-sensor.inc.php index 804c8189c..2fecd796c 100644 --- a/includes/discovery/cisco-entity-sensor.inc.php +++ b/includes/discovery/cisco-entity-sensor.inc.php @@ -1,152 +1,176 @@ $entry) - { - #echo("[" . $entry['entSensorType'] . "|" . $entry['entSensorValue']. "|" . $index . "]"); - - if ($entitysensor[$entry['entSensorType']] && is_numeric($entry['entSensorValue']) && is_numeric($index)) - { - $entPhysicalIndex = $index; - if ($entity_array[$index]['entPhysicalName'] || $device['os'] == "iosxr") - { - $descr = rewrite_entity_descr($entity_array[$index]['entPhysicalName']) . " - " . rewrite_entity_descr($entity_array[$index]['entPhysicalDescr']); - } else { - $descr = $entity_array[$index]['entPhysicalDescr']; - $descr = rewrite_entity_descr($descr); - } - - // Set description based on measured entity if it exists - if (is_numeric($entry['entSensorMeasuredEntity']) && $entry['entSensorMeasuredEntity']) - { - $measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalName']; - if (!$measured_descr) - { - $measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalDescr']; - } - - $descr = $measured_descr . " - " . $descr; - } - - // Bit dirty also, clean later - $descr = str_replace("Temp: ", "", $descr); - $descr = str_ireplace("temperature ", "", $descr); - - $oid = ".1.3.6.1.4.1.9.9.91.1.1.1.1.4.".$index; - $current = $entry['entSensorValue']; - $type = $entitysensor[$entry['entSensorType']]; - - #echo("$index : ".$entry['entSensorScale']."|"); - - // FIXME this stuff is foul - if ($entry['entSensorScale'] == "nano") { $divisor = "1000000000"; $multiplier = "1"; } - if ($entry['entSensorScale'] == "micro") { $divisor = "1000000"; $multiplier = "1"; } - if ($entry['entSensorScale'] == "milli") { $divisor = "1000"; $multiplier = "1"; } - if ($entry['entSensorScale'] == "units") { $divisor = "1"; $multiplier = "1"; } - if ($entry['entSensorScale'] == "kilo") { $divisor = "1"; $multiplier = "1000"; } - if ($entry['entSensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; } - if ($entry['entSensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; } - if (is_numeric($entry['entSensorPrecision']) && $entry['entSensorPrecision'] > "0") { $divisor = $divisor . str_pad('', $entry['entSensorPrecision'], "0"); } - $current = $current * $multiplier / $divisor; - - // Set thresholds to null - $limit = NULL; $low_limit = NULL; $warn_limit = NULL; $warn_limit_low = NULL; - - // Check thresholds for this entry (bit dirty, but it works!) - if (is_array($t_oids[$index])) - { - foreach ($t_oids[$index] as $t_index => $entry) - { - // Critical Limit - if ($entry['entSensorThresholdSeverity'] == "major" && $entry['entSensorThresholdRelation'] == "greaterOrEqual") - { - $limit = $entry['entSensorThresholdValue'] * $multiplier / $divisor; - } - - if ($entry['entSensorThresholdSeverity'] == "major" && $entry['entSensorThresholdRelation'] == "lessOrEqual") - { - $limit_low = $entry['entSensorThresholdValue'] * $multiplier / $divisor; - } - - // Warning Limit - if ($entry['entSensorThresholdSeverity'] == "minor" && $entry['entSensorThresholdRelation'] == "greaterOrEqual") - { - $warn_limit = $entry['entSensorThresholdValue'] * $multiplier / $divisor; - } - - if ($entry['entSensorThresholdSeverity'] == "minor" && $entry['entSensorThresholdRelation'] == "lessOrEqual") - { - $warn_limit_low = $entry['entSensorThresholdValue'] * $multiplier / $divisor; - } - } - } - // End Threshold code - - $ok = TRUE; - - if ($current == "-127") { $ok = FALSE; } // False reading -# if ($type == "temperature" && $current < 1) { $ok = FALSE; } // False reading. Temperature <1 :) - if ($descr == "") { $ok = FALSE; } // Invalid description. Lots of these on Nexus - - if ($ok) { -# echo("\n".$valid['sensor'].", $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current"); - discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity']); - } - $cisco_entity_temperature = 1; - unset($limit, $limit_low, $warn_limit, $warn_limit_low); - - } + if (!is_array($entity_array)) { + $entity_array = array(); + echo ' entPhysicalDescr'; + $entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalDescr', $entity_array, 'CISCO-ENTITY-SENSOR-MIB'); + echo ' entPhysicalName'; + $entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalName', $entity_array, 'CISCO-ENTITY-SENSOR-MIB'); } - } -} -?> + echo ' entSensorType'; + $oids = snmpwalk_cache_multi_oid($device, 'entSensorType', $oids, 'CISCO-ENTITY-SENSOR-MIB'); + echo ' entSensorScale'; + $oids = snmpwalk_cache_multi_oid($device, 'entSensorScale', $oids, 'CISCO-ENTITY-SENSOR-MIB'); + echo ' entSensorValue'; + $oids = snmpwalk_cache_multi_oid($device, 'entSensorValue', $oids, 'CISCO-ENTITY-SENSOR-MIB'); + echo ' entSensorMeasuredEntity'; + $oids = snmpwalk_cache_multi_oid($device, 'entSensorMeasuredEntity', $oids, 'CISCO-ENTITY-SENSOR-MIB'); + echo ' entSensorPrecision'; + $oids = snmpwalk_cache_multi_oid($device, 'entSensorPrecision', $oids, 'CISCO-ENTITY-SENSOR-MIB'); + + $t_oids = array(); + echo ' entSensorThresholdSeverity'; + $t_oids = snmpwalk_cache_twopart_oid($device, 'entSensorThresholdSeverity', $t_oids, 'CISCO-ENTITY-SENSOR-MIB'); + echo ' entSensorThresholdRelation'; + $t_oids = snmpwalk_cache_twopart_oid($device, 'entSensorThresholdRelation', $t_oids, 'CISCO-ENTITY-SENSOR-MIB'); + echo ' entSensorThresholdValue'; + $t_oids = snmpwalk_cache_twopart_oid($device, 'entSensorThresholdValue', $t_oids, 'CISCO-ENTITY-SENSOR-MIB'); + + if ($debug) { + print_r($oids); + } + + $entitysensor['voltsDC'] = 'voltage'; + $entitysensor['voltsAC'] = 'voltage'; + $entitysensor['amperes'] = 'current'; + $entitysensor['watt'] = 'power'; + $entitysensor['hertz'] = 'freq'; + $entitysensor['percentRH'] = 'humidity'; + $entitysensor['rpm'] = 'fanspeed'; + $entitysensor['celsius'] = 'temperature'; + $entitysensor['watts'] = 'power'; + $entitysensor['dBm'] = 'dbm'; + + if (is_array($oids)) { + foreach ($oids as $index => $entry) + { + // echo("[" . $entry['entSensorType'] . "|" . $entry['entSensorValue']. "|" . $index . "]"); + if ($entitysensor[$entry['entSensorType']] && is_numeric($entry['entSensorValue']) && is_numeric($index)) { + $entPhysicalIndex = $index; + if ($entity_array[$index]['entPhysicalName'] || $device['os'] == 'iosxr') { + $descr = rewrite_entity_descr($entity_array[$index]['entPhysicalName']).' - '.rewrite_entity_descr($entity_array[$index]['entPhysicalDescr']); + } + else { + $descr = $entity_array[$index]['entPhysicalDescr']; + $descr = rewrite_entity_descr($descr); + } + + // Set description based on measured entity if it exists + if (is_numeric($entry['entSensorMeasuredEntity']) && $entry['entSensorMeasuredEntity']) { + $measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalName']; + if (!$measured_descr) { + $measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalDescr']; + } + + $descr = $measured_descr.' - '.$descr; + } + + // Bit dirty also, clean later + $descr = str_replace('Temp: ', '', $descr); + $descr = str_ireplace('temperature ', '', $descr); + + $oid = '.1.3.6.1.4.1.9.9.91.1.1.1.1.4.'.$index; + $current = $entry['entSensorValue']; + $type = $entitysensor[$entry['entSensorType']]; + + // echo("$index : ".$entry['entSensorScale']."|"); + // FIXME this stuff is foul + if ($entry['entSensorScale'] == 'nano') { + $divisor = '1000000000'; + $multiplier = '1'; + } + + if ($entry['entSensorScale'] == 'micro') { + $divisor = '1000000'; + $multiplier = '1'; + } + + if ($entry['entSensorScale'] == 'milli') { + $divisor = '1000'; + $multiplier = '1'; + } + + if ($entry['entSensorScale'] == 'units') { + $divisor = '1'; + $multiplier = '1'; + } + + if ($entry['entSensorScale'] == 'kilo') { + $divisor = '1'; + $multiplier = '1000'; + } + + if ($entry['entSensorScale'] == 'mega') { + $divisor = '1'; + $multiplier = '1000000'; + } + + if ($entry['entSensorScale'] == 'giga') { + $divisor = '1'; + $multiplier = '1000000000'; + } + + if (is_numeric($entry['entSensorPrecision']) && $entry['entSensorPrecision'] > '0') { + $divisor = $divisor.str_pad('', $entry['entSensorPrecision'], '0'); + } + + $current = ($current * $multiplier / $divisor); + + // Set thresholds to null + $limit = null; + $low_limit = null; + $warn_limit = null; + $warn_limit_low = null; + + // Check thresholds for this entry (bit dirty, but it works!) + if (is_array($t_oids[$index])) { + foreach ($t_oids[$index] as $t_index => $entry) { + // Critical Limit + if ($entry['entSensorThresholdSeverity'] == 'major' && $entry['entSensorThresholdRelation'] == 'greaterOrEqual') { + $limit = ($entry['entSensorThresholdValue'] * $multiplier / $divisor); + } + + if ($entry['entSensorThresholdSeverity'] == 'major' && $entry['entSensorThresholdRelation'] == 'lessOrEqual') { + $limit_low = ($entry['entSensorThresholdValue'] * $multiplier / $divisor); + } + + // Warning Limit + if ($entry['entSensorThresholdSeverity'] == 'minor' && $entry['entSensorThresholdRelation'] == 'greaterOrEqual') { + $warn_limit = ($entry['entSensorThresholdValue'] * $multiplier / $divisor); + } + + if ($entry['entSensorThresholdSeverity'] == 'minor' && $entry['entSensorThresholdRelation'] == 'lessOrEqual') { + $warn_limit_low = ($entry['entSensorThresholdValue'] * $multiplier / $divisor); + } + }//end foreach + }//end if + + // End Threshold code + $ok = true; + + if ($current == '-127') { + $ok = false; + } //end if + // if ($type == "temperature" && $current < 1) { $ok = FALSE; } // False reading. Temperature <1 :) + if ($descr == '') { + $ok = false; + } //end if + + if ($ok) { + // echo("\n".$valid['sensor'].", $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current"); + discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity']); + } + + $cisco_entity_temperature = 1; + unset($limit, $limit_low, $warn_limit, $warn_limit_low); + }//end if + }//end foreach + }//end if +}//end if diff --git a/includes/discovery/cisco-sla.inc.php b/includes/discovery/cisco-sla.inc.php index f844a5f1f..f8af98725 100644 --- a/includes/discovery/cisco-sla.inc.php +++ b/includes/discovery/cisco-sla.inc.php @@ -1,107 +1,98 @@ $device['device_id'])); - // Get existing SLAs - $existing_slas = dbFetchColumn("SELECT `sla_id` FROM `slas` WHERE `device_id` = :device_id AND `deleted` = 0", array('device_id' => $device['device_id'])); - - foreach ($sla_table as $sla_nr => $sla_config) - { + foreach ($sla_table as $sla_nr => $sla_config) { $query_data = array( - 'device_id' => $device['device_id'], - 'sla_nr' => $sla_nr, - ); - $sla_id = dbFetchCell("SELECT `sla_id` FROM `slas` WHERE `device_id` = :device_id AND `sla_nr` = :sla_nr", $query_data); + 'device_id' => $device['device_id'], + 'sla_nr' => $sla_nr, + ); + $sla_id = dbFetchCell('SELECT `sla_id` FROM `slas` WHERE `device_id` = :device_id AND `sla_nr` = :sla_nr', $query_data); - $data = array( - 'device_id' => $device['device_id'], - 'sla_nr' => $sla_nr, - 'owner' => $sla_config['rttMonCtrlAdminOwner'], - 'tag' => $sla_config['rttMonCtrlAdminTag'], - 'rtt_type' => $sla_config['rttMonCtrlAdminRttType'], - 'status' => ($sla_config['rttMonCtrlAdminStatus'] == 'active') ? 1 : 0, - 'deleted' => 0, - ); + $data = array( + 'device_id' => $device['device_id'], + 'sla_nr' => $sla_nr, + 'owner' => $sla_config['rttMonCtrlAdminOwner'], + 'tag' => $sla_config['rttMonCtrlAdminTag'], + 'rtt_type' => $sla_config['rttMonCtrlAdminRttType'], + 'status' => ($sla_config['rttMonCtrlAdminStatus'] == 'active') ? 1 : 0, + 'deleted' => 0, + ); - // Some fallbacks for when the tag is empty - if (!$data['tag']) - { - switch ($data['rtt_type']) - { - case 'http': - $data['tag'] = $sla_config['rttMonEchoAdminURL']; - break; + // Some fallbacks for when the tag is empty + if (!$data['tag']) { + switch ($data['rtt_type']) + { + case 'http': + $data['tag'] = $sla_config['rttMonEchoAdminURL']; + break; - case 'dns': - $data['tag'] = $sla_config['rttMonEchoAdminTargetAddressString']; - break; + case 'dns': + $data['tag'] = $sla_config['rttMonEchoAdminTargetAddressString']; + break; - case 'echo': - $parts = explode(" ", $sla_config['rttMonEchoAdminTargetAddress']); - if (count($parts) == 4) - { - // IPv4 - $data['tag'] = implode(".", array_map('hexdec', $parts)); - } - elseif (count($parts) == 16) - { - // IPv6 - $data['tag'] = $parts[0].$parts[1].':'.$parts[2].$parts[3].':'.$parts[4].$parts[5].':'.$parts[6].$parts[7].':'.$parts[8].$parts[9].':'.$parts[10].$parts[11].':'.$parts[12].$parts[13].':'.$parts[14].$parts[15]; - $data['tag'] = preg_replace('/:0*([0-9])/', ':$1', $data['tag']); - } - break; - } + case 'echo': + $parts = explode(' ', $sla_config['rttMonEchoAdminTargetAddress']); + if (count($parts) == 4) { + // IPv4 + $data['tag'] = implode('.', array_map('hexdec', $parts)); + } + else if (count($parts) == 16) { + // IPv6 + $data['tag'] = $parts[0].$parts[1].':'.$parts[2].$parts[3].':'.$parts[4].$parts[5].':'.$parts[6].$parts[7].':'.$parts[8].$parts[9].':'.$parts[10].$parts[11].':'.$parts[12].$parts[13].':'.$parts[14].$parts[15]; + $data['tag'] = preg_replace('/:0*([0-9])/', ':$1', $data['tag']); + } + break; + }//end switch + }//end if + + if (!$sla_id) { + $sla_id = dbInsert($data, 'slas'); + echo '+'; + } + else { + // Remove from the list + $existing_slas = array_diff($existing_slas, array($sla_id)); + + dbUpdate($data, 'slas', '`sla_id` = :sla_id', array('sla_id' => $sla_id)); + echo '.'; + } + }//end foreach + + // Mark all remaining SLAs as deleted + foreach ($existing_slas as $existing_sla) { + dbUpdate(array('deleted' => 1), 'slas', '`sla_id` = :sla_id', array('sla_id' => $existing_sla)); + echo '-'; } - if (!$sla_id) - { - $sla_id = dbInsert($data, 'slas'); - echo "+"; - } - else - { - // Remove from the list - $existing_slas = array_diff($existing_slas, array($sla_id)); - - dbUpdate($data, 'slas', "`sla_id` = :sla_id", array('sla_id' => $sla_id)); - echo "."; - } - } - - // Mark all remaining SLAs as deleted - foreach ($existing_slas as $existing_sla) - { - dbUpdate(array('deleted' => 1), 'slas', "`sla_id` = :sla_id", array('sla_id' => $existing_sla)); - echo "-"; - } - - echo("\n"); -} # enable_sla && cisco - -?> + echo "\n"; +} diff --git a/includes/discovery/current.inc.php b/includes/discovery/current.inc.php index ef60dbfb9..c28644184 100644 --- a/includes/discovery/current.inc.php +++ b/includes/discovery/current.inc.php @@ -1,15 +1,14 @@ +echo "\n"; diff --git a/includes/discovery/current/gamatronicups.inc.php b/includes/discovery/current/gamatronicups.inc.php index 03dad6c25..be019523b 100644 --- a/includes/discovery/current/gamatronicups.inc.php +++ b/includes/discovery/current/gamatronicups.inc.php @@ -1,36 +1,37 @@ \ No newline at end of file diff --git a/includes/discovery/current/ipoman.inc.php b/includes/discovery/current/ipoman.inc.php index 8b29980b6..92524dbaa 100644 --- a/includes/discovery/current/ipoman.inc.php +++ b/includes/discovery/current/ipoman.inc.php @@ -1,60 +1,54 @@ $entry) - { - $cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.3.' . $index; - $divisor = 1000; - $descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') : "Inlet $index"); - $current = $entry['inletStatusCurrent'] / $divisor; - $high_limit = $entry['inletConfigCurrentHigh'] / 10; - - discover_sensor($valid['sensor'], 'current', $device, $cur_oid, '1.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', NULL, NULL, NULL, $high_limit, $current); - // FIXME: iPoMan 1201 also says it has 2 inlets, at least until firmware 1.06 - wtf? + if (!is_array($cache['ipoman'])) { + echo 'outletConfigDesc '; + $cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $cache['ipoman']['out'], 'IPOMANII-MIB'); + echo 'outletConfigLocation '; + $cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $cache['ipoman']['out'], 'IPOMANII-MIB'); + echo 'inletConfigDesc '; + $cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, 'inletConfigDesc', $cache['ipoman'], 'IPOMANII-MIB'); } - } - if (is_array($oids_out)) - { - foreach ($oids_out as $index => $entry) - { - $cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.3.' . $index; - $divisor = 1000; - $descr = (trim($cache['ipoman']['out'][$index]['outletConfigDesc'],'"') != '' ? trim($cache['ipoman']['out'][$index]['outletConfigDesc'],'"') : "Output $index"); - $current = $entry['outletStatusCurrent'] / $divisor; - $high_limit = $entry['outletConfigCurrentHigh'] / 10; + $oids_in = array(); + $oids_out = array(); - discover_sensor($valid['sensor'], 'current', $device, $cur_oid, '2.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', NULL, NULL, NULL, $high_limit, $current); + echo 'inletConfigCurrentHigh '; + $oids_in = snmpwalk_cache_multi_oid($device, 'inletConfigCurrentHigh', $oids_in, 'IPOMANII-MIB'); + echo 'inletStatusCurrent '; + $oids_in = snmpwalk_cache_multi_oid($device, 'inletStatusCurrent', $oids_in, 'IPOMANII-MIB'); + echo 'outletConfigCurrentHigh '; + $oids_out = snmpwalk_cache_multi_oid($device, 'outletConfigCurrentHigh', $oids_out, 'IPOMANII-MIB'); + echo 'outletStatusCurrent '; + $oids_out = snmpwalk_cache_multi_oid($device, 'outletStatusCurrent', $oids_out, 'IPOMANII-MIB'); + + if (is_array($oids_in)) { + foreach ($oids_in as $index => $entry) + { + $cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.3.'.$index; + $divisor = 1000; + $descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') : "Inlet $index"); + $current = ($entry['inletStatusCurrent'] / $divisor); + $high_limit = ($entry['inletConfigCurrentHigh'] / 10); + + discover_sensor($valid['sensor'], 'current', $device, $cur_oid, '1.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', null, null, null, $high_limit, $current); + // FIXME: iPoMan 1201 also says it has 2 inlets, at least until firmware 1.06 - wtf? + } } - } -} -?> \ No newline at end of file + if (is_array($oids_out)) { + foreach ($oids_out as $index => $entry) + { + $cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.3.'.$index; + $divisor = 1000; + $descr = (trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') != '' ? trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') : "Output $index"); + $current = ($entry['outletStatusCurrent'] / $divisor); + $high_limit = ($entry['outletConfigCurrentHigh'] / 10); + + discover_sensor($valid['sensor'], 'current', $device, $cur_oid, '2.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', null, null, null, $high_limit, $current); + } + } +}//end if diff --git a/includes/discovery/current/mgeups.inc.php b/includes/discovery/current/mgeups.inc.php index 0f161a4a6..c2a7b77a7 100644 --- a/includes/discovery/current/mgeups.inc.php +++ b/includes/discovery/current/mgeups.inc.php @@ -1,60 +1,69 @@ 1) $descr .= " Phase $i"; - $current = snmp_get($device, $current_oid, "-Oqv"); - if (!$current) - { - $current_oid .= ".0"; - $current = snmp_get($device, $current_oid, "-Oqv"); +if ($device['os'] == 'mgeups') { + echo 'MGE '; + $oids = trim(snmp_walk($device, '1.3.6.1.4.1.705.1.7.1', '-OsqnU')); + if ($debug) { + echo $oids."\n"; } - $current /= 10; - $type = "mge-ups"; - $precision = 10; - $index = $i; - $warnlimit = NULL; - $lowlimit = 0; - $limit = NULL; - $lowwarnlimit = NULL; - discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, $lowwarnlimit, $warnlimit, $limit, $current); - } - - $oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.6.1", "-OsqnU")); - if ($debug) { echo($oids."\n"); } - $numPhase = count(explode("\n",$oids)); - for($i = 1; $i <= $numPhase;$i++) - { + $numPhase = count(explode("\n", $oids)); + for ($i = 1; $i <= $numPhase; $i++) { unset($current); - $current_oid = ".1.3.6.1.4.1.705.1.6.2.1.6.$i"; - $descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i"; - $current = snmp_get($device, $current_oid, "-Oqv"); - if (!$current) - { - $current_oid .= ".0"; - $current = snmp_get($device, $current_oid, "-Oqv"); + $current_oid = ".1.3.6.1.4.1.705.1.7.2.1.5.$i"; + $descr = 'Output'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } + + $current = snmp_get($device, $current_oid, '-Oqv'); + if (!$current) { + $current_oid .= '.0'; + $current = snmp_get($device, $current_oid, '-Oqv'); + } + + $current /= 10; + $type = 'mge-ups'; + $precision = 10; + $index = $i; + $warnlimit = null; + $lowlimit = 0; + $limit = null; + $lowwarnlimit = null; + + discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, $lowwarnlimit, $warnlimit, $limit, $current); + }//end for + + $oids = trim(snmp_walk($device, '1.3.6.1.4.1.705.1.6.1', '-OsqnU')); + if ($debug) { + echo $oids."\n"; } - $current /= 10; - $type = "mge-ups"; - $precision = 10; - $index = 100+$i; - $warnlimit = NULL; - $lowlimit = 0; - $limit = NULL; - $lowwarnlimit = NULL; - discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, $lowwarnlimit, $warnlimit, $limit, $current); - } -} + $numPhase = count(explode("\n", $oids)); + for ($i = 1; $i <= $numPhase; $i++) { + unset($current); + $current_oid = ".1.3.6.1.4.1.705.1.6.2.1.6.$i"; + $descr = 'Input'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } -?> \ No newline at end of file + $current = snmp_get($device, $current_oid, '-Oqv'); + if (!$current) { + $current_oid .= '.0'; + $current = snmp_get($device, $current_oid, '-Oqv'); + } + + $current /= 10; + $type = 'mge-ups'; + $precision = 10; + $index = (100 + $i); + $warnlimit = null; + $lowlimit = 0; + $limit = null; + $lowwarnlimit = null; + + discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, $lowwarnlimit, $warnlimit, $limit, $current); + }//end for +}//end if diff --git a/includes/discovery/current/netvision.inc.php b/includes/discovery/current/netvision.inc.php index 1d55a7b7c..21acb200c 100644 --- a/includes/discovery/current/netvision.inc.php +++ b/includes/discovery/current/netvision.inc.php @@ -1,36 +1,37 @@ diff --git a/includes/discovery/current/sentry3.inc.php b/includes/discovery/current/sentry3.inc.php index b07e12536..0146abb39 100644 --- a/includes/discovery/current/sentry3.inc.php +++ b/includes/discovery/current/sentry3.inc.php @@ -1,113 +1,111 @@ 1 "tower" accessible via a single management interface - $tower_count = snmp_get($device,"systemTowerCount.0", "-Ovq", "Sentry3-MIB"); - $towers=1; - while ($towers <= $tower_count) { - - ///////////////////////////////// - # Check for Infeeds - $infeed_oids = snmp_walk($device, "infeedID.$towers.1", "-Osqn", "Sentry3-MIB"); - if ($debug) { echo($infeed_oids."\n"); } - $infeed_oids = trim($infeed_oids); - - if ($infeed_oids) echo("ServerTech Sentry Infeed "); - foreach (explode("\n", $infeed_oids) as $infeed_data) - { - $infeed_data = trim($infeed_data); - if ($infeed_data) - { - list($infeed_oid,$descr) = explode(" ", $infeed_data,2); - $split_oid = explode('.',$infeed_oid); - $infeed_index = $split_oid[count($split_oid)-1]; - - #infeedLoadValue - $infeed_oid = "1.3.6.1.4.1.1718.3.2.2.1.7." . $towers . ".1"; - - $descr_string = snmp_get($device,"infeedID.$towers.$infeed_index", "-Ovq", "Sentry3-MIB"); - $descr = "Infeed $descr_string"; - $low_warn_limit = NULL; - $low_limit = NULL; - $high_warn_limit = snmp_get($device,"infeedLoadHighThresh.$towers.$infeed_index", "-Ovq", "Sentry3-MIB"); - $high_limit = snmp_get($device,"infeedCapacity.$towers.$infeed_index", "-Ovq", "Sentry3-MIB"); - $current = snmp_get($device,"$infeed_oid", "-Ovq", "Sentry3-MIB") / $divisor; - - if ($current >= 0) { - discover_sensor($valid['sensor'], 'current', $device, $infeed_oid, $towers, 'sentry3', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current); + // These PDUs may have > 1 "tower" accessible via a single management interface + $tower_count = snmp_get($device, 'systemTowerCount.0', '-Ovq', 'Sentry3-MIB'); + $towers = 1; + while ($towers <= $tower_count) { + // + // Check for Infeeds + $infeed_oids = snmp_walk($device, "infeedID.$towers.1", '-Osqn', 'Sentry3-MIB'); + if ($debug) { + echo $infeed_oids."\n"; } - ///////////////////////////////// - # Check for per-outlet polling - #$outlet_oids = snmp_walk($device, "outletLoadValue.$towers.$infeed_index", "-Osqn", "Sentry3-MIB"); - $outlet_oids = snmp_walk($device, "outletLoadValue.$towers.1", "-Osqn", "Sentry3-MIB"); - $outlet_oids = trim($outlet_oids); + $infeed_oids = trim($infeed_oids); - if ($outlet_oids) echo("ServerTech Sentry Outlet "); - foreach (explode("\n", $outlet_oids) as $outlet_data) - { - $outlet_data = trim($outlet_data); - if ($outlet_data) - { - list($outlet_oid,$outlet_descr) = explode(" ", $outlet_data,2); - $outlet_split_oid = explode('.',$outlet_oid); - $outlet_index = $outlet_split_oid[count($outlet_split_oid)-1]; + if ($infeed_oids) { + echo 'ServerTech Sentry Infeed '; + } - $outletsuffix = "$towers.$infeed_index.$outlet_index"; - $outlet_insert_index=$towers . $outlet_index; + foreach (explode("\n", $infeed_oids) as $infeed_data) { + $infeed_data = trim($infeed_data); + if ($infeed_data) { + list($infeed_oid,$descr) = explode(' ', $infeed_data, 2); + $split_oid = explode('.', $infeed_oid); + $infeed_index = $split_oid[(count($split_oid) - 1)]; - #outletLoadValue: "A non-negative value indicates the measured load in hundredths of Amps" - $outlet_oid = "1.3.6.1.4.1.1718.3.2.3.1.7.$outletsuffix"; - $outlet_descr_string = snmp_get($device,"outletID.$outletsuffix", "-Ovq", "Sentry3-MIB"); - $outlet_descr = "Outlet $outlet_descr_string"; - $outlet_low_warn_limit = NULL; - $outlet_low_limit = NULL; - $outlet_high_warn_limit = NULL; - # Should be "outletCapacity" but is always -1. According to MIB: "A negative value indicates that the capacity was not available." - $outlet_high_limit = snmp_get($device,"outletLoadHighThresh.$outletsuffix", "-Ovq", "Sentry3-MIB"); - $outlet_current = snmp_get($device,"$outlet_oid", "-Ovq", "Sentry3-MIB") / $outlet_divisor; + // infeedLoadValue + $infeed_oid = '1.3.6.1.4.1.1718.3.2.2.1.7.'.$towers.'.1'; - if ($outlet_current >= 0) { - discover_sensor($valid['sensor'], 'current', $device, $outlet_oid, $outlet_insert_index, 'sentry3', $outlet_descr, $outlet_divisor, $multiplier, $outlet_low_limit, $outlet_low_warn_limit, $outlet_high_warn_limit, $outlet_high_limit, $outlet_current); - } - } // if ($outlet_data) + $descr_string = snmp_get($device, "infeedID.$towers.$infeed_index", '-Ovq', 'Sentry3-MIB'); + $descr = "Infeed $descr_string"; + $low_warn_limit = null; + $low_limit = null; + $high_warn_limit = snmp_get($device, "infeedLoadHighThresh.$towers.$infeed_index", '-Ovq', 'Sentry3-MIB'); + $high_limit = snmp_get($device, "infeedCapacity.$towers.$infeed_index", '-Ovq', 'Sentry3-MIB'); + $current = (snmp_get($device, "$infeed_oid", '-Ovq', 'Sentry3-MIB') / $divisor); - unset($outlet_data); - unset($outlet_oids); - unset($outlet_oid); - unset($outlet_descr_string); - unset($outlet_descr); - unset($outlet_low_warn_limit); - unset($outlet_low_limit); - unset($outlet_high_warn_limit); - unset($outlet_high_limit); - unset($outlet_current); + if ($current >= 0) { + discover_sensor($valid['sensor'], 'current', $device, $infeed_oid, $towers, 'sentry3', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current); + } - } // foreach (explode("\n", $outlet_oids) as $outlet_data) + // + // Check for per-outlet polling + // $outlet_oids = snmp_walk($device, "outletLoadValue.$towers.$infeed_index", "-Osqn", "Sentry3-MIB"); + $outlet_oids = snmp_walk($device, "outletLoadValue.$towers.1", '-Osqn', 'Sentry3-MIB'); + $outlet_oids = trim($outlet_oids); - } //if($infeed_data) - unset($infeed_data); - unset($infeed_oids); - unset($descr_string); - unset($descr); - unset($low_warn_limit); - unset($low_limit); - unset($high_warn_limit); - unset($high_limit); - unset($current); + if ($outlet_oids) { + echo 'ServerTech Sentry Outlet '; + } - } //foreach (explode("\n", $infeed_oids) as $infeed_data) + foreach (explode("\n", $outlet_oids) as $outlet_data) + { + $outlet_data = trim($outlet_data); + if ($outlet_data) { + list($outlet_oid,$outlet_descr) = explode(' ', $outlet_data, 2); + $outlet_split_oid = explode('.', $outlet_oid); + $outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)]; - $towers++; + $outletsuffix = "$towers.$infeed_index.$outlet_index"; + $outlet_insert_index = $towers.$outlet_index; - } // while ($towers <= $tower_count) + // outletLoadValue: "A non-negative value indicates the measured load in hundredths of Amps" + $outlet_oid = "1.3.6.1.4.1.1718.3.2.3.1.7.$outletsuffix"; + $outlet_descr_string = snmp_get($device, "outletID.$outletsuffix", '-Ovq', 'Sentry3-MIB'); + $outlet_descr = "Outlet $outlet_descr_string"; + $outlet_low_warn_limit = null; + $outlet_low_limit = null; + $outlet_high_warn_limit = null; + // Should be "outletCapacity" but is always -1. According to MIB: "A negative value indicates that the capacity was not available." + $outlet_high_limit = snmp_get($device, "outletLoadHighThresh.$outletsuffix", '-Ovq', 'Sentry3-MIB'); + $outlet_current = (snmp_get($device, "$outlet_oid", '-Ovq', 'Sentry3-MIB') / $outlet_divisor); - unset($towers); -} + if ($outlet_current >= 0) { + discover_sensor($valid['sensor'], 'current', $device, $outlet_oid, $outlet_insert_index, 'sentry3', $outlet_descr, $outlet_divisor, $multiplier, $outlet_low_limit, $outlet_low_warn_limit, $outlet_high_warn_limit, $outlet_high_limit, $outlet_current); + } + } //end if -?> + unset($outlet_data); + unset($outlet_oids); + unset($outlet_oid); + unset($outlet_descr_string); + unset($outlet_descr); + unset($outlet_low_warn_limit); + unset($outlet_low_limit); + unset($outlet_high_warn_limit); + unset($outlet_high_limit); + unset($outlet_current); + } //end foreach + } //end if + unset($infeed_data); + unset($infeed_oids); + unset($descr_string); + unset($descr); + unset($low_warn_limit); + unset($low_limit); + unset($high_warn_limit); + unset($high_limit); + unset($current); + } //end foreach + + $towers++; + } //end while + + unset($towers); +}//end if diff --git a/includes/discovery/current/xups.inc.php b/includes/discovery/current/xups.inc.php index 374696348..2e1a50da6 100644 --- a/includes/discovery/current/xups.inc.php +++ b/includes/discovery/current/xups.inc.php @@ -1,61 +1,72 @@ 1) $descr .= " Phase $i"; - $current = snmp_get($device, $current_oid, "-Oqv"); - $type = "xups"; - $divisor = 1; - $index = "4.4.1.3.".$i; + $oids = trim($oids); + foreach (explode("\n", $oids) as $data) + { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $current_id = $split_oid[(count($split_oid) - 1)]; + $current_oid = "1.3.6.1.4.1.534.1.2.3.$current_id"; + $divisor = 1; + $current = snmp_get($device, $current_oid, '-O vq'); + $descr = 'Battery'.(count(explode("\n", $oids)) == 1 ? '' : ' '.($current_id + 1)); + $type = 'xups'; + $index = '1.2.3.'.$current_id; - discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } + } - $oids = trim(snmp_walk($device, "xupsInputCurrent", "-OsqnU", "XUPS-MIB")); - if ($debug) { echo($oids."\n"); } - list($unused,$numPhase) = explode(' ',$oids); - for($i = 1; $i <= $numPhase;$i++) - { - $current_oid = "1.3.6.1.4.1.534.1.3.4.1.3.$i"; - $descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i"; - $current = snmp_get($device, $current_oid, "-Oqv"); - $type = "xups"; - $divisor = 1; - $index = "3.4.1.3.".$i; + $oids = trim(snmp_walk($device, 'xupsOutputCurrent', '-OsqnU', 'XUPS-MIB')); + if ($debug) { + echo $oids."\n"; + } - discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } -} + list($unused,$numPhase) = explode(' ', $oids); + for ($i = 1; $i <= $numPhase; $i++) { + $current_oid = "1.3.6.1.4.1.534.1.4.4.1.3.$i"; + $descr = 'Output'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } -?> \ No newline at end of file + $current = snmp_get($device, $current_oid, '-Oqv'); + $type = 'xups'; + $divisor = 1; + $index = '4.4.1.3.'.$i; + + discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } + + $oids = trim(snmp_walk($device, 'xupsInputCurrent', '-OsqnU', 'XUPS-MIB')); + if ($debug) { + echo $oids."\n"; + } + + list($unused,$numPhase) = explode(' ', $oids); + for ($i = 1; $i <= $numPhase; $i++) { + $current_oid = "1.3.6.1.4.1.534.1.3.4.1.3.$i"; + $descr = 'Input'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } + + $current = snmp_get($device, $current_oid, '-Oqv'); + $type = 'xups'; + $divisor = 1; + $index = '3.4.1.3.'.$i; + + discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } +}//end if diff --git a/includes/discovery/fanspeeds.inc.php b/includes/discovery/fanspeeds.inc.php index eca0c9eb3..6ad629549 100644 --- a/includes/discovery/fanspeeds.inc.php +++ b/includes/discovery/fanspeeds.inc.php @@ -1,16 +1,15 @@ +echo "\n"; diff --git a/includes/discovery/fanspeeds/areca.inc.php b/includes/discovery/fanspeeds/areca.inc.php index 477ad1eac..831cd78a5 100644 --- a/includes/discovery/fanspeeds/areca.inc.php +++ b/includes/discovery/fanspeeds/areca.inc.php @@ -1,25 +1,26 @@ \ No newline at end of file + if ($oids) { + echo 'Areca '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 1)]; + $oid = '1.3.6.1.4.1.18928.1.2.2.1.9.1.3.'.$index; + $current = snmp_get($device, $oid, '-Oqv', ''); + + discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, 'areca', trim($descr, '"'), '1', '1', null, null, null, null, $current); + } + } +}//end if diff --git a/includes/discovery/fanspeeds/lmsensors.inc.php b/includes/discovery/fanspeeds/lmsensors.inc.php index 21a310e18..a4aa7c6ca 100644 --- a/includes/discovery/fanspeeds/lmsensors.inc.php +++ b/includes/discovery/fanspeeds/lmsensors.inc.php @@ -1,29 +1,29 @@ '0') - { - discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, 'lmsensors', $descr, '1', '1', NULL, NULL, NULL, NULL, $current); - } +if ($device['os'] == 'linux') { + $oids = snmp_walk($device, 'lmFanSensorsDevice', '-OsqnU', 'LM-SENSORS-MIB'); + if ($debug) { + echo $oids."\n"; } - } -} -?> \ No newline at end of file + $oids = trim($oids); + if ($oids) { + echo 'LM-SENSORS '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 1)]; + $oid = '1.3.6.1.4.1.2021.13.16.3.1.3.'.$index; + $current = snmp_get($device, $oid, '-Oqv', 'LM-SENSORS-MIB'); + $descr = trim(str_ireplace('fan-', '', $descr)); + if ($current > '0') { + discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, 'lmsensors', $descr, '1', '1', null, null, null, null, $current); + } + } + } +}//end if diff --git a/includes/discovery/fanspeeds/supermicro.inc.php b/includes/discovery/fanspeeds/supermicro.inc.php index e2b00f149..be56aec02 100644 --- a/includes/discovery/fanspeeds/supermicro.inc.php +++ b/includes/discovery/fanspeeds/supermicro.inc.php @@ -1,43 +1,42 @@ \ No newline at end of file + $oids = trim($oids); + if ($oids) { + echo 'Supermicro '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$kind) = explode(' ', $data); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 1)]; + if ($kind == 0) { + $fan_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.4.$index"; + $descr_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.2.$index"; + $limit_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.6.$index"; + $divisor_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.9.$index"; + $monitor_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.10.$index"; + $descr = snmp_get($device, $descr_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); + $current = snmp_get($device, $fan_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); + $low_limit = snmp_get($device, $limit_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); + // $divisor = snmp_get($device, $divisor_oid, "-Oqv", "SUPERMICRO-HEALTH-MIB"); + // ^ This returns an incorrect precision. At least using the raw value... I think. -TL + $divisor = '1'; + $monitor = snmp_get($device, $monitor_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); + $descr = str_replace(' Fan Speed', '', $descr); + $descr = str_replace(' Speed', '', $descr); + if ($monitor == 'true') { + discover_sensor($valid['sensor'], 'fanspeed', $device, $fan_oid, $index, 'supermicro', $descr, $divisor, '1', $low_limit, null, null, null, $current); + } + } + }//end if + }//end foreach +}//end if diff --git a/includes/discovery/frequencies.inc.php b/includes/discovery/frequencies.inc.php index ca476d8ea..23b30b092 100644 --- a/includes/discovery/frequencies.inc.php +++ b/includes/discovery/frequencies.inc.php @@ -1,16 +1,15 @@ +echo "\n"; diff --git a/includes/discovery/frequencies/apc.inc.php b/includes/discovery/frequencies/apc.inc.php index 5c354661b..cfb4d08ef 100644 --- a/includes/discovery/frequencies/apc.inc.php +++ b/includes/discovery/frequencies/apc.inc.php @@ -1,71 +1,84 @@ 1) { $descr .= " $index"; } - discover_sensor($valid['sensor'], 'frequency', $device, $oid, "4.2.1.4.$index", $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); + if ($oids) { + echo 'APC In '; } - } - $oids = snmp_get($device, "1.3.6.1.4.1.318.1.1.1.3.2.4.0", "-OsqnU", ""); - if ($debug) { echo($oids."\n"); } - if ($oids) - { - echo(" APC In "); - list($oid,$current) = explode(" ",$oids); $divisor = 1; - $type = "apc"; - $index = "3.2.4.0"; - $descr = "Input"; - discover_sensor($valid['sensor'], 'frequency', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + $type = 'apc'; + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$current) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 1)]; + $oid = '1.3.6.1.4.1.318.1.1.8.5.3.2.1.4.'.$index; + $descr = 'Input Feed '.chr(64 + $index); + discover_sensor($valid['sensor'], 'frequency', $device, $oid, "3.2.1.4.$index", $type, $descr, $divisor, '1', null, null, null, null, $current); + } + } + + $oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.8.5.4.2.1.4', '-OsqnU', ''); + if ($debug) { + echo $oids."\n"; + } + + if ($oids) { + echo ' APC Out '; + } - $oids = snmp_get($device, "1.3.6.1.4.1.318.1.1.1.4.2.2.0", "-OsqnU", ""); - if ($debug) { echo($oids."\n"); } - if ($oids) - { - echo(" APC Out "); - list($oid,$current) = explode(" ",$oids); $divisor = 1; - $type = "apc"; - $index = "4.2.2.0"; - $descr = "Output"; - discover_sensor($valid['sensor'], 'frequency', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } -} + $type = 'apc'; + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$current) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 3)]; + $oid = '1.3.6.1.4.1.318.1.1.8.5.4.2.1.4.'.$index; + $descr = 'Output Feed'; + if (count(explode("\n", $oids)) > 1) { + $descr .= " $index"; + } -?> \ No newline at end of file + discover_sensor($valid['sensor'], 'frequency', $device, $oid, "4.2.1.4.$index", $type, $descr, $divisor, '1', null, null, null, null, $current); + } + } + + $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.3.2.4.0', '-OsqnU', ''); + if ($debug) { + echo $oids."\n"; + } + + if ($oids) { + echo ' APC In '; + list($oid,$current) = explode(' ', $oids); + $divisor = 1; + $type = 'apc'; + $index = '3.2.4.0'; + $descr = 'Input'; + discover_sensor($valid['sensor'], 'frequency', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } + + $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.4.2.2.0', '-OsqnU', ''); + if ($debug) { + echo $oids."\n"; + } + + if ($oids) { + echo ' APC Out '; + list($oid,$current) = explode(' ', $oids); + $divisor = 1; + $type = 'apc'; + $index = '4.2.2.0'; + $descr = 'Output'; + discover_sensor($valid['sensor'], 'frequency', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } +}//end if diff --git a/includes/discovery/frequencies/ipoman.inc.php b/includes/discovery/frequencies/ipoman.inc.php index 34c459480..a64f0d426 100644 --- a/includes/discovery/frequencies/ipoman.inc.php +++ b/includes/discovery/frequencies/ipoman.inc.php @@ -1,43 +1,38 @@ $entry) - { - $freq_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.4.' . $index; - $divisor = 10; - $descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') : "Inlet $index"); - $current = $entry['inletStatusFrequency'] / 10; - $low_limit = $entry['inletConfigFrequencyLow']; - $high_limit = $entry['inletConfigFrequencyHigh']; - discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, 'ipoman', $descr, $divisor, '1', $low_limit, NULL, NULL, $high_limit, $current); - // FIXME: iPoMan 1201 also says it has 2 inlets, at least until firmware 1.06 - wtf? + if (!is_array($cache['ipoman'])) { + echo 'outletConfigDesc '; + $cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $cache['ipoman']['out'], 'IPOMANII-MIB'); + echo 'outletConfigLocation '; + $cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $cache['ipoman']['out'], 'IPOMANII-MIB'); + echo 'inletConfigDesc '; + $cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, 'inletConfigDesc', $cache['ipoman']['in'], 'IPOMANII-MIB'); } - } -} -?> \ No newline at end of file + $oids = array(); + + echo 'inletConfigFrequencyHigh '; + $oids = snmpwalk_cache_multi_oid($device, 'inletConfigFrequencyHigh', $oids, 'IPOMANII-MIB'); + echo 'inletConfigFrequencyLow '; + $oids = snmpwalk_cache_multi_oid($device, 'inletConfigFrequencyLow', $oids, 'IPOMANII-MIB'); + echo 'inletStatusFrequency '; + $oids = snmpwalk_cache_multi_oid($device, 'inletStatusFrequency', $oids, 'IPOMANII-MIB'); + + if (is_array($oids)) { + foreach ($oids as $index => $entry) + { + $freq_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.4.'.$index; + $divisor = 10; + $descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') : "Inlet $index"); + $current = ($entry['inletStatusFrequency'] / 10); + $low_limit = $entry['inletConfigFrequencyLow']; + $high_limit = $entry['inletConfigFrequencyHigh']; + discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, 'ipoman', $descr, $divisor, '1', $low_limit, null, null, $high_limit, $current); + // FIXME: iPoMan 1201 also says it has 2 inlets, at least until firmware 1.06 - wtf? + } + } +}//end if diff --git a/includes/discovery/frequencies/mgeups.inc.php b/includes/discovery/frequencies/mgeups.inc.php index 034ec2e66..67a31218c 100644 --- a/includes/discovery/frequencies/mgeups.inc.php +++ b/includes/discovery/frequencies/mgeups.inc.php @@ -1,47 +1,57 @@ 1) $descr .= " Phase $i"; - $current = snmp_get($device, $freq_oid, "-Oqv"); - if (!$current) - { - $freq_oid .= ".0"; - $current = snmp_get($device, $freq_oid, "-Oqv"); +if ($device['os'] == 'mgeups') { + echo 'MGE '; + $oids = trim(snmp_walk($device, '1.3.6.1.4.1.705.1.7.1', '-OsqnU')); + if ($debug) { + echo $oids."\n"; } - $current /= 10; - $type = "mge-ups"; - $divisor = 10; - $index = $i; - discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } - $oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.6.1", "-OsqnU")); - if ($debug) { echo($oids."\n"); } - $numPhase = count(explode("\n",$oids)); - for($i = 1; $i <= $numPhase;$i++) - { - $freq_oid = ".1.3.6.1.4.1.705.1.6.2.1.3.$i"; - $descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i"; - $current = snmp_get($device, $freq_oid, "-Oqv"); - if (!$current) - { - $freq_oid .= ".0"; - $current = snmp_get($device, $freq_oid, "-Oqv"); - } - $current /= 10; - $type = "mge-ups"; - $divisor = 10; - $index = 100+$i; - discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } -} -?> \ No newline at end of file + $numPhase = count(explode("\n", $oids)); + for ($i = 1; $i <= $numPhase; $i++) { + $freq_oid = ".1.3.6.1.4.1.705.1.7.2.1.3.$i"; + $descr = 'Output'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } + + $current = snmp_get($device, $freq_oid, '-Oqv'); + if (!$current) { + $freq_oid .= '.0'; + $current = snmp_get($device, $freq_oid, '-Oqv'); + } + + $current /= 10; + $type = 'mge-ups'; + $divisor = 10; + $index = $i; + discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } + + $oids = trim(snmp_walk($device, '1.3.6.1.4.1.705.1.6.1', '-OsqnU')); + if ($debug) { + echo $oids."\n"; + } + + $numPhase = count(explode("\n", $oids)); + for ($i = 1; $i <= $numPhase; $i++) { + $freq_oid = ".1.3.6.1.4.1.705.1.6.2.1.3.$i"; + $descr = 'Input'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } + + $current = snmp_get($device, $freq_oid, '-Oqv'); + if (!$current) { + $freq_oid .= '.0'; + $current = snmp_get($device, $freq_oid, '-Oqv'); + } + + $current /= 10; + $type = 'mge-ups'; + $divisor = 10; + $index = (100 + $i); + discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } +}//end if diff --git a/includes/discovery/frequencies/netvision.inc.php b/includes/discovery/frequencies/netvision.inc.php index 6b80ff388..e26fef8c6 100644 --- a/includes/discovery/frequencies/netvision.inc.php +++ b/includes/discovery/frequencies/netvision.inc.php @@ -1,22 +1,23 @@ \ No newline at end of file diff --git a/includes/discovery/frequencies/xups.inc.php b/includes/discovery/frequencies/xups.inc.php index 3c7dbeb6b..911824a87 100644 --- a/includes/discovery/frequencies/xups.inc.php +++ b/includes/discovery/frequencies/xups.inc.php @@ -1,43 +1,38 @@ \ No newline at end of file + // XUPS-MIB::xupsBypassFrequency.0 = INTEGER: 500 + $freq_oid = '1.3.6.1.4.1.534.1.5.1.0'; + $descr = 'Bypass'; + $divisor = 10; + $current = snmp_get($device, $freq_oid, '-Oqv'); + if ($current != '') { + // Bypass is not always available in SNMP + $current /= $divisor; + $type = 'xups'; + $index = '5.1.0'; + discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } +}//end if diff --git a/includes/discovery/humidity/akcp.inc.php b/includes/discovery/humidity/akcp.inc.php index e4ca767d1..07dc0864c 100644 --- a/includes/discovery/humidity/akcp.inc.php +++ b/includes/discovery/humidity/akcp.inc.php @@ -1,39 +1,42 @@ \ No newline at end of file + $oids = trim($oids); + if ($oids) { + echo 'AKCP '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$status) = explode(' ', $data, 2); + if ($status == 2) { + // 2 = normal, 0 = not connected + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 1)]; + $descr_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.1.$index"; + $oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.3.$index"; + $warnlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.7.$index"; + $limit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.8.$index"; + $warnlowlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.9.$index"; + $lowlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.10.$index"; + + $descr = trim(snmp_get($device, $descr_oid, '-Oqv', ''), '"'); + $humidity = snmp_get($device, $oid, '-Oqv', ''); + $warnlimit = snmp_get($device, $warnlimit_oid, '-Oqv', ''); + $limit = snmp_get($device, $limit_oid, '-Oqv', ''); + $lowlimit = snmp_get($device, $lowlimit_oid, '-Oqv', ''); + $warnlowlimit = snmp_get($device, $warnlowlimit_oid, '-Oqv', ''); + + discover_sensor($valid['sensor'], 'humidity', $device, + $oid, $index, 'akcp', + $descr, '1', '1', $lowlimit, $warnlowlimit, $limit, $warnlimit, $humidity); + } + } + } +} diff --git a/includes/discovery/humidity/apc.inc.php b/includes/discovery/humidity/apc.inc.php index c68aefd78..fdad576fa 100644 --- a/includes/discovery/humidity/apc.inc.php +++ b/includes/discovery/humidity/apc.inc.php @@ -1,29 +1,25 @@ Sensor not available - discover_sensor($valid['sensor'], 'humidity', $device, $oid, $index, $sensorType, $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit , $current); - } - } -} + $descr = $apc_env_data[$index]['iemStatusProbeName']; + $current = $apc_env_data[$index]['iemStatusProbeCurrentHumid']; + $sensorType = 'apc'; + $oid = '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.6.'.$index; + $low_limit = ($apc_env_data[$index]['iemConfigProbeMinHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeMinHumidThreshold'] : null); + $low_warn_limit = ($apc_env_data[$index]['iemConfigProbeLowHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeLowHumidThreshold'] : null); + $high_warn_limit = ($apc_env_data[$index]['iemConfigProbeHighHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeHighHumidThreshold'] : null); + $high_limit = ($apc_env_data[$index]['iemConfigProbeMaxHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeMaxHumidThreshold'] : null); -?> + if ($current != 0) { + // Humidity = 0 -> Sensor not available + discover_sensor($valid['sensor'], 'humidity', $device, $oid, $index, $sensorType, $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current); + } + } +}//end if diff --git a/includes/discovery/humidity/ipoman.inc.php b/includes/discovery/humidity/ipoman.inc.php index 473ed64bb..4a3059b7b 100644 --- a/includes/discovery/humidity/ipoman.inc.php +++ b/includes/discovery/humidity/ipoman.inc.php @@ -2,27 +2,21 @@ // FIXME: EMD "stack" support // FIXME: What to do with IPOMANII-MIB::ipmEnvEmdConfigHumiOffset.0 ? +if ($device['os'] == 'ipoman') { + echo ' IPOMANII-MIB '; + $emd_installed = snmp_get($device, 'IPOMANII-MIB::ipmEnvEmdStatusEmdType.0', ' -Oqv'); -if ($device['os'] == "ipoman") -{ - echo(" IPOMANII-MIB "); - $emd_installed = snmp_get($device, "IPOMANII-MIB::ipmEnvEmdStatusEmdType.0"," -Oqv"); + if ($emd_installed == 'eMD-HT') { + $descr = snmp_get($device, 'IPOMANII-MIB::ipmEnvEmdConfigHumiName.0', '-Oqv'); + $current = (snmp_get($device, 'IPOMANII-MIB::ipmEnvEmdStatusHumidity.0', '-Oqv') / 10); + $high_limit = snmp_get($device, 'IPOMANII-MIB::ipmEnvEmdConfigHumiHighSetPoint.0', '-Oqv'); + $low_limit = snmp_get($device, 'IPOMANII-MIB::ipmEnvEmdConfigHumiLowSetPoint.0', '-Oqv'); - if ($emd_installed == 'eMD-HT') - { - $descr = snmp_get($device, "IPOMANII-MIB::ipmEnvEmdConfigHumiName.0", "-Oqv"); - $current = snmp_get($device, "IPOMANII-MIB::ipmEnvEmdStatusHumidity.0", "-Oqv") / 10; - $high_limit = snmp_get($device, "IPOMANII-MIB::ipmEnvEmdConfigHumiHighSetPoint.0", "-Oqv"); - $low_limit = snmp_get($device, "IPOMANII-MIB::ipmEnvEmdConfigHumiLowSetPoint.0", "-Oqv"); + if ($descr != '' && is_numeric($current) && $current > '0') { + $current_oid = '.1.3.6.1.4.1.2468.1.4.2.1.5.1.1.3.0'; + $descr = trim(str_replace('"', '', $descr)); - if ($descr != "" && is_numeric($current) && $current > "0") - { - $current_oid = ".1.3.6.1.4.1.2468.1.4.2.1.5.1.1.3.0"; - $descr = trim(str_replace("\"", "", $descr)); - - discover_sensor($valid['sensor'], 'humidity', $device, $current_oid, "1", 'ipoman', $descr, '10', '1', $low_limit, NULL, NULL, $high_limit, $current); + discover_sensor($valid['sensor'], 'humidity', $device, $current_oid, '1', 'ipoman', $descr, '10', '1', $low_limit, null, null, $high_limit, $current); + } } - } } - -?> \ No newline at end of file diff --git a/includes/discovery/humidity/mgeups.inc.php b/includes/discovery/humidity/mgeups.inc.php index aa085889d..3cd77e9eb 100644 --- a/includes/discovery/humidity/mgeups.inc.php +++ b/includes/discovery/humidity/mgeups.inc.php @@ -2,68 +2,65 @@ global $debug; -if ($device['os'] == "mgeups") -{ - # blatently copyied from APC +if ($device['os'] == 'mgeups') { + // blatently copyied from APC + echo 'MGE UPS External '; - echo("MGE UPS External "); + // Environmental monitoring on UPSes etc + // FIXME upsmgConfigEnvironmentTable and upsmgEnvironmentSensorTable are used but there are others ... + $mge_env_data = snmpwalk_cache_oid($device, 'upsmgConfigEnvironmentTable', array(), 'MG-SNMP-UPS-MIB'); + $mge_env_data = snmpwalk_cache_oid($device, 'upsmgEnvironmentSensorTable', $mge_env_data, 'MG-SNMP-UPS-MIB'); - # Environmental monitoring on UPSes etc - // FIXME upsmgConfigEnvironmentTable and upsmgEnvironmentSensorTable are used but there are others ... - $mge_env_data = snmpwalk_cache_oid($device, "upsmgConfigEnvironmentTable", array(), "MG-SNMP-UPS-MIB"); - $mge_env_data = snmpwalk_cache_oid($device, "upsmgEnvironmentSensorTable", $mge_env_data, "MG-SNMP-UPS-MIB"); + /* + upsmgConfigSensorIndex.1 = 1 + upsmgConfigSensorName.1 = "Environment sensor" + upsmgConfigTemperatureLow.1 = 5 + upsmgConfigTemperatureHigh.1 = 40 + upsmgConfigTemperatureHysteresis.1 = 2 + upsmgConfigHumidityLow.1 = 5 + upsmgConfigHumidityHigh.1 = 90 + upsmgConfigHumidityHysteresis.1 = 5 + upsmgConfigInput1Name.1 = "Input #1" + upsmgConfigInput1ClosedLabel.1 = "closed" + upsmgConfigInput1OpenLabel.1 = "open" + upsmgConfigInput2Name.1 = "Input #2" + upsmgConfigInput2ClosedLabel.1 = "closed" + upsmgConfigInput2OpenLabel.1 = "open" -/* -upsmgConfigSensorIndex.1 = 1 -upsmgConfigSensorName.1 = "Environment sensor" -upsmgConfigTemperatureLow.1 = 5 -upsmgConfigTemperatureHigh.1 = 40 -upsmgConfigTemperatureHysteresis.1 = 2 -upsmgConfigHumidityLow.1 = 5 -upsmgConfigHumidityHigh.1 = 90 -upsmgConfigHumidityHysteresis.1 = 5 -upsmgConfigInput1Name.1 = "Input #1" -upsmgConfigInput1ClosedLabel.1 = "closed" -upsmgConfigInput1OpenLabel.1 = "open" -upsmgConfigInput2Name.1 = "Input #2" -upsmgConfigInput2ClosedLabel.1 = "closed" -upsmgConfigInput2OpenLabel.1 = "open" + upsmgEnvironmentIndex.1 = 1 + upsmgEnvironmentComFailure.1 = no + upsmgEnvironmentTemperature.1 = 287 + upsmgEnvironmentTemperatureLow.1 = no + upsmgEnvironmentTemperatureHigh.1 = no + upsmgEnvironmentHumidity.1 = 17 + upsmgEnvironmentHumidityLow.1 = no + upsmgEnvironmentHumidityHigh.1 = no + upsmgEnvironmentInput1State.1 = open + upsmgEnvironmentInput2State.1 = open + */ -upsmgEnvironmentIndex.1 = 1 -upsmgEnvironmentComFailure.1 = no -upsmgEnvironmentTemperature.1 = 287 -upsmgEnvironmentTemperatureLow.1 = no -upsmgEnvironmentTemperatureHigh.1 = no -upsmgEnvironmentHumidity.1 = 17 -upsmgEnvironmentHumidityLow.1 = no -upsmgEnvironmentHumidityHigh.1 = no -upsmgEnvironmentInput1State.1 = open -upsmgEnvironmentInput2State.1 = open -*/ - - foreach (array_keys($mge_env_data) as $index) - { - $descr = $mge_env_data[$index]['upsmgConfigSensorName']; - $current = $mge_env_data[$index]['upsmgEnvironmentHumidity']; - $sensorType = 'mge'; - $oid = '.1.3.6.1.4.1.705.1.8.7.1.6.' . $index; - $low_limit = $mge_env_data[$index]['upsmgConfigHumidityLow']; - $high_limit = $mge_env_data[$index]['upsmgConfigHumidityHigh']; - $hysteresis = $mge_env_data[$index]['upsmgConfigHumidityHysteresis']; - - // FIXME warninglevels might need some other calculation in stead of hysteresis - $low_warn_limit = $low_limit + $hysteresis; - $high_warn_limit = $high_limit - $hysteresis; - - if ($debug) { echo("low_limit : $low_limit\nlow_warn_limit : $low_warn_limit\nhigh_warn_limit : $high_warn_limit\nhigh_limit : $high_limit\n"); } - - if ($current != 0) + foreach (array_keys($mge_env_data) as $index) { - # Humidity = 0 -> Sensor not available - // FIXME true for MGE as wel as APC? - discover_sensor($valid['sensor'], 'humidity', $device, $oid, $index, $sensorType, $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit , $current); - } - } -} + $descr = $mge_env_data[$index]['upsmgConfigSensorName']; + $current = $mge_env_data[$index]['upsmgEnvironmentHumidity']; + $sensorType = 'mge'; + $oid = '.1.3.6.1.4.1.705.1.8.7.1.6.'.$index; + $low_limit = $mge_env_data[$index]['upsmgConfigHumidityLow']; + $high_limit = $mge_env_data[$index]['upsmgConfigHumidityHigh']; + $hysteresis = $mge_env_data[$index]['upsmgConfigHumidityHysteresis']; -?> + // FIXME warninglevels might need some other calculation in stead of hysteresis + $low_warn_limit = ($low_limit + $hysteresis); + $high_warn_limit = ($high_limit - $hysteresis); + + if ($debug) { + echo "low_limit : $low_limit\nlow_warn_limit : $low_warn_limit\nhigh_warn_limit : $high_warn_limit\nhigh_limit : $high_limit\n"; + } + + if ($current != 0) { + // Humidity = 0 -> Sensor not available + // FIXME true for MGE as wel as APC? + discover_sensor($valid['sensor'], 'humidity', $device, $oid, $index, $sensorType, $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current); + } + }//end foreach +}//end if diff --git a/includes/discovery/humidity/netbotz.inc.php b/includes/discovery/humidity/netbotz.inc.php index 938386327..2ed4172ec 100644 --- a/includes/discovery/humidity/netbotz.inc.php +++ b/includes/discovery/humidity/netbotz.inc.php @@ -1,30 +1,33 @@ = 0) { - discover_sensor($valid['sensor'], 'humidity', $device, $humidity_oid, $humidity_id, 'netbotz', $descr, '1', '1', NULL, NULL, NULL, NULL, $humidity); - } +if ($device['os'] == 'netbotz') { + $oids = snmp_walk($device, '.1.3.6.1.4.1.5528.100.4.1.2.1.4', '-Osqn', ''); + if ($debug) { + echo $oids."\n"; } - unset($data); - } - unset($oids); -} -?> + $oids = trim($oids); + if ($oids) { + echo 'Netbotz '; + foreach (explode("\n", $oids) as $data) + { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $humidity_id = $split_oid[(count($split_oid) - 1)]; + // tempHumidSensorHumidValue + $humidity_oid = '.1.3.6.1.4.1.5528.100.4.1.2.1.8.'.$humidity_id; + $humidity = snmp_get($device, "$humidity_oid", '-Ovq', ''); + $descr = str_replace('"', '', $descr); + $descr = trim($descr); + if ($humidity >= 0) { + discover_sensor($valid['sensor'], 'humidity', $device, + $humidity_oid, $humidity_id, 'netbotz', + $descr, '1', '1', null, null, null, null, $humidity); + } + } + + unset($data); + } + + unset($oids); +} diff --git a/includes/discovery/humidity/pcoweb.inc.php b/includes/discovery/humidity/pcoweb.inc.php index b64d90e31..4a975e4ef 100644 --- a/includes/discovery/humidity/pcoweb.inc.php +++ b/includes/discovery/humidity/pcoweb.inc.php @@ -1,40 +1,59 @@ "CAREL-ug40cdz-MIB::roomRH.0", "descr" => "Room Relative Humidity", "oid" => ".1.3.6.1.4.1.9839.2.1.2.6.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::dehumPband.0", "descr" => "Dehumidification Prop. Band", "oid" => ".1.3.6.1.4.1.9839.2.1.3.12.0", "precision" => "1"), - array("mib" => "CAREL-ug40cdz-MIB::humidPband.0", "descr" => "Humidification Prop. Band", "oid" => ".1.3.6.1.4.1.9839.2.1.3.13.0", "precision" => "1"), - array("mib" => "CAREL-ug40cdz-MIB::dehumSetp.0", "descr" => "Dehumidification Set Point", "oid" => ".1.3.6.1.4.1.9839.2.1.3.16.0", "precision" => "1"), - array("mib" => "CAREL-ug40cdz-MIB::humidSetp.0", "descr" => "Humidification Set Point", "oid" => ".1.3.6.1.4.1.9839.2.1.3.17.0", "precision" => "1"), - ); + $humidities = array( + array( + 'mib' => 'CAREL-ug40cdz-MIB::roomRH.0', + 'descr' => 'Room Relative Humidity', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.6.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::dehumPband.0', + 'descr' => 'Dehumidification Prop. Band', + 'oid' => '.1.3.6.1.4.1.9839.2.1.3.12.0', + 'precision' => '1', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::humidPband.0', + 'descr' => 'Humidification Prop. Band', + 'oid' => '.1.3.6.1.4.1.9839.2.1.3.13.0', + 'precision' => '1', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::dehumSetp.0', + 'descr' => 'Dehumidification Set Point', + 'oid' => '.1.3.6.1.4.1.9839.2.1.3.16.0', + 'precision' => '1', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::humidSetp.0', + 'descr' => 'Humidification Set Point', + 'oid' => '.1.3.6.1.4.1.9839.2.1.3.17.0', + 'precision' => '1', + ), + ); - foreach ($humidities as $humidity) - { - $current = snmp_get($device, $humidity['mib'], "-OqvU") / $humidity['precision']; + foreach ($humidities as $humidity) { + $current = (snmp_get($device, $humidity['mib'], '-OqvU') / $humidity['precision']); - $high_limit = NULL; - $low_limit = NULL; + $high_limit = null; + $low_limit = null; - if (is_numeric($current) && $current != 0) - { - $index = implode(".",array_slice(explode(".",$humidity['oid']),-5)); - discover_sensor($valid['sensor'], 'humidity', $device, $humidity['oid'], $index, 'pcoweb', $humidity['descr'], $humidity['precision'], '1', $low_limit, NULL, NULL, $high_limit, $current); + if (is_numeric($current) && $current != 0) { + $index = implode('.', array_slice(explode('.', $humidity['oid']), -5)); + discover_sensor($valid['sensor'], 'humidity', $device, $humidity['oid'], $index, 'pcoweb', $humidity['descr'], $humidity['precision'], '1', $low_limit, null, null, $high_limit, $current); + } } - } -/* -FIXME - -hhAlarmThrsh.0 = INTEGER: 80 rH% -lhAlarmThrsh.0 = INTEGER: 30 rH% -smDehumSetp.0 = INTEGER: 75 rH% -smHumidSetp.0 = INTEGER: 35 rH% -*/ + /* + FIXME + hhAlarmThrsh.0 = INTEGER: 80 rH% + lhAlarmThrsh.0 = INTEGER: 30 rH% + smDehumSetp.0 = INTEGER: 75 rH% + smHumidSetp.0 = INTEGER: 35 rH% + */ } - -?> diff --git a/includes/discovery/humidity/sentry3.inc.php b/includes/discovery/humidity/sentry3.inc.php index 1f74805af..c3e4ff440 100644 --- a/includes/discovery/humidity/sentry3.inc.php +++ b/includes/discovery/humidity/sentry3.inc.php @@ -1,38 +1,44 @@ = 0) { - discover_sensor($valid['sensor'], 'humidity', $device, $humidity_oid, $index, 'sentry3', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current); - } +if ($device['os'] == 'sentry3') { + $oids = snmp_walk($device, 'tempHumidSensorHumidValue', '-Osqn', 'Sentry3-MIB'); + $divisor = '1'; + $multiplier = '1'; + if ($debug) { + echo $oids."\n"; } - unset($data); - } - unset($oids); -} -?> + $oids = trim($oids); + if ($oids) { + echo 'ServerTech Sentry '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 1)]; + + // tempHumidSensorHumidValue + $humidity_oid = '1.3.6.1.4.1.1718.3.2.5.1.10.1.'.$index; + $descr = 'Removable Sensor '.$index; + $low_warn_limit = '0'; + $low_limit = snmp_get($device, "tempHumidSensorHumidLowThresh.1.$index", '-Ovq', 'Sentry3-MIB'); + $high_warn_limit = '0'; + $high_limit = snmp_get($device, "tempHumidSensorHumidHighThresh.1.$index", '-Ovq', 'Sentry3-MIB'); + $current = snmp_get($device, "$humidity_oid", '-Ovq', 'Sentry3-MIB'); + + if ($current >= 0) { + discover_sensor($valid['sensor'], 'humidity', $device, + $humidity_oid, $index, 'sentry3', + $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, + $high_warn_limit, $high_limit, $current); + } + } + + unset($data); + } + + unset($oids); +} diff --git a/includes/discovery/mempools/avaya-ers.inc.php b/includes/discovery/mempools/avaya-ers.inc.php index 271d25bea..f43dc28ab 100644 --- a/includes/discovery/mempools/avaya-ers.inc.php +++ b/includes/discovery/mempools/avaya-ers.inc.php @@ -1,29 +1,26 @@ = 6.1) { - $mem = snmp_walk($device, $OID, "-Osqn"); + // Temperature info only known to be present in firmware 6.1 or higher + if ($fw_major_version >= 6.1) { + $mem = snmp_walk($device, $OID, '-Osqn'); - echo "$mem\n"; + echo "$mem\n"; - foreach (explode("\n", $mem) as $i => $t) { - $t = explode(" ",$t); - $oid = str_replace($OID, "", $t[0]); - discover_mempool($valid_mempool, $device, $oid, "avaya-ers", "Unit " . ($i+1) . " memory", "1", NULL, NULL); - } + foreach (explode("\n", $mem) as $i => $t) { + $t = explode(' ', $t); + $oid = str_replace($OID, '', $t[0]); + discover_mempool($valid_mempool, $device, $oid, 'avaya-ers', 'Unit '.($i + 1).' memory', '1', null, null); + } + } } - } } - -?> diff --git a/includes/discovery/mempools/fortigate.inc.php b/includes/discovery/mempools/fortigate.inc.php index ac68990b2..f8fe041a1 100644 --- a/includes/discovery/mempools/fortigate.inc.php +++ b/includes/discovery/mempools/fortigate.inc.php @@ -1,8 +1,6 @@ diff --git a/includes/discovery/mempools/netscaler.inc.php b/includes/discovery/mempools/netscaler.inc.php index 1d8459314..cdade351f 100644 --- a/includes/discovery/mempools/netscaler.inc.php +++ b/includes/discovery/mempools/netscaler.inc.php @@ -1,13 +1,7 @@ diff --git a/includes/discovery/mempools/vrp.inc.php b/includes/discovery/mempools/vrp.inc.php index 4960713e3..8b8237733 100644 --- a/includes/discovery/mempools/vrp.inc.php +++ b/includes/discovery/mempools/vrp.inc.php @@ -1,33 +1,32 @@ $entry) - { - if ($entry['hwEntityMemSize'] != 0 ) - { - if ($debug) { echo($index . " " . $entry['hwEntityBomEnDesc'] . " -> " . $entry['hwEntityMemUsage'] . " -> " . $entry['hwEntityMemSize'] . "\n"); } - $usage_oid = ".1.3.6.1.4.1.2011.5.25.31.1.1.1.1.7." . $index; - $descr = $entry['hwEntityBomEnDesc']; - $usage = $entry['hwEntityMemUsage']; - if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) + if (is_array($mempools_array)) { + foreach ($mempools_array as $index => $entry) { - discover_mempool($valid_mempool, $device, $index, "vrp", $descr, "1", NULL, NULL); - } - } // End if checks - } // End Foreach - } // End if array -} // End VRP mempools + if ($entry['hwEntityMemSize'] != 0) { + if ($debug) { + echo $index.' '.$entry['hwEntityBomEnDesc'].' -> '.$entry['hwEntityMemUsage'].' -> '.$entry['hwEntityMemSize']."\n"; + } -unset ($mempools_array); + $usage_oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.1.1.7.'.$index; + $descr = $entry['hwEntityBomEnDesc']; + $usage = $entry['hwEntityMemUsage']; + if (!strstr($descr, 'No') && !strstr($usage, 'No') && $descr != '') { + discover_mempool($valid_mempool, $device, $index, 'vrp', $descr, '1', null, null); + } + } //end if + } //end foreach + } //end if +} //end if -?> +unset($mempools_array); diff --git a/includes/discovery/os/acsw.inc.php b/includes/discovery/os/acsw.inc.php index 9d08cf4cc..f662254b9 100644 --- a/includes/discovery/os/acsw.inc.php +++ b/includes/discovery/os/acsw.inc.php @@ -1,16 +1,19 @@ diff --git a/includes/discovery/os/airport.inc.php b/includes/discovery/os/airport.inc.php index e20f256ce..bdf403e21 100644 --- a/includes/discovery/os/airport.inc.php +++ b/includes/discovery/os/airport.inc.php @@ -1,10 +1,13 @@ \ No newline at end of file diff --git a/includes/discovery/os/akcp.inc.php b/includes/discovery/os/akcp.inc.php index 1fa39310e..dd9b7ff50 100644 --- a/includes/discovery/os/akcp.inc.php +++ b/includes/discovery/os/akcp.inc.php @@ -1,9 +1,11 @@ \ No newline at end of file + if (preg_match('/SensorProbe/i', $sysDescr)) { + $os = 'akcp'; + } +} diff --git a/includes/discovery/os/apc.inc.php b/includes/discovery/os/apc.inc.php index 0c2ab869e..cb276dac8 100644 --- a/includes/discovery/os/apc.inc.php +++ b/includes/discovery/os/apc.inc.php @@ -1,11 +1,16 @@ \ No newline at end of file diff --git a/includes/discovery/os/arubaos.inc.php b/includes/discovery/os/arubaos.inc.php index f453e2a47..7364e5d19 100644 --- a/includes/discovery/os/arubaos.inc.php +++ b/includes/discovery/os/arubaos.inc.php @@ -1,8 +1,7 @@ diff --git a/includes/discovery/os/avocent.inc.php b/includes/discovery/os/avocent.inc.php index d22f39b5d..7c7dea245 100644 --- a/includes/discovery/os/avocent.inc.php +++ b/includes/discovery/os/avocent.inc.php @@ -1,9 +1,11 @@ \ No newline at end of file + if (preg_match('/^AlterPath/', $sysDescr)) { + $os = 'avocent'; + } +} diff --git a/includes/discovery/os/axiscam.inc.php b/includes/discovery/os/axiscam.inc.php index 792e00836..2060365f8 100644 --- a/includes/discovery/os/axiscam.inc.php +++ b/includes/discovery/os/axiscam.inc.php @@ -1,9 +1,11 @@ \ No newline at end of file + if (preg_match('/AXIS .* Video Server/', $sysDescr)) { + $os = 'axiscam'; + } +} diff --git a/includes/discovery/os/axisdocserver.inc.php b/includes/discovery/os/axisdocserver.inc.php index f6b25b84e..f4b865991 100644 --- a/includes/discovery/os/axisdocserver.inc.php +++ b/includes/discovery/os/axisdocserver.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/bcm963.inc.php b/includes/discovery/os/bcm963.inc.php index e0c721170..4113d29e0 100644 --- a/includes/discovery/os/bcm963.inc.php +++ b/includes/discovery/os/bcm963.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/bnt.inc.php b/includes/discovery/os/bnt.inc.php index 8f610d95e..37e0a8b17 100644 --- a/includes/discovery/os/bnt.inc.php +++ b/includes/discovery/os/bnt.inc.php @@ -1,9 +1,11 @@ \ No newline at end of file + if (preg_match('/^BNT /', $sysDescr)) { + $os = 'bnt'; + } +} diff --git a/includes/discovery/os/brother.inc.php b/includes/discovery/os/brother.inc.php index be6a4a6be..b56634a0b 100644 --- a/includes/discovery/os/brother.inc.php +++ b/includes/discovery/os/brother.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/cometsystem.inc.php b/includes/discovery/os/cometsystem.inc.php index 86cb86af1..6eedee41f 100644 --- a/includes/discovery/os/cometsystem.inc.php +++ b/includes/discovery/os/cometsystem.inc.php @@ -1,14 +1,9 @@ \ No newline at end of file diff --git a/includes/discovery/os/dell-laser.inc.php b/includes/discovery/os/dell-laser.inc.php index daa90da14..030ae8a94 100644 --- a/includes/discovery/os/dell-laser.inc.php +++ b/includes/discovery/os/dell-laser.inc.php @@ -1,10 +1,13 @@ \ No newline at end of file diff --git a/includes/discovery/os/deltaups.inc.php b/includes/discovery/os/deltaups.inc.php index c52aa4741..0df9ffb7d 100644 --- a/includes/discovery/os/deltaups.inc.php +++ b/includes/discovery/os/deltaups.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/dlink.inc.php b/includes/discovery/os/dlink.inc.php index 26e9c78de..313158ee1 100644 --- a/includes/discovery/os/dlink.inc.php +++ b/includes/discovery/os/dlink.inc.php @@ -1,11 +1,16 @@ \ No newline at end of file diff --git a/includes/discovery/os/dlinkap.inc.php b/includes/discovery/os/dlinkap.inc.php index 4add24995..3cd1d7179 100644 --- a/includes/discovery/os/dlinkap.inc.php +++ b/includes/discovery/os/dlinkap.inc.php @@ -1,10 +1,13 @@ \ No newline at end of file diff --git a/includes/discovery/os/epson.inc.php b/includes/discovery/os/epson.inc.php index 1369bdbf8..52467ca2f 100644 --- a/includes/discovery/os/epson.inc.php +++ b/includes/discovery/os/epson.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/gamatronicups.inc.php b/includes/discovery/os/gamatronicups.inc.php index 06e442c64..8ddc691a3 100644 --- a/includes/discovery/os/gamatronicups.inc.php +++ b/includes/discovery/os/gamatronicups.inc.php @@ -1,14 +1,9 @@ \ No newline at end of file diff --git a/includes/discovery/os/ies.inc.php b/includes/discovery/os/ies.inc.php index 1125cc186..62b2e49a6 100644 --- a/includes/discovery/os/ies.inc.php +++ b/includes/discovery/os/ies.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/ipoman.inc.php b/includes/discovery/os/ipoman.inc.php index 8a7300278..97c753b91 100644 --- a/includes/discovery/os/ipoman.inc.php +++ b/includes/discovery/os/ipoman.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/jetdirect.inc.php b/includes/discovery/os/jetdirect.inc.php index e0a6502c0..090a867f2 100644 --- a/includes/discovery/os/jetdirect.inc.php +++ b/includes/discovery/os/jetdirect.inc.php @@ -1,10 +1,13 @@ \ No newline at end of file diff --git a/includes/discovery/os/konica.inc.php b/includes/discovery/os/konica.inc.php index 911d78c32..90798bf9e 100644 --- a/includes/discovery/os/konica.inc.php +++ b/includes/discovery/os/konica.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/kyocera.inc.php b/includes/discovery/os/kyocera.inc.php index e0d5c56f9..7e7242572 100644 --- a/includes/discovery/os/kyocera.inc.php +++ b/includes/discovery/os/kyocera.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/liebert.inc.php b/includes/discovery/os/liebert.inc.php index f13b39e2d..2a7bfa324 100644 --- a/includes/discovery/os/liebert.inc.php +++ b/includes/discovery/os/liebert.inc.php @@ -1,8 +1,7 @@ diff --git a/includes/discovery/os/mgepdu.inc.php b/includes/discovery/os/mgepdu.inc.php index 718367cec..3b5c80a79 100644 --- a/includes/discovery/os/mgepdu.inc.php +++ b/includes/discovery/os/mgepdu.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/mgeups.inc.php b/includes/discovery/os/mgeups.inc.php index 9d94bce4a..6da303921 100644 --- a/includes/discovery/os/mgeups.inc.php +++ b/includes/discovery/os/mgeups.inc.php @@ -1,11 +1,16 @@ \ No newline at end of file diff --git a/includes/discovery/os/mrvld.inc.php b/includes/discovery/os/mrvld.inc.php index 738d5915f..2f8e5bff3 100644 --- a/includes/discovery/os/mrvld.inc.php +++ b/includes/discovery/os/mrvld.inc.php @@ -1,8 +1,7 @@ diff --git a/includes/discovery/os/netopia.inc.php b/includes/discovery/os/netopia.inc.php index 541503ce0..8bafc5a64 100644 --- a/includes/discovery/os/netopia.inc.php +++ b/includes/discovery/os/netopia.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/netvision.inc.php b/includes/discovery/os/netvision.inc.php index ec3c36096..8dc07c870 100644 --- a/includes/discovery/os/netvision.inc.php +++ b/includes/discovery/os/netvision.inc.php @@ -1,8 +1,7 @@ diff --git a/includes/discovery/os/netware.inc.php b/includes/discovery/os/netware.inc.php index 42f85b340..6e5ea3f46 100644 --- a/includes/discovery/os/netware.inc.php +++ b/includes/discovery/os/netware.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/nrg.inc.php b/includes/discovery/os/nrg.inc.php index 11bebecc1..9e9210421 100644 --- a/includes/discovery/os/nrg.inc.php +++ b/includes/discovery/os/nrg.inc.php @@ -1,8 +1,7 @@ diff --git a/includes/discovery/os/okilan.inc.php b/includes/discovery/os/okilan.inc.php index 70f396281..3403a2cf6 100644 --- a/includes/discovery/os/okilan.inc.php +++ b/includes/discovery/os/okilan.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/packetshaper.inc.php b/includes/discovery/os/packetshaper.inc.php index 849eae3cb..a36ed88aa 100644 --- a/includes/discovery/os/packetshaper.inc.php +++ b/includes/discovery/os/packetshaper.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/panos.inc.php b/includes/discovery/os/panos.inc.php index b0c9159ca..276b57906 100644 --- a/includes/discovery/os/panos.inc.php +++ b/includes/discovery/os/panos.inc.php @@ -1,8 +1,7 @@ diff --git a/includes/discovery/os/poweralert.inc.php b/includes/discovery/os/poweralert.inc.php index a2fbff009..fd4a4e1bc 100644 --- a/includes/discovery/os/poweralert.inc.php +++ b/includes/discovery/os/poweralert.inc.php @@ -1,8 +1,7 @@ diff --git a/includes/discovery/os/powervault.inc.php b/includes/discovery/os/powervault.inc.php index e2cb5f9c0..730e8f79f 100644 --- a/includes/discovery/os/powervault.inc.php +++ b/includes/discovery/os/powervault.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/powerware.inc.php b/includes/discovery/os/powerware.inc.php index 5d5b7ea6d..8e18f7742 100644 --- a/includes/discovery/os/powerware.inc.php +++ b/includes/discovery/os/powerware.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/prestige.inc.php b/includes/discovery/os/prestige.inc.php index c2240fc2f..c817d6e85 100644 --- a/includes/discovery/os/prestige.inc.php +++ b/includes/discovery/os/prestige.inc.php @@ -1,9 +1,10 @@ \ No newline at end of file diff --git a/includes/discovery/os/redback.inc.php b/includes/discovery/os/redback.inc.php index e53ff830d..4905b1f3d 100644 --- a/includes/discovery/os/redback.inc.php +++ b/includes/discovery/os/redback.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/ricoh.inc.php b/includes/discovery/os/ricoh.inc.php index 419d6dfd3..436ffe55e 100644 --- a/includes/discovery/os/ricoh.inc.php +++ b/includes/discovery/os/ricoh.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/routeros.inc.php b/includes/discovery/os/routeros.inc.php index 7a65b364d..323cc6257 100644 --- a/includes/discovery/os/routeros.inc.php +++ b/includes/discovery/os/routeros.inc.php @@ -1,19 +1,17 @@ = 5 - # sysDescr.0 = STRING: RouterOS RB493AH - if (preg_match("/^RouterOS/", $sysDescr)) { $os = "routeros"; } -} -?> + // Routeros >= 5 + // sysDescr.0 = STRING: RouterOS RB493AH + if (preg_match('/^RouterOS/', $sysDescr)) { + $os = 'routeros'; + } +} diff --git a/includes/discovery/os/sonicwall.inc.php b/includes/discovery/os/sonicwall.inc.php index 3a642f632..42a0f8640 100644 --- a/includes/discovery/os/sonicwall.inc.php +++ b/includes/discovery/os/sonicwall.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/supermicro-switch.inc.php b/includes/discovery/os/supermicro-switch.inc.php index f70783f52..fd8c9a507 100644 --- a/includes/discovery/os/supermicro-switch.inc.php +++ b/includes/discovery/os/supermicro-switch.inc.php @@ -1,10 +1,13 @@ diff --git a/includes/discovery/os/symbol.inc.php b/includes/discovery/os/symbol.inc.php index e90c95a67..cfee2ca17 100644 --- a/includes/discovery/os/symbol.inc.php +++ b/includes/discovery/os/symbol.inc.php @@ -1,8 +1,7 @@ diff --git a/includes/discovery/os/tranzeo.inc.php b/includes/discovery/os/tranzeo.inc.php index 6bd6d8535..55d0d73e3 100644 --- a/includes/discovery/os/tranzeo.inc.php +++ b/includes/discovery/os/tranzeo.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/vrp.inc.php b/includes/discovery/os/vrp.inc.php index 3855fb903..6c49cf862 100644 --- a/includes/discovery/os/vrp.inc.php +++ b/includes/discovery/os/vrp.inc.php @@ -1,11 +1,15 @@ \ No newline at end of file diff --git a/includes/discovery/os/windows.inc.php b/includes/discovery/os/windows.inc.php index 608298e56..671db0740 100644 --- a/includes/discovery/os/windows.inc.php +++ b/includes/discovery/os/windows.inc.php @@ -1,9 +1,11 @@ + if (preg_match('/Windows/', $sysDescr)) { + $os = 'windows'; + } +} diff --git a/includes/discovery/os/wxgoos.inc.php b/includes/discovery/os/wxgoos.inc.php index a8ee4e8e6..551d0e80a 100644 --- a/includes/discovery/os/wxgoos.inc.php +++ b/includes/discovery/os/wxgoos.inc.php @@ -1,12 +1,13 @@ \ No newline at end of file + if (strstr($sysObjectId, '.1.3.6.1.4.1.17373')) { + $os = 'wxgoos'; + } +} diff --git a/includes/discovery/os/xerox.inc.php b/includes/discovery/os/xerox.inc.php index 5fec318c2..f3972ebcd 100644 --- a/includes/discovery/os/xerox.inc.php +++ b/includes/discovery/os/xerox.inc.php @@ -1,9 +1,10 @@ \ No newline at end of file diff --git a/includes/discovery/os/zxr10.inc.php b/includes/discovery/os/zxr10.inc.php index dea79552e..352ed293b 100644 --- a/includes/discovery/os/zxr10.inc.php +++ b/includes/discovery/os/zxr10.inc.php @@ -1,8 +1,7 @@ diff --git a/includes/discovery/os/zywall.inc.php b/includes/discovery/os/zywall.inc.php index 5d46c7df7..0b3b25056 100644 --- a/includes/discovery/os/zywall.inc.php +++ b/includes/discovery/os/zywall.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/zyxeles.inc.php b/includes/discovery/os/zyxeles.inc.php index d539826ac..22b18dc58 100644 --- a/includes/discovery/os/zyxeles.inc.php +++ b/includes/discovery/os/zyxeles.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/os/zyxelnwa.inc.php b/includes/discovery/os/zyxelnwa.inc.php index e483cc1ca..e616b78ac 100644 --- a/includes/discovery/os/zyxelnwa.inc.php +++ b/includes/discovery/os/zyxelnwa.inc.php @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/includes/discovery/power.inc.php b/includes/discovery/power.inc.php index 838853de2..2161e5ec2 100644 --- a/includes/discovery/power.inc.php +++ b/includes/discovery/power.inc.php @@ -1,16 +1,15 @@ +echo "\n"; diff --git a/includes/discovery/power/ipoman.inc.php b/includes/discovery/power/ipoman.inc.php index acd51cebd..eba11ac4e 100644 --- a/includes/discovery/power/ipoman.inc.php +++ b/includes/discovery/power/ipoman.inc.php @@ -1,56 +1,49 @@ $entry) -# { -# $cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.5.' . $index; -# $divisor = 10; -# $descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') : "Inlet $index"); -# $power = $entry['inletStatusWH'] / $divisor; -# -# discover_sensor($valid['sensor'], 'power', $device, $cur_oid, '1.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', NULL, NULL, NULL, NULL, $power); -# // FIXME: iPoMan 1201 also says it has 2 inlets, at least until firmware 1.06 - wtf? -# } -# } - - if (is_array($oids_out)) - { - foreach ($oids_out as $index => $entry) - { - $cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.5.' . $index; - $divisor = 10; - $descr = (trim($cache['ipoman']['out'][$index]['outletConfigDesc'],'"') != '' ? trim($cache['ipoman']['out'][$index]['outletConfigDesc'],'"') : "Output $index"); - $power = $entry['outletStatusWH'] / $divisor; - - discover_sensor($valid['sensor'], 'power', $device, $cur_oid, '2.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', NULL, NULL, NULL, NULL, $power); + // Inlet Disabled due to the fact thats it's Kwh instead of just Watt + if (!is_array($cache['ipoman'])) { + echo 'outletConfigDesc '; + $cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $cache['ipoman']['out'], 'IPOMANII-MIB'); + echo 'outletConfigLocation '; + $cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $cache['ipoman']['out'], 'IPOMANII-MIB'); + // echo("inletConfigDesc "); + // $cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, "inletConfigDesc", $cache['ipoman'], "IPOMANII-MIB"); } - } -} -?> + // $oids_in = array(); + $oids_out = array(); + + // echo("inletStatusWH "); + // $oids_in = snmpwalk_cache_multi_oid($device, "inletStatusWH", $oids_in, "IPOMANII-MIB"); + echo 'outletStatusWH '; + $oids_out = snmpwalk_cache_multi_oid($device, 'outletStatusWH', $oids_out, 'IPOMANII-MIB'); + + // if (is_array($oids_in)) + // { + // foreach ($oids_in as $index => $entry) + // { + // $cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.5.' . $index; + // $divisor = 10; + // $descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') : "Inlet $index"); + // $power = $entry['inletStatusWH'] / $divisor; + // + // discover_sensor($valid['sensor'], 'power', $device, $cur_oid, '1.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', NULL, NULL, NULL, NULL, $power); + // // FIXME: iPoMan 1201 also says it has 2 inlets, at least until firmware 1.06 - wtf? + // } + // } + if (is_array($oids_out)) { + foreach ($oids_out as $index => $entry) + { + $cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.5.'.$index; + $divisor = 10; + $descr = (trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') != '' ? trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') : "Output $index"); + $power = ($entry['outletStatusWH'] / $divisor); + + discover_sensor($valid['sensor'], 'power', $device, $cur_oid, '2.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', null, null, null, null, $power); + } + } +}//end if diff --git a/includes/discovery/processors/avaya-ers.inc.php b/includes/discovery/processors/avaya-ers.inc.php index 1e1092cf1..b11f76ef4 100644 --- a/includes/discovery/processors/avaya-ers.inc.php +++ b/includes/discovery/processors/avaya-ers.inc.php @@ -1,18 +1,15 @@ $t) { - $t = explode(" ",$t); - $oid = $t[0]; - $val = $t[1]; - discover_processor($valid['processor'], $device, $oid, zeropad($i+1), "avaya-ers", "Unit " . ($i+1) . " processor", "1", $val, $i, NULL); + foreach (explode("\n", $procs) as $i => $t) { + $t = explode(' ', $t); + $oid = $t[0]; + $val = $t[1]; + discover_processor($valid['processor'], $device, $oid, zeropad($i + 1), 'avaya-ers', 'Unit '.($i + 1).' processor', '1', $val, $i, null); + } } - } } - -?> diff --git a/includes/discovery/processors/fortigate.inc.php b/includes/discovery/processors/fortigate.inc.php index 22ea6a516..d7c6060ab 100644 --- a/includes/discovery/processors/fortigate.inc.php +++ b/includes/discovery/processors/fortigate.inc.php @@ -1,23 +1,18 @@ +unset($processors_array); diff --git a/includes/discovery/processors/netscaler.inc.php b/includes/discovery/processors/netscaler.inc.php index a96ba62d8..0e08938f3 100644 --- a/includes/discovery/processors/netscaler.inc.php +++ b/includes/discovery/processors/netscaler.inc.php @@ -1,36 +1,27 @@ $data) { + $current = $data['nsCPUusage']; - foreach ($nsarray as $descr => $data) - { + $oid = '.1.3.6.1.4.1.5951.4.1.1.41.6.1.2.'.string_to_oid($descr); + $descr = $data['nsCPUname']; - $current = $data['nsCPUusage']; + discover_processor($valid['processor'], $device, $oid, $descr, 'netscaler', $descr, '1', $current, null, null); + } - $oid = ".1.3.6.1.4.1.5951.4.1.1.41.6.1.2." . string_to_oid($descr); - $descr = $data['nsCPUname']; - - discover_processor($valid['processor'], $device, $oid, $descr, "netscaler", $descr, "1", $current, NULL, NULL); - - } - - unset($nsarray, $oid, $descr, $current); - -} - -?> + unset($nsarray, $oid, $descr, $current); +}//end if diff --git a/includes/discovery/processors/radlan.inc.php b/includes/discovery/processors/radlan.inc.php index a5115b2b9..5032576e3 100644 --- a/includes/discovery/processors/radlan.inc.php +++ b/includes/discovery/processors/radlan.inc.php @@ -1,22 +1,17 @@ +unset($processors_array); diff --git a/includes/discovery/processors/vrp.inc.php b/includes/discovery/processors/vrp.inc.php index 68b95307e..e4e583904 100644 --- a/includes/discovery/processors/vrp.inc.php +++ b/includes/discovery/processors/vrp.inc.php @@ -1,33 +1,32 @@ $entry) - { - if ($entry['hwEntityMemSize'] != 0) - { - if ($debug) { echo($index . " " . $entry['hwEntityBomEnDesc'] . " -> " . $entry['hwEntityCpuUsage'] . " -> " . $entry['hwEntityMemSize']. "\n"); } - $usage_oid = ".1.3.6.1.4.1.2011.5.25.31.1.1.1.1.5." . $index; - $descr = $entry['hwEntityBomEnDesc']; - $usage = $entry['hwEntityCpuUsage']; - if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) + if (is_array($processors_array)) { + foreach ($processors_array as $index => $entry) { - discover_processor($valid['processor'], $device, $usage_oid, $index, "vrp", $descr, "1", $usage, NULL, NULL); - } - } // End if checks - } // End Foreach - } // End if array -} // End VRP Processors + if ($entry['hwEntityMemSize'] != 0) { + if ($debug) { + echo $index.' '.$entry['hwEntityBomEnDesc'].' -> '.$entry['hwEntityCpuUsage'].' -> '.$entry['hwEntityMemSize']."\n"; + } -unset ($processors_array); + $usage_oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.1.1.5.'.$index; + $descr = $entry['hwEntityBomEnDesc']; + $usage = $entry['hwEntityCpuUsage']; + if (!strstr($descr, 'No') && !strstr($usage, 'No') && $descr != '') { + discover_processor($valid['processor'], $device, $usage_oid, $index, 'vrp', $descr, '1', $usage, null, null); + } + } //end if + } //end foreach + } //end if +} //end if -?> +unset($processors_array); diff --git a/includes/discovery/processors/watchguard.inc.php b/includes/discovery/processors/watchguard.inc.php index aba03cc61..65d1c1b61 100644 --- a/includes/discovery/processors/watchguard.inc.php +++ b/includes/discovery/processors/watchguard.inc.php @@ -1,23 +1,18 @@ +unset($processors_array); diff --git a/includes/discovery/sensors-netscaler.inc.php b/includes/discovery/sensors-netscaler.inc.php index c7705b250..8470bb2a9 100644 --- a/includes/discovery/sensors-netscaler.inc.php +++ b/includes/discovery/sensors-netscaler.inc.php @@ -1,34 +1,48 @@ $data) -{ +foreach ($ns_sensor_array as $descr => $data) { + $current = $data['sysHealthCounterValue']; - $current = $data['sysHealthCounterValue']; + $oid = '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2.'.string_to_oid($descr); - $oid = ".1.3.6.1.4.1.5951.4.1.1.41.7.1.2." . string_to_oid($descr); + if (strpos($descr, 'Temp') !== false) { + $divisor = 0; + $multiplier = 0; + $type = 'temperature'; + } + else if (strpos($descr, 'Fan') !== false) { + $divisor = 0; + $multiplier = 0; + $type = 'fanspeed'; + } + else if (strpos($descr, 'Volt') !== false) { + $divisor = 1000; + $multiplier = 0; + $type = 'voltage'; + } + else if (strpos($descr, 'Vtt') !== false) { + $divisor = 1000; + $multiplier = 0; + $type = 'voltage'; + } - if (strpos($descr, "Temp") !== FALSE) { $divisor = 0; $multiplier = 0; $type = "temperature"; } - elseif (strpos($descr, "Fan") !== FALSE) { $divisor = 0; $multiplier = 0; $type = "fanspeed"; } - elseif (strpos($descr, "Volt") !== FALSE) { $divisor = 1000; $multiplier = 0; $type = "voltage"; } - elseif (strpos($descr, "Vtt") !== FALSE) { $divisor = 1000; $multiplier = 0; $type = "voltage"; } - - if ($divisor) { $current = $current / $divisor; }; - - discover_sensor($valid['sensor'], $type, $device, $oid, $descr, 'netscaler-health', $descr, $divisor, $multiplier, NULL, NULL, NULL, NULL, $current); + if ($divisor) { + $current = ($current / $divisor); + }; + discover_sensor($valid['sensor'], $type, $device, + $oid, $descr, 'netscaler-health', + $descr, $divisor, $multiplier, null, null, null, null, $current); } unset($ns_sensor_array); - -?> diff --git a/includes/discovery/services.inc.php b/includes/discovery/services.inc.php index a9d41bf81..3f3e3c988 100644 --- a/includes/discovery/services.inc.php +++ b/includes/discovery/services.inc.php @@ -1,37 +1,35 @@ "ssh", 25 => "smtp", 53 => "dns", 80 => "http", - 110 => "pop", 143 => "imap"); + // FIXME: use /etc/services? + $known_services = array( + 22 => 'ssh', + 25 => 'smtp', + 53 => 'dns', + 80 => 'http', + 110 => 'pop', + 143 => 'imap', + ); - # Services - if ($device['type'] == "server") - { - $oids = trim(snmp_walk($device, ".1.3.6.1.2.1.6.13.1.1.0.0.0.0", "-Osqn")); - foreach (explode("\n", $oids) as $data) - { - $data = trim($data); - if ($data) - { - list($oid, $tcpstatus) = explode(" ", $data); - if (trim($tcpstatus) == "listen") - { - $split_oid = explode('.',$oid); - $tcp_port = $split_oid[count($split_oid)-6]; - if ($known_services[$tcp_port]) - { - discover_service($device,$known_services[$tcp_port]); - } + // Services + if ($device['type'] == 'server') { + $oids = trim(snmp_walk($device, '.1.3.6.1.2.1.6.13.1.1.0.0.0.0', '-Osqn')); + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid, $tcpstatus) = explode(' ', $data); + if (trim($tcpstatus) == 'listen') { + $split_oid = explode('.', $oid); + $tcp_port = $split_oid[(count($split_oid) - 6)]; + if ($known_services[$tcp_port]) { + discover_service($device, $known_services[$tcp_port]); + } + } + } } - } } - } # End Services - echo("\n"); + echo "\n"; } - -?> \ No newline at end of file diff --git a/includes/discovery/temperatures/akcp.inc.php b/includes/discovery/temperatures/akcp.inc.php index e2c8c9b15..76602e418 100644 --- a/includes/discovery/temperatures/akcp.inc.php +++ b/includes/discovery/temperatures/akcp.inc.php @@ -1,39 +1,40 @@ + $oids = trim($oids); + if ($oids) { + echo 'AKCP '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$status) = explode(' ', $data, 2); + if ($status == 2) { + // 2 = normal, 0 = not connected + $split_oid = explode('.', $oid); + $temperature_id = $split_oid[(count($split_oid) - 1)]; + $descr_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.1.$temperature_id"; + $temperature_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.3.$temperature_id"; + $warnlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.7.$temperature_id"; + $limit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.8.$temperature_id"; + $lowwarnlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.9.$temperature_id"; + $lowlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.10.$temperature_id"; + + $descr = trim(snmp_get($device, $descr_oid, '-Oqv', ''), '"'); + $temperature = snmp_get($device, $temperature_oid, '-Oqv', ''); + $lowwarnlimit = snmp_get($device, $lowwarnlimit_oid, '-Oqv', ''); + $warnlimit = snmp_get($device, $warnlimit_oid, '-Oqv', ''); + $limit = snmp_get($device, $limit_oid, '-Oqv', ''); + $lowlimit = snmp_get($device, $lowlimit_oid, '-Oqv', ''); + + discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $temperature_id, 'akcp', $descr, '1', '1', $lowlimit, $low_warn_limit, $warnlimit, $limit, $temperature); + } + } + } +} diff --git a/includes/discovery/temperatures/aos-device.inc.php b/includes/discovery/temperatures/aos-device.inc.php index 1ffc52078..b386c0823 100644 --- a/includes/discovery/temperatures/aos-device.inc.php +++ b/includes/discovery/temperatures/aos-device.inc.php @@ -1,17 +1,15 @@ "0") - { - $temperature_oid = ".1.3.6.1.4.1.18248.1.1.1.0"; - discover_sensor($valid['sensor'], 'temperature', $device, ".1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.17.0", "1", 'alcatel-device', $descr, '1', '1', NULL, NULL, NULL, NULL, $temperature); - } + if ($descr != '' && is_numeric($temperature) && $temperature > '0') { + $temperature_oid = '.1.3.6.1.4.1.18248.1.1.1.0'; + discover_sensor($valid['sensor'], 'temperature', $device, + '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.17.0', '1', 'alcatel-device', + $descr, '1', '1', null, null, null, null, $temperature); + } } - -?> diff --git a/includes/discovery/temperatures/areca.inc.php b/includes/discovery/temperatures/areca.inc.php index ac25df88f..beffb9dd4 100644 --- a/includes/discovery/temperatures/areca.inc.php +++ b/includes/discovery/temperatures/areca.inc.php @@ -1,48 +1,56 @@ diff --git a/includes/discovery/temperatures/avaya-ers.inc.php b/includes/discovery/temperatures/avaya-ers.inc.php index 2d4e7bd63..9e066f01d 100644 --- a/includes/discovery/temperatures/avaya-ers.inc.php +++ b/includes/discovery/temperatures/avaya-ers.inc.php @@ -1,25 +1,24 @@ = 6.1) { - $temps = snmp_walk($device, "1.3.6.1.4.1.45.1.6.3.7.1.1.5.5", "-Osqn"); + // Temperature info only known to be present in firmware 6.1 or higher + if ($fw_major_version >= 6.1) { + $temps = snmp_walk($device, '1.3.6.1.4.1.45.1.6.3.7.1.1.5.5', '-Osqn'); - foreach (explode("\n", $temps) as $i => $t) { - $t = explode(" ",$t); - $oid = $t[0]; - $val = $t[1]; - # Sensors are reported as 2 * value - $val = trim($val) / 2; - discover_sensor($valid['sensor'], 'temperature', $device, $oid, zeropad($i+1), 'avaya-ers', "Unit " . ($i+1) . " temperature", '2', '1', NULL, NULL, NULL, NULL, $val); + foreach (explode("\n", $temps) as $i => $t) { + $t = explode(' ', $t); + $oid = $t[0]; + $val = $t[1]; + // Sensors are reported as 2 * value + $val = (trim($val) / 2); + discover_sensor($valid['sensor'], 'temperature', $device, + $oid, zeropad($i + 1), 'avaya-ers', + 'Unit '.($i + 1).' temperature', '2', '1', null, null, null, null, $val); + } } - } } - -?> diff --git a/includes/discovery/temperatures/cometsystem-p85xx.inc.php b/includes/discovery/temperatures/cometsystem-p85xx.inc.php index e9a82cc6f..cefae39dd 100644 --- a/includes/discovery/temperatures/cometsystem-p85xx.inc.php +++ b/includes/discovery/temperatures/cometsystem-p85xx.inc.php @@ -1,8 +1,7 @@ \d+) \. @@ -14,50 +13,43 @@ if ($device['os'] == "cometsystem-p85xx") ) /x'; - $oids = snmp_walk($device, ".1.3.6.1.4.1.22626.1.5.2", "-OsqnU", ""); - #if ($debug) { echo($oids."\n"); } - if ($oids) - { - $out = array(); - foreach (explode("\n", $oids) as $line) - { - preg_match($regexp, $line, $match); - if ($match['name']) - { - $out[$match['id']]['name'] = $match['name']; - } + $oids = snmp_walk($device, '.1.3.6.1.4.1.22626.1.5.2', '-OsqnU', ''); + // if ($debug) { echo($oids."\n"); } + if ($oids) { + $out = array(); + foreach (explode("\n", $oids) as $line) + { + preg_match($regexp, $line, $match); + if ($match['name']) { + $out[$match['id']]['name'] = $match['name']; + } - if ($match['temp_intval']) - { - $out[$match['id']]['temp_intval'] = $match['temp_intval']; - } + if ($match['temp_intval']) { + $out[$match['id']]['temp_intval'] = $match['temp_intval']; + } - if ($match['limit_high']) - { - $out[$match['id']]['limit_high'] = $match['limit_high']; - } + if ($match['limit_high']) { + $out[$match['id']]['limit_high'] = $match['limit_high']; + } - if ($match['limit_low']) - { - $out[$match['id']]['limit_low'] = $match['limit_low']; - } + if ($match['limit_low']) { + $out[$match['id']]['limit_low'] = $match['limit_low']; + } + } + + foreach ($out as $sensor_id => $sensor) { + if ($sensor['temp_intval'] != 9999) { + $temperature_oid = '.1.3.6.1.4.1.22626.1.5.2.'.$sensor_id.'.3.0'; + $temperature_id = $sensor_id; + $descr = trim($sensor['name'], ' "'); + $lowlimit = trim($sensor['limit_low'], ' "'); + $limit = trim($sensor['limit_high'], ' "'); + $temperature = $sensor['temp_intval']; + + discover_sensor($valid['sensor'], 'temperature', $device, + $temperature_oid, $temperature_id, 'cometsystem-p85xx', + $descr, '10', '1', $lowlimit, null, null, $limit, $temperature); + } + } } - - foreach ($out as $sensor_id=>$sensor) - { - if ($sensor['temp_intval'] != 9999) - { - $temperature_oid = '.1.3.6.1.4.1.22626.1.5.2.' . $sensor_id . '.3.0'; - $temperature_id = $sensor_id; - $descr = trim($sensor['name'], ' "'); - $lowlimit = trim($sensor['limit_low'], ' "'); - $limit = trim($sensor['limit_high'], ' "'); - $temperature = $sensor['temp_intval']; - - discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $temperature_id, 'cometsystem-p85xx', $descr, '10', '1', $lowlimit, NULL, NULL, $limit, $temperature); - } - } - } } - -?> diff --git a/includes/discovery/temperatures/dell.inc.php b/includes/discovery/temperatures/dell.inc.php index af93f3dee..73544ce6a 100644 --- a/includes/discovery/temperatures/dell.inc.php +++ b/includes/discovery/temperatures/dell.inc.php @@ -1,67 +1,69 @@ - * @copyright (C) 2006 - 2012 Adam Armstrong - * + * @author Squiz Pty Ltd + * @copyright 2015 Squiz Pty Ltd (ABN 77 084 670 600) */ -# MIB-Dell-10892::temperatureProbechassisIndex.1.1 = INTEGER: 1 -# MIB-Dell-10892::temperatureProbeIndex.1.1 = INTEGER: 1 -# MIB-Dell-10892::temperatureProbeStateCapabilities.1.1 = INTEGER: 0 -# MIB-Dell-10892::temperatureProbeStateSettings.1.1 = INTEGER: enabled(2) -# MIB-Dell-10892::temperatureProbeStatus.1.1 = INTEGER: ok(3) -# MIB-Dell-10892::temperatureProbeReading.1.1 = INTEGER: 320 -# MIB-Dell-10892::temperatureProbeType.1.1 = INTEGER: temperatureProbeTypeIsAmbientESM(3) -# MIB-Dell-10892::temperatureProbeLocationName.1.1 = STRING: "BMC Planar Temp" -# MIB-Dell-10892::temperatureProbeUpperCriticalThreshold.1.1 = INTEGER: 530 -# MIB-Dell-10892::temperatureProbeUpperNonCriticalThreshold.1.1 = INTEGER: 480 -# MIB-Dell-10892::temperatureProbeLowerNonCriticalThreshold.1.1 = INTEGER: 70 -# MIB-Dell-10892::temperatureProbeLowerCriticalThreshold.1.1 = INTEGER: 30 -# MIB-Dell-10892::temperatureProbeProbeCapabilities.1.1 = INTEGER: 0 - -if (strstr($device['hardware'], "Dell")) -{ - // stuff partially copied from akcp sensor - $oids = snmp_walk($device, "temperatureProbeStatus", "-Osqn", "MIB-Dell-10892"); - if ($debug) { echo($oids."\n"); } - $oids = trim($oids); - if ($oids) echo("Dell OMSA "); - foreach (explode("\n", $oids) as $data) - { - $data = trim($data); - if ($data) - { - list($oid,$status) = explode(" ", $data, 2); - if ($debug) { echo("status : ".$status."\n"); } - if ($status == "ok") # 2 = normal, 0 = not connected - { - $split_oid = explode('.',$oid); - $temperature_id = $split_oid[count($split_oid)-2].".".$split_oid[count($split_oid)-1]; - $descr_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.8.$temperature_id"; - $temperature_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.6.$temperature_id"; - $limit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.10.$temperature_id"; - $warnlimit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.11.$temperature_id"; - $lowwarnlimit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.12.$temperature_id"; - $lowlimit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.13.$temperature_id"; - - $descr = trim(snmp_get($device, $descr_oid, "-Oqv", "MIB-Dell-10892"),'"'); - $temperature = snmp_get($device, $temperature_oid, "-Oqv", "MIB-Dell-10892"); - $lowwarnlimit = snmp_get($device, $lowwarnlimit_oid, "-Oqv", "MIB-Dell-10892"); - $warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", "MIB-Dell-10892"); - $limit = snmp_get($device, $limit_oid, "-Oqv", "MIB-Dell-10892"); - $lowlimit = snmp_get($device, $lowlimit_oid, "-Oqv", "MIB-Dell-10892"); - - discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $temperature_id, 'dell', $descr, '10', '1', $lowlimit/10, $low_warn_limit/10, $warnlimit/10, $limit/10, $temperature/10); - } +// MIB-Dell-10892::temperatureProbechassisIndex.1.1 = INTEGER: 1 +// MIB-Dell-10892::temperatureProbeIndex.1.1 = INTEGER: 1 +// MIB-Dell-10892::temperatureProbeStateCapabilities.1.1 = INTEGER: 0 +// MIB-Dell-10892::temperatureProbeStateSettings.1.1 = INTEGER: enabled(2) +// MIB-Dell-10892::temperatureProbeStatus.1.1 = INTEGER: ok(3) +// MIB-Dell-10892::temperatureProbeReading.1.1 = INTEGER: 320 +// MIB-Dell-10892::temperatureProbeType.1.1 = INTEGER: temperatureProbeTypeIsAmbientESM(3) +// MIB-Dell-10892::temperatureProbeLocationName.1.1 = STRING: "BMC Planar Temp" +// MIB-Dell-10892::temperatureProbeUpperCriticalThreshold.1.1 = INTEGER: 530 +// MIB-Dell-10892::temperatureProbeUpperNonCriticalThreshold.1.1 = INTEGER: 480 +// MIB-Dell-10892::temperatureProbeLowerNonCriticalThreshold.1.1 = INTEGER: 70 +// MIB-Dell-10892::temperatureProbeLowerCriticalThreshold.1.1 = INTEGER: 30 +// MIB-Dell-10892::temperatureProbeProbeCapabilities.1.1 = INTEGER: 0 +if (strstr($device['hardware'], 'Dell')) { + // stuff partially copied from akcp sensor + $oids = snmp_walk($device, 'temperatureProbeStatus', '-Osqn', 'MIB-Dell-10892'); + if ($debug) { + echo $oids."\n"; } - } -} -?> + $oids = trim($oids); + if ($oids) { + echo 'Dell OMSA '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$status) = explode(' ', $data, 2); + if ($debug) { + echo 'status : '.$status."\n"; + } + + if ($status == 'ok') { + // 2 = normal, 0 = not connected + $split_oid = explode('.', $oid); + $temperature_id = $split_oid[(count($split_oid) - 2)].'.'.$split_oid[(count($split_oid) - 1)]; + $descr_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.8.$temperature_id"; + $temperature_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.6.$temperature_id"; + $limit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.10.$temperature_id"; + $warnlimit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.11.$temperature_id"; + $lowwarnlimit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.12.$temperature_id"; + $lowlimit_oid = ".1.3.6.1.4.1.674.10892.1.700.20.1.13.$temperature_id"; + + $descr = trim(snmp_get($device, $descr_oid, '-Oqv', 'MIB-Dell-10892'), '"'); + $temperature = snmp_get($device, $temperature_oid, '-Oqv', 'MIB-Dell-10892'); + $lowwarnlimit = snmp_get($device, $lowwarnlimit_oid, '-Oqv', 'MIB-Dell-10892'); + $warnlimit = snmp_get($device, $warnlimit_oid, '-Oqv', 'MIB-Dell-10892'); + $limit = snmp_get($device, $limit_oid, '-Oqv', 'MIB-Dell-10892'); + $lowlimit = snmp_get($device, $lowlimit_oid, '-Oqv', 'MIB-Dell-10892'); + + discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $temperature_id, 'dell', $descr, '10', '1', ($lowlimit / 10), ($low_warn_limit / 10), ($warnlimit / 10), ($limit / 10), ($temperature / 10)); + } + }//end if + }//end foreach +}//end if diff --git a/includes/discovery/temperatures/ftos-c-series.inc.php b/includes/discovery/temperatures/ftos-c-series.inc.php index 045675dc3..bc4af9dc5 100644 --- a/includes/discovery/temperatures/ftos-c-series.inc.php +++ b/includes/discovery/temperatures/ftos-c-series.inc.php @@ -1,26 +1,20 @@ $entry) - { - $entry['descr'] = "Slot ".$index; - $entry['oid'] = ".1.3.6.1.4.1.6027.3.8.1.2.1.1.5.".$index; - $entry['current'] = $entry['chSysCardTemp']; - discover_sensor($valid['sensor'], 'temperature', $device, $entry['oid'], $index, 'ftos-cseries', $entry['descr'], '1', '1', NULL, NULL, NULL, NULL, $entry['current']); +// F10-C-SERIES-CHASSIS-MIB::chSysCardType.1 = INTEGER: lc4802E48TB(1024) +// F10-C-SERIES-CHASSIS-MIB::chSysCardType.2 = INTEGER: lc0810EX8PB(2049) +// F10-C-SERIES-CHASSIS-MIB::chSysCardTemp.1 = Gauge32: 25 +// F10-C-SERIES-CHASSIS-MIB::chSysCardTemp.2 = Gauge32: 26 +if ($device['os'] == 'ftos' || $device['os_group'] == 'ftos') { + echo 'FTOS C-Series '; + $oids = snmpwalk_cache_oid($device, 'chSysCardTemp', array(), 'F10-C-SERIES-CHASSIS-MIB', $config['mib_dir'].':'.$config['mib_dir'].'/ftos'); + if (is_array($oids)) { + foreach ($oids as $index => $entry) + { + $entry['descr'] = 'Slot '.$index; + $entry['oid'] = '.1.3.6.1.4.1.6027.3.8.1.2.1.1.5.'.$index; + $entry['current'] = $entry['chSysCardTemp']; + discover_sensor($valid['sensor'], 'temperature', $device, $entry['oid'], $index, 'ftos-cseries', $entry['descr'], '1', '1', null, null, null, null, $entry['current']); + } } - } } - -?> diff --git a/includes/discovery/temperatures/ftos-e-series.inc.php b/includes/discovery/temperatures/ftos-e-series.inc.php index c06afc46d..62df5f73a 100644 --- a/includes/discovery/temperatures/ftos-e-series.inc.php +++ b/includes/discovery/temperatures/ftos-e-series.inc.php @@ -1,31 +1,25 @@ $entry) + { + $descr = 'Slot '.$index; + $oid = '.1.3.6.1.4.1.6027.3.1.1.2.3.1.8.'.$index; + $current = $entry['chSysCardUpperTemp']; - $oids = snmpwalk_cache_oid($device, "chSysCardUpperTemp", array(), "F10-CHASSIS-MIB", $config['mib_dir'].":".$config['mib_dir']."/ftos" ); - - if (is_array($oids)) - { - foreach ($oids as $index => $entry) - { - $descr = "Slot ".$index; - $oid = ".1.3.6.1.4.1.6027.3.1.1.2.3.1.8.".$index; - $current = $entry['chSysCardUpperTemp']; - - discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'ftos-eseries', $descr, '1', '1', NULL, NULL, NULL, NULL, $current); + discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'ftos-eseries', $descr, '1', '1', null, null, null, null, $current); + } } - } } - -?> diff --git a/includes/discovery/temperatures/ftos-s-series.inc.php b/includes/discovery/temperatures/ftos-s-series.inc.php index 09b043ad9..e16472c08 100644 --- a/includes/discovery/temperatures/ftos-s-series.inc.php +++ b/includes/discovery/temperatures/ftos-s-series.inc.php @@ -1,27 +1,21 @@ $entry) - { - $descr = "Unit ".$index . " " . $entry['chStackUnitSysType']; - $oid = ".1.3.6.1.4.1.6027.3.10.1.2.2.1.14.".$index; - $current = $entry['chStackUnitTemp']; - discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'ftos-sseries', $descr, '1', '1', NULL, NULL, NULL, NULL, $current); + if (is_array($oids)) { + foreach ($oids as $index => $entry) + { + $descr = 'Unit '.$index.' '.$entry['chStackUnitSysType']; + $oid = '.1.3.6.1.4.1.6027.3.10.1.2.2.1.14.'.$index; + $current = $entry['chStackUnitTemp']; + discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'ftos-sseries', $descr, '1', '1', null, null, null, null, $current); + } } - } } - -?> diff --git a/includes/discovery/temperatures/ipoman.inc.php b/includes/discovery/temperatures/ipoman.inc.php index 793297005..1de3afad0 100644 --- a/includes/discovery/temperatures/ipoman.inc.php +++ b/includes/discovery/temperatures/ipoman.inc.php @@ -2,27 +2,21 @@ // FIXME: EMD "stack" support? // FIXME: What to do with IPOMANII-MIB::ipmEnvEmdConfigTempOffset.0 ? +if ($device['os'] == 'ipoman') { + echo ' IPOMANII-MIB '; + $emd_installed = snmp_get($device, 'IPOMANII-MIB::ipmEnvEmdStatusEmdType.0', ' -Oqv'); -if ($device['os'] == "ipoman") -{ - echo(" IPOMANII-MIB "); - $emd_installed = snmp_get($device, "IPOMANII-MIB::ipmEnvEmdStatusEmdType.0"," -Oqv"); + if ($emd_installed != 'disabled') { + $descr = snmp_get($device, 'IPOMANII-MIB::ipmEnvEmdConfigTempName.0', '-Oqv'); + $current = (snmp_get($device, 'IPOMANII-MIB::ipmEnvEmdStatusTemperature.0', '-Oqv') / 10); + $high_limit = snmp_get($device, 'IPOMANII-MIB::ipmEnvEmdConfigTempHighSetPoint.0', '-Oqv'); + $low_limit = snmp_get($device, 'IPOMANII-MIB::ipmEnvEmdConfigTempLowSetPoint.0', '-Oqv'); - if ($emd_installed != 'disabled') - { - $descr = snmp_get($device, "IPOMANII-MIB::ipmEnvEmdConfigTempName.0", "-Oqv"); - $current = snmp_get($device, "IPOMANII-MIB::ipmEnvEmdStatusTemperature.0", "-Oqv") / 10; - $high_limit = snmp_get($device, "IPOMANII-MIB::ipmEnvEmdConfigTempHighSetPoint.0", "-Oqv"); - $low_limit = snmp_get($device, "IPOMANII-MIB::ipmEnvEmdConfigTempLowSetPoint.0", "-Oqv"); + if ($descr != '' && is_numeric($current) && $current > '0') { + $current_oid = '.1.3.6.1.4.1.2468.1.4.2.1.5.1.1.2.0'; + $descr = trim(str_replace('"', '', $descr)); - if ($descr != "" && is_numeric($current) && $current > "0") - { - $current_oid = ".1.3.6.1.4.1.2468.1.4.2.1.5.1.1.2.0"; - $descr = trim(str_replace("\"", "", $descr)); - - discover_sensor($valid['sensor'], 'temperature', $device, $current_oid, "1", 'ipoman', $descr, '10', '1', $low_limit, NULL, NULL, $high_limit, $current); + discover_sensor($valid['sensor'], 'temperature', $device, $current_oid, '1', 'ipoman', $descr, '10', '1', $low_limit, null, null, $high_limit, $current); + } } - } } - -?> diff --git a/includes/discovery/temperatures/ironware.inc.php b/includes/discovery/temperatures/ironware.inc.php index 591453bd1..ffc03f9c6 100644 --- a/includes/discovery/temperatures/ironware.inc.php +++ b/includes/discovery/temperatures/ironware.inc.php @@ -1,39 +1,35 @@ diff --git a/includes/discovery/temperatures/junos.inc.php b/includes/discovery/temperatures/junos.inc.php index 04987509c..3f0a87943 100644 --- a/includes/discovery/temperatures/junos.inc.php +++ b/includes/discovery/temperatures/junos.inc.php @@ -1,33 +1,29 @@ diff --git a/includes/discovery/temperatures/junose.inc.php b/includes/discovery/temperatures/junose.inc.php index 96eb310fd..63e4cdb05 100644 --- a/includes/discovery/temperatures/junose.inc.php +++ b/includes/discovery/temperatures/junose.inc.php @@ -1,28 +1,23 @@ $entry) + { + if (is_numeric($entry['juniSystemTempValue']) && is_numeric($index) && $entry['juniSystemTempValue'] > '0') { + $entPhysicalIndex = snmp_get($device, 'juniSystemTempPhysicalIndex.'.$index, '-Oqv', 'Juniper-System-MIB', '+'.$config['install_dir'].'/mibs/junose'); + $descr = snmp_get($device, 'entPhysicalDescr.'.$entPhysicalIndex, '-Oqv', 'ENTITY-MIB'); + $descr = preg_replace('/^Juniper\ [0-9a-zA-Z\-]+/', '', $descr); + // Wipe out ugly Juniper crap. Why put vendor and model in here? Idiots! + $descr = str_replace('temperature sensor on', '', trim($descr)); + $oid = '.1.3.6.1.4.1.4874.2.2.2.1.9.4.1.3.'.$index; + $current = $entry['juniSystemTempValue']; -if ($device['os'] == "junose") -{ - echo("JunOSe: "); - $oids = snmpwalk_cache_multi_oid($device, "juniSystemTempValue", array(), "Juniper-System-MIB", $config['install_dir']."/mibs/junose"); - if (is_array($oids)) - { - foreach ($oids as $index => $entry) - { - if (is_numeric($entry['juniSystemTempValue']) && is_numeric($index) && $entry['juniSystemTempValue'] > "0") - { - $entPhysicalIndex = snmp_get($device, "juniSystemTempPhysicalIndex.".$index, "-Oqv", "Juniper-System-MIB", "+".$config['install_dir']."/mibs/junose"); - $descr = snmp_get($device, "entPhysicalDescr.".$entPhysicalIndex, "-Oqv", "ENTITY-MIB"); - $descr = preg_replace("/^Juniper\ [0-9a-zA-Z\-]+/", "", $descr); // Wipe out ugly Juniper crap. Why put vendor and model in here? Idiots! - $descr = str_replace("temperature sensor on", "", trim($descr)); - $oid = ".1.3.6.1.4.1.4874.2.2.2.1.9.4.1.3.".$index; - $current = $entry['juniSystemTempValue']; - - discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'junose', $descr, '1', '1', NULL, NULL, NULL, NULL, $current); - } + discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'junose', $descr, '1', '1', null, null, null, null, $current); + } + } } - } -} - -?> +}//end if diff --git a/includes/discovery/temperatures/lm-sensors.inc.php b/includes/discovery/temperatures/lm-sensors.inc.php index cb4357780..1df73f023 100644 --- a/includes/discovery/temperatures/lm-sensors.inc.php +++ b/includes/discovery/temperatures/lm-sensors.inc.php @@ -1,30 +1,32 @@ + $oids = trim($oids); + if ($oids) { + echo 'LM-SENSORS-MIB: '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $temperature_id = $split_oid[(count($split_oid) - 1)]; + $temperature_oid = "1.3.6.1.4.1.2021.13.16.2.1.3.$temperature_id"; + $temperature = (snmp_get($device, $temperature_oid, '-Ovq') / 1000); + $descr = str_ireplace('temperature-', '', $descr); + $descr = str_ireplace('temp-', '', $descr); + $descr = trim($descr); + if ($temperature != '0' && $temperature <= '1000') { + discover_sensor($valid['sensor'], 'temperature', $device, + $temperature_oid, $temperature_id, 'lmsensors', + $descr, '1000', '1', null, null, null, null, $temperature); + } + } + } +} diff --git a/includes/discovery/temperatures/mgeups.inc.php b/includes/discovery/temperatures/mgeups.inc.php index 1c8045738..4b2ff3a32 100644 --- a/includes/discovery/temperatures/mgeups.inc.php +++ b/includes/discovery/temperatures/mgeups.inc.php @@ -2,63 +2,61 @@ global $debug; -if ($device['os'] == "mgeups") -{ - # blatently copyied from APC +if ($device['os'] == 'mgeups') { + // blatently copyied from APC + echo 'MGE UPS External '; - echo("MGE UPS External "); + // Environmental monitoring on UPSes etc + // FIXME upsmgConfigEnvironmentTable and upsmgEnvironmentSensorTable are used but there are others ... + $mge_env_data = snmpwalk_cache_oid($device, 'upsmgConfigEnvironmentTable', array(), 'MG-SNMP-UPS-MIB'); + $mge_env_data = snmpwalk_cache_oid($device, 'upsmgEnvironmentSensorTable', $mge_env_data, 'MG-SNMP-UPS-MIB'); - # Environmental monitoring on UPSes etc - // FIXME upsmgConfigEnvironmentTable and upsmgEnvironmentSensorTable are used but there are others ... - $mge_env_data = snmpwalk_cache_oid($device, "upsmgConfigEnvironmentTable", array(), "MG-SNMP-UPS-MIB"); - $mge_env_data = snmpwalk_cache_oid($device, "upsmgEnvironmentSensorTable", $mge_env_data, "MG-SNMP-UPS-MIB"); + /* + upsmgConfigSensorIndex.1 = 1 + upsmgConfigSensorName.1 = "Environment sensor" + upsmgConfigTemperatureLow.1 = 5 + upsmgConfigTemperatureHigh.1 = 40 + upsmgConfigTemperatureHysteresis.1 = 2 + upsmgConfigHumidityLow.1 = 5 + upsmgConfigHumidityHigh.1 = 90 + upsmgConfigHumidityHysteresis.1 = 5 + upsmgConfigInput1Name.1 = "Input #1" + upsmgConfigInput1ClosedLabel.1 = "closed" + upsmgConfigInput1OpenLabel.1 = "open" + upsmgConfigInput2Name.1 = "Input #2" + upsmgConfigInput2ClosedLabel.1 = "closed" + upsmgConfigInput2OpenLabel.1 = "open" -/* -upsmgConfigSensorIndex.1 = 1 -upsmgConfigSensorName.1 = "Environment sensor" -upsmgConfigTemperatureLow.1 = 5 -upsmgConfigTemperatureHigh.1 = 40 -upsmgConfigTemperatureHysteresis.1 = 2 -upsmgConfigHumidityLow.1 = 5 -upsmgConfigHumidityHigh.1 = 90 -upsmgConfigHumidityHysteresis.1 = 5 -upsmgConfigInput1Name.1 = "Input #1" -upsmgConfigInput1ClosedLabel.1 = "closed" -upsmgConfigInput1OpenLabel.1 = "open" -upsmgConfigInput2Name.1 = "Input #2" -upsmgConfigInput2ClosedLabel.1 = "closed" -upsmgConfigInput2OpenLabel.1 = "open" + upsmgEnvironmentIndex.1 = 1 + upsmgEnvironmentComFailure.1 = no + upsmgEnvironmentTemperature.1 = 287 + upsmgEnvironmentTemperatureLow.1 = no + upsmgEnvironmentTemperatureHigh.1 = no + upsmgEnvironmentHumidity.1 = 17 + upsmgEnvironmentHumidityLow.1 = no + upsmgEnvironmentHumidityHigh.1 = no + upsmgEnvironmentInput1State.1 = open + upsmgEnvironmentInput2State.1 = open + */ -upsmgEnvironmentIndex.1 = 1 -upsmgEnvironmentComFailure.1 = no -upsmgEnvironmentTemperature.1 = 287 -upsmgEnvironmentTemperatureLow.1 = no -upsmgEnvironmentTemperatureHigh.1 = no -upsmgEnvironmentHumidity.1 = 17 -upsmgEnvironmentHumidityLow.1 = no -upsmgEnvironmentHumidityHigh.1 = no -upsmgEnvironmentInput1State.1 = open -upsmgEnvironmentInput2State.1 = open -*/ + foreach (array_keys($mge_env_data) as $index) + { + $descr = $mge_env_data[$index]['upsmgConfigSensorName']; + $current = $mge_env_data[$index]['upsmgEnvironmentTemperature']; + $sensorType = 'mge'; + $oid = '.1.3.6.1.4.1.705.1.8.7.1.3.'.$index; + $low_limit = $mge_env_data[$index]['upsmgConfigTemperatureLow']; + $high_limit = $mge_env_data[$index]['upsmgConfigTemperatureHigh']; + $hysteresis = $mge_env_data[$index]['upsmgConfigTemperatureHysteresis']; - foreach (array_keys($mge_env_data) as $index) - { - $descr = $mge_env_data[$index]['upsmgConfigSensorName']; - $current = $mge_env_data[$index]['upsmgEnvironmentTemperature']; - $sensorType = 'mge'; - $oid = '.1.3.6.1.4.1.705.1.8.7.1.3.' . $index; - $low_limit = $mge_env_data[$index]['upsmgConfigTemperatureLow']; - $high_limit = $mge_env_data[$index]['upsmgConfigTemperatureHigh']; - $hysteresis = $mge_env_data[$index]['upsmgConfigTemperatureHysteresis']; + // FIXME warninglevels might need some other calculation in stead of hysteresis + $low_warn_limit = ($low_limit + $hysteresis); + $high_warn_limit = ($high_limit - $hysteresis); - // FIXME warninglevels might need some other calculation in stead of hysteresis - $low_warn_limit = $low_limit + $hysteresis; - $high_warn_limit = $high_limit - $hysteresis; + if ($debug) { + echo "low_limit : $low_limit\nlow_warn_limit : $low_warn_limit\nhigh_warn_limit : $high_warn_limit\nhigh_limit : $high_limit\n"; + } - if ($debug) { echo("low_limit : $low_limit\nlow_warn_limit : $low_warn_limit\nhigh_warn_limit : $high_warn_limit\nhigh_limit : $high_limit\n"); } - - discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, '10', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit , $current/10); - } -} - -?> + discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, '10', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, ($current / 10)); + } +}//end if diff --git a/includes/discovery/temperatures/netbotz.inc.php b/includes/discovery/temperatures/netbotz.inc.php index 5191246f6..6f6a31905 100644 --- a/includes/discovery/temperatures/netbotz.inc.php +++ b/includes/discovery/temperatures/netbotz.inc.php @@ -1,29 +1,29 @@ + $oids = trim($oids); + if ($oids) { + echo 'NetBotz '; + foreach (explode("\n", $oids) as $data) + { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $temperature_id = $split_oid[(count($split_oid) - 1)]; + $temperature_oid = ".1.3.6.1.4.1.5528.100.4.1.1.1.8.$temperature_id"; + $temperature = snmp_get($device, $temperature_oid, '-Ovq'); + $descr = str_replace('"', '', $descr); + $descr = preg_replace('/Temperature /', '', $descr); + $descr = trim($descr); + if ($temperature != '0' && $temperature <= '1000') { + discover_sensor($valid['sensor'], 'temperature', $device, + $temperature_oid, $temperature_id, 'netbotz', + $descr, '1', '1', null, null, null, null, $temperature); + } + } + } +} diff --git a/includes/discovery/temperatures/observernms-custom.inc.php b/includes/discovery/temperatures/observernms-custom.inc.php index d64398fdc..bacb3e9a1 100644 --- a/includes/discovery/temperatures/observernms-custom.inc.php +++ b/includes/discovery/temperatures/observernms-custom.inc.php @@ -1,26 +1,27 @@ + $oids = shell_exec($cmd); + $oids = trim($oids); + if ($oids) { + echo 'Observer-Style '; + } + + foreach (explode("\n", $oids) as $oid) { + $oid = trim($oid); + if ($oid != '') { + // FIXME snmp_get + $descr_query = $config['snmpget'].' -M '.$config['mibdir'].' -m SNMPv2-SMI -Osqn '.snmp_gen_auth($device).' '.$device['transport'].':'.$device['hostname'].':'.$device['port']." .1.3.6.1.4.1.2021.7891.$oid.2.1 | sed s/.1.3.6.1.4.1.2021.7891.$oid.2.1\ //"; + $descr = trim(str_replace('"', '', shell_exec($descr_query))); + $fulloid = ".1.3.6.1.4.1.2021.7891.$oid.101.1"; + discover_sensor($valid['sensor'], 'temperature', $device, $fulloid, $oid, 'observium', $descr, '1', '1', null, null, null, null, $current); + } + } +}//end if diff --git a/includes/discovery/temperatures/papouch-tme.inc.php b/includes/discovery/temperatures/papouch-tme.inc.php index 9d7d5ddb3..0b122976c 100644 --- a/includes/discovery/temperatures/papouch-tme.inc.php +++ b/includes/discovery/temperatures/papouch-tme.inc.php @@ -1,18 +1,16 @@ "0") - { - $temperature_oid = ".1.3.6.1.4.1.18248.1.1.1.0"; - $descr = trim(str_replace("\"", "", $descr)); - discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, "1", 'papouch-tme', $descr, '10', '1', NULL, NULL, NULL, NULL, $temperature); - } + if ($descr != '' && is_numeric($temperature) && $temperature > '0') { + $temperature_oid = '.1.3.6.1.4.1.18248.1.1.1.0'; + $descr = trim(str_replace('"', '', $descr)); + discover_sensor($valid['sensor'], 'temperature', $device, + $temperature_oid, '1', 'papouch-tme', + $descr, '10', '1', null, null, null, null, $temperature); + } } - -?> diff --git a/includes/discovery/temperatures/pcoweb.inc.php b/includes/discovery/temperatures/pcoweb.inc.php index eaa1c40b9..263e1906b 100644 --- a/includes/discovery/temperatures/pcoweb.inc.php +++ b/includes/discovery/temperatures/pcoweb.inc.php @@ -1,60 +1,144 @@ "CAREL-ug40cdz-MIB::roomTemp.0", "descr" => "Room Temperature", "oid" => ".1.3.6.1.4.1.9839.2.1.2.1.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::outdoorTemp.0", "descr" => "Ambient Temperature", "oid" => ".1.3.6.1.4.1.9839.2.1.2.2.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::deliveryTemp.0", "descr" => "Delivery Air Temperature", "oid" => ".1.3.6.1.4.1.9839.2.1.2.3.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::cwTemp.0", "descr" => "Chilled Water Temperature", "oid" => ".1.3.6.1.4.1.9839.2.1.2.4.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::hwTemp.0", "descr" => "Hot Water Temperature", "oid" => ".1.3.6.1.4.1.9839.2.1.2.5.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::cwoTemp.0", "descr" => "Chilled Water Outlet Temperature", "oid" => ".1.3.6.1.4.1.9839.2.1.2.7.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::suctTemp1.0", "descr" => "Circuit 1 Suction Temperature", "oid" => ".1.3.6.1.4.1.9839.2.1.2.10.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::suctTemp2.0", "descr" => "Circuit 2 Suction Temperature", "oid" => ".1.3.6.1.4.1.9839.2.1.2.11.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::evapTemp1.0", "descr" => "Circuit 1 Evap. Temperature", "oid" => ".1.3.6.1.4.1.9839.2.1.2.12.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::evapTemp2.0", "descr" => "Circuit 2 Evap. Temperature", "oid" => ".1.3.6.1.4.1.9839.2.1.2.13.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::ssh1.0", "descr" => "Circuit 1 Superheat", "oid" => ".1.3.6.1.4.1.9839.2.1.2.14.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::ssh2.0", "descr" => "Circuit 2 Superheat", "oid" => ".1.3.6.1.4.1.9839.2.1.2.15.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::coolSetP.0", "descr" => "Cooling Set Point", "oid" => ".1.3.6.1.4.1.9839.2.1.2.20.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::coolDiff.0", "descr" => "Cooling Prop. Band", "oid" => ".1.3.6.1.4.1.9839.2.1.2.21.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::cool2SetP.0", "descr" => "Cooling 2nd Set Point", "oid" => ".1.3.6.1.4.1.9839.2.1.2.22.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::heatSetP.0", "descr" => "Heating Set Point", "oid" => ".1.3.6.1.4.1.9839.2.1.2.23.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::heatDiff.0", "descr" => "Heating Prop. Band", "oid" => ".1.3.6.1.4.1.9839.2.1.2.25.0", "precision" => "10"), - array("mib" => "CAREL-ug40cdz-MIB::heat2SetP.0", "descr" => "Heating 2nd Set Point", "oid" => ".1.3.6.1.4.1.9839.2.1.2.24.0", "precision" => "10"), - ); + $temperatures = array( + array( + 'mib' => 'CAREL-ug40cdz-MIB::roomTemp.0', + 'descr' => 'Room Temperature', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.1.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::outdoorTemp.0', + 'descr' => 'Ambient Temperature', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.2.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::deliveryTemp.0', + 'descr' => 'Delivery Air Temperature', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.3.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::cwTemp.0', + 'descr' => 'Chilled Water Temperature', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.4.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::hwTemp.0', + 'descr' => 'Hot Water Temperature', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.5.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::cwoTemp.0', + 'descr' => 'Chilled Water Outlet Temperature', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.7.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::suctTemp1.0', + 'descr' => 'Circuit 1 Suction Temperature', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.10.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::suctTemp2.0', + 'descr' => 'Circuit 2 Suction Temperature', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.11.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::evapTemp1.0', + 'descr' => 'Circuit 1 Evap. Temperature', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.12.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::evapTemp2.0', + 'descr' => 'Circuit 2 Evap. Temperature', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.13.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::ssh1.0', + 'descr' => 'Circuit 1 Superheat', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.14.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::ssh2.0', + 'descr' => 'Circuit 2 Superheat', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.15.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::coolSetP.0', + 'descr' => 'Cooling Set Point', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.20.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::coolDiff.0', + 'descr' => 'Cooling Prop. Band', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.21.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::cool2SetP.0', + 'descr' => 'Cooling 2nd Set Point', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.22.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::heatSetP.0', + 'descr' => 'Heating Set Point', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.23.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::heatDiff.0', + 'descr' => 'Heating Prop. Band', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.25.0', + 'precision' => '10', + ), + array( + 'mib' => 'CAREL-ug40cdz-MIB::heat2SetP.0', + 'descr' => 'Heating 2nd Set Point', + 'oid' => '.1.3.6.1.4.1.9839.2.1.2.24.0', + 'precision' => '10', + ), + ); - foreach ($temperatures as $temperature) - { - $current = snmp_get($device, $temperature['mib'], "-OqvU") / $temperature['precision']; + foreach ($temperatures as $temperature) { + $current = (snmp_get($device, $temperature['mib'], '-OqvU') / $temperature['precision']); - $high_limit = NULL; - $low_limit = NULL; + $high_limit = null; + $low_limit = null; - if (is_numeric($current) && $current != 0) - { - $index = implode(".",array_slice(explode(".",$temperature['oid']),-5)); - discover_sensor($valid['sensor'], 'temperature', $device, $temperature['oid'], $index, 'pcoweb', $temperature['descr'], $temperature['precision'], '1', $low_limit, NULL, NULL, $high_limit, $current); + if (is_numeric($current) && $current != 0) { + $index = implode('.', array_slice(explode('.', $temperature['oid']), -5)); + discover_sensor($valid['sensor'], 'temperature', $device, $temperature['oid'], $index, 'pcoweb', $temperature['descr'], $temperature['precision'], '1', $low_limit, null, null, $high_limit, $current); + } } - } -/* -FIXME - -thrsHT.0 = INTEGER: 30 degrees C x10 -thrsLT.0 = INTEGER: 10 degrees C x10 -smCoolSetp.0 = INTEGER: 280 degrees C -smHeatSetp.0 = INTEGER: 160 degrees C -cwDehumSetp.0 = INTEGER: 70 degrees C -cwHtThrsh.0 = INTEGER: 150 degrees C -cwModeSetp.0 = INTEGER: 70 degrees C -radcoolSpES.0 = INTEGER: 80 degrees C -radcoolSpDX.0 = INTEGER: 280 degrees C -delTempLimit.0 = INTEGER: 14 degrees C x10 -dtAutChgMLT.0 = INTEGER: 20 degrees C -*/ + /* + FIXME + thrsHT.0 = INTEGER: 30 degrees C x10 + thrsLT.0 = INTEGER: 10 degrees C x10 + smCoolSetp.0 = INTEGER: 280 degrees C + smHeatSetp.0 = INTEGER: 160 degrees C + cwDehumSetp.0 = INTEGER: 70 degrees C + cwHtThrsh.0 = INTEGER: 150 degrees C + cwModeSetp.0 = INTEGER: 70 degrees C + radcoolSpES.0 = INTEGER: 80 degrees C + radcoolSpDX.0 = INTEGER: 280 degrees C + delTempLimit.0 = INTEGER: 14 degrees C x10 + dtAutChgMLT.0 = INTEGER: 20 degrees C + */ } - -?> diff --git a/includes/discovery/temperatures/rfc1628.inc.php b/includes/discovery/temperatures/rfc1628.inc.php index c90fe0fb5..a010e68af 100644 --- a/includes/discovery/temperatures/rfc1628.inc.php +++ b/includes/discovery/temperatures/rfc1628.inc.php @@ -1,26 +1,27 @@ + $oids = trim($oids); + if ($oids) { + echo 'RFC1628 Battery Temperature '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $temperature_id = $split_oid[(count($split_oid) - 1)]; + $temperature_oid = "1.3.6.1.2.1.33.1.2.7.$temperature_id"; + $temperature = snmp_get($device, $temperature_oid, '-Ovq'); + $descr = 'Battery'.(count(explode("\n", $oids)) == 1 ? '' : ' '.($temperature_id + 1)); + + discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $temperature_id, 'rfc1628', $descr, '1', '1', null, null, null, null, $temperature); + } + } +}//end if diff --git a/includes/discovery/temperatures/sentry3.inc.php b/includes/discovery/temperatures/sentry3.inc.php index ce94fa362..3bd43beb0 100644 --- a/includes/discovery/temperatures/sentry3.inc.php +++ b/includes/discovery/temperatures/sentry3.inc.php @@ -1,36 +1,40 @@ = 0) { - discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $index, 'sentry3', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current); - } +if ($device['os'] == 'sentry3') { + $oids = snmp_walk($device, 'tempHumidSensorTempValue', '-Osqn', 'Sentry3-MIB'); + if ($debug) { + echo $oids."\n"; } - } -} -?> + $oids = trim($oids); + $divisor = '10'; + $multiplier = '1'; + if ($oids) { + echo 'ServerTech Sentry3 Temperature '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 1)]; + + // tempHumidSensorTempValue + $temperature_oid = '1.3.6.1.4.1.1718.3.2.5.1.6.1.'.$index; + $descr = 'Removable Sensor '.$index; + $low_warn_limit = null; + $low_limit = (snmp_get($device, "tempHumidSensorTempLowThresh.1.$index", '-Ovq', 'Sentry3-MIB') / $divisor); + $high_warn_limit = null; + $high_limit = (snmp_get($device, "tempHumidSensorTempHighThresh.1.$index", '-Ovq', 'Sentry3-MIB') / $divisor); + $current = (snmp_get($device, "$temperature_oid", '-Ovq', 'Sentry3-MIB') / $divisor); + + if ($current >= 0) { + discover_sensor($valid['sensor'], 'temperature', $device, + $temperature_oid, $index, 'sentry3', + $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, + $high_warn_limit, $high_limit, $current); + } + } + } +} diff --git a/includes/discovery/temperatures/supermicro.inc.php b/includes/discovery/temperatures/supermicro.inc.php index e25e5a42e..9bb5a677e 100644 --- a/includes/discovery/temperatures/supermicro.inc.php +++ b/includes/discovery/temperatures/supermicro.inc.php @@ -1,39 +1,37 @@ + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$type) = explode(' ', $data); + $oid_ex = explode('.', $oid); + $index = $oid_ex[(count($oid_ex) - 1)]; + if ($type == 2) { + $temperature_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.4.$index"; + $descr_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.2.$index"; + $limit_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.5.$index"; + $divisor_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.9.$index"; + $monitor_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.10.$index"; + $descr = snmp_get($device, $descr_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); + $temperature = snmp_get($device, $temperature_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); + $limit = snmp_get($device, $limit_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); + $divisor = snmp_get($device, $divisor_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB') || 1; + $monitor = snmp_get($device, $monitor_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); + if ($monitor == 'true') { + $descr = trim(str_ireplace('temperature', '', $descr)); + discover_sensor($valid['sensor'], 'temperature', $device, + $temperature_oid, trim($index, '.'), 'supermicro', + $descr, $divisor, '1', null, null, null, $limit, $temperature); + } + } + } + } +} diff --git a/includes/discovery/temperatures/xups.inc.php b/includes/discovery/temperatures/xups.inc.php index 3c9d2ac4a..048d881ca 100644 --- a/includes/discovery/temperatures/xups.inc.php +++ b/includes/discovery/temperatures/xups.inc.php @@ -1,31 +1,34 @@ + $oids = trim($oids); + if ($oids) { + echo 'Powerware Ambient Temperature '; + } + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $temperature_id = $split_oid[(count($split_oid) - 1)]; + $temperature_oid = ".1.3.6.1.4.1.534.1.6.1.$temperature_id"; + $lowlimit = snmp_get($device, "upsEnvAmbientLowerLimit.$temperature_id", '-Ovq', 'XUPS-MIB'); + $highlimit = snmp_get($device, "upsEnvAmbientUpperLimit.$temperature_id", '-Ovq', 'XUPS-MIB'); + $temperature = snmp_get($device, $temperature_oid, '-Ovq'); + $descr = 'Ambient'.(count(explode("\n", $oids)) == 1 ? '' : ' '.($temperature_id + 1)); + + discover_sensor($valid['sensor'], 'temperature', $device, + $temperature_oid, '1.6.1.'.$temperature_id, 'powerware', + $descr, '1', '1', $lowlimit, null, null, $highlimit, $temperature); + } + } +} diff --git a/includes/discovery/temperatures/zyxel-ies.inc.php b/includes/discovery/temperatures/zyxel-ies.inc.php index 9aa9f88d0..818bfc417 100644 --- a/includes/discovery/temperatures/zyxel-ies.inc.php +++ b/includes/discovery/temperatures/zyxel-ies.inc.php @@ -1,26 +1,24 @@ $entry) - { - $entPhysicalIndex = $index; - $descr = trim(snmp_get($device, "accessSwitchSysTempDescr.".$index, "-Oqv", "ZYXEL-AS-MIB"),'"'); - $oid = ".1.3.6.1.4.1.890.1.5.1.1.6.1.2.".$index; - $current = $entry['accessSwitchSysTempCurValue']; - $divisor = '1'; - discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'zyxel-ies', $descr, '1', '1', NULL, $entry['accessSwitchSysTempHighThresh'], NULL, NULL, $current); + if (is_array($oids)) { + foreach ($oids as $index => $entry) + { + $entPhysicalIndex = $index; + $descr = trim(snmp_get($device, 'accessSwitchSysTempDescr.'.$index, '-Oqv', 'ZYXEL-AS-MIB'), '"'); + $oid = '.1.3.6.1.4.1.890.1.5.1.1.6.1.2.'.$index; + $current = $entry['accessSwitchSysTempCurValue']; + $divisor = '1'; + discover_sensor($valid['sensor'], 'temperature', $device, + $oid, $index, 'zyxel-ies', + $descr, '1', '1', null, $entry['accessSwitchSysTempHighThresh'], null, null, $current); + } } - } } - -?> diff --git a/includes/discovery/vlans/q-bridge-mib.inc.php b/includes/discovery/vlans/q-bridge-mib.inc.php index 3b55121a6..83908fbd9 100644 --- a/includes/discovery/vlans/q-bridge-mib.inc.php +++ b/includes/discovery/vlans/q-bridge-mib.inc.php @@ -1,31 +1,27 @@ $vlan) - { - echo(" $vlan_id"); - if (is_array($vlans_db[$vtpdomain_id][$vlan_id])) - { - echo("."); - } else { - dbInsert(array('device_id' => $device['device_id'], 'vlan_domain' => $vtpdomain_id, 'vlan_vlan' => $vlan_id, 'vlan_name' => $vlan['dot1qVlanStaticName'], 'vlan_type' => array('NULL')), 'vlans'); - echo("+"); + foreach ($vlans as $vlan_id => $vlan) { + echo " $vlan_id"; + if (is_array($vlans_db[$vtpdomain_id][$vlan_id])) { + echo '.'; + } + else { + dbInsert(array('device_id' => $device['device_id'], 'vlan_domain' => $vtpdomain_id, 'vlan_vlan' => $vlan_id, 'vlan_name' => $vlan['dot1qVlanStaticName'], 'vlan_type' => array('NULL')), 'vlans'); + echo '+'; } - $device['vlans'][$vtpdomain_id][$vlan_id] = $vlan_id; - } + $device['vlans'][$vtpdomain_id][$vlan_id] = $vlan_id; + } } -echo("\n"); - -?> +echo "\n"; diff --git a/includes/discovery/voltages/apc.inc.php b/includes/discovery/voltages/apc.inc.php index a69b5bc86..b309d21fb 100644 --- a/includes/discovery/voltages/apc.inc.php +++ b/includes/discovery/voltages/apc.inc.php @@ -1,106 +1,121 @@ 1) { $descr .= " $index"; } - - discover_sensor($valid['sensor'], 'voltage', $device, $oid, "4.3.1.3.$index", $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); + if ($oids) { + echo 'APC In '; } - } - $oids = snmp_get($device, "1.3.6.1.4.1.318.1.1.1.3.2.1.0", "-OsqnU", ""); - if ($debug) { echo($oids."\n"); } - if ($oids) - { - echo(" APC In "); - list($oid,$current) = explode(" ",$oids); $divisor = 1; - $type = "apc"; - $index = "3.2.1.0"; - $descr = "Input"; + $type = 'apc'; + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$current) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 3)]; + $oid = '1.3.6.1.4.1.318.1.1.8.5.3.3.1.3.'.$index.'.1.1'; + $descr = 'Input Feed '.chr(64 + $index); - discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + discover_sensor($valid['sensor'], 'voltage', $device, $oid, "3.3.1.3.$index", $type, $descr, $divisor, '1', null, null, null, null, $current); + } + } + + $oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.8.5.4.3.1.3', '-OsqnU', ''); + if ($debug) { + echo $oids."\n"; + } + + if ($oids) { + echo ' APC Out '; + } - $oids = snmp_get($device, "1.3.6.1.4.1.318.1.1.1.4.2.1.0", "-OsqnU", ""); - if ($debug) { echo($oids."\n"); } - if ($oids) - { - echo(" APC Out "); - list($oid,$current) = explode(" ",$oids); $divisor = 1; - $type = "apc"; - $index = "4.2.1.0"; - $descr = "Output"; + $type = 'apc'; + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$current) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 3)]; + $oid = '1.3.6.1.4.1.318.1.1.8.5.4.3.1.3.'.$index.'.1.1'; + $descr = 'Output Feed'; + if (count(explode("\n", $oids)) > 1) { + $descr .= " $index"; + } - discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + discover_sensor($valid['sensor'], 'voltage', $device, $oid, "4.3.1.3.$index", $type, $descr, $divisor, '1', null, null, null, null, $current); + } + } - #PDU - #$oids = snmp_get($device, "1.3.6.1.4.1.318.1.1.12.1.15.0", "-OsqnU", ""); - $oids = snmp_walk($device, "rPDUIdentDeviceLinetoLineVoltage.0", "-OsqnU", "PowerNet-MIB"); - if ($debug) { echo($oids."\n"); } - if ($oids) - { - echo(" Voltage In "); - list($oid,$current) = explode(" ",$oids); - $divisor = 1; - $type = "apc"; - $index = "1"; - $descr = "Input"; + $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.3.2.1.0', '-OsqnU', ''); + if ($debug) { + echo $oids."\n"; + } - discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + if ($oids) { + echo ' APC In '; + list($oid,$current) = explode(' ', $oids); + $divisor = 1; + $type = 'apc'; + $index = '3.2.1.0'; + $descr = 'Input'; - $oids = snmp_walk($device, "1.3.6.1.4.1.318.1.1.26.6.3.1.6", "-OsqnU", "PowerNet-MIB"); - if ($debug) { echo($oids."\n"); } - if ($oids) - { - echo(" Voltage In "); - list($oid,$current) = explode(" ",$oids); - $divisor = 1; - $type = "apc"; - $index = "1"; - $descr = "Input"; + discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } - discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + $oids = snmp_get($device, '1.3.6.1.4.1.318.1.1.1.4.2.1.0', '-OsqnU', ''); + if ($debug) { + echo $oids."\n"; + } -} + if ($oids) { + echo ' APC Out '; + list($oid,$current) = explode(' ', $oids); + $divisor = 1; + $type = 'apc'; + $index = '4.2.1.0'; + $descr = 'Output'; -?> + discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } + + // PDU + // $oids = snmp_get($device, "1.3.6.1.4.1.318.1.1.12.1.15.0", "-OsqnU", ""); + $oids = snmp_walk($device, 'rPDUIdentDeviceLinetoLineVoltage.0', '-OsqnU', 'PowerNet-MIB'); + if ($debug) { + echo $oids."\n"; + } + + if ($oids) { + echo ' Voltage In '; + list($oid,$current) = explode(' ', $oids); + $divisor = 1; + $type = 'apc'; + $index = '1'; + $descr = 'Input'; + + discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } + + $oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.26.6.3.1.6', '-OsqnU', 'PowerNet-MIB'); + if ($debug) { + echo $oids."\n"; + } + + if ($oids) { + echo ' Voltage In '; + list($oid,$current) = explode(' ', $oids); + $divisor = 1; + $type = 'apc'; + $index = '1'; + $descr = 'Input'; + + discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } +}//end if diff --git a/includes/discovery/voltages/areca.inc.php b/includes/discovery/voltages/areca.inc.php index 7c91923de..258203a80 100644 --- a/includes/discovery/voltages/areca.inc.php +++ b/includes/discovery/voltages/areca.inc.php @@ -1,29 +1,30 @@ \ No newline at end of file + if ($oids) { + echo 'Areca '; + } + + $divisor = 1000; + $type = 'areca'; + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 1)]; + $oid = '1.3.6.1.4.1.18928.1.2.2.1.8.1.3.'.$index; + $current = (snmp_get($device, $oid, '-Oqv', '') / $divisor); + if (trim($descr, '"') != 'Battery Status') { + // Battery Status is charge percentage, or 255 when no BBU + discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, trim($descr, '"'), $divisor, '1', null, null, null, null, $current); + } + } + } +}//end if diff --git a/includes/discovery/voltages/gamatronicups.inc.php b/includes/discovery/voltages/gamatronicups.inc.php index 477f42bc9..2fe1dbec4 100644 --- a/includes/discovery/voltages/gamatronicups.inc.php +++ b/includes/discovery/voltages/gamatronicups.inc.php @@ -1,34 +1,34 @@ \ No newline at end of file diff --git a/includes/discovery/voltages/ipoman.inc.php b/includes/discovery/voltages/ipoman.inc.php index dfebcea5a..a98282acb 100644 --- a/includes/discovery/voltages/ipoman.inc.php +++ b/includes/discovery/voltages/ipoman.inc.php @@ -1,44 +1,39 @@ $entry) - { - $volt_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.2.' . $index; - $divisor = 10; - $descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') : "Inlet $index"); - $current = $entry['inletStatusVoltage'] / 10; - $low_limit = $entry['inletConfigVoltageLow']; - $high_limit = $entry['inletConfigVoltageHigh']; - - discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, 'ipoman', $descr, $divisor, '1', $low_limit, NULL, NULL, $high_limit, $current); - // FIXME: iPoMan 1201 also says it has 2 inlets, at least until firmware 1.06 - wtf? + if (!is_array($cache['ipoman'])) { + echo 'outletConfigDesc '; + $cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $cache['ipoman']['out'], 'IPOMANII-MIB'); + echo 'outletConfigLocation '; + $cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $cache['ipoman']['out'], 'IPOMANII-MIB'); + echo 'inletConfigDesc '; + $cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, 'inletConfigDesc', $cache['ipoman']['in'], 'IPOMANII-MIB'); } - } -} -?> \ No newline at end of file + $oids = array(); + + echo 'inletConfigVoltageHigh '; + $oids = snmpwalk_cache_multi_oid($device, 'inletConfigVoltageHigh', $oids, 'IPOMANII-MIB'); + echo 'inletConfigVoltageLow '; + $oids = snmpwalk_cache_multi_oid($device, 'inletConfigVoltageLow', $oids, 'IPOMANII-MIB'); + echo 'inletStatusVoltage '; + $oids = snmpwalk_cache_multi_oid($device, 'inletStatusVoltage', $oids, 'IPOMANII-MIB'); + + if (is_array($oids)) { + foreach ($oids as $index => $entry) + { + $volt_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.2.'.$index; + $divisor = 10; + $descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') : "Inlet $index"); + $current = ($entry['inletStatusVoltage'] / 10); + $low_limit = $entry['inletConfigVoltageLow']; + $high_limit = $entry['inletConfigVoltageHigh']; + + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, 'ipoman', $descr, $divisor, '1', $low_limit, null, null, $high_limit, $current); + // FIXME: iPoMan 1201 also says it has 2 inlets, at least until firmware 1.06 - wtf? + } + } +}//end if diff --git a/includes/discovery/voltages/linux.inc.php b/includes/discovery/voltages/linux.inc.php index 410d02595..f599f02ee 100644 --- a/includes/discovery/voltages/linux.inc.php +++ b/includes/discovery/voltages/linux.inc.php @@ -1,28 +1,29 @@ + if ($oids) { + echo 'LM-SENSORS '; + } + + $divisor = 1000; + $type = 'lmsensors'; + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 1)]; + $oid = '1.3.6.1.4.1.2021.13.16.4.1.3.'.$index; + $current = (snmp_get($device, $oid, '-Oqv', 'LM-SENSORS-MIB') / $divisor); + + discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } + } +}//end if diff --git a/includes/discovery/voltages/mgeups.inc.php b/includes/discovery/voltages/mgeups.inc.php index 412e2dde5..6e715b995 100644 --- a/includes/discovery/voltages/mgeups.inc.php +++ b/includes/discovery/voltages/mgeups.inc.php @@ -1,50 +1,59 @@ 1) $descr .= " Phase $i"; - $current = snmp_get($device, $volt_oid, "-Oqv"); - if (!$current) - { - $volt_oid .= ".0"; - $current = snmp_get($device, $volt_oid, "-Oqv"); +if ($device['os'] == 'mgeups') { + echo 'MGE '; + $oids = trim(snmp_walk($device, 'mgoutputVoltage', '-OsqnU', 'MG-SNMP-UPS-MIB')); + if ($debug) { + echo $oids."\n"; } - $current /= 10; - $type = "mge-ups"; - $divisor = 10; - $index = $i; - discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + $numPhase = count(explode("\n", $oids)); + for ($i = 1; $i <= $numPhase; $i++) { + $volt_oid = ".1.3.6.1.4.1.705.1.7.2.1.2.$i"; + $descr = 'Output'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } - $oids = trim(snmp_walk($device, "mgeinputVoltage", "-OsqnU", "MG-SNMP-UPS-MIB")); - if ($debug) { echo($oids."\n"); } - $numPhase = count(explode("\n",$oids)); - for($i = 1; $i <= $numPhase;$i++) - { - $volt_oid = ".1.3.6.1.4.1.705.1.6.2.1.2.$i"; - $descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i"; - $current = snmp_get($device, $volt_oid, "-Oqv"); - if (!$current) - { - $volt_oid .= ".0"; - $current = snmp_get($device, $volt_oid, "-Oqv"); + $current = snmp_get($device, $volt_oid, '-Oqv'); + if (!$current) { + $volt_oid .= '.0'; + $current = snmp_get($device, $volt_oid, '-Oqv'); + } + + $current /= 10; + $type = 'mge-ups'; + $divisor = 10; + $index = $i; + + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); } - $current /= 10; - $type = "mge-ups"; - $divisor = 10; - $index = 100+$i; - discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } -} + $oids = trim(snmp_walk($device, 'mgeinputVoltage', '-OsqnU', 'MG-SNMP-UPS-MIB')); + if ($debug) { + echo $oids."\n"; + } -?> \ No newline at end of file + $numPhase = count(explode("\n", $oids)); + for ($i = 1; $i <= $numPhase; $i++) { + $volt_oid = ".1.3.6.1.4.1.705.1.6.2.1.2.$i"; + $descr = 'Input'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } + + $current = snmp_get($device, $volt_oid, '-Oqv'); + if (!$current) { + $volt_oid .= '.0'; + $current = snmp_get($device, $volt_oid, '-Oqv'); + } + + $current /= 10; + $type = 'mge-ups'; + $divisor = 10; + $index = (100 + $i); + + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } +}//end if diff --git a/includes/discovery/voltages/netvision.inc.php b/includes/discovery/voltages/netvision.inc.php index 54a9fc751..42c6d6453 100644 --- a/includes/discovery/voltages/netvision.inc.php +++ b/includes/discovery/voltages/netvision.inc.php @@ -1,47 +1,49 @@ diff --git a/includes/discovery/voltages/rfc1628.inc.php b/includes/discovery/voltages/rfc1628.inc.php index 09438d8eb..42cdd90e4 100644 --- a/includes/discovery/voltages/rfc1628.inc.php +++ b/includes/discovery/voltages/rfc1628.inc.php @@ -1,79 +1,105 @@ 1) $descr .= " Phase $i"; - $type = "rfc1628"; - $divisor = 10; if ($device['os'] == "netmanplus") { $divisor = 1; }; - $current = snmp_get($device, $volt_oid, "-Oqv") / $divisor; - $index = $i; + $oids = trim($oids); + foreach (explode("\n", $oids) as $data) + { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $volt_id = $split_oid[(count($split_oid) - 1)]; + $volt_oid = "1.3.6.1.2.1.33.1.2.5.$volt_id"; + $divisor = 10; + if ($device['os'] == 'poweralert') { + $divisor = 1; + }; + $volt = (snmp_get($device, $volt_oid, '-O vq') / $divisor); + $descr = 'Battery'.(count(explode("\n", $oids)) == 1 ? '' : ' '.($volt_id + 1)); + $type = 'rfc1628'; + $index = '1.2.5.'.$volt_id; - discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $volt); + } + } - $oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.3.2.0", "-OsqnU")); - if ($debug) { echo($oids."\n"); } - list($unused,$numPhase) = explode(' ',$oids); - for($i = 1; $i <= $numPhase;$i++) - { - $volt_oid = "1.3.6.1.2.1.33.1.3.3.1.3.$i"; - $descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i"; - $type = "rfc1628"; - $divisor = 10; - if ($device['os'] == "netmanplus" || $device['os'] == "poweralert") { $divisor = 1; }; - $current = snmp_get($device, $volt_oid, "-Oqv") / $divisor; - $index = 100+$i; + $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.4.3.0', '-OsqnU')); + if ($debug) { + echo $oids."\n"; + } - discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + list($unused,$numPhase) = explode(' ', $oids); + for ($i = 1; $i <= $numPhase; $i++) { + $volt_oid = ".1.3.6.1.2.1.33.1.4.4.1.2.$i"; + $descr = 'Output'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } - $oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.5.2.0", "-OsqnU")); - if ($debug) { echo($oids."\n"); } - list($unused,$numPhase) = explode(' ',$oids); - for($i = 1; $i <= $numPhase;$i++) - { - $volt_oid = "1.3.6.1.2.1.33.1.5.3.1.2.$i"; - $descr = "Bypass"; if ($numPhase > 1) $descr .= " Phase $i"; - $type = "rfc1628"; - $divisor = 10; - if ($device['os'] == "netmanplus" || $device['os'] == "poweralert") { $divisor = 1; }; - $current = snmp_get($device, $volt_oid, "-Oqv") / $divisor; - $index = 200+$i; + $type = 'rfc1628'; + $divisor = 10; + if ($device['os'] == 'netmanplus') { + $divisor = 1; + }; + $current = (snmp_get($device, $volt_oid, '-Oqv') / $divisor); + $index = $i; - discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } -} + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } -?> + $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.3.2.0', '-OsqnU')); + if ($debug) { + echo $oids."\n"; + } + + list($unused,$numPhase) = explode(' ', $oids); + for ($i = 1; $i <= $numPhase; $i++) { + $volt_oid = "1.3.6.1.2.1.33.1.3.3.1.3.$i"; + $descr = 'Input'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } + + $type = 'rfc1628'; + $divisor = 10; + if ($device['os'] == 'netmanplus' || $device['os'] == 'poweralert') { + $divisor = 1; + }; + $current = (snmp_get($device, $volt_oid, '-Oqv') / $divisor); + $index = (100 + $i); + + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } + + $oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.5.2.0', '-OsqnU')); + if ($debug) { + echo $oids."\n"; + } + + list($unused,$numPhase) = explode(' ', $oids); + for ($i = 1; $i <= $numPhase; $i++) { + $volt_oid = "1.3.6.1.2.1.33.1.5.3.1.2.$i"; + $descr = 'Bypass'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } + + $type = 'rfc1628'; + $divisor = 10; + if ($device['os'] == 'netmanplus' || $device['os'] == 'poweralert') { + $divisor = 1; + }; + $current = (snmp_get($device, $volt_oid, '-Oqv') / $divisor); + $index = (200 + $i); + + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } +}//end if diff --git a/includes/discovery/voltages/sentry3.inc.php b/includes/discovery/voltages/sentry3.inc.php index e77b69432..e2d704322 100644 --- a/includes/discovery/voltages/sentry3.inc.php +++ b/includes/discovery/voltages/sentry3.inc.php @@ -1,28 +1,31 @@ + if ($oids) { + echo 'Sentry3-MIB '; + } + + $divisor = 10; + $type = 'sentry3'; + + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $descr = 'Tower '.$index; + $index = $split_oid[(count($split_oid) - 1)]; + $oid = '1.3.6.1.4.1.1718.3.2.2.1.11.1.'.$index; + $current = (snmp_get($device, $oid, '-Oqv') / $divisor); + + discover_sensor($valid['sensor'], 'voltage', $device, + $oid, $index, $type, + $descr, $divisor, '1', null, null, null, null, $current); + } + } +}//end if diff --git a/includes/discovery/voltages/supermicro.inc.php b/includes/discovery/voltages/supermicro.inc.php index e4580e9cd..690d34747 100644 --- a/includes/discovery/voltages/supermicro.inc.php +++ b/includes/discovery/voltages/supermicro.inc.php @@ -1,44 +1,43 @@ \ No newline at end of file + $oids = trim($oids); + if ($oids) { + echo 'Supermicro '; + } + + $type = 'supermicro'; + $divisor = '1000'; + foreach (explode("\n", $oids) as $data) { + $data = trim($data); + if ($data) { + list($oid,$kind) = explode(' ', $data); + $split_oid = explode('.', $oid); + $index = $split_oid[(count($split_oid) - 1)]; + if ($kind == 1) { + $volt_oid = '1.3.6.1.4.1.10876.2.1.1.1.1.4.'.$index; + $descr_oid = '1.3.6.1.4.1.10876.2.1.1.1.1.2.'.$index; + $monitor_oid = '1.3.6.1.4.1.10876.2.1.1.1.1.10.'.$index; + $limit_oid = '1.3.6.1.4.1.10876.2.1.1.1.1.5.'.$index; + $lowlimit_oid = '1.3.6.1.4.1.10876.2.1.1.1.1.6.'.$index; + + $descr = snmp_get($device, $descr_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); + $current = (snmp_get($device, $volt_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB') / $divisor); + $limit = (snmp_get($device, $limit_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB') / $divisor); + $lowlimit = (snmp_get($device, $lowlimit_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB') / $divisor); + $monitor = snmp_get($device, $monitor_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB'); + $descr = trim(str_ireplace('Voltage', '', $descr)); + + if ($monitor == 'true') { + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', $lowlimit, null, null, $limit, $current); + } + } + }//end if + }//end foreach +}//end if diff --git a/includes/discovery/voltages/xups.inc.php b/includes/discovery/voltages/xups.inc.php index 8bb859be2..378f7737e 100644 --- a/includes/discovery/voltages/xups.inc.php +++ b/includes/discovery/voltages/xups.inc.php @@ -1,82 +1,99 @@ 1) $descr .= " Phase $i"; - $type = "xups"; - $divisor = 1; - $current = snmp_get($device, $volt_oid, "-Oqv") / $divisor; - $index = '3.4.1.2.'.$i; + $oids = trim($oids); + foreach (explode("\n", $oids) as $data) + { + $data = trim($data); + if ($data) { + list($oid,$descr) = explode(' ', $data, 2); + $split_oid = explode('.', $oid); + $volt_id = $split_oid[(count($split_oid) - 1)]; + $volt_oid = ".1.3.6.1.4.1.534.1.2.2.$volt_id"; + $divisor = 1; + $volt = (snmp_get($device, $volt_oid, '-O vq') / $divisor); + $descr = 'Battery'.(count(explode("\n", $oids)) == 1 ? '' : ' '.($volt_id + 1)); + $type = 'xups'; + $index = '1.2.5.'.$volt_id; - discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $volt); + } + } - # XUPS-MIB::xupsOutputNumPhases.0 = INTEGER: 1 - $oids = trim(snmp_walk($device, "xupsOutputNumPhases", "-OsqnU")); - if ($debug) { echo($oids."\n"); } - list($unused,$numPhase) = explode(' ',$oids); - for($i = 1; $i <= $numPhase;$i++) - { - # XUPS-MIB::xupsOutputVoltage.1 = INTEGER: 228 - $volt_oid = ".1.3.6.1.4.1.534.1.4.4.1.2.$i"; - $descr = "Output"; if ($numPhase > 1) $descr .= " Phase $i"; - $type = "xups"; - $divisor = 1; - $current = snmp_get($device, $volt_oid, "-Oqv") / $divisor; - $index = '4.4.1.2.'.$i; + // XUPS-MIB::xupsInputNumPhases.0 = INTEGER: 1 + $oids = trim(snmp_walk($device, 'xupsInputNumPhases', '-OsqnU', 'XUPS-MIB')); + if ($debug) { + echo $oids."\n"; + } - discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } + list($unused,$numPhase) = explode(' ', $oids); + for ($i = 1; $i <= $numPhase; $i++) { + // XUPS-MIB::xupsInputVoltage.1 = INTEGER: 228 + $volt_oid = ".1.3.6.1.4.1.534.1.3.4.1.2.$i"; + $descr = 'Output'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } - # XUPS-MIB::xupsBypassNumPhases.0 = INTEGER: 1 - $oids = trim(snmp_walk($device, "xupsBypassNumPhases", "-OsqnU")); - if ($debug) { echo($oids."\n"); } - list($unused,$numPhase) = explode(' ',$oids); - for($i = 1; $i <= $numPhase;$i++) - { - $volt_oid = ".1.3.6.1.4.1.534.1.5.3.1.2.$i"; - $descr = "Bypass"; if ($numPhase > 1) $descr .= " Phase $i"; - $type = "xups"; - $divisor = 1; - $current = snmp_get($device, $volt_oid, "-Oqv") / $divisor; - $index = '5.3.1.2.'.$i; + $type = 'xups'; + $divisor = 1; + $current = (snmp_get($device, $volt_oid, '-Oqv') / $divisor); + $index = '3.4.1.2.'.$i; - discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); - } -} + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } -?> \ No newline at end of file + // XUPS-MIB::xupsOutputNumPhases.0 = INTEGER: 1 + $oids = trim(snmp_walk($device, 'xupsOutputNumPhases', '-OsqnU')); + if ($debug) { + echo $oids."\n"; + } + + list($unused,$numPhase) = explode(' ', $oids); + for ($i = 1; $i <= $numPhase; $i++) { + // XUPS-MIB::xupsOutputVoltage.1 = INTEGER: 228 + $volt_oid = ".1.3.6.1.4.1.534.1.4.4.1.2.$i"; + $descr = 'Output'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } + + $type = 'xups'; + $divisor = 1; + $current = (snmp_get($device, $volt_oid, '-Oqv') / $divisor); + $index = '4.4.1.2.'.$i; + + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } + + // XUPS-MIB::xupsBypassNumPhases.0 = INTEGER: 1 + $oids = trim(snmp_walk($device, 'xupsBypassNumPhases', '-OsqnU')); + if ($debug) { + echo $oids."\n"; + } + + list($unused,$numPhase) = explode(' ', $oids); + for ($i = 1; $i <= $numPhase; $i++) { + $volt_oid = ".1.3.6.1.4.1.534.1.5.3.1.2.$i"; + $descr = 'Bypass'; + if ($numPhase > 1) { + $descr .= " Phase $i"; + } + + $type = 'xups'; + $divisor = 1; + $current = (snmp_get($device, $volt_oid, '-Oqv') / $divisor); + $index = '5.3.1.2.'.$i; + + discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); + } +}//end if diff --git a/includes/include-dir.inc.php b/includes/include-dir.inc.php index 49155614b..d5c0a7eab 100644 --- a/includes/include-dir.inc.php +++ b/includes/include-dir.inc.php @@ -1,26 +1,22 @@ +unset($include_dir_regexp, $include_dir); diff --git a/includes/polling/applications.inc.php b/includes/polling/applications.inc.php index 32c6c4057..a32dce5e6 100644 --- a/includes/polling/applications.inc.php +++ b/includes/polling/applications.inc.php @@ -1,26 +1,24 @@ +$app_rows = dbFetchRows('SELECT * FROM `applications` WHERE `device_id` = ?', array($device['device_id'])); + +if (count($app_rows)) { + echo 'Applications: '; + foreach ($app_rows as $app) + { + $app_include = $config['install_dir'].'/includes/polling/applications/'.$app['app_type'].'.inc.php'; + if (is_file($app_include)) { + include $app_include; + } + else { + echo $app['app_type'].' include missing! '; + } + } + + echo "\n"; +} diff --git a/includes/polling/applications/apache.inc.php b/includes/polling/applications/apache.inc.php index 4e496b07d..1f8614c88 100644 --- a/includes/polling/applications/apache.inc.php +++ b/includes/polling/applications/apache.inc.php @@ -1,26 +1,28 @@ +rrdtool_update($rrd_filename, "N:$total_access:$total_kbyte:$cpuload:$uptime:$reqpersec:$bytespersec:$bytesperreq:$busyworkers:$idleworkers:$score_wait:$score_start:$score_reading:$score_writing:$score_keepalive:$score_dns:$score_closing:$score_logging:$score_graceful:$score_idle:$score_open"); diff --git a/includes/polling/applications/drbd.inc.php b/includes/polling/applications/drbd.inc.php index bb1841d44..c399478cb 100644 --- a/includes/polling/applications/drbd.inc.php +++ b/includes/polling/applications/drbd.inc.php @@ -1,18 +1,18 @@ +unset($drbd) diff --git a/includes/polling/applications/mailscanner.inc.php b/includes/polling/applications/mailscanner.inc.php index 72eb7f914..a1b29bf47 100644 --- a/includes/polling/applications/mailscanner.inc.php +++ b/includes/polling/applications/mailscanner.inc.php @@ -1,29 +1,28 @@ +rrdtool_update($rrd_filename, "N:$msg_recv:$msg_rejected:$msg_relay:$msg_sent:$msg_waiting:$spam:$virus"); diff --git a/includes/polling/applications/memcached.inc.php b/includes/polling/applications/memcached.inc.php index 2c41ff208..f3bc0daa5 100644 --- a/includes/polling/applications/memcached.inc.php +++ b/includes/polling/applications/memcached.inc.php @@ -2,12 +2,14 @@ $data = $agent_data['app']['memcached'][$app['app_instance']]; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-memcached-".$app['app_id'].".rrd"; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-memcached-'.$app['app_id'].'.rrd'; -echo("memcached(".$app['app_instance'].") "); +echo 'memcached('.$app['app_instance'].') '; - if (!is_file($rrd_filename)) { - rrdtool_create ($rrd_filename, "--step 300 \ +if (!is_file($rrd_filename)) { + rrdtool_create( + $rrd_filename, + '--step 300 \ DS:uptime:GAUGE:600:0:125000000000 \ DS:threads:GAUGE:600:0:125000000000 \ DS:rusage_user_ms:DERIVE:600:0:125000000000 \ @@ -26,18 +28,34 @@ echo("memcached(".$app['app_instance'].") "); DS:evictions:DERIVE:600:0:125000000000 \ DS:bytes_read:DERIVE:600:0:125000000000 \ DS:bytes_written:DERIVE:600:0:125000000000 \ - ".$config['rrd_rra']); - } + '.$config['rrd_rra'] + ); +} - $dslist = array('uptime', 'threads', 'rusage_user_microseconds','rusage_system_microseconds','curr_items','total_items','limit_maxbytes','curr_connections','total_connections', - 'connection_structures','bytes','cmd_get','cmd_set','get_hits','get_misses','evictions','bytes_read','bytes_written'); +$dslist = array( + 'uptime', + 'threads', + 'rusage_user_microseconds', + 'rusage_system_microseconds', + 'curr_items', + 'total_items', + 'limit_maxbytes', + 'curr_connections', + 'total_connections', + 'connection_structures', + 'bytes', + 'cmd_get', + 'cmd_set', + 'get_hits', + 'get_misses', + 'evictions', + 'bytes_read', + 'bytes_written', +); - $values = array(); - foreach ($dslist as $ds) - { - $values[] = isset($data[$ds]) ? $data[$ds] : -1; - } +$values = array(); +foreach ($dslist as $ds) { + $values[] = isset($data[$ds]) ? $data[$ds] : (-1); +} - rrdtool_update($rrd_filename, "N:".implode(":", $values)); - -?> +rrdtool_update($rrd_filename, 'N:'.implode(':', $values)); diff --git a/includes/polling/applications/mysql.inc.php b/includes/polling/applications/mysql.inc.php index 15fe00935..13a362021 100644 --- a/includes/polling/applications/mysql.inc.php +++ b/includes/polling/applications/mysql.inc.php @@ -1,125 +1,124 @@ 'cr', - 'IBLFh' => 'ct', - 'IBLWn' => 'cu', - 'IBLWn' => 'cu', - 'SRows' => 'ck', - 'SRange' => 'cj', - 'SMPs' => 'ci', - 'SScan' => 'cl', - 'IBIRd' => 'ai', - 'IBIWr' => 'aj', - 'IBILg' => 'ak', - 'IBIFSc' => 'ah', - 'IDBRDd' => 'b2', - 'IDBRId' => 'b0', - 'IDBRRd' => 'b3', - 'IDBRUd' => 'b1', - 'IBRd' => 'ae', - 'IBCd' => 'af', - 'IBWr' => 'ag', - 'TLIe' => 'b5', - 'TLWd' => 'b4', - 'IBPse' => 'aa', - 'IBPDBp' => 'ac', - 'IBPFe' => 'ab', - 'IBPMps' => 'ad', - 'TOC' => 'bc', - 'OFs' => 'b7', - 'OTs' => 'b8', - 'OdTs' => 'b9', - 'IBSRs' => 'ay', - 'IBSWs' => 'ax', - 'IBOWs' => 'az', - 'QCs' => 'c1', - 'QCeFy' => 'bu', - 'MaCs' => 'bl', - 'MUCs' => 'bf', - 'ACs' => 'bd', - 'AdCs' => 'be', - 'TCd' => 'bi', - 'Cs' => 'bn', - 'IBTNx' => 'a5', - 'KRRs' => 'a0', - 'KRs' => 'a1', - 'KWR' => 'a2', - 'KWs' => 'a3', - 'QCQICe' => 'bz', - 'QCHs' => 'bv', - 'QCIs' => 'bw', - 'QCNCd' => 'by', - 'QCLMPs' => 'bx', - 'CTMPDTs' => 'cn', - 'CTMPTs' => 'cm', - 'CTMPFs' => 'co', - 'IBIIs' => 'au', - 'IBIMRd' => 'av', - 'IBIMs' => 'aw', - 'IBILog' => 'al', - 'IBISc' => 'am', - 'IBIFLg' => 'an', - 'IBFBl' => 'aq', - 'IBIIAo' => 'ap', - 'IBIAd' => 'as', - 'IBIAe' => 'at', - 'SFJn' => 'cd', - 'SFRJn' => 'ce', - 'SRe' => 'cf', - 'SRCk' => 'cg', - 'SSn' => 'ch', - 'SQs' => 'b6', - 'BRd' => 'cq', - 'BSt' => 'cp', - 'CDe' => 'c6', - 'CIt' => 'c4', - 'CISt' => 'ca', - 'CLd' => 'c8', - 'CRe' => 'c7', - 'CRSt' => 'cc', - 'CSt' => 'c5', - 'CUe' => 'c3', - 'CUMi' => 'c9', + 'IDBLBSe' => 'cr', + 'IBLFh' => 'ct', + 'IBLWn' => 'cu', + 'IBLWn' => 'cu', + 'SRows' => 'ck', + 'SRange' => 'cj', + 'SMPs' => 'ci', + 'SScan' => 'cl', + 'IBIRd' => 'ai', + 'IBIWr' => 'aj', + 'IBILg' => 'ak', + 'IBIFSc' => 'ah', + 'IDBRDd' => 'b2', + 'IDBRId' => 'b0', + 'IDBRRd' => 'b3', + 'IDBRUd' => 'b1', + 'IBRd' => 'ae', + 'IBCd' => 'af', + 'IBWr' => 'ag', + 'TLIe' => 'b5', + 'TLWd' => 'b4', + 'IBPse' => 'aa', + 'IBPDBp' => 'ac', + 'IBPFe' => 'ab', + 'IBPMps' => 'ad', + 'TOC' => 'bc', + 'OFs' => 'b7', + 'OTs' => 'b8', + 'OdTs' => 'b9', + 'IBSRs' => 'ay', + 'IBSWs' => 'ax', + 'IBOWs' => 'az', + 'QCs' => 'c1', + 'QCeFy' => 'bu', + 'MaCs' => 'bl', + 'MUCs' => 'bf', + 'ACs' => 'bd', + 'AdCs' => 'be', + 'TCd' => 'bi', + 'Cs' => 'bn', + 'IBTNx' => 'a5', + 'KRRs' => 'a0', + 'KRs' => 'a1', + 'KWR' => 'a2', + 'KWs' => 'a3', + 'QCQICe' => 'bz', + 'QCHs' => 'bv', + 'QCIs' => 'bw', + 'QCNCd' => 'by', + 'QCLMPs' => 'bx', + 'CTMPDTs' => 'cn', + 'CTMPTs' => 'cm', + 'CTMPFs' => 'co', + 'IBIIs' => 'au', + 'IBIMRd' => 'av', + 'IBIMs' => 'aw', + 'IBILog' => 'al', + 'IBISc' => 'am', + 'IBIFLg' => 'an', + 'IBFBl' => 'aq', + 'IBIIAo' => 'ap', + 'IBIAd' => 'as', + 'IBIAe' => 'at', + 'SFJn' => 'cd', + 'SFRJn' => 'ce', + 'SRe' => 'cf', + 'SRCk' => 'cg', + 'SSn' => 'ch', + 'SQs' => 'b6', + 'BRd' => 'cq', + 'BSt' => 'cp', + 'CDe' => 'c6', + 'CIt' => 'c4', + 'CISt' => 'ca', + 'CLd' => 'c8', + 'CRe' => 'c7', + 'CRSt' => 'cc', + 'CSt' => 'c5', + 'CUe' => 'c3', + 'CUMi' => 'c9', ); $values = array(); -foreach ($mapping as $key) -{ - $values[] = isset($map[$key]) ? $map[$key] : -1; +foreach ($mapping as $key) { + $values[] = isset($map[$key]) ? $map[$key] : (-1); } + $string = implode(':', $values); -if (!is_file($mysql_rrd)) -{ - rrdtool_create ($mysql_rrd, "--step 300 \ +if (!is_file($mysql_rrd)) { + rrdtool_create( + $mysql_rrd, + '--step 300 \ DS:IDBLBSe:GAUGE:600:0:125000000000 \ DS:IBLFh:DERIVE:600:0:125000000000 \ DS:IBLWn:DERIVE:600:0:125000000000 \ @@ -198,47 +197,45 @@ if (!is_file($mysql_rrd)) DS:CRSt:DERIVE:600:0:125000000000 \ DS:CSt:DERIVE:600:0:125000000000 \ DS:CUe:DERIVE:600:0:125000000000 \ - DS:CUMi:DERIVE:600:0:125000000000 ".$config['rrd_rra']); -} + DS:CUMi:DERIVE:600:0:125000000000 '.$config['rrd_rra'] + ); +}//end if rrdtool_update($mysql_rrd, "N:$string"); // Process state statistics - -$mysql_status_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-mysql-".$app['app_id']."-status.rrd"; +$mysql_status_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'-status.rrd'; $mapping_status = array( - 'State_closing_tables' => 'd2', - 'State_copying_to_tmp_table' => 'd3', - 'State_end' => 'd4', - 'State_freeing_items' => 'd5', - 'State_init' => 'd6', - 'State_locked' => 'd7', - 'State_login' => 'd8', - 'State_preparing' => 'd9', - 'State_reading_from_net' => 'da', - 'State_sending_data' => 'db', - 'State_sorting_result' => 'dc', - 'State_statistics' => 'dd', - 'State_updating' => 'de', - 'State_writing_to_net' => 'df', - 'State_none' => 'dg', - 'State_other' => 'dh' + 'State_closing_tables' => 'd2', + 'State_copying_to_tmp_table' => 'd3', + 'State_end' => 'd4', + 'State_freeing_items' => 'd5', + 'State_init' => 'd6', + 'State_locked' => 'd7', + 'State_login' => 'd8', + 'State_preparing' => 'd9', + 'State_reading_from_net' => 'da', + 'State_sending_data' => 'db', + 'State_sorting_result' => 'dc', + 'State_statistics' => 'dd', + 'State_updating' => 'de', + 'State_writing_to_net' => 'df', + 'State_none' => 'dg', + 'State_other' => 'dh', ); -$values = array(); $rrd_create = ""; -foreach ($mapping_status as $desc => $id) -{ - $values[] = isset($map[$id]) ? $map[$id] : -1; - $rrd_create .= " DS:".$id.":GAUGE:600:0:125000000000"; +$values = array(); +$rrd_create = ''; +foreach ($mapping_status as $desc => $id) { + $values[] = isset($map[$id]) ? $map[$id] : (-1); + $rrd_create .= ' DS:'.$id.':GAUGE:600:0:125000000000'; } + $string = implode(':', $values); -if (!is_file($mysql_status_rrd)) -{ - rrdtool_create ($mysql_status_rrd, "--step 300 ".$rrd_create." ".$config['rrd_rra']); +if (!is_file($mysql_status_rrd)) { + rrdtool_create($mysql_status_rrd, '--step 300 '.$rrd_create.' '.$config['rrd_rra']); } rrdtool_update($mysql_status_rrd, "N:$string"); - -?> diff --git a/includes/polling/applications/nginx.inc.php b/includes/polling/applications/nginx.inc.php index 72defc804..cace17bce 100644 --- a/includes/polling/applications/nginx.inc.php +++ b/includes/polling/applications/nginx.inc.php @@ -1,38 +1,37 @@ diff --git a/includes/polling/applications/ntp-client.inc.php b/includes/polling/applications/ntp-client.inc.php index 904be6ac1..ad5ecb9a4 100644 --- a/includes/polling/applications/ntp-client.inc.php +++ b/includes/polling/applications/ntp-client.inc.php @@ -1,27 +1,26 @@ +rrdtool_update($rrd_filename, "N:$offset:$frequency:$jitter:$noise:$stability"); diff --git a/includes/polling/applications/ntpd-server.inc.php b/includes/polling/applications/ntpd-server.inc.php index 80c7441f9..1b419d45e 100644 --- a/includes/polling/applications/ntpd-server.inc.php +++ b/includes/polling/applications/ntpd-server.inc.php @@ -1,20 +1,22 @@ +rrdtool_update($rrd_filename, "N:$stratum:$offset:$frequency:$jitter:$noise:$stability:$uptime:$buffer_recv:$buffer_free:$buffer_used:$packets_drop:$packets_ignore:$packets_recv:$packets_sent"); diff --git a/includes/polling/applications/powerdns.inc.php b/includes/polling/applications/powerdns.inc.php index 7a60a966c..586ec5e48 100644 --- a/includes/polling/applications/powerdns.inc.php +++ b/includes/polling/applications/powerdns.inc.php @@ -1,22 +1,24 @@ +rrdtool_update($rrd_filename, "N:$corrupt:$def_cacheInserts:$def_cacheLookup:$latency:$pc_hit:$pc_miss:$pc_size:$qsize:$qc_hit:$qc_miss:$rec_answers:$rec_questions:$servfail:$tcp_answers:$tcp_queries:$timedout:$udp_answers:$udp_queries:$udp4_answers:$udp4_queries:$udp6_answers:$udp6_queries"); diff --git a/includes/polling/applications/shoutcast.inc.php b/includes/polling/applications/shoutcast.inc.php index 192707a25..b06431ae8 100644 --- a/includes/polling/applications/shoutcast.inc.php +++ b/includes/polling/applications/shoutcast.inc.php @@ -1,37 +1,35 @@ $server) -{ - $server = trim($server); +foreach ($servers as $item => $server) { + $server = trim($server); - if (!empty($server)) - { - $data = explode(";", $server); - list($host, $port) = split(":", $data['0'], 2); - $bitrate = $data['1']; - $traf_in = $data['2']; - $traf_out = $data['3']; - $current = $data['4']; - $status = $data['5']; - $peak = $data['6']; - $max = $data['7']; - $unique = $data['8']; - $rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-shoutcast-".$app['app_id']."-".$host."_".$port.".rrd"; + if (!empty($server)) { + $data = explode(';', $server); + list($host, $port) = split(':', $data['0'], 2); + $bitrate = $data['1']; + $traf_in = $data['2']; + $traf_out = $data['3']; + $current = $data['4']; + $status = $data['5']; + $peak = $data['6']; + $max = $data['7']; + $unique = $data['8']; + $rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/app-shoutcast-'.$app['app_id'].'-'.$host.'_'.$port.'.rrd'; - if (!is_file($rrdfile)) - { - rrdtool_create($rrdfile, "--step 300 \ + if (!is_file($rrdfile)) { + rrdtool_create( + $rrdfile, + '--step 300 \ DS:bitrate:GAUGE:600:0:125000000000 \ DS:traf_in:GAUGE:600:0:125000000000 \ DS:traf_out:GAUGE:600:0:125000000000 \ @@ -39,11 +37,10 @@ foreach ($servers as $item=>$server) DS:status:GAUGE:600:0:125000000000 \ DS:peak:GAUGE:600:0:125000000000 \ DS:max:GAUGE:600:0:125000000000 \ - DS:unique:GAUGE:600:0:125000000000 ".$config['rrd_rra']); - } + DS:unique:GAUGE:600:0:125000000000 '.$config['rrd_rra'] + ); + } - rrdtool_update($rrdfile, "N:$bitrate:$traf_in:$traf_out:$current:$status:$peak:$max:$unique"); - } -} - -?> + rrdtool_update($rrdfile, "N:$bitrate:$traf_in:$traf_out:$current:$status:$peak:$max:$unique"); + }//end if +}//end foreach diff --git a/includes/polling/cisco-ace-loadbalancer.inc.php b/includes/polling/cisco-ace-loadbalancer.inc.php index 37019e06a..54df903ef 100644 --- a/includes/polling/cisco-ace-loadbalancer.inc.php +++ b/includes/polling/cisco-ace-loadbalancer.inc.php @@ -1,65 +1,67 @@ $serverfarm) { + $clean_index = preg_replace('@\d+\."(.*?)"\.\d+@', '\\1', $index); - $clean_index = preg_replace('@\d+\."(.*?)"\.\d+@', '\\1', $index); + $oids = array( + 'cesServerFarmRserverTotalConns', + 'cesServerFarmRserverCurrentConns', + 'cesServerFarmRserverFailedConns', + ); - $oids = array ( - "cesServerFarmRserverTotalConns", - "cesServerFarmRserverCurrentConns", - "cesServerFarmRserverFailedConns"); + $db_oids = array( + $clean_index => 'farm_id', + 'cesServerFarmRserverStateDescr' => 'StateDescr', + ); - $db_oids = array($clean_index => 'farm_id', "cesServerFarmRserverStateDescr" => "StateDescr"); + if (!is_array($serverfarms[$clean_index])) { + $rserver_id = dbInsert(array('device_id' => $device['device_id'], 'farm_id' => $clean_index, 'StateDescr' => $serverfarm['cesServerFarmRserverStateDescr']), 'loadbalancer_rservers'); + } + else { + foreach ($db_oids as $db_oid => $db_value) { + $db_update[$db_value] = $serverfarm[$db_oid]; + } - if (!is_array( $serverfarms[$clean_index])) - { - $rserver_id = dbInsert(array('device_id' => $device['device_id'], 'farm_id' => $clean_index, 'StateDescr' => $serverfarm['cesServerFarmRserverStateDescr']), 'loadbalancer_rservers'); - } else { - foreach ($db_oids as $db_oid => $db_value) { - $db_update[$db_value] = $serverfarm[$db_oid]; + $updated = dbUpdate($db_update, 'loadbalancer_rservers', '`rserver_id` = ?', $serverfarm['cesServerFarmRserverFailedConns']['farm_id']); } - $updated = dbUpdate($db_update, 'loadbalancer_rservers', '`rserver_id` = ?', $serverfarm['cesServerFarmRserverFailedConns']['farm_id']); - } + $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/rserver-'.$serverfarms[$clean_index]['rserver_id'].'.rrd'; - $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/rserver-".$serverfarms[$clean_index]['rserver_id'].".rrd"; - - foreach ($oids as $oid) - { - $oid_ds = truncate(str_replace("cesServerFarm", "", $oid), 19, ''); - $rrd_create .= " DS:$oid_ds:GAUGE:600:-1:100000000"; - } - - $rrdupdate = "N"; - - foreach ($oids as $oid) - { - if (is_numeric($serverfarm[$oid])) - { - $value = $serverfarm[$oid]; - } else { - $value = "0"; + foreach ($oids as $oid) { + $oid_ds = truncate(str_replace('cesServerFarm', '', $oid), 19, ''); + $rrd_create .= " DS:$oid_ds:GAUGE:600:-1:100000000"; } - $rrdupdate .= ":$value"; - } - $rrd_create .= " ".$config['rrd_rra']; + $rrdupdate = 'N'; - if (isset($serverfarms[$clean_index])) - { - if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); } - rrdtool_update($rrd_file, $rrdupdate); - } + foreach ($oids as $oid) { + if (is_numeric($serverfarm[$oid])) { + $value = $serverfarm[$oid]; + } + else { + $value = '0'; + } -} + $rrdupdate .= ":$value"; + } + + $rrd_create .= ' '.$config['rrd_rra']; + + if (isset($serverfarms[$clean_index])) { + if (!file_exists($rrd_file)) { + rrdtool_create($rrd_file, $rrd_create); + } + + rrdtool_update($rrd_file, $rrdupdate); + } +}//end foreach unset($oids, $oid, $serverfarm); - -?> - diff --git a/includes/polling/cisco-ace-serverfarms.inc.php b/includes/polling/cisco-ace-serverfarms.inc.php index e8d5c722d..421e8cf81 100644 --- a/includes/polling/cisco-ace-serverfarms.inc.php +++ b/includes/polling/cisco-ace-serverfarms.inc.php @@ -1,67 +1,71 @@ $vserver) { + $classmap = str_replace('class-map-', '', $vserver['slbVServerClassMap']); + $classmap_id = str_replace('9.', '', $index); - $classmap = str_replace("class-map-", "", $vserver['slbVServerClassMap']); - $classmap_id = str_replace("9.", "" , $index); + $oids = array( + 'slbVServerNumberOfConnections', + 'slbVServerDroppedConnections', + 'slbVServerClientPacketCounts', + 'slbVServerClientByteCounts', + 'slbVServerPacketCounts', + 'slbVServerByteCounts', + ); - $oids = array ( - "slbVServerNumberOfConnections", - "slbVServerDroppedConnections", - "slbVServerClientPacketCounts", - "slbVServerClientByteCounts", - "slbVServerPacketCounts", - "slbVServerByteCounts"); + $db_oids = array( + $classmap_id => 'classmap_id', + $classmap => 'classmap', + 'slbVServerState' => 'serverstate', + ); - $db_oids = array($classmap_id => 'classmap_id', $classmap => 'classmap', "slbVServerState" => "serverstate"); + if (!is_array($classmaps[$classmap])) { + $classmap_in = dbInsert(array('device_id' => $device['device_id'], 'classmap_id' => $classmap_id, 'classmap' => $classmap, 'serverstate' => $vserver['slbVServerState']), 'loadbalancer_vservers'); + } + else { + foreach ($db_oids as $db_oid => $db_value) { + $db_update[$db_value] = $vserver[$db_oid]; + } - if (!is_array( $classmaps[$classmap])) - { - $classmap_in = dbInsert(array('device_id' => $device['device_id'], 'classmap_id' => $classmap_id, 'classmap' => $classmap, 'serverstate' => $vserver['slbVServerState']), 'loadbalancer_vservers'); - } else { - foreach ($db_oids as $db_oid => $db_value) - { - $db_update[$db_value] = $vserver[$db_oid]; + $updated = dbUpdate($db_update, 'loadbalancer_vservers', '`classmap_id` = ?', $vserver['slbVServerState']['classmap']); } - $updated = dbUpdate($db_update, 'loadbalancer_vservers', '`classmap_id` = ?', $vserver['slbVServerState']['classmap']); - } + $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/vserver-'.$classmap_id.'.rrd'; + $rrd_create = $config['rrd_rra']; - $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/vserver-".$classmap_id.".rrd"; - $rrd_create = $config['rrd_rra']; - - foreach ($oids as $oid) - { - $oid_ds = truncate(str_replace("slbVServer", "", $oid), 19, ''); - $rrd_create .= " DS:$oid_ds:COUNTER:600:U:1000000000"; - } - - $rrdupdate = "N"; - - foreach ($oids as $oid) - { - if (is_numeric($vserver[$oid])) - { - $value = $vserver[$oid]; - } else { - $value = "0"; + foreach ($oids as $oid) { + $oid_ds = truncate(str_replace('slbVServer', '', $oid), 19, ''); + $rrd_create .= " DS:$oid_ds:COUNTER:600:U:1000000000"; } - $rrdupdate .= ":$value"; - } - if (isset($classmaps[$classmap])) - { - if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); } - rrdtool_update($rrd_file, $rrdupdate); - } -} + $rrdupdate = 'N'; + + foreach ($oids as $oid) { + if (is_numeric($vserver[$oid])) { + $value = $vserver[$oid]; + } + else { + $value = '0'; + } + + $rrdupdate .= ":$value"; + } + + if (isset($classmaps[$classmap])) { + if (!file_exists($rrd_file)) { + rrdtool_create($rrd_file, $rrd_create); + } + + rrdtool_update($rrd_file, $rrdupdate); + } +}//end foreach unset($oids, $oid, $vserver); - -?> diff --git a/includes/polling/cisco-sla.inc.php b/includes/polling/cisco-sla.inc.php index 2dcb6cd05..a54936073 100644 --- a/includes/polling/cisco-sla.inc.php +++ b/includes/polling/cisco-sla.inc.php @@ -1,64 +1,64 @@ + rrdtool_update($slarrd, $ts.':'.$val); + echo "\n"; +}//end foreach diff --git a/includes/polling/entity-physical.inc.php b/includes/polling/entity-physical.inc.php index 0b04e9b31..43aba44ca 100644 --- a/includes/polling/entity-physical.inc.php +++ b/includes/polling/entity-physical.inc.php @@ -1,96 +1,96 @@ $entry) + { + $group = 'c6kxbar'; + foreach ($entry as $key => $value) { + $subindex = null; + $entPhysical_state[$index][$subindex][$group][$key] = $value; + } + } - foreach ($mod_stats as $index => $entry) - { - $group = 'c6kxbar'; - foreach ($entry as $key => $value) - { - $subindex = NULL; - $entPhysical_state[$index][$subindex][$group][$key] = $value; - } - } + foreach ($chan_stats as $index => $entry) + { + list($index,$subindex) = explode('.', $index, 2); + $group = 'c6kxbar'; + foreach ($entry as $key => $value) { + $entPhysical_state[$index][$subindex][$group][$key] = $value; + } - foreach ($chan_stats as $index => $entry) - { - list($index,$subindex) = explode(".", $index, 2); - $group = 'c6kxbar'; - foreach ($entry as $key => $value) - { - $entPhysical_state[$index][$subindex][$group][$key] = $value; - } + $chan_update = $entry['cc6kxbarStatisticsInUtil']; + $chan_update .= ':'.$entry['cc6kxbarStatisticsOutUtil']; + $chan_update .= ':'.$entry['cc6kxbarStatisticsOutDropped']; + $chan_update .= ':'.$entry['cc6kxbarStatisticsOutErrors']; + $chan_update .= ':'.$entry['cc6kxbarStatisticsInErrors']; - $chan_update = $entry['cc6kxbarStatisticsInUtil']; - $chan_update .= ":".$entry['cc6kxbarStatisticsOutUtil']; - $chan_update .= ":".$entry['cc6kxbarStatisticsOutDropped']; - $chan_update .= ":".$entry['cc6kxbarStatisticsOutErrors']; - $chan_update .= ":".$entry['cc6kxbarStatisticsInErrors']; + $rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('c6kxbar-'.$index.'-'.$subindex.'.rrd'); - $rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("c6kxbar-".$index."-".$subindex.".rrd"); + if ($debug) { + echo "$rrd "; + } - if ($debug) { echo("$rrd "); } - - if (!is_file($rrd)) - { - rrdtool_create ($rrd, "--step 300 \ + if (!is_file($rrd)) { + rrdtool_create( + $rrd, + '--step 300 \ DS:inutil:GAUGE:600:0:100 \ DS:oututil:GAUGE:600:0:100 \ DS:outdropped:DERIVE:600:0:125000000000 \ DS:outerrors:DERIVE:600:0:125000000000 \ - DS:inerrors:DERIVE:600:0:125000000000 ".$config['rrd_rra']); - } + DS:inerrors:DERIVE:600:0:125000000000 '.$config['rrd_rra'] + ); + } - rrdtool_update($rrd,"N:$chan_update"); + rrdtool_update($rrd, "N:$chan_update"); + }//end foreach - } - -#print_r($entPhysical_state); - -} + // print_r($entPhysical_state); +}//end if // Set Entity state -foreach (dbFetch("SELECT * FROM `entPhysical_state` WHERE `device_id` = ?", array($device['device_id'])) as $entity) -{ - if (!isset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']])) - { - dbDelete('entPhysical_state', "`device_id` = ? AND `entPhysicalIndex` = ? AND `subindex` = ? AND `group` = ? AND `key` = ?", - array($device['device_id'], $entity['entPhysicalIndex'], $entity['subindex'], $entity['group'], $entity['key'])); - } else { - if ($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']] != $entity['value']) - { - echo("no match!"); +foreach (dbFetch('SELECT * FROM `entPhysical_state` WHERE `device_id` = ?', array($device['device_id'])) as $entity) { + if (!isset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']])) { + dbDelete( + 'entPhysical_state', + '`device_id` = ? AND `entPhysicalIndex` = ? AND `subindex` = ? AND `group` = ? AND `key` = ?', + array( + $device['device_id'], + $entity['entPhysicalIndex'], + $entity['subindex'], + $entity['group'], + $entity['key'], + ) + ); } - unset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]); - } -} + else { + if ($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']] != $entity['value']) { + echo 'no match!'; + } + + unset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]); + } +}//end foreach + // End Set Entity Attrivs - // Delete Entity state -foreach ($entPhysical_state as $epi => $entity) -{ - foreach ($entity as $subindex => $si) - { - foreach ($si as $group => $ti) - { - foreach ($ti as $key => $value) - { - dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $epi, 'subindex' => $subindex, 'group' => $group, 'key' => $key, 'value' => $value), 'entPhysical_state'); - } +foreach ($entPhysical_state as $epi => $entity) { + foreach ($entity as $subindex => $si) { + foreach ($si as $group => $ti) { + foreach ($ti as $key => $value) { + dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $epi, 'subindex' => $subindex, 'group' => $group, 'key' => $key, 'value' => $value), 'entPhysical_state'); + } + } } - } } + // End Delete Entity state - -echo("\n"); - -?> +echo "\n"; diff --git a/includes/polling/mempools/avaya-ers.inc.php b/includes/polling/mempools/avaya-ers.inc.php index 219779938..6d40b5214 100644 --- a/includes/polling/mempools/avaya-ers.inc.php +++ b/includes/polling/mempools/avaya-ers.inc.php @@ -1,19 +1,15 @@ diff --git a/includes/polling/mempools/fortigate.inc.php b/includes/polling/mempools/fortigate.inc.php index 0b2a9323b..0001b40f8 100644 --- a/includes/polling/mempools/fortigate.inc.php +++ b/includes/polling/mempools/fortigate.inc.php @@ -2,14 +2,11 @@ // Simple hard-coded poller for Fortinet Fortigate // Yes, it really can be this simple. +echo 'Fortigate MemPool'; -echo "Fortigate MemPool"; +$mempool['perc'] = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgSysMemUsage.0', '-OvQ'); +$mempool['total'] = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgSysMemCapacity.0', '-OvQ'); +$mempool['used'] = ($mempool['total'] * ($mempool['perc'] / 100)); +$mempool['free'] = ($mempool['total'] - $mempool['used']); -$mempool['perc'] = snmp_get($device, "FORTINET-FORTIGATE-MIB::fgSysMemUsage.0", "-OvQ"); -$mempool['total'] = snmp_get($device, "FORTINET-FORTIGATE-MIB::fgSysMemCapacity.0", "-OvQ"); -$mempool['used'] = $mempool['total'] * ($mempool['perc']/100); -$mempool['free'] = $mempool['total'] - $mempool['used']; - -echo "(U: ".$mempool['used']." T: ".$mempool['total']." F: ".$mempool['free'].") "; - -?> \ No newline at end of file +echo '(U: '.$mempool['used'].' T: '.$mempool['total'].' F: '.$mempool['free'].') '; diff --git a/includes/polling/mempools/hpLocal.inc.php b/includes/polling/mempools/hpLocal.inc.php index 40647e895..c503cbe11 100644 --- a/includes/polling/mempools/hpLocal.inc.php +++ b/includes/polling/mempools/hpLocal.inc.php @@ -1,28 +1,27 @@ \ No newline at end of file diff --git a/includes/polling/mempools/netscaler.inc.php b/includes/polling/mempools/netscaler.inc.php index bcf681515..ffa8ec0e2 100644 --- a/includes/polling/mempools/netscaler.inc.php +++ b/includes/polling/mempools/netscaler.inc.php @@ -1,16 +1,12 @@ +$mempool['total'] = (snmp_get($device, '.1.3.6.1.4.1.5951.4.1.1.41.4.0', '-OvQ') * 1047552); +$mempool['perc'] = snmp_get($device, '.1.3.6.1.4.1.5951.4.1.1.41.2.0', '-OvQ'); +$mempool['used'] = ($mempool['total'] / 100 * $mempool['perc']); +$mempool['free'] = ($mempool['total'] - $mempool['used']); diff --git a/includes/polling/mempools/vrp.inc.php b/includes/polling/mempools/vrp.inc.php index 64f1611f1..5345e3a73 100644 --- a/includes/polling/mempools/vrp.inc.php +++ b/includes/polling/mempools/vrp.inc.php @@ -2,25 +2,30 @@ $oid = $mempool['mempool_index']; -if($debug) {echo("Huawei VRP Mempool");} +if ($debug) { + echo 'Huawei VRP Mempool'; +} -if(!is_array($mempool_cache['vrp'])) { - if ($debug) {echo("caching");} - $mempool_cache['vrp'] = array(); - $mempool_cache['vrp'] = snmpwalk_cache_multi_oid($device, "hwEntityMemSize", $mempool_cache['vrp'], "HUAWEI-ENTITY-EXTENT-MIB" , $config['install_dir']."/mibs"); - $mempool_cache['vrp'] = snmpwalk_cache_multi_oid($device, "hwEntityMemUsage", $mempool_cache['vrp'], "HUAWEI-ENTITY-EXTENT-MIB" , $config['install_dir']."/mibs"); - if ($debug) {print_r($mempool_cache);} +if (!is_array($mempool_cache['vrp'])) { + if ($debug) { + echo 'caching'; + } + + $mempool_cache['vrp'] = array(); + $mempool_cache['vrp'] = snmpwalk_cache_multi_oid($device, 'hwEntityMemSize', $mempool_cache['vrp'], 'HUAWEI-ENTITY-EXTENT-MIB', $config['install_dir'].'/mibs'); + $mempool_cache['vrp'] = snmpwalk_cache_multi_oid($device, 'hwEntityMemUsage', $mempool_cache['vrp'], 'HUAWEI-ENTITY-EXTENT-MIB', $config['install_dir'].'/mibs'); + if ($debug) { + print_r($mempool_cache); + } } $entry = $mempool_cache['vrp'][$mempool[mempool_index]]; -if ( $entry['hwEntityMemSize'] < 0 ) { -$entry['hwEntityMemSize'] = $entry['hwEntityMemSize'] * -1; +if ($entry['hwEntityMemSize'] < 0) { + $entry['hwEntityMemSize'] = ($entry['hwEntityMemSize'] * -1); } -$perc = $entry['hwEntityMemUsage']; +$perc = $entry['hwEntityMemUsage']; $mempool['total'] = $entry['hwEntityMemSize']; -$mempool['used'] = $entry['hwEntityMemSize'] / 100 * $perc; -$mempool['free'] = $entry['hwEntityMemSize'] - $mempool['used']; - -?> +$mempool['used'] = ($entry['hwEntityMemSize'] / 100 * $perc); +$mempool['free'] = ($entry['hwEntityMemSize'] - $mempool['used']); diff --git a/includes/polling/netscaler-stats.inc.php b/includes/polling/netscaler-stats.inc.php index eccad01a4..5db1724b8 100644 --- a/includes/polling/netscaler-stats.inc.php +++ b/includes/polling/netscaler-stats.inc.php @@ -1,69 +1,136 @@ diff --git a/includes/polling/netscaler-vsvr.inc.php b/includes/polling/netscaler-vsvr.inc.php index cc2cd99c9..f6a462f21 100644 --- a/includes/polling/netscaler-vsvr.inc.php +++ b/includes/polling/netscaler-vsvr.inc.php @@ -1,120 +1,142 @@ $vsvr) - { - if (isset($vsvr['vsvrName'])) - { - $vsvr_exist[$vsvr['vsvrName']] = 1; - $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netscaler-vsvr-".safename($vsvr['vsvrName']).".rrd"; - $rrdupdate = "N"; + foreach ($vsvr_array as $index => $vsvr) { + if (isset($vsvr['vsvrName'])) { + $vsvr_exist[$vsvr['vsvrName']] = 1; + $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/netscaler-vsvr-'.safename($vsvr['vsvrName']).'.rrd'; + $rrdupdate = 'N'; - foreach ($oids as $oid) - { - if (is_numeric($vsvr[$oid])) - { - $rrdupdate .= ":".$vsvr[$oid]; - } else { - $rrdupdate .= ":U"; + foreach ($oids as $oid) { + if (is_numeric($vsvr[$oid])) { + $rrdupdate .= ':'.$vsvr[$oid]; + } + else { + $rrdupdate .= ':U'; + } + } + + echo str_pad($vsvr['vsvrName'], 25).' | '.str_pad($vsvr['vsvrType'], 5).' | '.str_pad($vsvr['vsvrState'], 6).' | '.str_pad($vsvr['vsvrIpAddress'], 16).' | '.str_pad($vsvr['vsvrPort'], 5); + echo ' | '.str_pad($vsvr['vsvrRequestRate'], 8).' | '.str_pad($vsvr['vsvrRxBytesRate'].'B/s', 8).' | '.str_pad($vsvr['vsvrTxBytesRate'].'B/s', 8); + + $db_update = array( + 'vsvr_ip' => $vsvr['vsvrIpAddress'], + 'vsvr_port' => $vsvr['vsvrPort'], + 'vsvr_state' => $vsvr['vsvrState'], + 'vsvr_type' => $vsvr['vsvrType'], + 'vsvr_req_rate' => $vsvr['RequestRate'], + 'vsvr_bps_in' => $vsvr['vsvrRxBytesRate'], + 'vsvr_bps_out' => $vsvr['vsvrTxBytesRate'], + ); + + if (!is_array($vsvrs[$vsvr['vsvrName']])) { + $db_insert = array_merge(array('device_id' => $device['device_id'], 'vsvr_name' => $vsvr['vsvrName']), $db_update); + $vsvr_id = dbInsert($db_insert, 'netscaler_vservers'); + echo ' +'; + } + else { + $updated = dbUpdate($db_update, 'netscaler_vservers', '`vsvr_id` = ?', array($vsvrs[$vsvr['vsvrName']]['vsvr_id'])); + echo ' U'; + } + + if (!file_exists($rrd_file)) { + rrdtool_create($rrd_file, $rrd_create); + } + + rrdtool_update($rrd_file, $rrdupdate); + + echo "\n"; + }//end if + }//end foreach + + if ($debug) { + print_r($vsvr_exist); + } + + foreach ($vsvrs as $db_name => $db_id) { + if (!$vsvr_exist[$db_name]) { + echo '-'.$db_name; + dbDelete('netscaler_vservers', '`vsvr_id` = ?', array($db_id)); } - } - - echo(str_pad($vsvr['vsvrName'], 25) . " | " . str_pad($vsvr['vsvrType'],5) . " | " . str_pad($vsvr['vsvrState'],6) ." | ". str_pad($vsvr['vsvrIpAddress'],16) ." | ". str_pad($vsvr['vsvrPort'],5)); - echo(" | " . str_pad($vsvr['vsvrRequestRate'],8) . " | " . str_pad($vsvr['vsvrRxBytesRate']."B/s", 8)." | ". str_pad($vsvr['vsvrTxBytesRate']."B/s", 8)); - - $db_update = array('vsvr_ip' => $vsvr['vsvrIpAddress'], 'vsvr_port' => $vsvr['vsvrPort'], 'vsvr_state' => $vsvr['vsvrState'], 'vsvr_type' => $vsvr['vsvrType'], - 'vsvr_req_rate' => $vsvr['RequestRate'], 'vsvr_bps_in' => $vsvr['vsvrRxBytesRate'], 'vsvr_bps_out' => $vsvr['vsvrTxBytesRate']); - - if (!is_array($vsvrs[$vsvr['vsvrName']])) - { - $db_insert = array_merge(array('device_id' => $device['device_id'], 'vsvr_name' => $vsvr['vsvrName']), $db_update); - $vsvr_id = dbInsert($db_insert, 'netscaler_vservers'); echo(" +"); - } else { - $updated = dbUpdate($db_update, 'netscaler_vservers', '`vsvr_id` = ?', array($vsvrs[$vsvr['vsvrName']]['vsvr_id'])); - echo(" U"); - } - - if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); } - rrdtool_update($rrd_file, $rrdupdate); - - echo("\n"); } - - } - - if ($debug) { print_r($vsvr_exist); } - - foreach ($vsvrs as $db_name => $db_id) - { - if (!$vsvr_exist[$db_name]) - { - echo("-".$db_name); - dbDelete('netscaler_vservers', "`vsvr_id` = ?", array($db_id)); - } - } -} - -?> +}//end if diff --git a/includes/polling/os.inc.php b/includes/polling/os.inc.php index cd3da2861..fcbf24a65 100644 --- a/includes/polling/os.inc.php +++ b/includes/polling/os.inc.php @@ -1,50 +1,40 @@ ".$version, $device, 'system'); +if ($version && $device['version'] != $version) { + $update_array['version'] = $version; + log_event('OS Version -> '.$version, $device, 'system'); } -if ($features != $device['features']) -{ - $update_array['features'] = $features; - log_event("OS Features -> ".$features, $device, 'system'); +if ($features != $device['features']) { + $update_array['features'] = $features; + log_event('OS Features -> '.$features, $device, 'system'); } -if ($hardware && $hardware != $device['hardware']) -{ - $update_array['hardware'] = $hardware; - log_event("Hardware -> ".$hardware, $device, 'system'); +if ($hardware && $hardware != $device['hardware']) { + $update_array['hardware'] = $hardware; + log_event('Hardware -> '.$hardware, $device, 'system'); } -if ($serial && $serial != $device['serial']) -{ - $update_array['serial'] = $serial; - log_event("Serial -> ".$serial, $device, 'system'); +if ($serial && $serial != $device['serial']) { + $update_array['serial'] = $serial; + log_event('Serial -> '.$serial, $device, 'system'); } -if ($icon && $icon != $device['icon']) -{ - $update_array['icon'] = $icon; - log_event("Icon -> ".$icon, $device, 'system'); +if ($icon && $icon != $device['icon']) { + $update_array['icon'] = $icon; + log_event('Icon -> '.$icon, $device, 'system'); } -echo("\nHardware: ".$hardware." Version: ".$version." Features: ".$features." Serial: ".$serial."\n"); - -?> +echo "\nHardware: ".$hardware.' Version: '.$version.' Features: '.$features.' Serial: '.$serial."\n"; diff --git a/includes/polling/os/acsw.inc.php b/includes/polling/os/acsw.inc.php index ecd1daf24..a3a6f2a13 100644 --- a/includes/polling/os/acsw.inc.php +++ b/includes/polling/os/acsw.inc.php @@ -1,54 +1,50 @@ +// if(isset($cisco_hardware_oids[$poll_device['sysObjectID']])) { $hardware = $cisco_hardware_oids[$poll_device['sysObjectID']]; } +if (strpos($poll_device['sysDescr'], 'IOS XR')) { + list(,$version) = explode(',', $poll_device['sysDescr']); + $version = trim($version); + list(,$version) = explode(' ', $version); + list($version) = explode("\n", $version); + trim($version); +} diff --git a/includes/polling/os/airport.inc.php b/includes/polling/os/airport.inc.php index 365d25483..0f8fd2bfc 100644 --- a/includes/polling/os/airport.inc.php +++ b/includes/polling/os/airport.inc.php @@ -1,5 +1,3 @@ \ No newline at end of file +$version = snmp_get($device, 'sysConfFirmwareVersion.0', '-Ovq', 'AIRPORT-BASESTATION-3-MIB'); diff --git a/includes/polling/os/allied.inc.php b/includes/polling/os/allied.inc.php index 506cb1063..e83282078 100644 --- a/includes/polling/os/allied.inc.php +++ b/includes/polling/os/allied.inc.php @@ -1,52 +1,41 @@ \ No newline at end of file +$version = str_replace('"', '', $version); +$features = str_replace('"', '', $features); +$hardware = str_replace('"', '', $hardware); diff --git a/includes/polling/os/areca.inc.php b/includes/polling/os/areca.inc.php index 3f6664165..e1442a2de 100644 --- a/includes/polling/os/areca.inc.php +++ b/includes/polling/os/areca.inc.php @@ -1,18 +1,21 @@ \ No newline at end of file +$version = trim(snmp_get($device, '1.3.6.1.4.1.18928.1.1.1.4.0', '-OQv', '', ''), '"'); +if (!$version) { + $version = trim(snmp_get($device, '1.3.6.1.4.1.18928.1.2.1.4.0', '-OQv', '', ''), '"'); +} + +$serial = trim(snmp_get($device, '1.3.6.1.4.1.18928.1.1.1.3.0', '-OQv', '', ''), '"'); +if (!$serial) { + $serial = trim(snmp_get($device, '1.3.6.1.4.1.18928.1.2.1.3.0', '-OQv', '', ''), '"'); +} + +if (isHexString($serial)) { + // Sometimes firmware outputs serial as hex-string + $serial = snmp_hexstring($serial); +} diff --git a/includes/polling/os/arubaos.inc.php b/includes/polling/os/arubaos.inc.php index b3c85a863..784ed7ee0 100644 --- a/includes/polling/os/arubaos.inc.php +++ b/includes/polling/os/arubaos.inc.php @@ -1,22 +1,26 @@ +echo "\n"; + +if ($aruba_info[0]['wlsxSwitchRole'] == 'master') { + $features = 'Master Controller'; +} +else { + $features = 'Local Controller for '.$aruba_info[0]['wlsxSwitchMasterIp']; +} diff --git a/includes/polling/os/avaya-ers.inc.php b/includes/polling/os/avaya-ers.inc.php index af2e9ae4a..163c82c18 100644 --- a/includes/polling/os/avaya-ers.inc.php +++ b/includes/polling/os/avaya-ers.inc.php @@ -1,42 +1,40 @@ 1) { - $features = "Stack of $stack_size units"; + $features = "Stack of $stack_size units"; } -$version = str_replace("\"","", $version); -$features = str_replace("\"","", $features); -$hardware = str_replace("\"","", $hardware); - -?> +$version = str_replace('"', '', $version); +$features = str_replace('"', '', $features); +$hardware = str_replace('"', '', $hardware); diff --git a/includes/polling/os/avocent.inc.php b/includes/polling/os/avocent.inc.php index 23f480b30..2646c66ec 100644 --- a/includes/polling/os/avocent.inc.php +++ b/includes/polling/os/avocent.inc.php @@ -1,11 +1,8 @@ diff --git a/includes/polling/os/bnt.inc.php b/includes/polling/os/bnt.inc.php index 943cdf017..89e0d8ea7 100644 --- a/includes/polling/os/bnt.inc.php +++ b/includes/polling/os/bnt.inc.php @@ -2,9 +2,6 @@ preg_match('/Blade Network Technologies (.*)$/', $poll_device['sysDescr'], $store); -if (isset($store[1])) -{ - $hardware = $store[1]; +if (isset($store[1])) { + $hardware = $store[1]; } - -?> \ No newline at end of file diff --git a/includes/polling/os/brother.inc.php b/includes/polling/os/brother.inc.php index 98f0eab75..442fe1e36 100644 --- a/includes/polling/os/brother.inc.php +++ b/includes/polling/os/brother.inc.php @@ -1,45 +1,41 @@ \ No newline at end of file +// Strip off useless brand fields +$hardware = str_replace('Brother ', '', $hardware); +$hardware = str_ireplace(' series', '', $hardware); + +if (isHexString($serial)) { + // Sometimes firmware outputs serial as hex-string + $serial = snmp_hexstring($serial); +} diff --git a/includes/polling/os/dell-laser.inc.php b/includes/polling/os/dell-laser.inc.php index e3ba6f013..05be449b8 100644 --- a/includes/polling/os/dell-laser.inc.php +++ b/includes/polling/os/dell-laser.inc.php @@ -1,37 +1,30 @@ \ No newline at end of file diff --git a/includes/polling/os/drac.inc.php b/includes/polling/os/drac.inc.php index f99269d4e..8974a44e3 100644 --- a/includes/polling/os/drac.inc.php +++ b/includes/polling/os/drac.inc.php @@ -1,7 +1,5 @@ \ No newline at end of file +$version = trim(snmp_get($device, '.1.3.6.1.4.1.674.10892.2.1.2.1.0', '-OQv'), '"'); +$hardware = trim(snmp_get($device, '.1.3.6.1.4.1.674.10892.2.1.1.2.0', '-OQv'), '"'); +$serial = trim(snmp_get($device, '.1.3.6.1.4.1.674.10892.2.1.1.11.0', '-OQv'), '"'); diff --git a/includes/polling/os/extremeware.inc.php b/includes/polling/os/extremeware.inc.php index 00d92c2d5..94509495a 100644 --- a/includes/polling/os/extremeware.inc.php +++ b/includes/polling/os/extremeware.inc.php @@ -1,46 +1,40 @@ +$version = str_replace('"', '', $version); +$features = str_replace('"', '', $features); +$hardware = str_replace('"', '', $hardware); diff --git a/includes/polling/os/fabos.inc.php b/includes/polling/os/fabos.inc.php index 90c08e986..b4feb9abb 100644 --- a/includes/polling/os/fabos.inc.php +++ b/includes/polling/os/fabos.inc.php @@ -1,6 +1,4 @@ +$version = trim(snmp_get($device, '1.3.6.1.4.1.1588.2.1.1.1.1.6.0', '-Ovq'), '"'); +$hardware = trim(snmp_get($device, 'ENTITY-MIB::entPhysicalDescr.1', '-Ovq'), '"'); diff --git a/includes/polling/os/firebox.inc.php b/includes/polling/os/firebox.inc.php index 72a3adebc..dbe5d7f79 100644 --- a/includes/polling/os/firebox.inc.php +++ b/includes/polling/os/firebox.inc.php @@ -1,10 +1,8 @@ \ No newline at end of file +$version = (isset($matches[1]) ? $matches[1] : ''); +// $hardware = "Still need to figger hardware out!"; +// $serial = "Still need to figger serial out!"; +// $features = "Still need to figger features out!"; diff --git a/includes/polling/os/ftos.inc.php b/includes/polling/os/ftos.inc.php index 3e7e5ca49..f24e264d8 100644 --- a/includes/polling/os/ftos.inc.php +++ b/includes/polling/os/ftos.inc.php @@ -1,55 +1,44 @@ +$version = str_replace('"', '', $version); +$features = str_replace('"', '', $features); +$hardware = str_replace('"', '', $hardware); diff --git a/includes/polling/os/ies.inc.php b/includes/polling/os/ies.inc.php index f63a822bc..da679f4a4 100644 --- a/includes/polling/os/ies.inc.php +++ b/includes/polling/os/ies.inc.php @@ -1,8 +1,6 @@ \ No newline at end of file diff --git a/includes/polling/os/ipoman.inc.php b/includes/polling/os/ipoman.inc.php index 294db2c46..2e72f13d5 100644 --- a/includes/polling/os/ipoman.inc.php +++ b/includes/polling/os/ipoman.inc.php @@ -1,10 +1,13 @@ \ No newline at end of file +if ($matches[2]) { + $serial = $matches[2]; +} diff --git a/includes/polling/os/ironware.inc.php b/includes/polling/os/ironware.inc.php index 5a59932fc..e7a2406f0 100644 --- a/includes/polling/os/ironware.inc.php +++ b/includes/polling/os/ironware.inc.php @@ -1,15 +1,19 @@ +$version = str_replace('V', '', $version); +$version = str_replace('"', '', $version); diff --git a/includes/polling/os/jetdirect.inc.php b/includes/polling/os/jetdirect.inc.php index 370ef363e..323ec81c3 100644 --- a/includes/polling/os/jetdirect.inc.php +++ b/includes/polling/os/jetdirect.inc.php @@ -1,31 +1,25 @@ \ No newline at end of file diff --git a/includes/polling/os/junos.inc.php b/includes/polling/os/junos.inc.php index 3066e25af..dc698106e 100644 --- a/includes/polling/os/junos.inc.php +++ b/includes/polling/os/junos.inc.php @@ -1,19 +1,17 @@ \ No newline at end of file +list($version) = explode(']', $jun_ver); +list(,$version) = explode('[', $version); +$features = ''; diff --git a/includes/polling/os/junose.inc.php b/includes/polling/os/junose.inc.php index f434cf02a..e51eabb3e 100644 --- a/includes/polling/os/junose.inc.php +++ b/includes/polling/os/junose.inc.php @@ -1,22 +1,18 @@ \ No newline at end of file +list($version) = explode(' ', $junose_version); +list(,$version) = explode('(', $version); +list($features) = explode(']', $junose_version); +list(,$features) = explode('[', $features); diff --git a/includes/polling/os/jwos.inc.php b/includes/polling/os/jwos.inc.php index 91b649bfd..689d03335 100644 --- a/includes/polling/os/jwos.inc.php +++ b/includes/polling/os/jwos.inc.php @@ -1,16 +1,13 @@ \ No newline at end of file +$hardware = snmp_get($device, 'jnxWxChassisType.0', '-Ovq', 'JUNIPER-WX-GLOBAL-REG'); +$hardware = strtoupper(str_replace('jnx', '', $hardware)); +$hardware .= ' '.snmp_get($device, 'jnxWxSysHwVersion.0', '-Ovq', 'JUNIPER-WX-GLOBAL-REG'); diff --git a/includes/polling/os/konica.inc.php b/includes/polling/os/konica.inc.php index fe94a8d86..2ecac249f 100644 --- a/includes/polling/os/konica.inc.php +++ b/includes/polling/os/konica.inc.php @@ -1,13 +1,11 @@ \ No newline at end of file diff --git a/includes/polling/os/kyocera.inc.php b/includes/polling/os/kyocera.inc.php index 4931342cf..3ff7a2f40 100644 --- a/includes/polling/os/kyocera.inc.php +++ b/includes/polling/os/kyocera.inc.php @@ -1,14 +1,11 @@ \ No newline at end of file +// SNMPv2-SMI::enterprises.1347.43.5.4.1.5.1.1 = STRING: "2H9_2F00.002.002" +$version = trim(snmp_get($device, '1.3.6.1.4.1.1347.43.5.4.1.5.1.1', '-OQv', '', ''), '" '); diff --git a/includes/polling/os/mgeups.inc.php b/includes/polling/os/mgeups.inc.php index 7d0bac261..f1cd43c92 100644 --- a/includes/polling/os/mgeups.inc.php +++ b/includes/polling/os/mgeups.inc.php @@ -1,14 +1,11 @@ \ No newline at end of file +$serial = trim(snmp_get($device, 'upsmgIdentSerialNumber.0', '-OQv', 'MG-SNMP-UPS-MIB'), '" '); diff --git a/includes/polling/os/minkelsrms.inc.php b/includes/polling/os/minkelsrms.inc.php index a7bc0b4c6..9922a2e16 100644 --- a/includes/polling/os/minkelsrms.inc.php +++ b/includes/polling/os/minkelsrms.inc.php @@ -1,7 +1,4 @@ \ No newline at end of file +// AKCP clone +require 'includes/polling/os/akcp.inc.php'; diff --git a/includes/polling/os/netmanplus.inc.php b/includes/polling/os/netmanplus.inc.php index 5b76ea3d4..e209c6a37 100644 --- a/includes/polling/os/netmanplus.inc.php +++ b/includes/polling/os/netmanplus.inc.php @@ -1,5 +1,3 @@ \ No newline at end of file +$version = trim(snmp_get($device, '1.3.6.1.2.1.33.1.1.3.0', '-OQv', 'UPS-MIB'), '"'); diff --git a/includes/polling/os/netscaler.inc.php b/includes/polling/os/netscaler.inc.php index 48cc359e3..d1677471e 100644 --- a/includes/polling/os/netscaler.inc.php +++ b/includes/polling/os/netscaler.inc.php @@ -1,16 +1,13 @@ +require 'includes/polling/netscaler-stats.inc.php'; diff --git a/includes/polling/os/nrg.inc.php b/includes/polling/os/nrg.inc.php index e46a27001..fdb861830 100644 --- a/includes/polling/os/nrg.inc.php +++ b/includes/polling/os/nrg.inc.php @@ -1,17 +1,14 @@ +// SNMPv2-SMI::enterprises.367.3.2.1.2.1.4.0 = STRING: "M6394300657" +// $serial = trim(snmp_get($device, "1.3.6.1.4.1.367.3.2.1.2.1.4.0", "-OQv", "", ""),'" '); diff --git a/includes/polling/os/okilan.inc.php b/includes/polling/os/okilan.inc.php index 6cf8b486a..6c71798f1 100644 --- a/includes/polling/os/okilan.inc.php +++ b/includes/polling/os/okilan.inc.php @@ -1,10 +1,7 @@ \ No newline at end of file +// Strip off useless brand fields +$hardware = str_replace('OKI ', '', $hardware); diff --git a/includes/polling/os/panos.inc.php b/includes/polling/os/panos.inc.php index a76793aad..e61a64dd8 100644 --- a/includes/polling/os/panos.inc.php +++ b/includes/polling/os/panos.inc.php @@ -1,21 +1,18 @@ diff --git a/includes/polling/os/poweralert.inc.php b/includes/polling/os/poweralert.inc.php index 8b5ad0a8e..41349cef5 100644 --- a/includes/polling/os/poweralert.inc.php +++ b/includes/polling/os/poweralert.inc.php @@ -1,17 +1,14 @@ +$sysLocation = trim(snmp_get($device, '.1.3.6.1.4.1.850.10.2.2.1.12.1', '-Ovq', 'TRIPPLITE-MIB'), '"'); +$sysName = trim(snmp_get($device, '.1.3.6.1.2.1.33.1.1.5.0', '-Ovq', 'TRIPPLITE-MIB'), '"'); +$serial = trim(snmp_get($device, '.1.3.6.1.4.1.850.100.1.1.4.0', '-Ovq', 'TRIPPLITE-MIB'), '"'); +$version = snmp_get($device, 'upsIdentAgentSoftwareVersion.0', '-Ovq', 'UPS-MIB'); diff --git a/includes/polling/os/powerconnect.inc.php b/includes/polling/os/powerconnect.inc.php index 4646e10bd..97de6124e 100644 --- a/includes/polling/os/powerconnect.inc.php +++ b/includes/polling/os/powerconnect.inc.php @@ -1,12 +1,9 @@ \ No newline at end of file diff --git a/includes/polling/os/powervault.inc.php b/includes/polling/os/powervault.inc.php index 3cb155875..fc5c7e01a 100644 --- a/includes/polling/os/powervault.inc.php +++ b/includes/polling/os/powervault.inc.php @@ -1,5 +1,3 @@ \ No newline at end of file +$version = trim(snmp_get($device, '1.3.6.1.4.1.674.10893.2.102.3.1.1.9.1', '-OQv', '', ''), '"'); diff --git a/includes/polling/os/radlan.inc.php b/includes/polling/os/radlan.inc.php index ade5a8893..aa0da3818 100644 --- a/includes/polling/os/radlan.inc.php +++ b/includes/polling/os/radlan.inc.php @@ -1,22 +1,19 @@ \ No newline at end of file +$version = str_replace('"', '', $version); +$features = str_replace('"', '', $features); +$hardware = str_replace('"', '', $hardware); diff --git a/includes/polling/os/ricoh.inc.php b/includes/polling/os/ricoh.inc.php index a72773159..10172afcb 100644 --- a/includes/polling/os/ricoh.inc.php +++ b/includes/polling/os/ricoh.inc.php @@ -1,12 +1,10 @@ \ No newline at end of file +// SNMPv2-SMI::enterprises.367.3.2.1.2.1.4.0 = STRING: "M6394300657" +$serial = trim(snmp_get($device, '1.3.6.1.4.1.367.3.2.1.2.1.4.0', '-OQv', '', ''), '" '); diff --git a/includes/polling/os/sonicwall.inc.php b/includes/polling/os/sonicwall.inc.php index 556a3fa3f..b11150cf1 100644 --- a/includes/polling/os/sonicwall.inc.php +++ b/includes/polling/os/sonicwall.inc.php @@ -1,19 +1,15 @@ +// SNMPv2-SMI::enterprises.8741.2.1.1.1.0 = STRING: "NSA 2400" +// SNMPv2-SMI::enterprises.8741.2.1.1.2.0 = STRING: "0017C599BD08" +// SNMPv2-SMI::enterprises.8741.2.1.1.3.0 = STRING: "SonicOS Enhanced 5.8.1.7-4o" +// SNMPv2-SMI::enterprises.8741.2.1.1.4.0 = STRING: "5.0.3.3" +// SNMPv2-SMI::enterprises.8741.2.1.1.1.0 = STRING: "TZ 210" +// SNMPv2-SMI::enterprises.8741.2.1.1.2.0 = STRING: "0017C568903C" +// SNMPv2-SMI::enterprises.8741.2.1.1.3.0 = STRING: "SonicOS Enhanced 5.6.0.11-61o" +// SNMPv2-SMI::enterprises.8741.2.1.1.4.0 = STRING: "5.0.2.11" +$hardware = trim(snmp_get($device, '.1.3.6.1.4.1.8741.2.1.1.1.0', '-OQv', '', ''), '" '); +$serial = trim(snmp_get($device, '.1.3.6.1.4.1.8741.2.1.1.2.0', '-OQv', '', ''), '" '); +$fwversion = trim(snmp_get($device, '.1.3.6.1.4.1.8741.2.1.1.3.0', '-OQv', '', ''), '" '); +$romversion = trim(snmp_get($device, '.1.3.6.1.4.1.8741.2.1.1.4.0', '-OQv', '', ''), '" '); +$version = "(Firmware $fwversion / ROM $romversion)"; diff --git a/includes/polling/os/speedtouch.inc.php b/includes/polling/os/speedtouch.inc.php index 1abe8c623..64851ece7 100644 --- a/includes/polling/os/speedtouch.inc.php +++ b/includes/polling/os/speedtouch.inc.php @@ -1,20 +1,15 @@ diff --git a/includes/polling/os/symbol.inc.php b/includes/polling/os/symbol.inc.php index fcfeaaac4..8062405ba 100644 --- a/includes/polling/os/symbol.inc.php +++ b/includes/polling/os/symbol.inc.php @@ -1,9 +1,8 @@ \ No newline at end of file +$fnSysVersion = snmp_get($device, '.1.3.6.1.4.1.388.11.2.2.1.3.2.0', '-Ovq'); +$serial = trim(snmp_get($device, '.1.3.6.1.4.1.388.11.2.2.1.1.0', '-Ovq'), '"'); +$version = trim(snmp_get($device, '.1.3.6.1.4.1.388.11.2.2.1.3.2.0', '-Ovq'), '"'); +// preg_match("/HW=(^\s]+)/",$sysDescr,$hardwarematches); +preg_match('/\s+[^\s]+/', $poll_device['sysDescr'], $hardwarematches); +$hardware = $hardwarematches[0]; diff --git a/includes/polling/os/tranzeo.inc.php b/includes/polling/os/tranzeo.inc.php index 4d42475dc..f2ce8aaf6 100644 --- a/includes/polling/os/tranzeo.inc.php +++ b/includes/polling/os/tranzeo.inc.php @@ -1,16 +1,13 @@ \ No newline at end of file +list(,$version) = explode(' ', $version); +list($version) = explode('(', $version); +list(,$features) = explode(' ', $features); diff --git a/includes/polling/os/vrp.inc.php b/includes/polling/os/vrp.inc.php index 4d4a12cb0..4901ad163 100644 --- a/includes/polling/os/vrp.inc.php +++ b/includes/polling/os/vrp.inc.php @@ -1,8 +1,6 @@ \ No newline at end of file +preg_match("/Version .*\n/", $poll_device['sysDescr'], $matches); +$version = trim(str_replace('Version ', '', $matches[0])); diff --git a/includes/polling/os/vyatta.inc.php b/includes/polling/os/vyatta.inc.php index d0a26bc99..39e323dbf 100644 --- a/includes/polling/os/vyatta.inc.php +++ b/includes/polling/os/vyatta.inc.php @@ -1,5 +1,3 @@ +list($features, $version) = explode('-', trim(str_replace('Vyatta', '', snmp_get($device, 'SNMPv2-MIB::sysDescr.0', '-Oqv', 'SNMPv2-MIB'))), 2); diff --git a/includes/polling/os/xerox.inc.php b/includes/polling/os/xerox.inc.php index a63bda998..5fbb733ee 100644 --- a/includes/polling/os/xerox.inc.php +++ b/includes/polling/os/xerox.inc.php @@ -1,25 +1,19 @@ \ No newline at end of file +$version = trim(snmp_get($device, '1.3.6.1.4.1.236.11.5.1.1.1.2.0', '-OQv', '', ''), '" '); diff --git a/includes/polling/os/zxr10.inc.php b/includes/polling/os/zxr10.inc.php index fab869660..a65403a19 100644 --- a/includes/polling/os/zxr10.inc.php +++ b/includes/polling/os/zxr10.inc.php @@ -5,5 +5,3 @@ list($version) = explode(',', $poll_device['sysDescr']); preg_match('/Version V(\S+) (.+) Software,/', $poll_device['sysDescr'], $matches); $hardware = $matches[2]; - -?> diff --git a/includes/polling/os/zywall.inc.php b/includes/polling/os/zywall.inc.php index 91156e604..9b67f5f78 100644 --- a/includes/polling/os/zywall.inc.php +++ b/includes/polling/os/zywall.inc.php @@ -1,5 +1,3 @@ \ No newline at end of file diff --git a/includes/polling/os/zyxelnwa.inc.php b/includes/polling/os/zyxelnwa.inc.php index 91156e604..9b67f5f78 100644 --- a/includes/polling/os/zyxelnwa.inc.php +++ b/includes/polling/os/zyxelnwa.inc.php @@ -1,5 +1,3 @@ \ No newline at end of file diff --git a/includes/polling/ospf.inc.php b/includes/polling/ospf.inc.php index a7cc83078..9f2e0c3e0 100644 --- a/includes/polling/ospf.inc.php +++ b/includes/polling/ospf.inc.php @@ -1,342 +1,381 @@ $ospf_entry) -{ - // If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array - if (!isset($ospf_instances_db[$ospf_instance_id])) - { - dbInsert(array('device_id' => $device['device_id'], 'ospf_instance_id' => $ospf_instance_id), 'ospf_instances'); - echo("+"); - $ospf_instances_db[$entry['ospf_instance_id']] = dbFetchRow("SELECT * FROM `ospf_instances` WHERE `device_id` = ? AND `ospf_instance_id` = ?", array($device['device_id'],$ospf_instance_id)); - $ospf_instances_db[$entry['ospf_instance_id']] = $entry; - } +$ospf_instances_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfGeneralGroup', array(), 'OSPF-MIB'); +foreach ($ospf_instances_poll as $ospf_instance_id => $ospf_entry) { + // If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array + if (!isset($ospf_instances_db[$ospf_instance_id])) { + dbInsert(array('device_id' => $device['device_id'], 'ospf_instance_id' => $ospf_instance_id), 'ospf_instances'); + echo '+'; + $ospf_instances_db[$entry['ospf_instance_id']] = dbFetchRow('SELECT * FROM `ospf_instances` WHERE `device_id` = ? AND `ospf_instance_id` = ?', array($device['device_id'], $ospf_instance_id)); + $ospf_instances_db[$entry['ospf_instance_id']] = $entry; + } } -if ($debug) -{ - echo("\nPolled: "); - print_r($ospf_instances_poll); - echo("Database: "); - print_r($ospf_instances_db); - echo("\n"); +if ($debug) { + echo "\nPolled: "; + print_r($ospf_instances_poll); + echo 'Database: '; + print_r($ospf_instances_db); + echo "\n"; } // Loop array of entries and update -if (is_array($ospf_instances_db)) -{ - foreach ($ospf_instances_db as $ospf_instance_db) - { - $ospf_instance_poll = $ospf_instances_poll[$ospf_instance_db['ospf_instance_id']]; - foreach ($ospf_oids_db as $oid) - { // Loop the OIDs - if ($ospf_instance_db[$oid] != $ospf_instance_poll[$oid]) - { // If data has changed, build a query - $ospf_instance_update[$oid] = $ospf_instance_poll[$oid]; - #log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['port_id']); // FIXME - } - } - if ($ospf_instance_update) - { - dbUpdate($ospf_instance_update, 'ospf_instances', '`device_id` = ? AND `ospf_instance_id` = ?', array($device['device_id'], $ospf_instance_id)); - echo("U"); - unset($ospf_instance_update); - } else { - echo("."); - } +if (is_array($ospf_instances_db)) { + foreach ($ospf_instances_db as $ospf_instance_db) { + $ospf_instance_poll = $ospf_instances_poll[$ospf_instance_db['ospf_instance_id']]; + foreach ($ospf_oids_db as $oid) { + // Loop the OIDs + if ($ospf_instance_db[$oid] != $ospf_instance_poll[$oid]) { + // If data has changed, build a query + $ospf_instance_update[$oid] = $ospf_instance_poll[$oid]; + // log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['port_id']); // FIXME + } + } - unset($ospf_instance_poll); - unset($ospf_instance_db); - $ospf_instance_count++; - } -} + if ($ospf_instance_update) { + dbUpdate($ospf_instance_update, 'ospf_instances', '`device_id` = ? AND `ospf_instance_id` = ?', array($device['device_id'], $ospf_instance_id)); + echo 'U'; + unset($ospf_instance_update); + } + else { + echo '.'; + } + + unset($ospf_instance_poll); + unset($ospf_instance_db); + $ospf_instance_count++; + }//end foreach +}//end if unset($ospf_instances_poll); unset($ospf_instances_db); -echo(" Areas: "); +echo ' Areas: '; -$ospf_area_oids = array('ospfAuthType','ospfImportAsExtern','ospfSpfRuns','ospfAreaBdrRtrCount','ospfAsBdrRtrCount','ospfAreaLsaCount','ospfAreaLsaCksumSum','ospfAreaSummary','ospfAreaStatus'); +$ospf_area_oids = array( + 'ospfAuthType', + 'ospfImportAsExtern', + 'ospfSpfRuns', + 'ospfAreaBdrRtrCount', + 'ospfAsBdrRtrCount', + 'ospfAreaLsaCount', + 'ospfAreaLsaCksumSum', + 'ospfAreaSummary', + 'ospfAreaStatus', +); // Build array of existing entries -foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id'])) as $entry) -{ - $ospf_areas_db[$entry['ospfAreaId']] = $entry; +foreach (dbFetchRows('SELECT * FROM `ospf_areas` WHERE `device_id` = ?', array($device['device_id'])) as $entry) { + $ospf_areas_db[$entry['ospfAreaId']] = $entry; } // Pull data from device -$ospf_areas_poll = snmpwalk_cache_oid($device, "OSPF-MIB::ospfAreaEntry", array(), "OSPF-MIB"); +$ospf_areas_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfAreaEntry', array(), 'OSPF-MIB'); -foreach ($ospf_areas_poll as $ospf_area_id => $ospf_area) -{ - // If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array - if (!isset($ospf_areas_db[$ospf_area_id])) - { - dbInsert(array('device_id' => $device['device_id'], 'ospfAreaId' => $ospf_area_id), 'ospf_areas'); - echo("+"); - $entry = dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ? AND `ospfAreaId` = ?",array($device['device_id'], $ospf_area_id)); - $ospf_areas_db[$entry['ospf_area_id']] = $entry; - } +foreach ($ospf_areas_poll as $ospf_area_id => $ospf_area) { + // If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array + if (!isset($ospf_areas_db[$ospf_area_id])) { + dbInsert(array('device_id' => $device['device_id'], 'ospfAreaId' => $ospf_area_id), 'ospf_areas'); + echo '+'; + $entry = dbFetchRows('SELECT * FROM `ospf_areas` WHERE `device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_id)); + $ospf_areas_db[$entry['ospf_area_id']] = $entry; + } } -if ($debug) -{ - echo("\nPolled: "); - print_r($ospf_areas_poll); - echo("Database: "); - print_r($ospf_areas_db); - echo("\n"); +if ($debug) { + echo "\nPolled: "; + print_r($ospf_areas_poll); + echo 'Database: '; + print_r($ospf_areas_db); + echo "\n"; } // Loop array of entries and update -if (is_array($ospf_areas_db)) -{ - foreach ($ospf_areas_db as $ospf_area_db) - { - if (is_array($ospf_ports_poll[$ospf_port_db['ospf_port_id']])) - { - $ospf_area_poll = $ospf_areas_poll[$ospf_area_db['ospfAreaId']]; - foreach ($ospf_area_oids as $oid) - { // Loop the OIDs - if ($ospf_area_db[$oid] != $ospf_area_poll[$oid]) - { // If data has changed, build a query - $ospf_area_update[$oid] = $ospf_area_poll[$oid]; - #log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['port_id']); // FIXME +if (is_array($ospf_areas_db)) { + foreach ($ospf_areas_db as $ospf_area_db) { + if (is_array($ospf_ports_poll[$ospf_port_db['ospf_port_id']])) { + $ospf_area_poll = $ospf_areas_poll[$ospf_area_db['ospfAreaId']]; + foreach ($ospf_area_oids as $oid) { + // Loop the OIDs + if ($ospf_area_db[$oid] != $ospf_area_poll[$oid]) { + // If data has changed, build a query + $ospf_area_update[$oid] = $ospf_area_poll[$oid]; + // log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['port_id']); // FIXME + } + } + + if ($ospf_area_update) { + dbUpdate($ospf_area_update, 'ospf_areas', '`device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_id)); + echo 'U'; + unset($ospf_area_update); + } + else { + echo '.'; + } + + unset($ospf_area_poll); + unset($ospf_area_db); + $ospf_area_count++; } - } - if ($ospf_area_update) - { - dbUpdate($ospf_area_update, 'ospf_areas', '`device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_id)); - echo("U"); - unset($ospf_area_update); - } else { - echo("."); - } - unset($ospf_area_poll); - unset($ospf_area_db); - $ospf_area_count++; - } else { - dbDelete('ospf_ports', '`device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_db['ospfAreaId'])); - } - } -} + else { + dbDelete('ospf_ports', '`device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_db['ospfAreaId'])); + }//end if + }//end foreach +}//end if unset($ospf_areas_db); unset($ospf_areas_poll); -#$ospf_ports = snmpwalk_cache_oid($device, "OSPF-MIB::ospfIfEntry", array(), "OSPF-MIB"); -#print_r($ospf_ports); +// $ospf_ports = snmpwalk_cache_oid($device, "OSPF-MIB::ospfIfEntry", array(), "OSPF-MIB"); +// print_r($ospf_ports); +echo ' Ports: '; -echo(" Ports: "); - -$ospf_port_oids = array('ospfIfIpAddress','port_id','ospfAddressLessIf','ospfIfAreaId','ospfIfType','ospfIfAdminStat','ospfIfRtrPriority','ospfIfTransitDelay','ospfIfRetransInterval','ospfIfHelloInterval','ospfIfRtrDeadInterval','ospfIfPollInterval','ospfIfState','ospfIfDesignatedRouter','ospfIfBackupDesignatedRouter','ospfIfEvents','ospfIfAuthKey','ospfIfStatus','ospfIfMulticastForwarding','ospfIfDemand','ospfIfAuthType'); +$ospf_port_oids = array( + 'ospfIfIpAddress', + 'port_id', + 'ospfAddressLessIf', + 'ospfIfAreaId', + 'ospfIfType', + 'ospfIfAdminStat', + 'ospfIfRtrPriority', + 'ospfIfTransitDelay', + 'ospfIfRetransInterval', + 'ospfIfHelloInterval', + 'ospfIfRtrDeadInterval', + 'ospfIfPollInterval', + 'ospfIfState', + 'ospfIfDesignatedRouter', + 'ospfIfBackupDesignatedRouter', + 'ospfIfEvents', + 'ospfIfAuthKey', + 'ospfIfStatus', + 'ospfIfMulticastForwarding', + 'ospfIfDemand', + 'ospfIfAuthType', +); // Build array of existing entries -foreach (dbFetchRows("SELECT * FROM `ospf_ports` WHERE `device_id` = ?", array($device['device_id'])) as $entry) -{ - $ospf_ports_db[$entry['ospf_port_id']] = $entry; +foreach (dbFetchRows('SELECT * FROM `ospf_ports` WHERE `device_id` = ?', array($device['device_id'])) as $entry) { + $ospf_ports_db[$entry['ospf_port_id']] = $entry; } // Pull data from device -$ospf_ports_poll = snmpwalk_cache_oid($device, "OSPF-MIB::ospfIfEntry", array(), "OSPF-MIB"); +$ospf_ports_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfIfEntry', array(), 'OSPF-MIB'); -foreach ($ospf_ports_poll as $ospf_port_id => $ospf_port) -{ - // If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array - if (!isset($ospf_ports_db[$ospf_port_id])) - { - dbInsert(array('device_id' => $device['device_id'], 'ospf_port_id' => $ospf_port_id), 'ospf_ports'); - echo("+"); - $ospf_ports_db[$entry['ospf_port_id']] = dbFetchRow("SELECT * FROM `ospf_ports` WHERE `device_id` = ? AND `ospf_port_id` = ?", array($device['device_id'], $ospf_port_id)); - } +foreach ($ospf_ports_poll as $ospf_port_id => $ospf_port) { + // If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array + if (!isset($ospf_ports_db[$ospf_port_id])) { + dbInsert(array('device_id' => $device['device_id'], 'ospf_port_id' => $ospf_port_id), 'ospf_ports'); + echo '+'; + $ospf_ports_db[$entry['ospf_port_id']] = dbFetchRow('SELECT * FROM `ospf_ports` WHERE `device_id` = ? AND `ospf_port_id` = ?', array($device['device_id'], $ospf_port_id)); + } } -if ($debug) -{ - echo("\nPolled: "); - print_r($ospf_ports_poll); - echo("Database: "); - print_r($ospf_ports_db); - echo("\n"); +if ($debug) { + echo "\nPolled: "; + print_r($ospf_ports_poll); + echo 'Database: '; + print_r($ospf_ports_db); + echo "\n"; } // Loop array of entries and update -if (is_array($ospf_ports_db)) -{ - foreach ($ospf_ports_db as $ospf_port_id => $ospf_port_db) - { - if (is_array($ospf_ports_poll[$ospf_port_db['ospf_port_id']])) - { - $ospf_port_poll = $ospf_ports_poll[$ospf_port_db['ospf_port_id']]; +if (is_array($ospf_ports_db)) { + foreach ($ospf_ports_db as $ospf_port_id => $ospf_port_db) { + if (is_array($ospf_ports_poll[$ospf_port_db['ospf_port_id']])) { + $ospf_port_poll = $ospf_ports_poll[$ospf_port_db['ospf_port_id']]; - if ($ospf_port_poll['ospfAddressLessIf']) - { - $ospf_port_poll['port_id'] = @dbFetchCell("SELECT `port_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ospf_port_poll['ospfAddressLessIf'])); - } else { - $ospf_port_poll['port_id'] = @dbFetchCell("SELECT A.`port_id` FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND I.device_id = ?", array($ospf_port_poll['ospfIfIpAddress'], $device['device_id'])); - } + if ($ospf_port_poll['ospfAddressLessIf']) { + $ospf_port_poll['port_id'] = @dbFetchCell('SELECT `port_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $ospf_port_poll['ospfAddressLessIf'])); + } + else { + $ospf_port_poll['port_id'] = @dbFetchCell('SELECT A.`port_id` FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND I.device_id = ?', array($ospf_port_poll['ospfIfIpAddress'], $device['device_id'])); + } - foreach ($ospf_port_oids as $oid) - { // Loop the OIDs - if ($ospf_port_db[$oid] != $ospf_port_poll[$oid]) - { // If data has changed, build a query - $ospf_port_update[$oid] = $ospf_port_poll[$oid]; - #log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['port_id']); // FIXME + foreach ($ospf_port_oids as $oid) { + // Loop the OIDs + if ($ospf_port_db[$oid] != $ospf_port_poll[$oid]) { + // If data has changed, build a query + $ospf_port_update[$oid] = $ospf_port_poll[$oid]; + // log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['port_id']); // FIXME + } + } + + if ($ospf_port_update) { + dbUpdate($ospf_port_update, 'ospf_ports', '`device_id` = ? AND `ospf_port_id` = ?', array($device['device_id'], $ospf_port_id)); + echo 'U'; + unset($ospf_port_update); + } + else { + echo '.'; + } + + unset($ospf_port_poll); + unset($ospf_port_db); + $ospf_port_count++; } - } - if ($ospf_port_update) - { - dbUpdate($ospf_port_update, 'ospf_ports', '`device_id` = ? AND `ospf_port_id` = ?', array($device['device_id'], $ospf_port_id)); - echo("U"); - unset($ospf_port_update); - } else { - echo("."); - } - unset($ospf_port_poll); - unset($ospf_port_db); - $ospf_port_count++; - } else { - dbDelete('ospf_ports', '`device_id` = ? AND `ospf_port_id` = ?', array($device['device_id'], $ospf_port_db['ospf_port_id'])); - # "DELETE FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_db['ospf_port_id']."'"); - echo("-"); - } - } -} + else { + dbDelete('ospf_ports', '`device_id` = ? AND `ospf_port_id` = ?', array($device['device_id'], $ospf_port_db['ospf_port_id'])); + // "DELETE FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_db['ospf_port_id']."'"); + echo '-'; + }//end if + }//end foreach +}//end if -#OSPF-MIB::ospfNbrIpAddr.172.22.203.98.0 172.22.203.98 -#OSPF-MIB::ospfNbrAddressLessIndex.172.22.203.98.0 0 -#OSPF-MIB::ospfNbrRtrId.172.22.203.98.0 172.22.203.128 -#OSPF-MIB::ospfNbrOptions.172.22.203.98.0 2 -#OSPF-MIB::ospfNbrPriority.172.22.203.98.0 0 -#OSPF-MIB::ospfNbrState.172.22.203.98.0 full -#OSPF-MIB::ospfNbrEvents.172.22.203.98.0 6 -#OSPF-MIB::ospfNbrLsRetransQLen.172.22.203.98.0 1 -#OSPF-MIB::ospfNbmaNbrStatus.172.22.203.98.0 active -#OSPF-MIB::ospfNbmaNbrPermanence.172.22.203.98.0 dynamic -#OSPF-MIB::ospfNbrHelloSuppressed.172.22.203.98.0 false +// OSPF-MIB::ospfNbrIpAddr.172.22.203.98.0 172.22.203.98 +// OSPF-MIB::ospfNbrAddressLessIndex.172.22.203.98.0 0 +// OSPF-MIB::ospfNbrRtrId.172.22.203.98.0 172.22.203.128 +// OSPF-MIB::ospfNbrOptions.172.22.203.98.0 2 +// OSPF-MIB::ospfNbrPriority.172.22.203.98.0 0 +// OSPF-MIB::ospfNbrState.172.22.203.98.0 full +// OSPF-MIB::ospfNbrEvents.172.22.203.98.0 6 +// OSPF-MIB::ospfNbrLsRetransQLen.172.22.203.98.0 1 +// OSPF-MIB::ospfNbmaNbrStatus.172.22.203.98.0 active +// OSPF-MIB::ospfNbmaNbrPermanence.172.22.203.98.0 dynamic +// OSPF-MIB::ospfNbrHelloSuppressed.172.22.203.98.0 false +echo ' Neighbours: '; -echo(' Neighbours: '); - -$ospf_nbr_oids_db = array('ospfNbrIpAddr', 'ospfNbrAddressLessIndex', 'ospfNbrRtrId', 'ospfNbrOptions', 'ospfNbrPriority', 'ospfNbrState', 'ospfNbrEvents', 'ospfNbrLsRetransQLen', 'ospfNbmaNbrStatus', 'ospfNbmaNbrPermanence', 'ospfNbrHelloSuppressed'); +$ospf_nbr_oids_db = array( + 'ospfNbrIpAddr', + 'ospfNbrAddressLessIndex', + 'ospfNbrRtrId', + 'ospfNbrOptions', + 'ospfNbrPriority', + 'ospfNbrState', + 'ospfNbrEvents', + 'ospfNbrLsRetransQLen', + 'ospfNbmaNbrStatus', + 'ospfNbmaNbrPermanence', + 'ospfNbrHelloSuppressed', +); $ospf_nbr_oids_rrd = array(); -$ospf_nbr_oids = array_merge($ospf_nbr_oids_db, $ospf_nbr_oids_rrd); +$ospf_nbr_oids = array_merge($ospf_nbr_oids_db, $ospf_nbr_oids_rrd); // Build array of existing entries -foreach (dbFetchRows("SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?", array($device['device_id'])) as $nbr_entry) -{ - $ospf_nbrs_db[$nbr_entry['ospf_nbr_id']] = $nbr_entry; +foreach (dbFetchRows('SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?', array($device['device_id'])) as $nbr_entry) { + $ospf_nbrs_db[$nbr_entry['ospf_nbr_id']] = $nbr_entry; } // Pull data from device -$ospf_nbrs_poll = snmpwalk_cache_oid($device, "OSPF-MIB::ospfNbrEntry", array(), "OSPF-MIB"); +$ospf_nbrs_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfNbrEntry', array(), 'OSPF-MIB'); -foreach ($ospf_nbrs_poll as $ospf_nbr_id => $ospf_nbr) -{ - // If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array - if (!isset($ospf_nbrs_db[$ospf_nbr_id])) - { - dbInsert(array('device_id' => $device['device_id'], 'ospf_nbr_id' => $ospf_nbr_id), 'ospf_nbrs'); - echo("+"); - $entry = dbFetchRow("SELECT * FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` = ?", array($device['device_id'], $ospf_nbr_id)); - $ospf_nbrs_db[$entry['ospf_nbr_id']] = $entry; - } +foreach ($ospf_nbrs_poll as $ospf_nbr_id => $ospf_nbr) { + // If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array + if (!isset($ospf_nbrs_db[$ospf_nbr_id])) { + dbInsert(array('device_id' => $device['device_id'], 'ospf_nbr_id' => $ospf_nbr_id), 'ospf_nbrs'); + echo '+'; + $entry = dbFetchRow('SELECT * FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` = ?', array($device['device_id'], $ospf_nbr_id)); + $ospf_nbrs_db[$entry['ospf_nbr_id']] = $entry; + } } -if ($debug) -{ - echo("\nPolled: "); - print_r($ospf_nbrs_poll); - echo("Database: "); - print_r($ospf_nbrs_db); - echo("\n"); +if ($debug) { + echo "\nPolled: "; + print_r($ospf_nbrs_poll); + echo 'Database: '; + print_r($ospf_nbrs_db); + echo "\n"; } // Loop array of entries and update -if (is_array($ospf_nbrs_db)) -{ - foreach ($ospf_nbrs_db as $ospf_nbr_id => $ospf_nbr_db) - { - if (is_array($ospf_nbrs_poll[$ospf_nbr_db['ospf_nbr_id']])) - { - $ospf_nbr_poll = $ospf_nbrs_poll[$ospf_nbr_db['ospf_nbr_id']]; +if (is_array($ospf_nbrs_db)) { + foreach ($ospf_nbrs_db as $ospf_nbr_id => $ospf_nbr_db) { + if (is_array($ospf_nbrs_poll[$ospf_nbr_db['ospf_nbr_id']])) { + $ospf_nbr_poll = $ospf_nbrs_poll[$ospf_nbr_db['ospf_nbr_id']]; - $ospf_nbr_poll['port_id'] = @dbFetchCell("SELECT A.`port_id` FROM ipv4_addresses AS A, nbrs AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND I.device_id = ?", array($ospf_nbr_poll['ospfNbrIpAddr'], $device['device_id'])); + $ospf_nbr_poll['port_id'] = @dbFetchCell('SELECT A.`port_id` FROM ipv4_addresses AS A, nbrs AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND I.device_id = ?', array($ospf_nbr_poll['ospfNbrIpAddr'], $device['device_id'])); - if ($ospf_nbr_db['port_id'] != $ospf_nbr_poll['port_id']) - { - if ($ospf_nbr_poll['port_id']) { - $ospf_nbr_update = array('port_id' => $ospf_nbr_poll['port_id']); - } else { - $ospf_nbr_update = array('port_id' => array('NULL')); + if ($ospf_nbr_db['port_id'] != $ospf_nbr_poll['port_id']) { + if ($ospf_nbr_poll['port_id']) { + $ospf_nbr_update = array('port_id' => $ospf_nbr_poll['port_id']); + } + else { + $ospf_nbr_update = array('port_id' => array('NULL')); + } + } + + foreach ($ospf_nbr_oids as $oid) { + // Loop the OIDs + if ($debug) { + echo $ospf_nbr_db[$oid].'|'.$ospf_nbr_poll[$oid]."\n"; + } + + if ($ospf_nbr_db[$oid] != $ospf_nbr_poll[$oid]) { + // If data has changed, build a query + $ospf_nbr_update[$oid] = $ospf_nbr_poll[$oid]; + // log_event("$oid -> ".$this_nbr[$oid], $device, 'ospf', $nbr['port_id']); // FIXME + } + } + + if ($ospf_nbr_update) { + dbUpdate($ospf_nbr_update, 'ospf_nbrs', '`device_id` = ? AND `ospf_nbr_id` = ?', array($device['device_id'], $ospf_nbr_id)); + echo 'U'; + unset($ospf_nbr_update); + } + else { + echo '.'; + } + + unset($ospf_nbr_poll); + unset($ospf_nbr_db); + $ospf_nbr_count++; } - } - - foreach ($ospf_nbr_oids as $oid) - { // Loop the OIDs - if ($debug) { echo($ospf_nbr_db[$oid]."|".$ospf_nbr_poll[$oid]."\n"); } - if ($ospf_nbr_db[$oid] != $ospf_nbr_poll[$oid]) - { // If data has changed, build a query - $ospf_nbr_update[$oid] = $ospf_nbr_poll[$oid]; - #log_event("$oid -> ".$this_nbr[$oid], $device, 'ospf', $nbr['port_id']); // FIXME - } - } - if ($ospf_nbr_update) - { - dbUpdate($ospf_nbr_update, 'ospf_nbrs', '`device_id` = ? AND `ospf_nbr_id` = ?', array($device['device_id'], $ospf_nbr_id)); - echo("U"); - unset($ospf_nbr_update); - } else { - echo("."); - } - - unset($ospf_nbr_poll); - unset($ospf_nbr_db); - $ospf_nbr_count++; - } else { - dbDelete('ospf_nbrs', '`device_id` = ? AND `ospf_nbr_id` = ?', array($device['device_id'], $ospf_nbr_db['ospf_nbr_id'])); - echo("-"); - } - } -} + else { + dbDelete('ospf_nbrs', '`device_id` = ? AND `ospf_nbr_id` = ?', array($device['device_id'], $ospf_nbr_db['ospf_nbr_id'])); + echo '-'; + }//end if + }//end foreach +}//end if // Create device-wide statistics RRD +$filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('ospf-statistics.rrd'); -$filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ospf-statistics.rrd"); +if (!is_file($filename)) { + rrdtool_create( + $filename, + '--step 300 \ + DS:instances:GAUGE:600:0:1000000 \ + DS:areas:GAUGE:600:0:1000000 \ + DS:ports:GAUGE:600:0:1000000 \ + DS:neighbours:GAUGE:600:0:1000000 '.$config['rrd_rra'] + ); +} -if (!is_file($filename)) -{ - rrdtool_create($filename, "--step 300 \ - DS:instances:GAUGE:600:0:1000000 \ - DS:areas:GAUGE:600:0:1000000 \ - DS:ports:GAUGE:600:0:1000000 \ - DS:neighbours:GAUGE:600:0:1000000 ".$config['rrd_rra']); - } - -$rrd_update = "N:".$ospf_instance_count.":".$ospf_area_count.":".$ospf_port_count.":".$ospf_neighbour_count; -$ret = rrdtool_update("$filename", $rrd_update); +$rrd_update = 'N:'.$ospf_instance_count.':'.$ospf_area_count.':'.$ospf_port_count.':'.$ospf_neighbour_count; +$ret = rrdtool_update("$filename", $rrd_update); unset($ospf_ports_db); unset($ospf_ports_poll); -echo("\n"); - -?> +echo "\n"; diff --git a/includes/polling/processors/ucd-old.inc.php b/includes/polling/processors/ucd-old.inc.php index bca70b1ec..f37006f24 100644 --- a/includes/polling/processors/ucd-old.inc.php +++ b/includes/polling/processors/ucd-old.inc.php @@ -1,11 +1,8 @@ +$proc = (100 - $idle); diff --git a/includes/polling/ucd-diskio.inc.php b/includes/polling/ucd-diskio.inc.php index 92a3af276..36a8c3a3f 100644 --- a/includes/polling/ucd-diskio.inc.php +++ b/includes/polling/ucd-diskio.inc.php @@ -1,44 +1,47 @@ diff --git a/includes/polling/unix-agent/dmi.inc.php b/includes/polling/unix-agent/dmi.inc.php index 9f8c6d7fc..d03718d08 100644 --- a/includes/polling/unix-agent/dmi.inc.php +++ b/includes/polling/unix-agent/dmi.inc.php @@ -3,12 +3,9 @@ $dmi = $agent_data['dmi']; unset($agent_data['dmi']); -foreach (explode("\n",$dmi) as $line) -{ - list($field,$contents) = explode("=",$line,2); - $agent_data['dmi'][$field] = trim($contents); +foreach (explode("\n", $dmi) as $line) { + list($field,$contents) = explode('=', $line, 2); + $agent_data['dmi'][$field] = trim($contents); } unset($dmi); - -?> \ No newline at end of file diff --git a/includes/polling/unix-agent/hddtemp.inc.php b/includes/polling/unix-agent/hddtemp.inc.php index b4715ac0c..17078e0d0 100644 --- a/includes/polling/unix-agent/hddtemp.inc.php +++ b/includes/polling/unix-agent/hddtemp.inc.php @@ -2,25 +2,26 @@ global $agent_sensors; -include_once("includes/discovery/functions.inc.php"); +require_once 'includes/discovery/functions.inc.php'; -if ($agent_data['haddtemp'] != '|') -{ - $disks = explode('||',trim($agent_data['hddtemp'],'|')); +if ($agent_data['haddtemp'] != '|') { + $disks = explode('||', trim($agent_data['hddtemp'], '|')); - if (count($disks)) - { - echo "hddtemp: "; - foreach ($disks as $disk) - { - list($blockdevice,$descr,$temperature,$unit) = explode('|',$disk,4); - $diskcount++; - discover_sensor($valid['sensor'], 'temperature', $device, '', $diskcount, 'hddtemp', "$blockdevice: $descr", '1', '1', NULL, NULL, NULL, NULL, $temperature, 'agent'); + if (count($disks)) { + echo 'hddtemp: '; + foreach ($disks as $disk) + { + list($blockdevice,$descr,$temperature,$unit) = explode('|', $disk, 4); + $diskcount++; + discover_sensor($valid['sensor'], 'temperature', $device, '', $diskcount, 'hddtemp', "$blockdevice: $descr", '1', '1', null, null, null, null, $temperature, 'agent'); - $agent_sensors['temperature']['hddtemp'][$diskcount] = array('description' => "$blockdevice: $descr", 'current' => $temperature, 'index' => $diskcount); + $agent_sensors['temperature']['hddtemp'][$diskcount] = array( + 'description' => "$blockdevice: $descr", + 'current' => $temperature, + 'index' => $diskcount, + ); + } + + echo "\n"; } - echo "\n"; - } -} - -?> \ No newline at end of file +}//end if diff --git a/includes/port-descr-parser.inc.php b/includes/port-descr-parser.inc.php index 710d8c931..2b0f475aa 100644 --- a/includes/port-descr-parser.inc.php +++ b/includes/port-descr-parser.inc.php @@ -2,32 +2,27 @@ // Very basic parser to parse classic Observium-type schemes. // Parser should populate $port_ifAlias array with type, descr, circuit, speed and notes +unset($port_ifAlias); -unset ($port_ifAlias); +echo $this_port['ifAlias']; -echo($this_port['ifAlias']); +list($type,$descr) = preg_split('/[\:\[\]\{\}\(\)]/', $this_port['ifAlias']); +list(,$circuit) = preg_split('/[\{\}]/', $this_port['ifAlias']); +list(,$notes) = preg_split('/[\(\)]/', $this_port['ifAlias']); +list(,$speed) = preg_split('/[\[\]]/', $this_port['ifAlias']); +$descr = trim($descr); -list($type,$descr) = preg_split("/[\:\[\]\{\}\(\)]/", $this_port['ifAlias']); -list(,$circuit) = preg_split("/[\{\}]/", $this_port['ifAlias']); -list(,$notes) = preg_split("/[\(\)]/", $this_port['ifAlias']); -list(,$speed) = preg_split("/[\[\]]/", $this_port['ifAlias']); -$descr = trim($descr); +if ($type && $descr) { + $type = strtolower($type); + $port_ifAlias['type'] = $type; + $port_ifAlias['descr'] = $descr; + $port_ifAlias['circuit'] = $circuit; + $port_ifAlias['speed'] = $speed; + $port_ifAlias['notes'] = $notes; -if ($type && $descr) -{ - $type = strtolower($type); - $port_ifAlias['type'] = $type; - $port_ifAlias['descr'] = $descr; - $port_ifAlias['circuit'] = $circuit; - $port_ifAlias['speed'] = $speed; - $port_ifAlias['notes'] = $notes; - - if ($debug) - { - print_r($port_ifAlias); - } + if ($debug) { + print_r($port_ifAlias); + } } -unset ($port_type, $port_descr, $port_circuit, $port_notes, $port_speed); - -?> \ No newline at end of file +unset($port_type, $port_descr, $port_circuit, $port_notes, $port_speed); diff --git a/includes/services.inc.php b/includes/services.inc.php index eeacaa870..d94ce09c9 100644 --- a/includes/services.inc.php +++ b/includes/services.inc.php @@ -1,15 +1,14 @@ diff --git a/includes/snom-graphing.php b/includes/snom-graphing.php index 249bab1fe..c6dedfb7f 100644 --- a/includes/snom-graphing.php +++ b/includes/snom-graphing.php @@ -2,36 +2,58 @@ // FIXME not used, do we still need this? -function callsgraphSNOM ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { - global $config; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; - $optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical ,"--alt-autoscale-max", - "-l 0", - "-E", - "--title", $title, - "DEF:call=$database:CALLS:AVERAGE", - "CDEF:calls=call,360,*", - "LINE1.25:calls#FF9900:Calls", - "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:".$config['mono_font']."", - "--font", "AXIS:6:".$config['mono_font']."", - "--font-render-mode", "normal");} +function callsgraphSNOM($rrd, $graph, $from, $to, $width, $height, $title, $vertical) +{ + global $config; - $opts = array_merge($config['rrdgraph_defaults'], $optsa, $optsb); + $database = $config['rrd_dir'].'/'.$rrd; + $imgfile = 'graphs/'."$graph"; + $optsa = array( + '--start', + $from, + '--end', + $to, + '--width', + $width, + '--height', + $height, + '--vertical-label', + $vertical, + '--alt-autoscale-max', + '-l 0', + '-E', + '--title', + $title, + "DEF:call=$database:CALLS:AVERAGE", + 'CDEF:calls=call,360,*', + 'LINE1.25:calls#FF9900:Calls', + '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:'.$config['mono_font'].'', + '--font', + 'AXIS:6:'.$config['mono_font'].'', + '--font-render-mode', + 'normal', + ); + } - $ret = rrd_graph("$imgfile", $opts, count($opts)); + $opts = array_merge($config['rrdgraph_defaults'], $optsa, $optsb); - if ( !is_array($ret) ) { - $err = rrd_error(); - echo("rrd_graph() ERROR: $err\n"); - return FALSE; - } else { - return $imgfile; - } -} + $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; + } + +}//end callsgraphSNOM() diff --git a/includes/static-config.php b/includes/static-config.php index 46b064123..e136a1d74 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -1,5 +1,3 @@ +echo 'Please remove static-config.inc.php from the bottom of your config.php'; diff --git a/includes/vmware_guestid.inc.php b/includes/vmware_guestid.inc.php index 6ed011717..5fcc590f7 100644 --- a/includes/vmware_guestid.inc.php +++ b/includes/vmware_guestid.inc.php @@ -1,100 +1,99 @@ +$config['vmware_guestid']['winNetEnterpriseGuest'] = 'Windows Server 2003, Enterprise Edition'; +$config['vmware_guestid']['winNetStandard64Guest'] = 'Windows Server 2003, Standard Edition (64 bit)'; +$config['vmware_guestid']['winNetStandardGuest'] = 'Windows Server 2003, Standard Edition'; +$config['vmware_guestid']['winNetWebGuest'] = 'Windows Server 2003, Web Edition'; +$config['vmware_guestid']['winNTGuest'] = 'Windows NT 4'; +$config['vmware_guestid']['winVista64Guest'] = 'Windows Vista (64 bit)'; +$config['vmware_guestid']['winVistaGuest'] = 'Windows Vista'; +$config['vmware_guestid']['winXPHomeGuest'] = 'Windows XP Home Edition'; +$config['vmware_guestid']['winXPPro64Guest'] = 'Windows XP Professional Edition (64 bit)'; +$config['vmware_guestid']['winXPProGuest'] = 'Windows XP Professional'; diff --git a/renamehost.php b/renamehost.php index 1178be36a..e1a369eed 100755 --- a/renamehost.php +++ b/renamehost.php @@ -1,7 +1,7 @@ #!/usr/bin/env php * @copyright (C) 2006 - 2012 Adam Armstrong - * */ chdir(dirname($argv[0])); -include("includes/defaults.inc.php"); -include("config.php"); -include("includes/definitions.inc.php"); -include("includes/functions.php"); +require 'includes/defaults.inc.php'; +require 'config.php'; +require 'includes/definitions.inc.php'; +require 'includes/functions.php'; -# Remove a host and all related data from the system - -if ($argv[1] && $argv[2]) -{ - $host = strtolower($argv[1]); - $id = getidbyname($host); - if ($id) - { - $tohost = strtolower($argv[2]); - $toid = getidbyname($tohost); - if ($toid) - { - echo("NOT renamed. New hostname $tohost already exists.\n"); - } else { - renamehost($id, $tohost, 'console'); - echo("Renamed $host\n"); +// Remove a host and all related data from the system +if ($argv[1] && $argv[2]) { + $host = strtolower($argv[1]); + $id = getidbyname($host); + if ($id) { + $tohost = strtolower($argv[2]); + $toid = getidbyname($tohost); + if ($toid) { + echo "NOT renamed. New hostname $tohost already exists.\n"; + } + else { + renamehost($id, $tohost, 'console'); + echo "Renamed $host\n"; + } + } + else { + echo "Host doesn't exist!\n"; } - } else { - echo("Host doesn't exist!\n"); - } } -else -{ - echo("Host Rename Tool\nUsage: ./renamehost.php \n"); +else { + echo "Host Rename Tool\nUsage: ./renamehost.php \n"; } - -?> diff --git a/scripts/geshi-ios.php b/scripts/geshi-ios.php index ab587b511..fbfd63c69 100755 --- a/scripts/geshi-ios.php +++ b/scripts/geshi-ios.php @@ -1,171 +1,173 @@ 'IOS', + 'LANG_NAME' => 'IOS', 'COMMENT_SINGLE' => array(1 => '!'), - 'CASE_KEYWORDS' => GESHI_CAPS_LOWER, - 'OOLANG' => false, - 'NUMBERS' => GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX, - 'KEYWORDS' => array( + 'CASE_KEYWORDS' => GESHI_CAPS_LOWER, + 'OOLANG' => false, + 'NUMBERS' => GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX, + 'KEYWORDS' => array( 1 => array( - 'no', 'shutdown' + 'no', + 'shutdown', ), - # 2 => array( - # 'router', 'interface', 'service', 'config-register', 'upgrade', 'version', 'hostname', 'boot-start-marker', 'boot', 'boot-end-marker', 'enable', 'aaa', 'clock', 'ip', - # 'logging', 'access-list', 'route-map', 'snmp-server', 'mpls', 'speed', 'media-type', 'negotiation', 'timestamps', 'prefix-list', 'network', 'mask', 'unsuppress-map', - # 'neighbor', 'remote-as', 'ebgp-multihop', 'update-source', 'description', 'peer-group', 'policy-map', 'class-map', 'class', 'match', 'access-group', 'bandwidth', 'username', - # 'password', 'send-community', 'next-hop-self', 'route-reflector-client', 'ldp', 'discovery', 'advertise-labels', 'label', 'protocol', 'login', 'debug', 'log', 'duplex', 'router-id', - # 'authentication', 'mode', 'maximum-paths', 'address-family', 'set', 'local-preference', 'community', 'trap-source', 'location', 'host', 'tacacs-server', 'session-id', - # 'flow-export', 'destination', 'source', 'in', 'out', 'permit', 'deny', 'control-plane', 'line', 'con' ,'aux', 'vty', 'access-class', 'ntp', 'server', 'end', 'source-interface', - # 'key', 'chain', 'key-string', 'redundancy', 'match-any', 'queue-limit', 'encapsulation', 'pvc', 'vbr-nrt', 'address', 'bundle-enable', 'atm', 'sonet', 'clns', 'route-cache', - # 'default-information', 'redistribute', 'log-adjacency-changes', 'metric', 'spf-interval', 'prc-interval', 'lsp-refresh-interval', 'max-lsp-lifetime', 'set-overload-bit', - # 'on-startup', 'wait-for-bgp', 'system', 'flash', 'timezone', 'subnet-zero', 'cef', 'flow-cache', 'timeout', 'active', 'domain', 'lookup', 'dhcp', 'use', 'vrf', 'hello', 'interval', - # 'priority', 'ilmi-keepalive', 'buffered', 'debugging', 'fpd', 'secret', 'accounting', 'exec', 'group', 'local', 'recurring', 'source-route', 'call', 'rsvp-sync', 'scripting', - # 'mtu', 'passive-interface', 'area' , 'distribute-list', 'metric-style', 'is-type', 'originate', 'activate', 'both', 'auto-summary', 'synchronization', 'aggregate-address', 'le', 'ge', - # 'bgp-community', 'route', 'exit-address-family', 'standard', 'file', 'verify', 'domain-name', 'domain-lookup', 'route-target', 'export', 'import', 'map', 'rd', 'mfib', 'vtp', 'mls', - # 'hardware-switching', 'replication-mode', 'ingress', 'flow', 'error', 'action', 'slb', 'purge', 'share-global', 'routing', 'traffic-eng', 'tunnels', 'propagate-ttl', 'switchport', 'vlan', - # 'portfast', 'counters', 'max', 'age', 'ethernet', 'evc', 'uni', 'count', 'oam', 'lmi', 'gmt', 'netflow', 'pseudowire-class', 'spanning-tree', 'name', 'circuit-type' - # ), - # 3 => array( - # 'isis', 'ospf', 'eigrp', 'rip', 'igrp', 'bgp', 'ipv4', 'unicast', 'multicast', 'ipv6', 'connected', 'static', 'subnets', 'tcl' - # ), - # 4 => array( - # 'point-to-point', 'aal5snap', 'rj45', 'auto', 'full', 'half', 'precedence', 'percent', 'datetime', 'msec', 'locatime', 'summer-time', 'md5', 'wait-for-bgp', 'wide', - # 'level-1', 'level-2', 'log-neighbor-changes', 'directed-request', 'password-encryption', 'common', 'origin-as', 'bgp-nexthop', 'random-detect', 'localtime', 'sso', 'stm-1', - # 'dot1q', 'isl', 'new-model', 'always', 'summary-only', 'freeze', 'global', 'forwarded', 'access', 'trunk', 'edge', 'transparent' - # ), + // 2 => array( + // 'router', 'interface', 'service', 'config-register', 'upgrade', 'version', 'hostname', 'boot-start-marker', 'boot', 'boot-end-marker', 'enable', 'aaa', 'clock', 'ip', + // 'logging', 'access-list', 'route-map', 'snmp-server', 'mpls', 'speed', 'media-type', 'negotiation', 'timestamps', 'prefix-list', 'network', 'mask', 'unsuppress-map', + // 'neighbor', 'remote-as', 'ebgp-multihop', 'update-source', 'description', 'peer-group', 'policy-map', 'class-map', 'class', 'match', 'access-group', 'bandwidth', 'username', + // 'password', 'send-community', 'next-hop-self', 'route-reflector-client', 'ldp', 'discovery', 'advertise-labels', 'label', 'protocol', 'login', 'debug', 'log', 'duplex', 'router-id', + // 'authentication', 'mode', 'maximum-paths', 'address-family', 'set', 'local-preference', 'community', 'trap-source', 'location', 'host', 'tacacs-server', 'session-id', + // 'flow-export', 'destination', 'source', 'in', 'out', 'permit', 'deny', 'control-plane', 'line', 'con' ,'aux', 'vty', 'access-class', 'ntp', 'server', 'end', 'source-interface', + // 'key', 'chain', 'key-string', 'redundancy', 'match-any', 'queue-limit', 'encapsulation', 'pvc', 'vbr-nrt', 'address', 'bundle-enable', 'atm', 'sonet', 'clns', 'route-cache', + // 'default-information', 'redistribute', 'log-adjacency-changes', 'metric', 'spf-interval', 'prc-interval', 'lsp-refresh-interval', 'max-lsp-lifetime', 'set-overload-bit', + // 'on-startup', 'wait-for-bgp', 'system', 'flash', 'timezone', 'subnet-zero', 'cef', 'flow-cache', 'timeout', 'active', 'domain', 'lookup', 'dhcp', 'use', 'vrf', 'hello', 'interval', + // 'priority', 'ilmi-keepalive', 'buffered', 'debugging', 'fpd', 'secret', 'accounting', 'exec', 'group', 'local', 'recurring', 'source-route', 'call', 'rsvp-sync', 'scripting', + // 'mtu', 'passive-interface', 'area' , 'distribute-list', 'metric-style', 'is-type', 'originate', 'activate', 'both', 'auto-summary', 'synchronization', 'aggregate-address', 'le', 'ge', + // 'bgp-community', 'route', 'exit-address-family', 'standard', 'file', 'verify', 'domain-name', 'domain-lookup', 'route-target', 'export', 'import', 'map', 'rd', 'mfib', 'vtp', 'mls', + // 'hardware-switching', 'replication-mode', 'ingress', 'flow', 'error', 'action', 'slb', 'purge', 'share-global', 'routing', 'traffic-eng', 'tunnels', 'propagate-ttl', 'switchport', 'vlan', + // 'portfast', 'counters', 'max', 'age', 'ethernet', 'evc', 'uni', 'count', 'oam', 'lmi', 'gmt', 'netflow', 'pseudowire-class', 'spanning-tree', 'name', 'circuit-type' + // ), + // 3 => array( + // 'isis', 'ospf', 'eigrp', 'rip', 'igrp', 'bgp', 'ipv4', 'unicast', 'multicast', 'ipv6', 'connected', 'static', 'subnets', 'tcl' + // ), + // 4 => array( + // 'point-to-point', 'aal5snap', 'rj45', 'auto', 'full', 'half', 'precedence', 'percent', 'datetime', 'msec', 'locatime', 'summer-time', 'md5', 'wait-for-bgp', 'wide', + // 'level-1', 'level-2', 'log-neighbor-changes', 'directed-request', 'password-encryption', 'common', 'origin-as', 'bgp-nexthop', 'random-detect', 'localtime', 'sso', 'stm-1', + // 'dot1q', 'isl', 'new-model', 'always', 'summary-only', 'freeze', 'global', 'forwarded', 'access', 'trunk', 'edge', 'transparent' + // ), ), - 'REGEXPS' => array ( - 1 => array( - GESHI_SEARCH => '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', + 'REGEXPS' => array( + 1 => array( + GESHI_SEARCH => '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', GESHI_REPLACE => '\\1', - GESHI_BEFORE => '', + GESHI_BEFORE => '', ), - 2 => array( - GESHI_SEARCH => '(255\.\d{1,3}\.\d{1,3}\.\d{1,3})', + 2 => array( + GESHI_SEARCH => '(255\.\d{1,3}\.\d{1,3}\.\d{1,3})', GESHI_REPLACE => '\\1', - GESHI_BEFORE => '', + GESHI_BEFORE => '', ), - 3 => array( - GESHI_SEARCH => '(source|interface|update-source|router-id) ([A-Za-z0-9\/\:\-\.]+)', + 3 => array( + GESHI_SEARCH => '(source|interface|update-source|router-id) ([A-Za-z0-9\/\:\-\.]+)', GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ', + GESHI_BEFORE => '\\1 ', ), - 4 => array( - GESHI_SEARCH => '(neighbor) ([\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}]+|[a-zA-Z0-9\-\_]+)', + 4 => array( + GESHI_SEARCH => '(neighbor) ([\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}]+|[a-zA-Z0-9\-\_]+)', GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ', + GESHI_BEFORE => '\\1 ', ), - 5 => array( - GESHI_SEARCH => '(distribute-map|access-group|policy-map|class-map\ match-any|ip\ access-list\ extended|match\ community|community-list\ standard|community-list\ expanded|ip\ access-list\ standard|router\ bgp|remote-as|key\ chain|service-policy\ input|service-policy\ output|class|login\ authentication|authentication\ key-chain|username|import\ map|export\ map|domain-name|hostname|route-map|access-class|ip\ vrf\ forwarding|ip\ vrf|vtp\ domain|name|pseudowire-class|pw-class|prefix-list|vrf) ([A-Za-z0-9\-\_\.]+)', + 5 => array( + GESHI_SEARCH => '(distribute-map|access-group|policy-map|class-map\ match-any|ip\ access-list\ extended|match\ community|community-list\ standard|community-list\ expanded|ip\ access-list\ standard|router\ bgp|remote-as|key\ chain|service-policy\ input|service-policy\ output|class|login\ authentication|authentication\ key-chain|username|import\ map|export\ map|domain-name|hostname|route-map|access-class|ip\ vrf\ forwarding|ip\ vrf|vtp\ domain|name|pseudowire-class|pw-class|prefix-list|vrf) ([A-Za-z0-9\-\_\.]+)', GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ', + GESHI_BEFORE => '\\1 ', ), - 6 => array( - GESHI_SEARCH => '(password|key-string|key) ([0-9]) (.+)', + 6 => array( + GESHI_SEARCH => '(password|key-string|key) ([0-9]) (.+)', GESHI_REPLACE => '\\2 \\3', - GESHI_BEFORE => '\\1 ', + GESHI_BEFORE => '\\1 ', ), - 7 => array( - GESHI_SEARCH => '(enable) ([a-z]+) ([0-9]) (.+)', + 7 => array( + GESHI_SEARCH => '(enable) ([a-z]+) ([0-9]) (.+)', GESHI_REPLACE => '\\3 \\4', - GESHI_BEFORE => '\\1 \\2 ', + GESHI_BEFORE => '\\1 \\2 ', ), - 8 => array( - GESHI_SEARCH => '(description|location|contact|remark) (.+)', + 8 => array( + GESHI_SEARCH => '(description|location|contact|remark) (.+)', GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ', + GESHI_BEFORE => '\\1 ', ), - 9 => array( - GESHI_SEARCH => '([0-9\.\_\*]+\:[0-9\.\_\*]+)', + 9 => array( + GESHI_SEARCH => '([0-9\.\_\*]+\:[0-9\.\_\*]+)', GESHI_REPLACE => '\\1', ), 10 => array( - GESHI_SEARCH => '(boot) ([a-z]+) (.+)', + GESHI_SEARCH => '(boot) ([a-z]+) (.+)', GESHI_REPLACE => '\\3', - GESHI_BEFORE => '\\1 \\2 ' + GESHI_BEFORE => '\\1 \\2 ', ), 11 => array( - GESHI_SEARCH => '(net) ([0-9a-z\.]+)', + GESHI_SEARCH => '(net) ([0-9a-z\.]+)', GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ' + GESHI_BEFORE => '\\1 ', ), 12 => array( - GESHI_SEARCH => '(access-list|RO|RW) ([0-9]+)', + GESHI_SEARCH => '(access-list|RO|RW) ([0-9]+)', GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ' + GESHI_BEFORE => '\\1 ', ), 13 => array( - GESHI_SEARCH => '(vlan) ([0-9]+)', + GESHI_SEARCH => '(vlan) ([0-9]+)', GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ' + GESHI_BEFORE => '\\1 ', ), 14 => array( - GESHI_SEARCH => '(encapsulation|speed|duplex|mtu|metric|media-type|negotiation|transport\ input|bgp-community|set\ as-path\ prepend|maximum-prefix|version|local-preference|continue|redistribute|cluster-id|vtp\ mode|label\ protocol|spanning-tree\ mode) (.+)', + GESHI_SEARCH => '(encapsulation|speed|duplex|mtu|metric|media-type|negotiation|transport\ input|bgp-community|set\ as-path\ prepend|maximum-prefix|version|local-preference|continue|redistribute|cluster-id|vtp\ mode|label\ protocol|spanning-tree\ mode) (.+)', GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ' + GESHI_BEFORE => '\\1 ', ), ), 'STYLES' => array( 'REGEXPS' => array( - 0 => 'color: #ff0000;', - 1 => 'color: #0000cc;', # x.x.x.x - 2 => 'color: #000099; font-style: italic', # 255.x.x.x - 3 => 'color: #000000; font-weight: bold; font-style: italic;', # interface xxx - 4 => 'color: #ff0000;', # neighbor x.x.x.x - 5 => 'color: #000099;', # variable names - 6 => 'color: #cc0000;', - 7 => 'color: #cc0000;', # passwords - 8 => 'color: #555555;', # description - 9 => 'color: #990099;', # communities - 10 => 'color: #cc0000; font-style: italic;', # no/shut - 11 => 'color: #000099;', # net numbers - 12 => 'color: #000099;', # acls - 13 => 'color: #000099;', # acls - 14 => 'color: #990099;', # warnings + 0 => 'color: #ff0000;', + 1 => 'color: #0000cc;', + // x.x.x.x + 2 => 'color: #000099; font-style: italic', + // 255.x.x.x + 3 => 'color: #000000; font-weight: bold; font-style: italic;', + // interface xxx + 4 => 'color: #ff0000;', + // neighbor x.x.x.x + 5 => 'color: #000099;', + // variable names + 6 => 'color: #cc0000;', + 7 => 'color: #cc0000;', + // passwords + 8 => 'color: #555555;', + // description + 9 => 'color: #990099;', + // communities + 10 => 'color: #cc0000; font-style: italic;', + // no/shut + 11 => 'color: #000099;', + // net numbers + 12 => 'color: #000099;', + // acls + 13 => 'color: #000099;', + // acls + 14 => 'color: #990099;', + // warnings ), 'KEYWORDS' => array( - 1 => 'color: #cc0000; font-weight: bold;', # no/shut - 2 => 'color: #000000;', # commands - 3 => 'color: #000000; font-weight: bold;', # proto/service - 4 => 'color: #000000;', # options - 5 => 'color: #ff0000;' + 1 => 'color: #cc0000; font-weight: bold;', + // no/shut + 2 => 'color: #000000;', + // commands + 3 => 'color: #000000; font-weight: bold;', + // proto/service + 4 => 'color: #000000;', + // options + 5 => 'color: #ff0000;', ), - 'COMMENTS' => array( - 1 => 'color: #808080; font-style: italic;' - ), - 'ESCAPE_CHAR' => array( - 0 => 'color: #000099; font-weight: bold;' - ), - 'BRACKETS' => array( - 0 => 'color: #66cc66;' - ), - 'STRINGS' => array( - 0 => 'color: #ff0000;' - ), - 'NUMBERS' => array( - 0 => 'color: #cc0000;' - ), - 'METHODS' => array( - 0 => 'color: #006600;' - ), - 'SYMBOLS' => array( - 0 => 'color: #66cc66;' - ), - 'SCRIPT' => array( + 'COMMENTS' => array(1 => 'color: #808080; font-style: italic;'), + 'ESCAPE_CHAR' => array(0 => 'color: #000099; font-weight: bold;'), + 'BRACKETS' => array(0 => 'color: #66cc66;'), + 'STRINGS' => array(0 => 'color: #ff0000;'), + 'NUMBERS' => array(0 => 'color: #cc0000;'), + 'METHODS' => array(0 => 'color: #006600;'), + 'SYMBOLS' => array(0 => 'color: #66cc66;'), + 'SCRIPT' => array( 0 => '', 1 => '', 2 => '', - 3 => '' - ) + 3 => '', + ), - ) + ), ); - -?> \ No newline at end of file diff --git a/snmptrap.php b/snmptrap.php index 049da4c7c..04f6f5de6 100755 --- a/snmptrap.php +++ b/snmptrap.php @@ -10,7 +10,6 @@ * @subpackage snmptraps * @author Adam Armstrong * @copyright (C) 2006 - 2012 Adam Armstrong - * */ ini_set('display_errors', 1); @@ -18,27 +17,30 @@ ini_set('display_startup_errors', 1); ini_set('log_errors', 1); ini_set('error_reporting', E_ALL); -include("includes/defaults.inc.php"); -include("config.php"); -include("includes/definitions.inc.php"); -include("includes/functions.php"); +require 'includes/defaults.inc.php'; +require 'config.php'; +require 'includes/definitions.inc.php'; +require 'includes/functions.php'; -$entry = explode(",", $argv[1]); +$entry = explode(',', $argv[1]); logfile($argv[1]); -#print_r($entry); +// print_r($entry); +$device = @dbFetchRow('SELECT * FROM devices WHERE `hostname` = ?', array($entry['0'])); -$device = @dbFetchRow("SELECT * FROM devices WHERE `hostname` = ?", array($entry['0'])); - -if (!$device['device_id']) -{ - $device = @dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id", array($entry['0'])); +if (!$device['device_id']) { + $device = @dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.port_id = A.port_id', array($entry['0'])); } -if (!$device['device_id']) { exit; } else { } +if (!$device['device_id']) { + exit; +} -$file = $config['install_dir'] . "/includes/snmptrap/".$entry['1'].".inc.php"; -if (is_file($file)) { include("$file"); } else { echo("unknown trap ($file)"); } - -?> +$file = $config['install_dir'].'/includes/snmptrap/'.$entry['1'].'.inc.php'; +if (is_file($file)) { + include "$file"; +} +else { + echo "unknown trap ($file)"; +} diff --git a/upgrade-scripts/fix-port-rrd.php b/upgrade-scripts/fix-port-rrd.php index 9862af1b8..3d95d6860 100755 --- a/upgrade-scripts/fix-port-rrd.php +++ b/upgrade-scripts/fix-port-rrd.php @@ -1,52 +1,56 @@ 1) { + echo (round((($i / $count) * 100), 2)."% \r"); + } +} + + +function getDirectoryTree($outerDir, &$files=array()) +{ + $dirs = array_diff(scandir($outerDir), array( '.', '..' )); + foreach ($dirs as $d) { + if (is_dir($outerDir.'/'.$d)) { + getDirectoryTree($outerDir.'/'.$d, $files); } + else { + if (preg_match('/^[\d]+.rrd$/', $d)) { + array_push($files, preg_replace('/\/+/', '/', $outerDir.'/'.$d)); + } + } + } - echo($count . " Files \n"); - $start = date("U"); - $i = 0; - foreach ($files as $file){ - fixRdd($file); - $i++; - if (date("U") - $start > 1) - echo(round(($i / $count) * 100, 2) . "% \r"); - } + return $files; - function getDirectoryTree( $outerDir, &$files = array()){ - - $dirs = array_diff( scandir( $outerDir ), Array( ".", ".." ) ); - foreach ( $dirs as $d ){ - if (is_dir($outerDir."/".$d) ){ - getDirectoryTree($outerDir.'/'. $d, $files); - }else{ - if (preg_match('/^[\d]+.rrd$/', $d)) - array_push($files, preg_replace('/\/+/', '/', $outerDir.'/'. $d)); - - } - } - return $files; - } +}//end getDirectoryTree() - function fixRdd($file){ - global $config; - global $rrdcached; - $fileC = shell_exec( "{$config['rrdtool']} dump $file $rrdcached" ); +function fixRdd($file) +{ + global $config; + global $rrdcached; + $fileC = shell_exec("{$config['rrdtool']} dump $file $rrdcached"); -#--------------------------------------------------------------------------------------------------------- - -$first = << INDISCARDS DERIVE @@ -54,9 +58,9 @@ $first = << 0.0000000000e+00 1.2500000000e+10 - UNKN - 0.0000000000e+00 - 0 + UNKN + 0.0000000000e+00 + 0 OUTDISCARDS @@ -65,9 +69,9 @@ $first = << 0.0000000000e+00 1.2500000000e+10 - UNKN - 0.0000000000e+00 - 0 + UNKN + 0.0000000000e+00 + 0 INUNKNOWNPROTOS @@ -128,20 +132,18 @@ $first = << FIRST; - - -$second = << - 0.0000000000e+00 - NaN - NaN - 0 + $second = << + 0.0000000000e+00 + NaN + NaN + 0 - - 0.0000000000e+00 - NaN - NaN - 0 + + 0.0000000000e+00 + NaN + NaN + 0 0.0000000000e+00 @@ -173,35 +175,28 @@ $second = << NaN 0 - + SECOND; -$third = << NaN NaN NaN NaN NaN NaN NaN THIRD; + // --------------------------------------------------------------------------------------------------------- + if (!preg_match('/DISCARDS/', $fileC)) { + $fileC = str_replace('', $first, $fileC); + $fileC = str_replace('', $second, $fileC); + $fileC = str_replace('', $third, $fileC); + $tmpfname = tempnam('/tmp', 'OBS'); + file_put_contents($tmpfname, $fileC); + @unlink($file); + $newfile = preg_replace('/(\d+)\.rrd/', 'port-\\1.rrd', $file); + @unlink($newfile); + shell_exec($config['rrdtool']." restore $tmpfname $newfile"); + unlink($tmpfname); + } + +}//end fixRdd() - -#--------------------------------------------------------------------------------------------------------- - if (!preg_match('/DISCARDS/', $fileC)){ - $fileC = str_replace('', $first, $fileC); - $fileC = str_replace('', $second, $fileC); - $fileC = str_replace('', $third, $fileC); - $tmpfname = tempnam("/tmp", "OBS"); - file_put_contents($tmpfname, $fileC); - @unlink($file); - $newfile = preg_replace("/(\d+)\.rrd/", "port-\\1.rrd", $file); - @unlink($newfile); - shell_exec($config['rrdtool'] . " restore $tmpfname $newfile"); - unlink($tmpfname); - - } - - - } - - echo("\n"); - -?> - +echo "\n"; diff --git a/upgrade-scripts/fix-sensor-rrd.php b/upgrade-scripts/fix-sensor-rrd.php index df373de71..e508dbf2d 100755 --- a/upgrade-scripts/fix-sensor-rrd.php +++ b/upgrade-scripts/fix-sensor-rrd.php @@ -1,79 +1,81 @@ 1) - echo(round(($i / $count) * 100, 2) . "% \r"); - } +echo $count." Files \n"; +$start = date('U'); +$i = 0; - function sensor_getDirectoryTree( $outerDir, &$files = array()){ - - $dirs = array_diff( scandir( $outerDir ), Array( ".", ".." ) ); - foreach ( $dirs as $d ){ - if (is_dir($outerDir."/".$d) ){ - sensor_getDirectoryTree($outerDir.'/'. $d, $files); - } else { - if ((preg_match('/^fan-.*.rrd$/', $d)) || - (preg_match('/^current-.*.rrd$/', $d)) || - (preg_match('/^freq-.*.rrd$/', $d)) || - (preg_match('/^humidity-.*.rrd$/', $d)) || - (preg_match('/^volt-.*.rrd$/', $d)) || - (preg_match('/^temp-.*.rrd$/', $d)) ) - array_push($files, preg_replace('/\/+/', '/', $outerDir.'/'. $d)); - - } - } - return $files; - } +foreach ($files as $file) { + sensor_fixRdd($file); + $i++; + if ((date('U') - $start) > 1) { + echo (round((($i / $count) * 100), 2)."% \r"); + } +} - function sensor_fixRdd($file){ - global $config; - global $rrdcached; - $fileC = shell_exec( "{$config['rrdtool']} dump $file $rrdcached"); - if (preg_match('/ fan/', $fileC)) - { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r fan:sensor"); - rename($file,str_replace('/fan-','/fanspeed-',$file)); - } - elseif (preg_match('/ volt/', $fileC)) - { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r volt:sensor"); - rename($file,str_replace('/volt-','/voltage-',$file)); - } - elseif (preg_match('/ current/', $fileC)) - { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r current:sensor"); - } - elseif (preg_match('/ freq/', $fileC)) - { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r freq:sensor"); - rename($file,str_replace('/freq-','/frequency-',$file)); - } - elseif (preg_match('/ humidity/', $fileC)) - { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r humidity:sensor"); - } - elseif (preg_match('/ temp/', $fileC)) - { - shell_exec("{$config['rrdtool']} tune $file $rrdcached -r temp:sensor"); - rename($file,str_replace('/temp-','/temperature-',$file)); - } - } +function sensor_getDirectoryTree($outerDir, &$files=array()) +{ - echo("\n"); + $dirs = array_diff(scandir($outerDir), array( '.', '..' )); + foreach ($dirs as $d) { + if (is_dir($outerDir.'/'.$d)) { + sensor_getDirectoryTree($outerDir.'/'.$d, $files); + } + else { + if ((preg_match('/^fan-.*.rrd$/', $d)) + || (preg_match('/^current-.*.rrd$/', $d)) + || (preg_match('/^freq-.*.rrd$/', $d)) + || (preg_match('/^humidity-.*.rrd$/', $d)) + || (preg_match('/^volt-.*.rrd$/', $d)) + || (preg_match('/^temp-.*.rrd$/', $d)) + ) { + array_push($files, preg_replace('/\/+/', '/', $outerDir.'/'.$d)); + } + } + } -?> + return $files; +} + + +function sensor_fixRdd($file) +{ + global $config; + global $rrdcached; + $fileC = shell_exec("{$config['rrdtool']} dump $file $rrdcached"); + if (preg_match('/ fan/', $fileC)) { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r fan:sensor"); + rename($file, str_replace('/fan-', '/fanspeed-', $file)); + } + else if (preg_match('/ volt/', $fileC)) { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r volt:sensor"); + rename($file, str_replace('/volt-', '/voltage-', $file)); + } + else if (preg_match('/ current/', $fileC)) { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r current:sensor"); + } + else if (preg_match('/ freq/', $fileC)) { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r freq:sensor"); + rename($file, str_replace('/freq-', '/frequency-', $file)); + } + else if (preg_match('/ humidity/', $fileC)) { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r humidity:sensor"); + } + else if (preg_match('/ temp/', $fileC)) { + shell_exec("{$config['rrdtool']} tune $file $rrdcached -r temp:sensor"); + rename($file, str_replace('/temp-', '/temperature-', $file)); + } + +} + + +echo "\n"; From 76636702d76dbd90653ee2c30f5c29d187f67d67 Mon Sep 17 00:00:00 2001 From: Job Snijders Date: Fri, 10 Jul 2015 14:42:54 +0200 Subject: [PATCH 09/43] Remove empty file --- html/pages/configuration.inc.php | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 html/pages/configuration.inc.php diff --git a/html/pages/configuration.inc.php b/html/pages/configuration.inc.php deleted file mode 100644 index a9e8e32dd..000000000 --- a/html/pages/configuration.inc.php +++ /dev/null @@ -1,4 +0,0 @@ - - From fa0d021fec0c8a7e0cc3b429c85d2cf275c9a885 Mon Sep 17 00:00:00 2001 From: Job Snijders Date: Fri, 10 Jul 2015 14:43:21 +0200 Subject: [PATCH 10/43] Remove empty file --- html/pages/device/graphs/laload.inc.php | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 html/pages/device/graphs/laload.inc.php diff --git a/html/pages/device/graphs/laload.inc.php b/html/pages/device/graphs/laload.inc.php deleted file mode 100644 index 62a2de0c8..000000000 --- a/html/pages/device/graphs/laload.inc.php +++ /dev/null @@ -1,3 +0,0 @@ - From e8d830498ca21e9782826394d6fbdd51d518e5b0 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 12 Jul 2015 19:12:04 +0100 Subject: [PATCH 11/43] Updated Mellanox detection to use sysObjectID --- includes/discovery/os/mellanox.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/os/mellanox.inc.php b/includes/discovery/os/mellanox.inc.php index 7400f910b..1b2516e68 100644 --- a/includes/discovery/os/mellanox.inc.php +++ b/includes/discovery/os/mellanox.inc.php @@ -1,7 +1,7 @@ Date: Mon, 13 Jul 2015 16:08:03 +0200 Subject: [PATCH 12/43] Adjust code to Best Practice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Adjust the code I’ve introduced to Scrut and general Best Practice --- html/includes/print-alerts.inc.php | 2 -- html/pages/alert-stats.inc.php | 1 - html/pages/device/alert-stats.inc.php | 1 - includes/discovery/os/barracuda.inc.php | 1 - includes/discovery/os/drac.inc.php | 2 -- includes/discovery/os/ibmnos.inc.php | 1 - includes/discovery/os/ruckuswireless.inc.php | 1 - includes/polling/os/asa.inc.php | 2 -- includes/polling/os/fortigate.inc.php | 2 -- includes/polling/os/ibmnos.inc.php | 1 - includes/polling/os/ruckuswireless.inc.php | 2 -- 11 files changed, 16 deletions(-) diff --git a/html/includes/print-alerts.inc.php b/html/includes/print-alerts.inc.php index 2a6d71a47..dcbab4b3d 100644 --- a/html/includes/print-alerts.inc.php +++ b/html/includes/print-alerts.inc.php @@ -47,5 +47,3 @@ if ($alert_state!='') { } echo(""); - -?> diff --git a/html/pages/alert-stats.inc.php b/html/pages/alert-stats.inc.php index 1fcf43830..d392f1dd2 100644 --- a/html/pages/alert-stats.inc.php +++ b/html/pages/alert-stats.inc.php @@ -10,4 +10,3 @@ * the source code distribution for details. */ require_once('includes/print-graph-alerts.inc.php'); -?> \ No newline at end of file diff --git a/html/pages/device/alert-stats.inc.php b/html/pages/device/alert-stats.inc.php index 1fcf43830..d392f1dd2 100644 --- a/html/pages/device/alert-stats.inc.php +++ b/html/pages/device/alert-stats.inc.php @@ -10,4 +10,3 @@ * the source code distribution for details. */ require_once('includes/print-graph-alerts.inc.php'); -?> \ No newline at end of file diff --git a/includes/discovery/os/barracuda.inc.php b/includes/discovery/os/barracuda.inc.php index a28de36f2..bf5d52445 100644 --- a/includes/discovery/os/barracuda.inc.php +++ b/includes/discovery/os/barracuda.inc.php @@ -14,4 +14,3 @@ if (!$os) { $os = "barracudaloadbalancer"; } } -?> diff --git a/includes/discovery/os/drac.inc.php b/includes/discovery/os/drac.inc.php index 783ba91a1..27e047362 100644 --- a/includes/discovery/os/drac.inc.php +++ b/includes/discovery/os/drac.inc.php @@ -8,5 +8,3 @@ if (!$os) { $os = "drac"; } } - -?> diff --git a/includes/discovery/os/ibmnos.inc.php b/includes/discovery/os/ibmnos.inc.php index 48c6c3dec..707eaebb9 100644 --- a/includes/discovery/os/ibmnos.inc.php +++ b/includes/discovery/os/ibmnos.inc.php @@ -14,4 +14,3 @@ if (!$os) { $os = "ibmnos"; } } -?> diff --git a/includes/discovery/os/ruckuswireless.inc.php b/includes/discovery/os/ruckuswireless.inc.php index edc1c90f9..f12dd5ab2 100644 --- a/includes/discovery/os/ruckuswireless.inc.php +++ b/includes/discovery/os/ruckuswireless.inc.php @@ -14,4 +14,3 @@ if (!$os) { $os = "ruckuswireless"; } } -?> diff --git a/includes/polling/os/asa.inc.php b/includes/polling/os/asa.inc.php index d94ba4a47..d31f35cda 100644 --- a/includes/polling/os/asa.inc.php +++ b/includes/polling/os/asa.inc.php @@ -30,5 +30,3 @@ if (isset($data[1]['entPhysicalModelName']) && $data[1]['entPhysicalModelName'] if (isset($data[1]['entPhysicalSerialNum']) && $data[1]['entPhysicalSerialNum'] != "") { $serial = $data[1]['entPhysicalSerialNum']; } - -?> \ No newline at end of file diff --git a/includes/polling/os/fortigate.inc.php b/includes/polling/os/fortigate.inc.php index e32ca4e69..a53b83dea 100644 --- a/includes/polling/os/fortigate.inc.php +++ b/includes/polling/os/fortigate.inc.php @@ -42,5 +42,3 @@ if (is_numeric($cpu_usage)) rrdtool_update($cpurrd, " N:$cpu_usage"); $graphs['fortigate_cpu'] = TRUE; } - -?> diff --git a/includes/polling/os/ibmnos.inc.php b/includes/polling/os/ibmnos.inc.php index a8cfcaff5..c70e4c518 100644 --- a/includes/polling/os/ibmnos.inc.php +++ b/includes/polling/os/ibmnos.inc.php @@ -39,4 +39,3 @@ if (strpos($sysdescr_value, 'IBM Networking Operating System') !== false) { $version = trim(snmp_get($device, ".1.3.6.1.2.1.47.1.1.1.1.10.1", "-Ovq") , '" '); $serial = trim(snmp_get($device, ".1.3.6.1.2.1.47.1.1.1.1.11.1", "-Ovq") , '" '); } -?> diff --git a/includes/polling/os/ruckuswireless.inc.php b/includes/polling/os/ruckuswireless.inc.php index d864e0b7b..0f5d55c70 100644 --- a/includes/polling/os/ruckuswireless.inc.php +++ b/includes/polling/os/ruckuswireless.inc.php @@ -50,5 +50,3 @@ $ruckus_mibs = array( "ruckusZDWLANAPTable" => "RUCKUS-ZD-WLAN-MIB", ); poll_mibs($ruckus_mibs, $device, $graphs); - -?> From 0436e3c483f45e1486368122900d04f34484d811 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 13 Jul 2015 17:21:07 +0100 Subject: [PATCH 13/43] Added ability to update users passwords --- html/pages/edituser.inc.php | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/html/pages/edituser.inc.php b/html/pages/edituser.inc.php index 6a9a7d283..8abb7a3dd 100644 --- a/html/pages/edituser.inc.php +++ b/html/pages/edituser.inc.php @@ -249,6 +249,17 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } update_user($vars['user_id'],$vars['new_realname'],$vars['new_level'],$vars['can_modify_passwd'],$vars['new_email']); print_message("User has been updated"); + if (!empty($vars['new_pass1']) && $vars['new_pass1'] == $vars['new_pass2'] && passwordscanchange($vars['cur_username'])) { + if (changepassword($vars['cur_username'],$vars['new_pass1']) == 1) { + print_message("User password has been updated"); + } + else { + print_error("Password couldn't be updated"); + } + } + elseif (!empty($vars['new_pass1']) && $vars['new_pass1'] != $vars['new_pass2']) { + print_error("The supplied passwords didn't match so weren't updated"); + } } if(can_update_users() == '1') { @@ -298,6 +309,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); echo("
    +
    @@ -327,8 +339,26 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - -
    +
    "); + +if (passwordscanchange($users_details['username'])) { + echo " +
    + +
    + +
    +
    +
    + +
    + +
    +
    + "; +} + + echo("
    "); +if (!is_dir($config['rrd_dir'])) { + echo "
    RRD Log Directory is missing ({$config['rrd_dir']}). Graphing may fail.
    "; } -if (!is_dir($config['temp_dir'])) -{ - echo("
    Temp Directory is missing ({$config['temp_dir']}). Graphing may fail.
    "); +if (!is_dir($config['temp_dir'])) { + echo "
    Temp Directory is missing ({$config['temp_dir']}). Graphing may fail.
    "; } -if (!is_writable($config['temp_dir'])) -{ - echo("
    Temp Directory is not writable ({$config['tmp_dir']}). Graphing may fail.
    "); +if (!is_writable($config['temp_dir'])) { + echo "
    Temp Directory is not writable ({$config['tmp_dir']}). Graphing may fail.
    "; } // Clear up any old sessions -dbDelete('session', "`session_expiry` < ?", array(time())); +dbDelete('session', '`session_expiry` < ?', array(time())); -if ($vars['page'] == "logout" && $_SESSION['authenticated']) -{ - dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Logged Out'), 'authlog'); - dbDelete('session', "`session_username` = ? AND session_value = ?", array($_SESSION['username'],$_COOKIE['sess_id'])); - unset($_SESSION); - unset($_COOKIE); - setcookie ("sess_id", "", time() - 60*60*24*$config['auth_remember'], "/"); - setcookie ("token", "", time() - 60*60*24*$config['auth_remember'], "/"); - setcookie ("auth", "", time() - 60*60*24*$config['auth_remember'], "/"); - session_destroy(); - $auth_message = "Logged Out"; - header('Location: /'); - exit; +if ($vars['page'] == 'logout' && $_SESSION['authenticated']) { + dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Logged Out'), 'authlog'); + dbDelete('session', '`session_username` = ? AND session_value = ?', array($_SESSION['username'], $_COOKIE['sess_id'])); + unset($_SESSION); + unset($_COOKIE); + setcookie('sess_id', '', (time() - 60 * 60 * 24 * $config['auth_remember']), '/'); + setcookie('token', '', (time() - 60 * 60 * 24 * $config['auth_remember']), '/'); + setcookie('auth', '', (time() - 60 * 60 * 24 * $config['auth_remember']), '/'); + session_destroy(); + $auth_message = 'Logged Out'; + header('Location: /'); + exit; } // We are only interested in login details passed via POST. if (isset($_POST['username']) && isset($_POST['password'])) { - $_SESSION['username'] = mres($_POST['username']); - $_SESSION['password'] = $_POST['password']; -} elseif(isset($_GET['username']) && isset($_GET['password'])) { - $_SESSION['username'] = mres($_GET['username']); - $_SESSION['password'] = $_GET['password']; + $_SESSION['username'] = mres($_POST['username']); + $_SESSION['password'] = $_POST['password']; +} +else if (isset($_GET['username']) && isset($_GET['password'])) { + $_SESSION['username'] = mres($_GET['username']); + $_SESSION['password'] = $_GET['password']; } -if (!isset($config['auth_mechanism'])) -{ - $config['auth_mechanism'] = "mysql"; +if (!isset($config['auth_mechanism'])) { + $config['auth_mechanism'] = 'mysql'; } -if (file_exists('includes/authentication/' . $config['auth_mechanism'] . '.inc.php')) -{ - include_once('includes/authentication/' . $config['auth_mechanism'] . '.inc.php'); +if (file_exists('includes/authentication/'.$config['auth_mechanism'].'.inc.php')) { + include_once 'includes/authentication/'.$config['auth_mechanism'].'.inc.php'; } -else -{ - print_error('ERROR: no valid auth_mechanism defined!'); - exit(); +else { + print_error('ERROR: no valid auth_mechanism defined!'); + exit(); } $auth_success = 0; -if ((isset($_SESSION['username'])) || (isset($_COOKIE['sess_id'],$_COOKIE['token']))) -{ - if ((authenticate($_SESSION['username'],$_SESSION['password'])) || (reauthenticate($_COOKIE['sess_id'],$_COOKIE['token']))) - { - $_SESSION['userlevel'] = get_userlevel($_SESSION['username']); - $_SESSION['user_id'] = get_userid($_SESSION['username']); - if (!$_SESSION['authenticated']) - { - if( $config['twofactor'] === true && !isset($_SESSION['twofactor']) ) { - require_once($config['install_dir'].'/html/includes/authentication/twofactor.lib.php'); - twofactor_auth(); - } - if( !$config['twofactor'] || $_SESSION['twofactor'] ) { - $_SESSION['authenticated'] = true; - dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Logged In'), 'authlog'); - } +if ((isset($_SESSION['username'])) || (isset($_COOKIE['sess_id'],$_COOKIE['token']))) { + if ((authenticate($_SESSION['username'], $_SESSION['password'])) || (reauthenticate($_COOKIE['sess_id'], $_COOKIE['token']))) { + $_SESSION['userlevel'] = get_userlevel($_SESSION['username']); + $_SESSION['user_id'] = get_userid($_SESSION['username']); + if (!$_SESSION['authenticated']) { + if ($config['twofactor'] === true && !isset($_SESSION['twofactor'])) { + include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; + twofactor_auth(); + } + + if (!$config['twofactor'] || $_SESSION['twofactor']) { + $_SESSION['authenticated'] = true; + dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Logged In'), 'authlog'); + } + } + + if (isset($_POST['remember'])) { + $sess_id = session_id(); + $hasher = new PasswordHash(8, false); + $token = strgen(); + $auth = strgen(); + $hasher = new PasswordHash(8, false); + $token_id = $_SESSION['username'].'|'.$hasher->HashPassword($_SESSION['username'].$token); + // If we have been asked to remember the user then set the relevant cookies and create a session in the DB. + setcookie('sess_id', $sess_id, (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true); + setcookie('token', $token_id, (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true); + setcookie('auth', $auth, (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true); + dbInsert(array('session_username' => $_SESSION['username'], 'session_value' => $sess_id, 'session_token' => $token, 'session_auth' => $auth, 'session_expiry' => time() + 60 * 60 * 24 * $config['auth_remember']), 'session'); + } + + if (isset($_COOKIE['sess_id'],$_COOKIE['token'],$_COOKIE['auth'])) { + // If we have the remember me cookies set then update session expiry times to keep us logged in. + $sess_id = session_id(); + dbUpdate(array('session_value' => $sess_id, 'session_expiry' => time() + 60 * 60 * 24 * $config['auth_remember']), 'session', 'session_auth=?', array($_COOKIE['auth'])); + setcookie('sess_id', $sess_id, (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true); + setcookie('token', $_COOKIE['token'], (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true); + setcookie('auth', $_COOKIE['auth'], (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true); + } + + $permissions = permissions_cache($_SESSION['user_id']); + if (isset($_POST['username'])) { + header('Location: '.$_SERVER['REQUEST_URI'], true, 303); + exit; + } } - if (isset($_POST['remember'])) - { - $sess_id = session_id(); - $hasher = new PasswordHash(8, FALSE); - $token = strgen(); - $auth = strgen(); - $hasher = new PasswordHash(8, FALSE); - $token_id = $_SESSION['username'].'|'.$hasher->HashPassword($_SESSION['username'].$token); - // If we have been asked to remember the user then set the relevant cookies and create a session in the DB. - setcookie("sess_id", $sess_id, time()+60*60*24*$config['auth_remember'], "/", null, false, true); - setcookie("token", $token_id, time()+60*60*24*$config['auth_remember'], "/", null, false, true); - setcookie("auth", $auth, time()+60*60*24*$config['auth_remember'], "/", null, false, true); - dbInsert(array('session_username' => $_SESSION['username'], 'session_value' => $sess_id, 'session_token' => $token, 'session_auth' => $auth, 'session_expiry' => time()+60*60*24*$config['auth_remember']), 'session'); + else if (isset($_SESSION['username'])) { + $auth_message = 'Authentication Failed'; + unset($_SESSION['authenticated']); + dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Authentication Failure'), 'authlog'); } - if (isset($_COOKIE['sess_id'],$_COOKIE['token'],$_COOKIE['auth'])) - { - // If we have the remember me cookies set then update session expiry times to keep us logged in. - $sess_id = session_id(); - dbUpdate(array('session_value' => $sess_id, 'session_expiry' => time()+60*60*24*$config['auth_remember']), 'session', 'session_auth=?', array($_COOKIE['auth'])); - setcookie("sess_id", $sess_id, time()+60*60*24*$config['auth_remember'], "/", null, false, true); - setcookie("token", $_COOKIE['token'], time()+60*60*24*$config['auth_remember'], "/", null, false, true); - setcookie("auth", $_COOKIE['auth'], time()+60*60*24*$config['auth_remember'], "/", null, false, true); - } - $permissions = permissions_cache($_SESSION['user_id']); - if (isset($_POST['username'])) { - header('Location: '.$_SERVER['REQUEST_URI'],TRUE,303); - exit; - } - } - elseif (isset($_SESSION['username'])) - { - $auth_message = "Authentication Failed"; - unset ($_SESSION['authenticated']); - dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Authentication Failure'), 'authlog'); - } } -?> diff --git a/html/includes/authentication/http-auth.inc.php b/html/includes/authentication/http-auth.inc.php index 883cd2d08..221de3adc 100644 --- a/html/includes/authentication/http-auth.inc.php +++ b/html/includes/authentication/http-auth.inc.php @@ -1,104 +1,99 @@ HashPassword($password); return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname), 'users'); - } else { - return FALSE; + } + else { + return false; } } -function user_exists($username) -{ - // FIXME this doesn't seem right? (adama) - return dbFetchCell("SELECT * FROM `users` WHERE `username` = ?", array($username)); + +function user_exists($username) { + // FIXME this doesn't seem right? (adama) + return dbFetchCell('SELECT * FROM `users` WHERE `username` = ?', array($username)); } -function get_userlevel($username) -{ - return dbFetchCell("SELECT `level` FROM `users` WHERE `username`= ?", array($username)); + +function get_userlevel($username) { + return dbFetchCell('SELECT `level` FROM `users` WHERE `username`= ?', array($username)); } -function get_userid($username) -{ - return dbFetchCell("SELECT `user_id` FROM `users` WHERE `username`= ?", array($username)); + +function get_userid($username) { + return dbFetchCell('SELECT `user_id` FROM `users` WHERE `username`= ?', array($username)); } -function deluser($username) -{ - # Not supported - return 0; + +function deluser($username) { + // Not supported + return 0; } -function get_userlist() -{ - return dbFetchRows("SELECT * FROM `users`"); + +function get_userlist() { + return dbFetchRows('SELECT * FROM `users`'); } -function can_update_users() -{ - # supported so return 1 - return 1; + +function can_update_users() { + // supported so return 1 + return 1; } -function get_user($user_id) -{ - return dbFetchRow("SELECT * FROM `users` WHERE `user_id` = ?", array($user_id)); + +function get_user($user_id) { + return dbFetchRow('SELECT * FROM `users` WHERE `user_id` = ?', array($user_id)); } -function update_user($user_id,$realname,$level,$can_modify_passwd,$email) -{ - dbUpdate(array('realname' => $realname, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'email' => $email), 'users', '`user_id` = ?', array($user_id)); -} -?> +function update_user($user_id, $realname, $level, $can_modify_passwd, $email) { + dbUpdate(array('realname' => $realname, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'email' => $email), 'users', '`user_id` = ?', array($user_id)); +} diff --git a/html/includes/authentication/ldap.inc.php b/html/includes/authentication/ldap.inc.php index c0416ab0f..c55b54009 100644 --- a/html/includes/authentication/ldap.inc.php +++ b/html/includes/authentication/ldap.inc.php @@ -1,228 +1,237 @@ Fatal error: LDAP TLS required but not successfully negotiated:" . ldap_error($ds) . ""); - exit; - } +if ($config['auth_ldap_starttls'] && ($config['auth_ldap_starttls'] == 'optional' || $config['auth_ldap_starttls'] == 'require')) { + $tls = ldap_start_tls($ds); + if ($config['auth_ldap_starttls'] == 'require' && $tls == false) { + echo '

    Fatal error: LDAP TLS required but not successfully negotiated:'.ldap_error($ds).'

    '; + exit; + } } -function authenticate($username,$password) -{ - global $config, $ds; - - if ($username && $ds) - { - if ($config['auth_ldap_version']) - { - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']); + +function authenticate($username, $password) { + global $config, $ds; + + if ($username && $ds) { + if ($config['auth_ldap_version']) { + ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']); + } + + if (ldap_bind($ds, $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'], $password)) { + if (!$config['auth_ldap_group']) { + return 1; + } + else { + $ldap_groups = get_group_list(); + foreach ($ldap_groups as $ldap_group) { + $ldap_comparison = ldap_compare( + $ds, + $ldap_group, + $config['auth_ldap_groupmemberattr'], + get_membername($username) + ); + if ($ldap_comparison === true) { + return 1; + } + } + } + } + else { + echo ldap_error($ds); + } } - if (ldap_bind($ds, $config['auth_ldap_prefix'] . $username . $config['auth_ldap_suffix'], $password)) - { - if (!$config['auth_ldap_group']) - { + else { + // FIXME return a warning that LDAP couldn't connect? + } + + return 0; + +} + + +function reauthenticate($sess_id, $token) { + return 0; + +} + + +function passwordscanchange($username='') { + return 0; + +} + + +function changepassword($username, $newpassword) { + // Not supported (for now) + +} + + +function auth_usermanagement() { + return 0; + +} + + +function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd='1') { + // Not supported + return 0; + +} + + +function user_exists($username) { + global $config, $ds; + + $filter = '('.$config['auth_ldap_prefix'].$username.')'; + $search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter); + $entries = ldap_get_entries($ds, $search); + if ($entries['count']) { return 1; - } - else - { - $ldap_groups = get_group_list(); - foreach($ldap_groups as $ldap_group) { - $ldap_comparison = ldap_compare($ds, - $ldap_group, - $config['auth_ldap_groupmemberattr'], - get_membername($username)); - if($ldap_comparison === true) { - return 1; - } + } + + return 0; + +} + + +function get_userlevel($username) { + global $config, $ds; + + $userlevel = 0; + + // Find all defined groups $username is in + $filter = '(&(|(cn='.join(')(cn=', array_keys($config['auth_ldap_groups'])).'))('.$config['auth_ldap_groupmemberattr'].'='.get_membername($username).'))'; + $search = ldap_search($ds, $config['auth_ldap_groupbase'], $filter); + $entries = ldap_get_entries($ds, $search); + + // Loop the list and find the highest level + foreach ($entries as $entry) { + $groupname = $entry['cn'][0]; + if ($config['auth_ldap_groups'][$groupname]['level'] > $userlevel) { + $userlevel = $config['auth_ldap_groups'][$groupname]['level']; } - } } - else - { - echo(ldap_error($ds)); + + return $userlevel; + +} + + +function get_userid($username) { + global $config, $ds; + + $filter = '('.$config['auth_ldap_prefix'].$username.')'; + $search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter); + $entries = ldap_get_entries($ds, $search); + + if ($entries['count']) { + return $entries[0]['uidnumber'][0]; } - } - else - { - // FIXME return a warning that LDAP couldn't connect? - } - return 0; + return -1; + } -function reauthenticate($sess_id,$token) -{ - return 0; + +function deluser($username) { + // Not supported + return 0; + } -function passwordscanchange($username = "") -{ - return 0; -} -function changepassword($username,$newpassword) -{ - # Not supported (for now) -} +function get_userlist() { + global $config, $ds; + $userlist = array(); -function auth_usermanagement() -{ - return 0; -} + $filter = '('.$config['auth_ldap_prefix'].'*)'; -function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd = '1') -{ - # Not supported - return 0; -} + $search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter); + $entries = ldap_get_entries($ds, $search); -function user_exists($username) -{ - global $config, $ds; - - $filter = "(" . $config['auth_ldap_prefix'] . $username . ")"; - $search = ldap_search($ds, trim($config['auth_ldap_suffix'],','), $filter); - $entries = ldap_get_entries($ds, $search); - if ($entries['count']) - { - return 1; - } - - return 0; -} - -function get_userlevel($username) -{ - global $config, $ds; - - $userlevel = 0; - - # Find all defined groups $username is in - $filter = "(&(|(cn=" . join(")(cn=", array_keys($config['auth_ldap_groups'])) . "))(". $config['auth_ldap_groupmemberattr']. "=" . get_membername($username) . "))"; - $search = ldap_search($ds, $config['auth_ldap_groupbase'], $filter); - $entries = ldap_get_entries($ds, $search); - - # Loop the list and find the highest level - foreach ($entries as $entry) - { - $groupname = $entry['cn'][0]; - if ($config['auth_ldap_groups'][$groupname]['level'] > $userlevel) - { - $userlevel = $config['auth_ldap_groups'][$groupname]['level']; - } - } - - return $userlevel; -} - -function get_userid($username) -{ - global $config, $ds; - - $filter = "(" . $config['auth_ldap_prefix'] . $username . ")"; - $search = ldap_search($ds, trim($config['auth_ldap_suffix'],','), $filter); - $entries = ldap_get_entries($ds, $search); - - if ($entries['count']) - { - return $entries[0]['uidnumber'][0]; - } - - return -1; -} - -function deluser($username) -{ - # Not supported - return 0; -} - -function get_userlist() -{ - global $config, $ds; - $userlist = array(); - - $filter = '(' . $config['auth_ldap_prefix'] . '*)'; - - $search = ldap_search($ds, trim($config['auth_ldap_suffix'],','), $filter); - $entries = ldap_get_entries($ds, $search); - - if ($entries['count']) - { - foreach ($entries as $entry) - { - $username = $entry['uid'][0]; - $realname = $entry['cn'][0]; - $user_id = $entry['uidnumber'][0]; - $email = $entry[$config['auth_ldap_emailattr']][0]; - $ldap_groups = get_group_list(); - foreach($ldap_groups as $ldap_group) { - $ldap_comparison = ldap_compare($ds, - $ldap_group, - $config['auth_ldap_groupmemberattr'], - get_membername($username)); - if (!isset($config['auth_ldap_group']) || $ldap_comparison === true) { - $userlist[] = array('username' => $username, 'realname' => $realname, 'user_id' => $user_id, 'email' => $email); + if ($entries['count']) { + foreach ($entries as $entry) { + $username = $entry['uid'][0]; + $realname = $entry['cn'][0]; + $user_id = $entry['uidnumber'][0]; + $email = $entry[$config['auth_ldap_emailattr']][0]; + $ldap_groups = get_group_list(); + foreach ($ldap_groups as $ldap_group) { + $ldap_comparison = ldap_compare( + $ds, + $ldap_group, + $config['auth_ldap_groupmemberattr'], + get_membername($username) + ); + if (!isset($config['auth_ldap_group']) || $ldap_comparison === true) { + $userlist[] = array( + 'username' => $username, + 'realname' => $realname, + 'user_id' => $user_id, + 'email' => $email, + ); + } + } } - } } - } - - return $userlist; + return $userlist; } -function can_update_users() -{ - # not supported so return 0 - return 0; + +function can_update_users() { + // not supported so return 0 + return 0; + } -function get_user($user_id) -{ - # not supported - return 0; + +function get_user($user_id) { + // not supported + return 0; + } -function update_user($user_id,$realname,$level,$can_modify_passwd,$email) -{ - # not supported - return 0; + +function update_user($user_id, $realname, $level, $can_modify_passwd, $email) { + // not supported + return 0; + } -function get_membername ($username) -{ - global $config; - if ($config['auth_ldap_groupmembertype'] == "fulldn") - { - $membername = $config['auth_ldap_prefix'] . $username . $config['auth_ldap_suffix']; - } - else - { - $membername = $username; - } - return $membername; + +function get_membername($username) { + global $config; + if ($config['auth_ldap_groupmembertype'] == 'fulldn') { + $membername = $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix']; + } + else { + $membername = $username; + } + + return $membername; + } + function get_group_list() { - global $config; + global $config; - $ldap_groups = array(); - $default_group = 'cn=groupname,ou=groups,dc=example,dc=com'; - if(isset($config['auth_ldap_group'])) { - if($config['auth_ldap_group'] !== $default_group) { - $ldap_groups[] = $config['auth_ldap_group']; + $ldap_groups = array(); + $default_group = 'cn=groupname,ou=groups,dc=example,dc=com'; + if (isset($config['auth_ldap_group'])) { + if ($config['auth_ldap_group'] !== $default_group) { + $ldap_groups[] = $config['auth_ldap_group']; + } } - } - foreach($config['auth_ldap_groups'] as $key => $value) { - $dn = "cn=$key," . $config['auth_ldap_groupbase']; - $ldap_groups[] = $dn; - } - return $ldap_groups; -} -?> + foreach ($config['auth_ldap_groups'] as $key => $value) { + $dn = "cn=$key,".$config['auth_ldap_groupbase']; + $ldap_groups[] = $dn; + } + + return $ldap_groups; + +} diff --git a/html/includes/authentication/mysql.inc.php b/html/includes/authentication/mysql.inc.php index cf91f27c2..84e119cea 100644 --- a/html/includes/authentication/mysql.inc.php +++ b/html/includes/authentication/mysql.inc.php @@ -1,71 +1,69 @@ CheckPassword($password, $row['password'])) - { - return 1; - } - } - return 0; -} -function reauthenticate($sess_id,$token) -{ - list($uname,$hash) = explode("|",$token); - $session = dbFetchRow("SELECT * FROM `session` WHERE `session_username` = '$uname' AND session_value='$sess_id'"); - $hasher = new PasswordHash(8, FALSE); - if($hasher->CheckPassword($uname.$session['session_token'],$hash)) - { - $_SESSION['username'] = $uname; - return 1; - } - else - { + $hasher = new PasswordHash(8, false); + if ($hasher->CheckPassword($password, $row['password'])) { + return 1; + } + }//end if + return 0; - } -} -function passwordscanchange($username = "") -{ - /* - * By default allow the password to be modified, unless the existing - * user is explicitly prohibited to do so. - */ +}//end authenticate() + + +function reauthenticate($sess_id, $token) { + list($uname,$hash) = explode('|', $token); + $session = dbFetchRow("SELECT * FROM `session` WHERE `session_username` = '$uname' AND session_value='$sess_id'"); + $hasher = new PasswordHash(8, false); + if ($hasher->CheckPassword($uname.$session['session_token'], $hash)) { + $_SESSION['username'] = $uname; + return 1; + } + else { + return 0; + } + +}//end reauthenticate() + + +function passwordscanchange($username='') { + /* + * By default allow the password to be modified, unless the existing + * user is explicitly prohibited to do so. + */ + + if (empty($username) || !user_exists($username)) { + return 1; + } + else { + return dbFetchCell('SELECT can_modify_passwd FROM users WHERE username = ?', array($username)); + } + +}//end passwordscanchange() - if (empty($username) || !user_exists($username)) - { - return 1; - } else { - return dbFetchCell("SELECT can_modify_passwd FROM users WHERE username = ?", array($username)); - } -} /** * From: http://code.activestate.com/recipes/576894-generate-a-salt/ @@ -74,92 +72,98 @@ function passwordscanchange($username = "") * @param $max integer The number of characters in the string * @author AfroSoft */ -function generateSalt($max = 15) -{ - $characterList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - $i = 0; - $salt = ""; - do - { - $salt .= $characterList{mt_rand(0,strlen($characterList))}; - $i++; - } while ($i <= $max); +function generateSalt($max=15) { + $characterList = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $i = 0; + $salt = ''; + do { + $salt .= $characterList{mt_rand(0, strlen($characterList))}; + $i++; + } while ($i <= $max); - return $salt; -} + return $salt; -function changepassword($username,$password) -{ - $hasher = new PasswordHash(8, FALSE); - $encrypted = $hasher->HashPassword($password); - return dbUpdate(array('password' => $encrypted), 'users', '`username` = ?', array($username)); -} +}//end generateSalt() -function auth_usermanagement() -{ - return 1; -} -function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd=1, $description ="", $twofactor=0) -{ - if (!user_exists($username)) - { - $hasher = new PasswordHash(8, FALSE); +function changepassword($username, $password) { + $hasher = new PasswordHash(8, false); $encrypted = $hasher->HashPassword($password); - return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users'); - } else { - return FALSE; - } -} + return dbUpdate(array('password' => $encrypted), 'users', '`username` = ?', array($username)); -function user_exists($username) -{ - $return = @dbFetchCell("SELECT COUNT(*) FROM users WHERE username = ?", array($username)); - return $return; -} +}//end changepassword() -function get_userlevel($username) -{ - return dbFetchCell("SELECT `level` FROM `users` WHERE `username` = ?", array($username)); -} -function get_userid($username) -{ - return dbFetchCell("SELECT `user_id` FROM `users` WHERE `username` = ?", array($username)); -} +function auth_usermanagement() { + return 1; -function deluser($username) -{ +}//end auth_usermanagement() - dbDelete('bill_perms', "`user_name` = ?", array($username)); - dbDelete('devices_perms', "`user_name` = ?", array($username)); - dbDelete('ports_perms', "`user_name` = ?", array($username)); - dbDelete('users_prefs', "`user_name` = ?", array($username)); - dbDelete('users', "`user_name` = ?", array($username)); - return dbDelete('users', "`username` = ?", array($username)); +function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd=1, $description='', $twofactor=0) { + if (!user_exists($username)) { + $hasher = new PasswordHash(8, false); + $encrypted = $hasher->HashPassword($password); + return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users'); + } + else { + return false; + } -} +}//end adduser() -function get_userlist() -{ - return dbFetchRows("SELECT * FROM `users`"); -} -function can_update_users() -{ - # supported so return 1 - return 1; -} +function user_exists($username) { + $return = @dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username)); + return $return; -function get_user($user_id) -{ - return dbFetchRow("SELECT * FROM `users` WHERE `user_id` = ?", array($user_id)); -} +}//end user_exists() -function update_user($user_id,$realname,$level,$can_modify_passwd,$email) -{ - dbUpdate(array('realname' => $realname, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'email' => $email), 'users', '`user_id` = ?', array($user_id)); -} -?> +function get_userlevel($username) { + return dbFetchCell('SELECT `level` FROM `users` WHERE `username` = ?', array($username)); + +}//end get_userlevel() + + +function get_userid($username) { + return dbFetchCell('SELECT `user_id` FROM `users` WHERE `username` = ?', array($username)); + +}//end get_userid() + + +function deluser($username) { + dbDelete('bill_perms', '`user_name` = ?', array($username)); + dbDelete('devices_perms', '`user_name` = ?', array($username)); + dbDelete('ports_perms', '`user_name` = ?', array($username)); + dbDelete('users_prefs', '`user_name` = ?', array($username)); + dbDelete('users', '`user_name` = ?', array($username)); + + return dbDelete('users', '`username` = ?', array($username)); + +}//end deluser() + + +function get_userlist() { + return dbFetchRows('SELECT * FROM `users`'); + +}//end get_userlist() + + +function can_update_users() { + // supported so return 1 + return 1; + +}//end can_update_users() + + +function get_user($user_id) { + return dbFetchRow('SELECT * FROM `users` WHERE `user_id` = ?', array($user_id)); + +}//end get_user() + + +function update_user($user_id, $realname, $level, $can_modify_passwd, $email) { + dbUpdate(array('realname' => $realname, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'email' => $email), 'users', '`user_id` = ?', array($user_id)); + +}//end update_user() diff --git a/html/includes/authentication/twofactor.lib.php b/html/includes/authentication/twofactor.lib.php index 0d54628c9..92f2aea2f 100644 --- a/html/includes/authentication/twofactor.lib.php +++ b/html/includes/authentication/twofactor.lib.php @@ -4,14 +4,15 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ /** * Two-Factor Authentication Library @@ -44,14 +45,14 @@ const otpWindow = 4; * Base32 Decoding dictionary */ $base32 = array( - "A" => 0, "B" => 1, "C" => 2, "D" => 3, - "E" => 4, "F" => 5, "G" => 6, "H" => 7, - "I" => 8, "J" => 9, "K" => 10, "L" => 11, - "M" => 12, "N" => 13, "O" => 14, "P" => 15, - "Q" => 16, "R" => 17, "S" => 18, "T" => 19, - "U" => 20, "V" => 21, "W" => 22, "X" => 23, - "Y" => 24, "Z" => 25, "2" => 26, "3" => 27, - "4" => 28, "5" => 29, "6" => 30, "7" => 31 + "A" => 0, "B" => 1, "C" => 2, "D" => 3, + "E" => 4, "F" => 5, "G" => 6, "H" => 7, + "I" => 8, "J" => 9, "K" => 10, "L" => 11, + "M" => 12, "N" => 13, "O" => 14, "P" => 15, + "Q" => 16, "R" => 17, "S" => 18, "T" => 19, + "U" => 20, "V" => 21, "W" => 22, "X" => 23, + "Y" => 24, "Z" => 25, "2" => 26, "3" => 27, + "4" => 28, "5" => 29, "6" => 30, "7" => 31 ); /** @@ -128,14 +129,16 @@ function oath_hotp($key, $counter=false) { function verify_hotp($key,$otp,$counter=false) { if( oath_hotp($key,$counter) == $otp ) { return true; - } else { + } + else { if( $counter === false ) { //TimeBased HOTP requires lookbehind and lookahead. $counter = floor(microtime(true)/keyInterval); $initcount = $counter-((otpWindow+1)*keyInterval); $endcount = $counter+(otpWindow*keyInterval); $totp = true; - } else { + } + else { //Counter based HOTP only has lookahead, not lookbehind. $initcount = $counter-1; $endcount = $counter+otpWindow; @@ -145,7 +148,8 @@ function verify_hotp($key,$otp,$counter=false) { if( oath_hotp($key,$initcount) == $otp ) { if( !$totp ) { return $initcount; - } else { + } + else { return true; } } @@ -200,23 +204,28 @@ function twofactor_auth() { $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); if( empty($twofactor['twofactor']) ) { $_SESSION['twofactor'] = true; - } else { + } + else { $twofactor = json_decode($twofactor['twofactor'],true); if( $twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time()-$twofactor['last']) < $config['twofactor_lock']) ) { $auth_message = "Too many failures, please ".($config['twofactor_lock'] ? "wait ".$config['twofactor_lock']." seconds" : "contact administrator")."."; - } else { + } + else { if( !$_POST['twofactor'] ) { $twofactorform = true; - } else { + } + else { if( ($server_c = verify_hotp($twofactor['key'],$_POST['twofactor'],$twofactor['counter'])) === false ) { $twofactor['fails']++; $twofactor['last'] = time(); $auth_message = "Wrong Two-Factor Token."; - } else { + } + else { if( $twofactor['counter'] !== false ) { if( $server_c !== true && $server_c !== $twofactor['counter'] ) { $twofactor['counter'] = $server_c+1; - } else { + } + else { $twofactor['counter']++; } } diff --git a/html/includes/collectd/functions.php b/html/includes/collectd/functions.php index d7b44a969..b004f832d 100644 --- a/html/includes/collectd/functions.php +++ b/html/includes/collectd/functions.php @@ -1,4 +1,5 @@ - * @@ -19,7 +20,7 @@ define('REGEXP_HOST', '/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/'); define('REGEXP_PLUGIN', '/^[a-zA-Z0-9_.-]+$/'); -/** +/* * Read input variable from GET, POST or COOKIE taking * care of magic quotes * @name Name of value to return @@ -28,84 +29,114 @@ define('REGEXP_PLUGIN', '/^[a-zA-Z0-9_.-]+$/'); * @return $default if name in unknown in $array, otherwise * input value with magic quotes stripped off */ -function read_var($name, &$array, $default = null) { - if (isset($array[$name])) { - if (is_array($array[$name])) { - if (get_magic_quotes_gpc()) { - $ret = array(); - while (list($k, $v) = each($array[$name])) - $ret[stripslashes($k)] = stripslashes($v); - return $ret; - } else - return $array[$name]; - } else if (is_string($array[$name]) && get_magic_quotes_gpc()) { - return stripslashes($array[$name]); - } else - return $array[$name]; - } else - return $default; -} +function read_var($name, &$array, $default=null) { + if (isset($array[$name])) { + if (is_array($array[$name])) { + if (get_magic_quotes_gpc()) { + $ret = array(); + while (list($k, $v) = each($array[$name])) { + $ret[stripslashes($k)] = stripslashes($v); + } -/** + return $ret; + } + else { + return $array[$name]; + } + } + else if (is_string($array[$name]) && get_magic_quotes_gpc()) { + return stripslashes($array[$name]); + } + else { + return $array[$name]; + } + } + else { + return $default; + } + +}//end read_var() + + +/* * Alphabetically compare host names, comparing label * from tld to node name */ function collectd_compare_host($a, $b) { - $ea = explode('.', $a); - $eb = explode('.', $b); - $i = count($ea) - 1; - $j = count($eb) - 1; - while ($i >= 0 && $j >= 0) - if (($r = strcmp($ea[$i--], $eb[$j--])) != 0) - return $r; - return 0; -} + $ea = explode('.', $a); + $eb = explode('.', $b); + $i = (count($ea) - 1); + $j = (count($eb) - 1); + while ($i >= 0 && $j >= 0) { + if (($r = strcmp($ea[$i--], $eb[$j--])) != 0) { + return $r; + } + } + + return 0; + +}//end collectd_compare_host() + /** * Fetch list of hosts found in collectd's datadirs. * @return Sorted list of hosts (sorted by label from rigth to left) */ function collectd_list_hosts() { - global $config; + global $config; - $hosts = array(); - foreach($config['datadirs'] as $datadir) - if ($d = @opendir($datadir)) { - while (($dent = readdir($d)) !== false) - if ($dent != '.' && $dent != '..' && is_dir($datadir.'/'.$dent) && preg_match(REGEXP_HOST, $dent)) - $hosts[] = $dent; - closedir($d); - } else - error_log('Failed to open datadir: '.$datadir); - $hosts = array_unique($hosts); - usort($hosts, 'collectd_compare_host'); - return $hosts; + $hosts = array(); + foreach($config['datadirs'] as $datadir) { + if ($d = @opendir($datadir)) { + while (($dent = readdir($d)) !== false) { + if ($dent != '.' && $dent != '..' && is_dir($datadir.'/'.$dent) && preg_match(REGEXP_HOST, $dent)) { + $hosts[] = $dent; + } + } + closedir($d); + } + else { + error_log('Failed to open datadir: '.$datadir); + } + } + $hosts = array_unique($hosts); + usort($hosts, 'collectd_compare_host'); + return $hosts; } + /** * Fetch list of plugins found in collectd's datadirs for given host. * @arg_host Name of host for which to return plugins * @return Sorted list of plugins (sorted alphabetically) */ function collectd_list_plugins($arg_host) { - global $config; + global $config; + + $plugins = array(); + foreach ($config['datadirs'] as $datadir) { + if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir.'/'.$arg_host))) { + while (($dent = readdir($d)) !== false) { + if ($dent != '.' && $dent != '..' && is_dir($datadir.'/'.$arg_host.'/'.$dent)) { + if ($i = strpos($dent, '-')) { + $plugins[] = substr($dent, 0, $i); + } + else { + $plugins[] = $dent; + } + } + } + + closedir($d); + } + } + + $plugins = array_unique($plugins); + sort($plugins); + return $plugins; + +}//end collectd_list_plugins() - $plugins = array(); - foreach ($config['datadirs'] as $datadir) - if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir.'/'.$arg_host))) { - while (($dent = readdir($d)) !== false) - if ($dent != '.' && $dent != '..' && is_dir($datadir.'/'.$arg_host.'/'.$dent)) { - if ($i = strpos($dent, '-')) - $plugins[] = substr($dent, 0, $i); - else - $plugins[] = $dent; - } - closedir($d); - } - $plugins = array_unique($plugins); - sort($plugins); - return $plugins; -} /** * Fetch list of plugin instances found in collectd's datadirs for given host+plugin @@ -114,29 +145,38 @@ function collectd_list_plugins($arg_host) { * @return Sorted list of plugin instances (sorted alphabetically) */ function collectd_list_pinsts($arg_host, $arg_plugin) { - global $config; + global $config; + + $pinsts = array(); + foreach ($config['datadirs'] as $datadir) { + if (preg_match(REGEXP_HOST, $arg_host) && ($d = opendir($datadir.'/'.$arg_host))) { + while (($dent = readdir($d)) !== false) { + if ($dent != '.' && $dent != '..' && is_dir($datadir.'/'.$arg_host.'/'.$dent)) { + if ($i = strpos($dent, '-')) { + $plugin = substr($dent, 0, $i); + $pinst = substr($dent, ($i + 1)); + } + else { + $plugin = $dent; + $pinst = ''; + } + + if ($plugin == $arg_plugin) { + $pinsts[] = $pinst; + } + } + } + + closedir($d); + } + }//end foreach + + $pinsts = array_unique($pinsts); + sort($pinsts); + return $pinsts; + +}//end collectd_list_pinsts() - $pinsts = array(); - foreach ($config['datadirs'] as $datadir) - if (preg_match(REGEXP_HOST, $arg_host) && ($d = opendir($datadir.'/'.$arg_host))) { - while (($dent = readdir($d)) !== false) - if ($dent != '.' && $dent != '..' && is_dir($datadir.'/'.$arg_host.'/'.$dent)) { - if ($i = strpos($dent, '-')) { - $plugin = substr($dent, 0, $i); - $pinst = substr($dent, $i+1); - } else { - $plugin = $dent; - $pinst = ''; - } - if ($plugin == $arg_plugin) - $pinsts[] = $pinst; - } - closedir($d); - } - $pinsts = array_unique($pinsts); - sort($pinsts); - return $pinsts; -} /** * Fetch list of types found in collectd's datadirs for given host+plugin+instance @@ -146,28 +186,38 @@ function collectd_list_pinsts($arg_host, $arg_plugin) { * @return Sorted list of types (sorted alphabetically) */ function collectd_list_types($arg_host, $arg_plugin, $arg_pinst) { - global $config; + global $config; + + $types = array(); + $my_plugin = $arg_plugin.(strlen($arg_pinst) ? '-'.$arg_pinst : ''); + if (!preg_match(REGEXP_PLUGIN, $my_plugin)) { + return $types; + } + + foreach ($config['datadirs'] as $datadir) { + if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir.'/'.$arg_host.'/'.$my_plugin))) { + while (($dent = readdir($d)) !== false) { + if ($dent != '.' && $dent != '..' && is_file($datadir.'/'.$arg_host.'/'.$my_plugin.'/'.$dent) && substr($dent, (strlen($dent) - 4)) == '.rrd') { + $dent = substr($dent, 0, (strlen($dent) - 4)); + if ($i = strpos($dent, '-')) { + $types[] = substr($dent, 0, $i); + } + else { + $types[] = $dent; + } + } + } + + closedir($d); + } + } + + $types = array_unique($types); + sort($types); + return $types; + +}//end collectd_list_types() - $types = array(); - $my_plugin = $arg_plugin . (strlen($arg_pinst) ? '-'.$arg_pinst : ''); - if (!preg_match(REGEXP_PLUGIN, $my_plugin)) - return $types; - foreach ($config['datadirs'] as $datadir) - if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir.'/'.$arg_host.'/'.$my_plugin))) { - while (($dent = readdir($d)) !== false) - if ($dent != '.' && $dent != '..' && is_file($datadir.'/'.$arg_host.'/'.$my_plugin.'/'.$dent) && substr($dent, strlen($dent)-4) == '.rrd') { - $dent = substr($dent, 0, strlen($dent)-4); - if ($i = strpos($dent, '-')) - $types[] = substr($dent, 0, $i); - else - $types[] = $dent; - } - closedir($d); - } - $types = array_unique($types); - sort($types); - return $types; -} /** * Fetch list of type instances found in collectd's datadirs for given host+plugin+instance+type @@ -178,33 +228,44 @@ function collectd_list_types($arg_host, $arg_plugin, $arg_pinst) { * @return Sorted list of type instances (sorted alphabetically) */ function collectd_list_tinsts($arg_host, $arg_plugin, $arg_pinst, $arg_type) { - global $config; + global $config; + + $tinsts = array(); + $my_plugin = $arg_plugin.(strlen($arg_pinst) ? '-'.$arg_pinst : ''); + if (!preg_match(REGEXP_PLUGIN, $my_plugin)) { + return $types; + } + + foreach ($config['datadirs'] as $datadir) { + if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir.'/'.$arg_host.'/'.$my_plugin))) { + while (($dent = readdir($d)) !== false) { + if ($dent != '.' && $dent != '..' && is_file($datadir.'/'.$arg_host.'/'.$my_plugin.'/'.$dent) && substr($dent, (strlen($dent) - 4)) == '.rrd') { + $dent = substr($dent, 0, (strlen($dent) - 4)); + if ($i = strpos($dent, '-')) { + $type = substr($dent, 0, $i); + $tinst = substr($dent, ($i + 1)); + } + else { + $type = $dent; + $tinst = ''; + } + + if ($type == $arg_type) { + $tinsts[] = $tinst; + } + } + } + + closedir($d); + } + }//end foreach + + $tinsts = array_unique($tinsts); + sort($tinsts); + return $tinsts; + +}//end collectd_list_tinsts() - $tinsts = array(); - $my_plugin = $arg_plugin . (strlen($arg_pinst) ? '-'.$arg_pinst : ''); - if (!preg_match(REGEXP_PLUGIN, $my_plugin)) - return $types; - foreach ($config['datadirs'] as $datadir) - if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir.'/'.$arg_host.'/'.$my_plugin))) { - while (($dent = readdir($d)) !== false) - if ($dent != '.' && $dent != '..' && is_file($datadir.'/'.$arg_host.'/'.$my_plugin.'/'.$dent) && substr($dent, strlen($dent)-4) == '.rrd') { - $dent = substr($dent, 0, strlen($dent)-4); - if ($i = strpos($dent, '-')) { - $type = substr($dent, 0, $i); - $tinst = substr($dent, $i+1); - } else { - $type = $dent; - $tinst = ''; - } - if ($type == $arg_type) - $tinsts[] = $tinst; - } - closedir($d); - } - $tinsts = array_unique($tinsts); - sort($tinsts); - return $tinsts; -} /** * Parse symlinks in order to get an identifier that collectd understands @@ -219,29 +280,35 @@ function collectd_list_tinsts($arg_host, $arg_plugin, $arg_pinst, $arg_type) { * @return Identifier that collectd's FLUSH command understands */ function collectd_identifier($host, $plugin, $pinst, $type, $tinst) { - global $config; - $rrd_realpath = null; - $orig_identifier = sprintf('%s/%s%s%s/%s%s%s', $host, $plugin, strlen($pinst) ? '-' : '', $pinst, $type, strlen($tinst) ? '-' : '', $tinst); - $identifier = null; - foreach ($config['datadirs'] as $datadir) - if (is_file($datadir.'/'.$orig_identifier.'.rrd')) { - $rrd_realpath = realpath($datadir.'/'.$orig_identifier.'.rrd'); - break; - } - if ($rrd_realpath) { - $identifier = basename($rrd_realpath); - $identifier = substr($identifier, 0, strlen($identifier)-4); - $rrd_realpath = dirname($rrd_realpath); - $identifier = basename($rrd_realpath).'/'.$identifier; - $rrd_realpath = dirname($rrd_realpath); - $identifier = basename($rrd_realpath).'/'.$identifier; - } + global $config; + $rrd_realpath = null; + $orig_identifier = sprintf('%s/%s%s%s/%s%s%s', $host, $plugin, strlen($pinst) ? '-' : '', $pinst, $type, strlen($tinst) ? '-' : '', $tinst); + $identifier = null; + foreach ($config['datadirs'] as $datadir) { + if (is_file($datadir.'/'.$orig_identifier.'.rrd')) { + $rrd_realpath = realpath($datadir.'/'.$orig_identifier.'.rrd'); + break; + } + } + + if ($rrd_realpath) { + $identifier = basename($rrd_realpath); + $identifier = substr($identifier, 0, (strlen($identifier) - 4)); + $rrd_realpath = dirname($rrd_realpath); + $identifier = basename($rrd_realpath).'/'.$identifier; + $rrd_realpath = dirname($rrd_realpath); + $identifier = basename($rrd_realpath).'/'.$identifier; + } + + if (is_null($identifier)) { + return $orig_identifier; + } + else { + return $identifier; + } + +}//end collectd_identifier() - if (is_null($identifier)) - return $orig_identifier; - else - return $identifier; -} /** * Tell collectd that it should FLUSH all data it has regarding the @@ -253,124 +320,178 @@ function collectd_identifier($host, $plugin, $pinst, $type, $tinst) { * @tinst Type instance */ function collectd_flush($identifier) { - global $config; + global $config; - if (!$config['collectd_sock']) - return false; - if (is_null($identifier) || (is_array($identifier) && count($identifier) == 0) || !(is_string($identifier) || is_array($identifier))) - return false; + if (!$config['collectd_sock']) { + return false; + } - if (is_null($host) || !is_string($host) || strlen($host) == 0) - return false; - if (is_null($plugin) || !is_string($plugin) || strlen($plugin) == 0) - return false; - if (is_null($pinst) || !is_string($pinst)) - return false; - if (is_null($type) || !is_string($type) || strlen($type) == 0) - return false; - if (is_null($tinst) || (is_array($tinst) && count($tinst) == 0) || !(is_string($tinst) || is_array($tinst))) - return false; + if (is_null($identifier) || (is_array($identifier) && count($identifier) == 0) || !(is_string($identifier) || is_array($identifier))) { + return false; + } - $u_errno = 0; - $u_errmsg = ''; - if ($socket = @fsockopen($config['collectd_sock'], 0, $u_errno, $u_errmsg)) { - $cmd = 'FLUSH plugin=rrdtool'; - if (is_array($identifier)) { - foreach ($identifier as $val) - $cmd .= sprintf(' identifier="%s"', $val); - } else - $cmd .= sprintf(' identifier="%s"', $identifier); - $cmd .= "\n"; + if (is_null($host) || !is_string($host) || strlen($host) == 0) { + return false; + } - $r = fwrite($socket, $cmd, strlen($cmd)); - if ($r === false || $r != strlen($cmd)) - error_log(sprintf("graph.php: Failed to write whole command to unix-socket: %d out of %d written", $r === false ? -1 : $r, strlen($cmd))); + if (is_null($plugin) || !is_string($plugin) || strlen($plugin) == 0) { + return false; + } - $resp = fgets($socket); - if ($resp === false) - error_log(sprintf("graph.php: Failed to read response from collectd for command: %s", trim($cmd))); + if (is_null($pinst) || !is_string($pinst)) { + return false; + } - $n = (int)$resp; - while ($n-- > 0) - fgets($socket); + if (is_null($type) || !is_string($type) || strlen($type) == 0) { + return false; + } + + if (is_null($tinst) || (is_array($tinst) && count($tinst) == 0) || !(is_string($tinst) || is_array($tinst))) { + return false; + } + + $u_errno = 0; + $u_errmsg = ''; + if ($socket = @fsockopen($config['collectd_sock'], 0, $u_errno, $u_errmsg)) { + $cmd = 'FLUSH plugin=rrdtool'; + if (is_array($identifier)) { + foreach ($identifier as $val) { + $cmd .= sprintf(' identifier="%s"', $val); + } + } + else { + $cmd .= sprintf(' identifier="%s"', $identifier); + } + + $cmd .= "\n"; + + $r = fwrite($socket, $cmd, strlen($cmd)); + if ($r === false || $r != strlen($cmd)) { + error_log(sprintf('graph.php: Failed to write whole command to unix-socket: %d out of %d written', $r === false ? (-1) : $r, strlen($cmd))); + } + + $resp = fgets($socket); + if ($resp === false) { + error_log(sprintf('graph.php: Failed to read response from collectd for command: %s', trim($cmd))); + } + + $n = (int) $resp; + while ($n-- > 0) { + fgets($socket); + } + + fclose($socket); + } //end if + else { + error_log(sprintf('graph.php: Failed to open unix-socket to collectd: %d: %s', $u_errno, $u_errmsg)); + } + +}//end collectd_flush() - fclose($socket); - } else - error_log(sprintf("graph.php: Failed to open unix-socket to collectd: %d: %s", $u_errno, $u_errmsg)); -} class CollectdColor { - private $r = 0; - private $g = 0; - private $b = 0; - function __construct($value = null) { - if (is_null($value)) { - } else if (is_array($value)) { - if (isset($value['r'])) - $this->r = $value['r'] > 0 ? ($value['r'] > 1 ? 1 : $value['r']) : 0; - if (isset($value['g'])) - $this->g = $value['g'] > 0 ? ($value['g'] > 1 ? 1 : $value['g']) : 0; - if (isset($value['b'])) - $this->b = $value['b'] > 0 ? ($value['b'] > 1 ? 1 : $value['b']) : 0; - } else if (is_string($value)) { - $matches = array(); - if ($value == 'random') { - $this->randomize(); - } else if (preg_match('/([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])/', $value, $matches)) { - $this->r = ('0x'.$matches[1]) / 255.0; - $this->g = ('0x'.$matches[2]) / 255.0; - $this->b = ('0x'.$matches[3]) / 255.0; - } - } else if (is_a($value, 'CollectdColor')) { - $this->r = $value->r; - $this->g = $value->g; - $this->b = $value->b; - } - } + private $r = 0; - function randomize() { - $this->r = rand(0, 255) / 255.0; - $this->g = rand(0, 255) / 255.0; - $this->b = 0.0; - $min = 0.0; - $max = 1.0; + private $g = 0; - if (($this->r + $this->g) < 1.0) { - $min = 1.0 - ($this->r + $this->g); - } else { - $max = 2.0 - ($this->r + $this->g); - } - $this->b = $min + ((rand(0, 255)/255.0) * ($max - $min)); - } + private $b = 0; - function fade($bkgnd = null, $alpha = 0.25) { - if (is_null($bkgnd) || !is_a($bkgnd, 'CollectdColor')) { - $bg_r = 1.0; - $bg_g = 1.0; - $bg_b = 1.0; - } else { - $bg_r = $bkgnd->r; - $bg_g = $bkgnd->g; - $bg_b = $bkgnd->b; - } - $this->r = $alpha * $this->r + ((1.0 - $alpha) * $bg_r); - $this->g = $alpha * $this->g + ((1.0 - $alpha) * $bg_g); - $this->b = $alpha * $this->b + ((1.0 - $alpha) * $bg_b); - } + function __construct($value=null) { + if (is_null($value)) { + } + else if (is_array($value)) { + if (isset($value['r'])) { + $this->r = $value['r'] > 0 ? ($value['r'] > 1 ? 1 : $value['r']) : 0; + } - function as_array() { - return array('r'=>$this->r, 'g'=>$this->g, 'b'=>$this->b); - } + if (isset($value['g'])) { + $this->g = $value['g'] > 0 ? ($value['g'] > 1 ? 1 : $value['g']) : 0; + } - function as_string() { - $r = (int)($this->r*255); - $g = (int)($this->g*255); - $b = (int)($this->b*255); - return sprintf('%02x%02x%02x', $r > 255 ? 255 : $r, $g > 255 ? 255 : $g, $b > 255 ? 255 : $b); - } -} + if (isset($value['b'])) { + $this->b = $value['b'] > 0 ? ($value['b'] > 1 ? 1 : $value['b']) : 0; + } + } + else if (is_string($value)) { + $matches = array(); + if ($value == 'random') { + $this->randomize(); + } + else if (preg_match('/([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])/', $value, $matches)) { + $this->r = (('0x'.$matches[1]) / 255.0); + $this->g = (('0x'.$matches[2]) / 255.0); + $this->b = (('0x'.$matches[3]) / 255.0); + } + } + else if (is_a($value, 'CollectdColor')) { + $this->r = $value->r; + $this->g = $value->g; + $this->b = $value->b; + }//end if + + }//end __construct() + + + function randomize() { + $this->r = (rand(0, 255) / 255.0); + $this->g = (rand(0, 255) / 255.0); + $this->b = 0.0; + $min = 0.0; + $max = 1.0; + + if (($this->r + $this->g) < 1.0) { + $min = (1.0 - ($this->r + $this->g)); + } + else { + $max = (2.0 - ($this->r + $this->g)); + } + + $this->b = ($min + ((rand(0, 255) / 255.0) * ($max - $min))); + + }//end randomize() + + + function fade($bkgnd=null, $alpha=0.25) { + if (is_null($bkgnd) || !is_a($bkgnd, 'CollectdColor')) { + $bg_r = 1.0; + $bg_g = 1.0; + $bg_b = 1.0; + } + else { + $bg_r = $bkgnd->r; + $bg_g = $bkgnd->g; + $bg_b = $bkgnd->b; + } + + $this->r = ($alpha * $this->r + ((1.0 - $alpha) * $bg_r)); + $this->g = ($alpha * $this->g + ((1.0 - $alpha) * $bg_g)); + $this->b = ($alpha * $this->b + ((1.0 - $alpha) * $bg_b)); + + }//end fade() + + + function as_array() { + return array( + 'r' => $this->r, + 'g' => $this->g, + 'b' => $this->b, + ); + + }//end as_array() + + + function as_string() { + $r = (int) ($this->r * 255); + $g = (int) ($this->g * 255); + $b = (int) ($this->b * 255); + return sprintf('%02x%02x%02x', $r > 255 ? 255 : $r, $g > 255 ? 255 : $g, $b > 255 ? 255 : $b); + + }//end as_string() + + +}//end class /** @@ -379,11 +500,15 @@ class CollectdColor { * @return String with one surrounding pair of quotes stripped */ function rrd_strip_quotes($str) { - if ($str[0] == '"' && $str[strlen($str)-1] == '"') - return substr($str, 1, strlen($str)-2); - else - return $str; -} + if ($str[0] == '"' && $str[(strlen($str) - 1)] == '"') { + return substr($str, 1, (strlen($str) - 2)); + } + else { + return $str; + } + +}//end rrd_strip_quotes() + /** * Determine useful information about RRD file @@ -391,66 +516,86 @@ function rrd_strip_quotes($str) { * @return Array describing the RRD file */ function rrd_info($file) { - $info = array('filename'=>$file); + $info = array('filename' => $file); - $rrd = popen(RRDTOOL.' info '.escapeshellarg($file), 'r'); - if ($rrd) { - while (($s = fgets($rrd)) !== false) { - $p = strpos($s, '='); - if ($p === false) - continue; - $key = trim(substr($s, 0, $p)); - $value = trim(substr($s, $p+1)); - if (strncmp($key,'ds[', 3) == 0) { - /* DS definition */ - $p = strpos($key, ']'); - $ds = substr($key, 3, $p-3); - if (!isset($info['DS'])) - $info['DS'] = array(); - $ds_key = substr($key, $p+2); + $rrd = popen(RRDTOOL.' info '.escapeshellarg($file), 'r'); + if ($rrd) { + while (($s = fgets($rrd)) !== false) { + $p = strpos($s, '='); + if ($p === false) { + continue; + } - if (strpos($ds_key, '[') === false) { - if (!isset($info['DS']["$ds"])) - $info['DS']["$ds"] = array(); - $info['DS']["$ds"]["$ds_key"] = rrd_strip_quotes($value); - } - } else if (strncmp($key, 'rra[', 4) == 0) { - /* RRD definition */ - $p = strpos($key, ']'); - $rra = substr($key, 4, $p-4); - if (!isset($info['RRA'])) - $info['RRA'] = array(); - $rra_key = substr($key, $p+2); + $key = trim(substr($s, 0, $p)); + $value = trim(substr($s, ($p + 1))); + if (strncmp($key, 'ds[', 3) == 0) { + // DS definition + $p = strpos($key, ']'); + $ds = substr($key, 3, ($p - 3)); + if (!isset($info['DS'])) { + $info['DS'] = array(); + } - if (strpos($rra_key, '[') === false) { - if (!isset($info['RRA']["$rra"])) - $info['RRA']["$rra"] = array(); - $info['RRA']["$rra"]["$rra_key"] = rrd_strip_quotes($value); - } - } else if (strpos($key, '[') === false) { - $info[$key] = rrd_strip_quotes($value); - } - } - pclose($rrd); - } - return $info; -} + $ds_key = substr($key, ($p + 2)); + + if (strpos($ds_key, '[') === false) { + if (!isset($info['DS']["$ds"])) { + $info['DS']["$ds"] = array(); + } + + $info['DS']["$ds"]["$ds_key"] = rrd_strip_quotes($value); + } + } + else if (strncmp($key, 'rra[', 4) == 0) { + // RRD definition + $p = strpos($key, ']'); + $rra = substr($key, 4, ($p - 4)); + if (!isset($info['RRA'])) { + $info['RRA'] = array(); + } + + $rra_key = substr($key, ($p + 2)); + + if (strpos($rra_key, '[') === false) { + if (!isset($info['RRA']["$rra"])) { + $info['RRA']["$rra"] = array(); + } + + $info['RRA']["$rra"]["$rra_key"] = rrd_strip_quotes($value); + } + } + else if (strpos($key, '[') === false) { + $info[$key] = rrd_strip_quotes($value); + }//end if + }//end while + + pclose($rrd); + }//end if + + return $info; + +}//end rrd_info() + + +function rrd_get_color($code, $line=true) { + global $config; + $name = ($line ? 'f_' : 'h_').$code; + if (!isset($config['rrd_colors'][$name])) { + $c_f = new CollectdColor('random'); + $c_h = new CollectdColor($c_f); + $c_h->fade(); + $config['rrd_colors']['f_'.$code] = $c_f->as_string(); + $config['rrd_colors']['h_'.$code] = $c_h->as_string(); + } + + return $config['rrd_colors'][$name]; + +}//end rrd_get_color() -function rrd_get_color($code, $line = true) { - global $config; - $name = ($line ? 'f_' : 'h_').$code; - if (!isset($config['rrd_colors'][$name])) { - $c_f = new CollectdColor('random'); - $c_h = new CollectdColor($c_f); - $c_h->fade(); - $config['rrd_colors']['f_'.$code] = $c_f->as_string(); - $config['rrd_colors']['h_'.$code] = $c_h->as_string(); - } - return $config['rrd_colors'][$name]; -} /** * Draw RRD file based on it's structure + * * @host * @plugin * @pinst @@ -459,116 +604,176 @@ function rrd_get_color($code, $line = true) { * @opts * @return Commandline to call RRDGraph in order to generate the final graph */ -function collectd_draw_rrd($host, $plugin, $pinst = null, $type, $tinst = null, $opts = array()) { - global $config; - $timespan_def = null; - if (!isset($opts['timespan'])) - $timespan_def = reset($config['timespan']); - else foreach ($config['timespan'] as &$ts) - if ($ts['name'] == $opts['timespan']) - $timespan_def = $ts; +function collectd_draw_rrd($host, $plugin, $pinst=null, $type, $tinst=null, $opts=array()) { + global $config; + $timespan_def = null; + if (!isset($opts['timespan'])) { + $timespan_def = reset($config['timespan']); + } + else { + foreach ($config['timespan'] as &$ts) { + if ($ts['name'] == $opts['timespan']) { + $timespan_def = $ts; + } + } + } - if (!isset($opts['rrd_opts'])) - $opts['rrd_opts'] = array(); - if (isset($opts['logarithmic']) && $opts['logarithmic']) - array_unshift($opts['rrd_opts'], '-o'); + if (!isset($opts['rrd_opts'])) { + $opts['rrd_opts'] = array(); + } - $rrdinfo = null; - $rrdfile = sprintf('%s/%s%s%s/%s%s%s', $host, $plugin, is_null($pinst) ? '' : '-', $pinst, $type, is_null($tinst) ? '' : '-', $tinst); - foreach ($config['datadirs'] as $datadir) - if (is_file($datadir.'/'.$rrdfile.'.rrd')) { - $rrdinfo = rrd_info($datadir.'/'.$rrdfile.'.rrd'); - if (isset($rrdinfo['RRA']) && is_array($rrdinfo['RRA'])) - break; - else - $rrdinfo = null; - } + if (isset($opts['logarithmic']) && $opts['logarithmic']) { + array_unshift($opts['rrd_opts'], '-o'); + } - if (is_null($rrdinfo)) - return false; + $rrdinfo = null; + $rrdfile = sprintf('%s/%s%s%s/%s%s%s', $host, $plugin, is_null($pinst) ? '' : '-', $pinst, $type, is_null($tinst) ? '' : '-', $tinst); + foreach ($config['datadirs'] as $datadir) { + if (is_file($datadir.'/'.$rrdfile.'.rrd')) { + $rrdinfo = rrd_info($datadir.'/'.$rrdfile.'.rrd'); + if (isset($rrdinfo['RRA']) && is_array($rrdinfo['RRA'])) { + break; + } + else { + $rrdinfo = null; + } + } + } - $graph = array(); - $has_avg = false; - $has_max = false; - $has_min = false; - reset($rrdinfo['RRA']); - $l_max = 0; - while (list($k, $v) = each($rrdinfo['RRA'])) { - if ($v['cf'] == 'MAX') - $has_max = true; - else if ($v['cf'] == 'AVERAGE') - $has_avg = true; - else if ($v['cf'] == 'MIN') - $has_min = true; - } + if (is_null($rrdinfo)) { + return false; + } - // Build legend. This may not work for all RRDs, i don't know :) - if ($has_avg) - $graph[] = "COMMENT: Last"; - if ($has_min) - $graph[] = "COMMENT: Min"; - if ($has_max) - $graph[] = "COMMENT: Max"; - if ($has_avg) - $graph[] = "COMMENT: Avg\\n"; + $graph = array(); + $has_avg = false; + $has_max = false; + $has_min = false; + reset($rrdinfo['RRA']); + $l_max = 0; + while (list($k, $v) = each($rrdinfo['RRA'])) { + if ($v['cf'] == 'MAX') { + $has_max = true; + } + else if ($v['cf'] == 'AVERAGE') { + $has_avg = true; + } + else if ($v['cf'] == 'MIN') { + $has_min = true; + } + } + // Build legend. This may not work for all RRDs, i don't know :) + if ($has_avg) { + $graph[] = 'COMMENT: Last'; + } - reset($rrdinfo['DS']); - while (list($k, $v) = each($rrdinfo['DS'])) { - if (strlen($k) > $l_max) - $l_max = strlen($k); - if ($has_min) - $graph[] = sprintf('DEF:%s_min=%s:%s:MIN', $k, $rrdinfo['filename'], $k); - if ($has_avg) - $graph[] = sprintf('DEF:%s_avg=%s:%s:AVERAGE', $k, $rrdinfo['filename'], $k); - if ($has_max) - $graph[] = sprintf('DEF:%s_max=%s:%s:MAX', $k, $rrdinfo['filename'], $k); - } - if ($has_min && $has_max || $has_min && $has_avg || $has_avg && $has_max) { - $n = 1; - reset($rrdinfo['DS']); - while (list($k, $v) = each($rrdinfo['DS'])) { - $graph[] = sprintf('LINE:%s_%s', $k, $has_min ? 'min' : 'avg'); - $graph[] = sprintf('CDEF:%s_var=%s_%s,%s_%s,-', $k, $k, $has_max ? 'max' : 'avg', $k, $has_min ? 'min' : 'avg'); - $graph[] = sprintf('AREA:%s_var#%s::STACK', $k, rrd_get_color($n++, false)); - } - } + if ($has_min) { + $graph[] = 'COMMENT: Min'; + } - reset($rrdinfo['DS']); - $n = 1; - while (list($k, $v) = each($rrdinfo['DS'])) { - $graph[] = sprintf('LINE1:%s_avg#%s:%s ', $k, rrd_get_color($n++, true), $k.substr(' ', 0, $l_max-strlen($k))); - if (isset($opts['tinylegend']) && $opts['tinylegend']) - continue; - if ($has_avg) - $graph[] = sprintf('GPRINT:%s_avg:AVERAGE:%%5.1lf%%s', $k, $has_max || $has_min || $has_avg ? ',' : "\\l"); - if ($has_min) - $graph[] = sprintf('GPRINT:%s_min:MIN:%%5.1lf%%s', $k, $has_max || $has_avg ? ',' : "\\l"); - if ($has_max) - $graph[] = sprintf('GPRINT:%s_max:MAX:%%5.1lf%%s', $k, $has_avg ? ',' : "\\l"); - if ($has_avg) - $graph[] = sprintf('GPRINT:%s_avg:LAST:%%5.1lf%%s\\l', $k); - } + if ($has_max) { + $graph[] = 'COMMENT: Max'; + } - #$rrd_cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $rrdfile); - $rrd_cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height']); - if($config['rrd_width'] <= "300") { - $small_opts = array ('--font', "LEGEND:7:mono", '--font', "AXIS:6:mono", "--font-render-mode", "normal"); - $rrd_cmd = array_merge($rrd_cmd, $small_opts); + if ($has_avg) { + $graph[] = "COMMENT: Avg\\n"; + } + + reset($rrdinfo['DS']); + while (list($k, $v) = each($rrdinfo['DS'])) { + if (strlen($k) > $l_max) { + $l_max = strlen($k); } - $rrd_cmd = array_merge($rrd_cmd, $config['rrd_opts_array'], $opts['rrd_opts'], $graph); + if ($has_min) { + $graph[] = sprintf('DEF:%s_min=%s:%s:MIN', $k, $rrdinfo['filename'], $k); + } - $cmd = RRDTOOL; - $count_rrd_cmd = count($rrd_cmd); - for ($i = 1; $i < $count_rrd_cmd; $i++) - $cmd .= ' '.escapeshellarg($rrd_cmd[$i]); + if ($has_avg) { + $graph[] = sprintf('DEF:%s_avg=%s:%s:AVERAGE', $k, $rrdinfo['filename'], $k); + } + + if ($has_max) { + $graph[] = sprintf('DEF:%s_max=%s:%s:MAX', $k, $rrdinfo['filename'], $k); + } + } + + if ($has_min && $has_max || $has_min && $has_avg || $has_avg && $has_max) { + $n = 1; + reset($rrdinfo['DS']); + while (list($k, $v) = each($rrdinfo['DS'])) { + $graph[] = sprintf('LINE:%s_%s', $k, $has_min ? 'min' : 'avg'); + $graph[] = sprintf('CDEF:%s_var=%s_%s,%s_%s,-', $k, $k, $has_max ? 'max' : 'avg', $k, $has_min ? 'min' : 'avg'); + $graph[] = sprintf('AREA:%s_var#%s::STACK', $k, rrd_get_color($n++, false)); + } + } + + reset($rrdinfo['DS']); + $n = 1; + while (list($k, $v) = each($rrdinfo['DS'])) { + $graph[] = sprintf('LINE1:%s_avg#%s:%s ', $k, rrd_get_color($n++, true), $k.substr(' ', 0, ($l_max - strlen($k)))); + if (isset($opts['tinylegend']) && $opts['tinylegend']) { + continue; + } + + if ($has_avg) { + $graph[] = sprintf('GPRINT:%s_avg:AVERAGE:%%5.1lf%%s', $k, $has_max || $has_min || $has_avg ? ',' : '\\l'); + } + + if ($has_min) { + $graph[] = sprintf('GPRINT:%s_min:MIN:%%5.1lf%%s', $k, $has_max || $has_avg ? ',' : '\\l'); + } + + if ($has_max) { + $graph[] = sprintf('GPRINT:%s_max:MAX:%%5.1lf%%s', $k, $has_avg ? ',' : '\\l'); + } + + if ($has_avg) { + $graph[] = sprintf('GPRINT:%s_avg:LAST:%%5.1lf%%s\\l', $k); + } + }//end while + + // $rrd_cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $rrdfile); + $rrd_cmd = array( + RRDTOOL, + 'graph', + '-', + '-E', + '-a', + 'PNG', + '-w', + $config['rrd_width'], + '-h', + $config['rrd_height'], + ); + if ($config['rrd_width'] <= '300') { + $small_opts = array( + '--font', + 'LEGEND:7:mono', + '--font', + 'AXIS:6:mono', + '--font-render-mode', + 'normal', + ); + $rrd_cmd = array_merge($rrd_cmd, $small_opts); + } + + $rrd_cmd = array_merge($rrd_cmd, $config['rrd_opts_array'], $opts['rrd_opts'], $graph); + + $cmd = RRDTOOL; + $count_rrd_cmd = count($rrd_cmd); + for ($i = 1; $i < $count_rrd_cmd; $i++) { + $cmd .= ' '.escapeshellarg($rrd_cmd[$i]); + } + + return $cmd; + +}//end collectd_draw_rrd() - return $cmd; -} /** * Draw RRD file based on it's structure + * * @timespan * @host * @plugin @@ -576,50 +781,78 @@ function collectd_draw_rrd($host, $plugin, $pinst = null, $type, $tinst = null, * @type * @tinst * @opts - * @return Commandline to call RRDGraph in order to generate the final graph + * @return Commandline to call RRDGraph in order to generate the final graph */ -function collectd_draw_generic($timespan, $host, $plugin, $pinst = null, $type, $tinst = null) { - global $config, $GraphDefs; - $timespan_def = NULL; - foreach ($config['timespan'] as &$ts) - if ($ts['name'] == $timespan) - $timespan_def = $ts; - if (is_null($timespan_def)) - $timespan_def = reset($config['timespan']); +function collectd_draw_generic($timespan, $host, $plugin, $pinst=null, $type, $tinst=null) { + global $config, $GraphDefs; + $timespan_def = null; + foreach ($config['timespan'] as &$ts) { + if ($ts['name'] == $timespan) { + $timespan_def = $ts; + } + } - if (!isset($GraphDefs[$type])) - return false; + if (is_null($timespan_def)) { + $timespan_def = reset($config['timespan']); + } - $rrd_file = sprintf('%s/%s%s%s/%s%s%s', $host, $plugin, is_null($pinst) ? '' : '-', $pinst, $type, is_null($tinst) ? '' : '-', $tinst); - #$rrd_cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $rrd_file); - $rrd_cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height']); + if (!isset($GraphDefs[$type])) { + return false; + } - if($config['rrd_width'] <= "300") { - $small_opts = array ('--font', 'LEGEND:7:mono', '--font', 'AXIS:6:mono', '--font-render-mode', 'normal'); - $rrd_cmd = array_merge($rrd_cmd, $small_opts); + $rrd_file = sprintf('%s/%s%s%s/%s%s%s', $host, $plugin, is_null($pinst) ? '' : '-', $pinst, $type, is_null($tinst) ? '' : '-', $tinst); + // $rrd_cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $rrd_file); + $rrd_cmd = array( + RRDTOOL, + 'graph', + '-', + '-E', + '-a', + 'PNG', + '-w', + $config['rrd_width'], + '-h', + $config['rrd_height'], + ); + + if ($config['rrd_width'] <= '300') { + $small_opts = array( + '--font', + 'LEGEND:7:mono', + '--font', + 'AXIS:6:mono', + '--font-render-mode', + 'normal', + ); + $rrd_cmd = array_merge($rrd_cmd, $small_opts); + } + + $rrd_cmd = array_merge($rrd_cmd, $config['rrd_opts_array']); + $rrd_args = $GraphDefs[$type]; + + foreach ($config['datadirs'] as $datadir) { + $file = $datadir.'/'.$rrd_file.'.rrd'; + if (!is_file($file)) { + continue; } - $rrd_cmd = array_merge($rrd_cmd, $config['rrd_opts_array']); - $rrd_args = $GraphDefs[$type]; + $file = str_replace(':', '\\:', $file); + $rrd_args = str_replace('{file}', $file, $rrd_args); - foreach ($config['datadirs'] as $datadir) { - $file = $datadir.'/'.$rrd_file.'.rrd'; - if (!is_file($file)) - continue; + $rrdgraph = array_merge($rrd_cmd, $rrd_args); + $cmd = RRDTOOL; + $count_rrdgraph = count($rrdgraph); + for ($i = 1; $i < $count_rrdgraph; $i++) { + $cmd .= ' '.escapeshellarg($rrdgraph[$i]); + } - $file = str_replace(":", "\\:", $file); - $rrd_args = str_replace('{file}', $file, $rrd_args); + return $cmd; + } - $rrdgraph = array_merge($rrd_cmd, $rrd_args); - $cmd = RRDTOOL; - $count_rrdgraph = count($rrdgraph); - for ($i = 1; $i < $count_rrdgraph; $i++) - $cmd .= ' '.escapeshellarg($rrdgraph[$i]); + return false; + +}//end collectd_draw_generic() - return $cmd; - } - return false; -} /** * Draw stack-graph for set of RRD files @@ -628,97 +861,137 @@ function collectd_draw_generic($timespan, $host, $plugin, $pinst = null, $type, * @return Commandline to call RRDGraph in order to generate the final graph */ function collectd_draw_meta_stack(&$opts, &$sources) { - global $config; - $timespan_def = null; - if (!isset($opts['timespan'])) - $timespan_def = reset($config['timespan']); - else foreach ($config['timespan'] as &$ts) - if ($ts['name'] == $opts['timespan']) - $timespan_def = $ts; + global $config; + $timespan_def = null; + if (!isset($opts['timespan'])) { + $timespan_def = reset($config['timespan']); + } + else { + foreach ($config['timespan'] as &$ts) { + if ($ts['name'] == $opts['timespan']) { + $timespan_def = $ts; + } + } + } - if (!isset($opts['title'])) - $opts['title'] = 'Unknown title'; - if (!isset($opts['rrd_opts'])) - $opts['rrd_opts'] = array(); - if (!isset($opts['colors'])) - $opts['colors'] = array(); - if (isset($opts['logarithmic']) && $opts['logarithmic']) - array_unshift($opts['rrd_opts'], '-o'); + if (!isset($opts['title'])) { + $opts['title'] = 'Unknown title'; + } -# $cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], -# '-t', $opts['title']); + if (!isset($opts['rrd_opts'])) { + $opts['rrd_opts'] = array(); + } - $cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height']); + if (!isset($opts['colors'])) { + $opts['colors'] = array(); + } - if($config['rrd_width'] <= "300") { - $small_opts = array ('--font', 'LEGEND:7:mono', '--font', 'AXIS:6:mono', '--font-render-mode', 'normal'); - $cmd = array_merge($cmd, $small_opts); + if (isset($opts['logarithmic']) && $opts['logarithmic']) { + array_unshift($opts['rrd_opts'], '-o'); + } + + // $cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], + // '-t', $opts['title']); + $cmd = array( + RRDTOOL, + 'graph', + '-', + '-E', + '-a', + 'PNG', + '-w', + $config['rrd_width'], + '-h', + $config['rrd_height'], + ); + + if ($config['rrd_width'] <= '300') { + $small_opts = array( + '--font', + 'LEGEND:7:mono', + '--font', + 'AXIS:6:mono', + '--font-render-mode', + 'normal', + ); + $cmd = array_merge($cmd, $small_opts); + } + + $cmd = array_merge($cmd, $config['rrd_opts_array'], $opts['rrd_opts']); + $max_inst_name = 0; + + foreach ($sources as &$inst_data) { + $inst_name = $inst_data['name']; + $file = $inst_data['file']; + $ds = isset($inst_data['ds']) ? $inst_data['ds'] : 'value'; + + if (strlen($inst_name) > $max_inst_name) { + $max_inst_name = strlen($inst_name); } + if (!is_file($file)) { + continue; + } - $cmd = array_merge($cmd, $config['rrd_opts_array'], $opts['rrd_opts']); - $max_inst_name = 0; + $cmd[] = 'DEF:'.$inst_name.'_min='.$file.':'.$ds.':MIN'; + $cmd[] = 'DEF:'.$inst_name.'_avg='.$file.':'.$ds.':AVERAGE'; + $cmd[] = 'DEF:'.$inst_name.'_max='.$file.':'.$ds.':MAX'; + $cmd[] = 'CDEF:'.$inst_name.'_nnl='.$inst_name.'_avg,UN,0,'.$inst_name.'_avg,IF'; + } - foreach($sources as &$inst_data) { - $inst_name = $inst_data['name']; - $file = $inst_data['file']; - $ds = isset($inst_data['ds']) ? $inst_data['ds'] : 'value'; + $inst_data = end($sources); + $inst_name = $inst_data['name']; + $cmd[] = 'CDEF:'.$inst_name.'_stk='.$inst_name.'_nnl'; - if (strlen($inst_name) > $max_inst_name) - $max_inst_name = strlen($inst_name); + $inst_data1 = end($sources); + while (($inst_data0 = prev($sources)) !== false) { + $inst_name0 = $inst_data0['name']; + $inst_name1 = $inst_data1['name']; - if (!is_file($file)) - continue; + $cmd[] = 'CDEF:'.$inst_name0.'_stk='.$inst_name0.'_nnl,'.$inst_name1.'_stk,+'; + $inst_data1 = $inst_data0; + } - $cmd[] = 'DEF:'.$inst_name.'_min='.$file.':'.$ds.':MIN'; - $cmd[] = 'DEF:'.$inst_name.'_avg='.$file.':'.$ds.':AVERAGE'; - $cmd[] = 'DEF:'.$inst_name.'_max='.$file.':'.$ds.':MAX'; - $cmd[] = 'CDEF:'.$inst_name.'_nnl='.$inst_name.'_avg,UN,0,'.$inst_name.'_avg,IF'; - } - $inst_data = end($sources); - $inst_name = $inst_data['name']; - $cmd[] = 'CDEF:'.$inst_name.'_stk='.$inst_name.'_nnl'; + foreach ($sources as &$inst_data) { + $inst_name = $inst_data['name']; + // $legend = sprintf('%s', $inst_name); + $legend = $inst_name; + while (strlen($legend) < $max_inst_name) { + $legend .= ' '; + } - $inst_data1 = end($sources); - while (($inst_data0 = prev($sources)) !== false) { - $inst_name0 = $inst_data0['name']; - $inst_name1 = $inst_data1['name']; + $number_format = isset($opts['number_format']) ? $opts['number_format'] : '%6.1lf'; - $cmd[] = 'CDEF:'.$inst_name0.'_stk='.$inst_name0.'_nnl,'.$inst_name1.'_stk,+'; - $inst_data1 = $inst_data0; - } + if (isset($opts['colors'][$inst_name])) { + $line_color = new CollectdColor($opts['colors'][$inst_name]); + } + else { + $line_color = new CollectdColor('random'); + } - foreach($sources as &$inst_data) { - $inst_name = $inst_data['name']; -# $legend = sprintf('%s', $inst_name); - $legend = $inst_name; - while (strlen($legend) < $max_inst_name) - $legend .= ' '; - $number_format = isset($opts['number_format']) ? $opts['number_format'] : '%6.1lf'; + $area_color = new CollectdColor($line_color); + $area_color->fade(); - if (isset($opts['colors'][$inst_name])) - $line_color = new CollectdColor($opts['colors'][$inst_name]); - else - $line_color = new CollectdColor('random'); - $area_color = new CollectdColor($line_color); - $area_color->fade(); + $cmd[] = 'AREA:'.$inst_name.'_stk#'.$area_color->as_string(); + $cmd[] = 'LINE1:'.$inst_name.'_stk#'.$line_color->as_string().':'.$legend; + if (!(isset($opts['tinylegend']) && $opts['tinylegend'])) { + $cmd[] = 'GPRINT:'.$inst_name.'_avg:LAST:'.$number_format.''; + $cmd[] = 'GPRINT:'.$inst_name.'_avg:AVERAGE:'.$number_format.''; + $cmd[] = 'GPRINT:'.$inst_name.'_min:MIN:'.$number_format.''; + $cmd[] = 'GPRINT:'.$inst_name.'_max:MAX:'.$number_format.'\\l'; + } + }//end foreach - $cmd[] = 'AREA:'.$inst_name.'_stk#'.$area_color->as_string(); - $cmd[] = 'LINE1:'.$inst_name.'_stk#'.$line_color->as_string().':'.$legend; - if (!(isset($opts['tinylegend']) && $opts['tinylegend'])) { - $cmd[] = 'GPRINT:'.$inst_name.'_avg:LAST:'.$number_format.''; - $cmd[] = 'GPRINT:'.$inst_name.'_avg:AVERAGE:'.$number_format.''; - $cmd[] = 'GPRINT:'.$inst_name.'_min:MIN:'.$number_format.''; - $cmd[] = 'GPRINT:'.$inst_name.'_max:MAX:'.$number_format.'\\l'; - } - } + $rrdcmd = RRDTOOL; + $count_cmd = count($cmd); + for ($i = 1; $i < $count_cmd; $i++) { + $rrdcmd .= ' '.escapeshellarg($cmd[$i]); + } + + return $rrdcmd; + +}//end collectd_draw_meta_stack() - $rrdcmd = RRDTOOL; - $count_cmd = count($cmd); - for ($i = 1; $i < $count_cmd; $i++) - $rrdcmd .= ' '.escapeshellarg($cmd[$i]); - return $rrdcmd; -} /** * Draw stack-graph for set of RRD files @@ -727,79 +1000,113 @@ function collectd_draw_meta_stack(&$opts, &$sources) { * @return Commandline to call RRDGraph in order to generate the final graph */ function collectd_draw_meta_line(&$opts, &$sources) { - global $config; - $timespan_def = null; - if (!isset($opts['timespan'])) - $timespan_def = reset($config['timespan']); - else foreach ($config['timespan'] as &$ts) - if ($ts['name'] == $opts['timespan']) - $timespan_def = $ts; + global $config; + $timespan_def = null; + if (!isset($opts['timespan'])) { + $timespan_def = reset($config['timespan']); + } + else { + foreach ($config['timespan'] as &$ts) { + if ($ts['name'] == $opts['timespan']) { + $timespan_def = $ts; + } + } + } - if (!isset($opts['title'])) - $opts['title'] = 'Unknown title'; - if (!isset($opts['rrd_opts'])) - $opts['rrd_opts'] = array(); - if (!isset($opts['colors'])) - $opts['colors'] = array(); - if (isset($opts['logarithmic']) && $opts['logarithmic']) - array_unshift($opts['rrd_opts'], '-o'); + if (!isset($opts['title'])) { + $opts['title'] = 'Unknown title'; + } -# $cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $opts['title']); -# $cmd = array_merge($cmd, $config['rrd_opts_array'], $opts['rrd_opts']); + if (!isset($opts['rrd_opts'])) { + $opts['rrd_opts'] = array(); + } - $cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height']); + if (!isset($opts['colors'])) { + $opts['colors'] = array(); + } - if($config['rrd_width'] <= "300") { - $small_opts = array ('--font', 'LEGEND:7:mono', '--font', 'AXIS:6:mono', '--font-render-mode', 'normal'); - $cmd = array_merge($cmd, $small_opts); + if (isset($opts['logarithmic']) && $opts['logarithmic']) { + array_unshift($opts['rrd_opts'], '-o'); + } + + // $cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $opts['title']); + // $cmd = array_merge($cmd, $config['rrd_opts_array'], $opts['rrd_opts']); + $cmd = array( + RRDTOOL, + 'graph', + '-', + '-E', + '-a', + 'PNG', + '-w', + $config['rrd_width'], + '-h', + $config['rrd_height'], + ); + + if ($config['rrd_width'] <= '300') { + $small_opts = array( + '--font', + 'LEGEND:7:mono', + '--font', + 'AXIS:6:mono', + '--font-render-mode', + 'normal', + ); + $cmd = array_merge($cmd, $small_opts); + } + + $max_inst_name = 0; + + foreach ($sources as &$inst_data) { + $inst_name = $inst_data['name']; + $file = $inst_data['file']; + $ds = isset($inst_data['ds']) ? $inst_data['ds'] : 'value'; + + if (strlen($inst_name) > $max_inst_name) { + $max_inst_name = strlen($inst_name); } + if (!is_file($file)) { + continue; + } + $cmd[] = 'DEF:'.$inst_name.'_min='.$file.':'.$ds.':MIN'; + $cmd[] = 'DEF:'.$inst_name.'_avg='.$file.':'.$ds.':AVERAGE'; + $cmd[] = 'DEF:'.$inst_name.'_max='.$file.':'.$ds.':MAX'; + } - $max_inst_name = 0; + foreach ($sources as &$inst_data) { + $inst_name = $inst_data['name']; + $legend = sprintf('%s', $inst_name); + while (strlen($legend) < $max_inst_name) { + $legend .= ' '; + } - foreach ($sources as &$inst_data) { - $inst_name = $inst_data['name']; - $file = $inst_data['file']; - $ds = isset($inst_data['ds']) ? $inst_data['ds'] : 'value'; + $number_format = isset($opts['number_format']) ? $opts['number_format'] : '%6.1lf'; - if (strlen($inst_name) > $max_inst_name) - $max_inst_name = strlen($inst_name); + if (isset($opts['colors'][$inst_name])) { + $line_color = new CollectdColor($opts['colors'][$inst_name]); + } + else { + $line_color = new CollectdColor('random'); + } - if (!is_file($file)) - continue; + $cmd[] = 'LINE1:'.$inst_name.'_avg#'.$line_color->as_string().':'.$legend; + if (!(isset($opts['tinylegend']) && $opts['tinylegend'])) { + $cmd[] = 'GPRINT:'.$inst_name.'_min:MIN:'.$number_format.''; + $cmd[] = 'GPRINT:'.$inst_name.'_avg:AVERAGE:'.$number_format.''; + $cmd[] = 'GPRINT:'.$inst_name.'_max:MAX:'.$number_format.''; + $cmd[] = 'GPRINT:'.$inst_name.'_avg:LAST:'.$number_format.'\\l'; + } + }//end foreach - $cmd[] = 'DEF:'.$inst_name.'_min='.$file.':'.$ds.':MIN'; - $cmd[] = 'DEF:'.$inst_name.'_avg='.$file.':'.$ds.':AVERAGE'; - $cmd[] = 'DEF:'.$inst_name.'_max='.$file.':'.$ds.':MAX'; - } + $rrdcmd = RRDTOOL; + $count_cmd = count($cmd); + for ($i = 1; $i < $count_cmd; $i++) { + $rrdcmd .= ' '.escapeshellarg($cmd[$i]); + } - foreach ($sources as &$inst_data) { - $inst_name = $inst_data['name']; - $legend = sprintf('%s', $inst_name); - while (strlen($legend) < $max_inst_name) - $legend .= ' '; - $number_format = isset($opts['number_format']) ? $opts['number_format'] : '%6.1lf'; + return $rrdcmd; - if (isset($opts['colors'][$inst_name])) - $line_color = new CollectdColor($opts['colors'][$inst_name]); - else - $line_color = new CollectdColor('random'); - - $cmd[] = 'LINE1:'.$inst_name.'_avg#'.$line_color->as_string().':'.$legend; - if (!(isset($opts['tinylegend']) && $opts['tinylegend'])) { - $cmd[] = 'GPRINT:'.$inst_name.'_min:MIN:'.$number_format.''; - $cmd[] = 'GPRINT:'.$inst_name.'_avg:AVERAGE:'.$number_format.''; - $cmd[] = 'GPRINT:'.$inst_name.'_max:MAX:'.$number_format.''; - $cmd[] = 'GPRINT:'.$inst_name.'_avg:LAST:'.$number_format.'\\l'; - } - } - - $rrdcmd = RRDTOOL; - $count_cmd = count($cmd); - for ($i = 1; $i < $count_cmd; $i++) - $rrdcmd .= ' '.escapeshellarg($cmd[$i]); - return $rrdcmd; -} - -?> +}//end collectd_draw_meta_line() diff --git a/html/includes/dev-overview-data.inc.php b/html/includes/dev-overview-data.inc.php index 3d5882594..889613c83 100644 --- a/html/includes/dev-overview-data.inc.php +++ b/html/includes/dev-overview-data.inc.php @@ -1,89 +1,87 @@ '); -echo("
    +echo '
    '; +echo "
    -
    "); +
    "; -if ($config['overview_show_sysDescr']) -{ - echo('' . $device['sysDescr'] . ""); +if ($config['overview_show_sysDescr']) { + echo ''.$device['sysDescr'].''; } -echo('
    - '); +echo ' +
    '; $uptime = $device['uptime']; -if ($device['os'] == "ios") { formatCiscoHardware($device); } -if ($device['features']) { $device['features'] = "(".$device['features'].")"; } +if ($device['os'] == 'ios') { + formatCiscoHardware($device); +} + +if ($device['features']) { + $device['features'] = '('.$device['features'].')'; +} + $device['os_text'] = $config['os'][$device['os']]['text']; -if ($device['hardware']) -{ - echo(' +if ($device['hardware']) { + echo ' - - '); + + '; } -echo(' +echo ' - - '); + + '; -if ($device['serial']) -{ - echo(' +if ($device['serial']) { + echo ' - - '); + + '; } -if ($device['sysContact']) -{ - echo(' - '); - if (get_dev_attrib($device,'override_sysContact_bool')) - { - echo(' - +if ($device['sysContact']) { + echo ' + '; + if (get_dev_attrib($device, 'override_sysContact_bool')) { + echo ' + - '); - } - echo(' - - '); + '; + } + + echo ' + + '; } -if ($device['location']) -{ - echo(' +if ($device['location']) { + echo ' - - '); - if (get_dev_attrib($device,'override_sysLocation_bool') && !empty($device['real_location'])) - { - echo(' + + '; + if (get_dev_attrib($device, 'override_sysLocation_bool') && !empty($device['real_location'])) { + echo ' - - '); - } + + '; + } } -if ($uptime) -{ - echo(' +if ($uptime) { + echo ' - - '); + + '; } -echo('
    Hardware' . $device['hardware']. '
    '.$device['hardware'].'
    Operating System' . $device['os_text'] . ' ' . $device['version'] . ' ' . $device['features'] . '
    '.$device['os_text'].' '.$device['version'].' '.$device['features'].'
    Serial' . $device['serial']. '
    '.$device['serial'].'
    Contact' . htmlspecialchars(get_dev_attrib($device,'override_sysContact_string')) . '
    Contact'.htmlspecialchars(get_dev_attrib($device, 'override_sysContact_string')).'
    SNMP Contact' . htmlspecialchars($device['sysContact']). '
    SNMP Contact'.htmlspecialchars($device['sysContact']).'
    Location' . $device['location']. '
    '.$device['location'].'
    SNMP Location' . $device['real_location']. '
    '.$device['real_location'].'
    Uptime' . formatUptime($uptime) . '
    '.formatUptime($uptime).'
    +echo '
    -
    '); -?> +
    '; diff --git a/html/includes/device-header.inc.php b/html/includes/device-header.inc.php index fc885958b..8c6775930 100644 --- a/html/includes/device-header.inc.php +++ b/html/includes/device-header.inc.php @@ -1,73 +1,70 @@ '.$image.' - ' . generate_device_link($device) . ' -
    ' . $device['location'] . ' - '); + '.generate_device_link($device).' +
    '.$device['location'].' + '; - if (isset($config['os'][$device['os']]['over'])) -{ - $graphs = $config['os'][$device['os']]['over']; +if (isset($config['os'][$device['os']]['over'])) { + $graphs = $config['os'][$device['os']]['over']; } -elseif (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) -{ - $graphs = $config['os'][$device['os_group']]['over']; +else if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) { + $graphs = $config['os'][$device['os_group']]['over']; } -else -{ - $graphs = $config['os']['default']['over']; +else { + $graphs = $config['os']['default']['over']; } -$graph_array = array(); -$graph_array['height'] = "100"; -$graph_array['width'] = "310"; -$graph_array['to'] = $config['time']['now']; -$graph_array['device'] = $device['device_id']; -$graph_array['type'] = "device_bits"; -$graph_array['from'] = $config['time']['day']; -$graph_array['legend'] = "no"; +$graph_array = array(); +$graph_array['height'] = '100'; +$graph_array['width'] = '310'; +$graph_array['to'] = $config['time']['now']; +$graph_array['device'] = $device['device_id']; +$graph_array['type'] = 'device_bits'; +$graph_array['from'] = $config['time']['day']; +$graph_array['legend'] = 'no'; $graph_array['popup_title'] = $descr; -$graph_array['height'] = "45"; -$graph_array['width'] = "150"; -$graph_array['bg'] = "FFFFFF00"; +$graph_array['height'] = '45'; +$graph_array['width'] = '150'; +$graph_array['bg'] = 'FFFFFF00'; -foreach ($graphs as $entry) -{ - if ($entry['graph']) - { - $graph_array['type'] = $entry['graph']; +foreach ($graphs as $entry) { + if ($entry['graph']) { + $graph_array['type'] = $entry['graph']; - echo("
    "); - print_graph_popup($graph_array); - echo("
    ".$entry['text']."
    "); - echo("
    "); - } + echo "
    "; + print_graph_popup($graph_array); + echo "
    ".$entry['text'].'
    '; + echo '
    '; + } } unset($graph_array); -echo(' - '); - -?> +echo ' + '; diff --git a/html/includes/device-summary-horiz.inc.php b/html/includes/device-summary-horiz.inc.php index ae5d576c0..6f27b50af 100644 --- a/html/includes/device-summary-horiz.inc.php +++ b/html/includes/device-summary-horiz.inc.php @@ -1,5 +1,5 @@
    diff --git a/html/includes/device-summary-vert.inc.php b/html/includes/device-summary-vert.inc.php index 8e0a1ff32..ee4e63d07 100644 --- a/html/includes/device-summary-vert.inc.php +++ b/html/includes/device-summary-vert.inc.php @@ -1,5 +1,5 @@
    diff --git a/html/includes/error-no-perm.inc.php b/html/includes/error-no-perm.inc.php index 09717037b..37a1c9c7e 100644 --- a/html/includes/error-no-perm.inc.php +++ b/html/includes/error-no-perm.inc.php @@ -16,5 +16,3 @@ echo("
    "); print_optionbar_end(); echo("
    "); - -?> diff --git a/html/includes/front/boxes.inc.php b/html/includes/front/boxes.inc.php index 665c1d738..e767aa698 100644 --- a/html/includes/front/boxes.inc.php +++ b/html/includes/front/boxes.inc.php @@ -11,31 +11,23 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -?> - div" - style="clear: both"> -'); +data-cycle-fx="fade" +data-cycle-timeout="10000" +data-cycle-slides="> div" +style="clear: both"> +'; -foreach (get_matching_files($config['html_dir']."/includes/front/", "/^top_.*\.php$/") as $file) -{ - if(($file == 'top_ports.inc.php' && $config['top_ports'] == 0) || ($file == 'top_device_bits.inc.php' && $config['top_devices'] == 0)) - { - } - else - { - echo("
    \n"); - include_once($file); - echo("
    \n"); - } +foreach (get_matching_files($config['html_dir'].'/includes/front/', '/^top_.*\.php$/') as $file) { + if (($file == 'top_ports.inc.php' && $config['top_ports'] == 0) || ($file == 'top_device_bits.inc.php' && $config['top_devices'] == 0)) { + } + else { + echo "
    \n"; + include_once $file; + echo "
    \n"; + } } -echo("
    \n"); - -?> - +echo "
    \n"; diff --git a/html/includes/front/top_device_bits.inc.php b/html/includes/front/top_device_bits.inc.php index 4b48bfd4a..9c0e87362 100644 --- a/html/includes/front/top_device_bits.inc.php +++ b/html/includes/front/top_device_bits.inc.php @@ -14,9 +14,9 @@ */ $minutes = 15; -$seconds = $minutes * 60; -$top = $config['front_page_settings']['top']['devices']; -if (is_admin() === TRUE || is_read() === TRUE) { +$seconds = ($minutes * 60); +$top = $config['front_page_settings']['top']['devices']; +if (is_admin() === true || is_read() === true) { $query = " SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total FROM ports as p, devices as d @@ -27,9 +27,10 @@ if (is_admin() === TRUE || is_read() === TRUE) { GROUP BY d.device_id ORDER BY total desc LIMIT $top - "; -} else { - $query = " + "; +} +else { + $query = " SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total FROM ports as p, devices as d, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `d`.`device_id` AND @@ -40,19 +41,21 @@ if (is_admin() === TRUE || is_read() === TRUE) { GROUP BY d.device_id ORDER BY total desc LIMIT $top - "; + "; $param[] = array($_SESSION['user_id']); +}//end if + +echo "Top $top devices (last $minutes minutes)\n"; +echo "\n"; +foreach (dbFetchRows($query, $param) as $result) { + echo ''.''.''."\n"; } -echo("Top $top devices (last $minutes minutes)\n"); -echo("
    '.generate_device_link($result, shorthost($result['hostname'])).''.generate_device_link( + $result, + generate_minigraph_image($result, $config['time']['day'], $config['time']['now'], 'device_bits', 'no', 150, 21, '&', 'top10'), + array(), + 0, + 0, + 0 + ).'
    \n"); -foreach (dbFetchRows($query,$param) as $result) { - echo("". - "". - "". - "\n"); -} -echo("
    ".generate_device_link($result, shorthost($result['hostname']))."".generate_device_link($result, - generate_minigraph_image($result, $config['time']['day'], $config['time']['now'], "device_bits", "no", 150, 21, '&', "top10"), array(), 0, 0, 0)."
    \n"); - -?> +echo "\n"; diff --git a/html/includes/front/top_ports.inc.php b/html/includes/front/top_ports.inc.php index 008525207..c3bf3bc30 100644 --- a/html/includes/front/top_ports.inc.php +++ b/html/includes/front/top_ports.inc.php @@ -14,9 +14,9 @@ */ $minutes = 15; -$seconds = $minutes * 60; -$top = $config['front_page_settings']['top']['ports']; -if (is_admin() === TRUE || is_read() === TRUE) { +$seconds = ($minutes * 60); +$top = $config['front_page_settings']['top']['ports']; +if (is_admin() === true || is_read() === true) { $query = " SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total FROM ports as p, devices as d @@ -26,9 +26,10 @@ if (is_admin() === TRUE || is_read() === TRUE) { OR p.ifOutOctets_rate > 0 ) ORDER BY total desc LIMIT $top - "; -} else { - $query = " + "; +} +else { + $query = " SELECT *, I.ifInOctets_rate + I.ifOutOctets_rate as total FROM ports as I, devices as d, `devices_perms` AS `P`, `ports_perms` AS `PP` @@ -39,19 +40,17 @@ if (is_admin() === TRUE || is_read() === TRUE) { OR I.ifOutOctets_rate > 0 ) ORDER BY total desc LIMIT $top - "; - $param[] = array($_SESSION['user_id'],$_SESSION['user_id']); + "; + $param[] = array( + $_SESSION['user_id'], + $_SESSION['user_id'], + ); +}//end if + +echo "Top $top ports (last $minutes minutes)\n"; +echo "\n"; +foreach (dbFetchRows($query, $param) as $result) { + echo ''.''.''.''."\n"; } -echo("Top $top ports (last $minutes minutes)\n"); -echo("
    '.generate_device_link($result, shorthost($result['hostname'])).''.generate_port_link($result).''.generate_port_link($result, generate_port_thumbnail($result)).'
    \n"); -foreach (dbFetchRows($query,$param) as $result) { - echo("". - "". - "". - "". - "\n"); -} -echo("
    ".generate_device_link($result, shorthost($result['hostname']))."".generate_port_link($result)."".generate_port_link($result, generate_port_thumbnail($result))."
    \n"); - -?> +echo "\n"; diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index fc7c52a09..6aed9fa6f 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -10,351 +10,437 @@ * @author LibreNMS Contributors * @copyright (C) 2006 - 2012 Adam Armstrong (as Observium) * @copyright (C) 2013 LibreNMS Group - * */ -function data_uri($file, $mime) -{ - $contents = file_get_contents($file); - $base64 = base64_encode($contents); - return ('data:' . $mime . ';base64,' . $base64); -} -function nicecase($item) -{ - switch ($item) - { - case "dbm": - return "dBm"; - case "mysql": - return" MySQL"; - case "powerdns": - return "PowerDNS"; - case "bind": - return "BIND"; +function data_uri($file, $mime) { + $contents = file_get_contents($file); + $base64 = base64_encode($contents); + return ('data:'.$mime.';base64,'.$base64); + +}//end data_uri() + + +function nicecase($item) { + switch ($item) { + case 'dbm': + return 'dBm'; + + case 'mysql': + return ' MySQL'; + + case 'powerdns': + return 'PowerDNS'; + + case 'bind': + return 'BIND'; + default: - return ucfirst($item); - } -} - -function toner2colour($descr, $percent) -{ - $colour = get_percentage_colours(100-$percent); - - if (substr($descr,-1) == 'C' || stripos($descr,"cyan" ) !== false) { $colour['left'] = "55D6D3"; $colour['right'] = "33B4B1"; } - if (substr($descr,-1) == 'M' || stripos($descr,"magenta") !== false) { $colour['left'] = "F24AC8"; $colour['right'] = "D028A6"; } - if (substr($descr,-1) == 'Y' || stripos($descr,"yellow" ) !== false - || stripos($descr,"giallo" ) !== false - || stripos($descr,"gul" ) !== false) { $colour['left'] = "FFF200"; $colour['right'] = "DDD000"; } - if (substr($descr,-1) == 'K' || stripos($descr,"black" ) !== false - || stripos($descr,"nero" ) !== false) { $colour['left'] = "000000"; $colour['right'] = "222222"; } - - return $colour; -} - -function generate_link($text, $vars, $new_vars = array()) -{ - return ''.$text.''; -} - -function generate_url($vars, $new_vars = array()) -{ - - $vars = array_merge($vars, $new_vars); - - $url = $vars['page']."/"; - unset($vars['page']); - - foreach ($vars as $var => $value) - { - if ($value == "0" || $value != "" && strstr($var, "opt") === FALSE && is_numeric($var) === FALSE) - { - $url .= $var ."=".urlencode($value)."/"; + return ucfirst($item); } - } - return($url); +}//end nicecase() -} -function escape_quotes($text) -{ - return str_replace('"', "\'", str_replace("'", "\'", $text)); -} +function toner2colour($descr, $percent) { + $colour = get_percentage_colours(100 - $percent); -function generate_overlib_content($graph_array, $text) -{ + if (substr($descr, -1) == 'C' || stripos($descr, 'cyan') !== false) { + $colour['left'] = '55D6D3'; + $colour['right'] = '33B4B1'; + } + + if (substr($descr, -1) == 'M' || stripos($descr, 'magenta') !== false) { + $colour['left'] = 'F24AC8'; + $colour['right'] = 'D028A6'; + } + + if (substr($descr, -1) == 'Y' || stripos($descr, 'yellow') !== false + || stripos($descr, 'giallo') !== false + || stripos($descr, 'gul') !== false + ) { + $colour['left'] = 'FFF200'; + $colour['right'] = 'DDD000'; + } + + if (substr($descr, -1) == 'K' || stripos($descr, 'black') !== false + || stripos($descr, 'nero') !== false + ) { + $colour['left'] = '000000'; + $colour['right'] = '222222'; + } + + return $colour; + +}//end toner2colour() + + +function generate_link($text, $vars, $new_vars=array()) { + return ''.$text.''; + +}//end generate_link() + + +function generate_url($vars, $new_vars=array()) { + $vars = array_merge($vars, $new_vars); + + $url = $vars['page'].'/'; + unset($vars['page']); + + foreach ($vars as $var => $value) { + if ($value == '0' || $value != '' && strstr($var, 'opt') === false && is_numeric($var) === false) { + $url .= $var.'='.urlencode($value).'/'; + } + } + + return ($url); + +}//end generate_url() + + +function escape_quotes($text) { + return str_replace('"', "\'", str_replace("'", "\'", $text)); + +}//end escape_quotes() + + +function generate_overlib_content($graph_array, $text) { global $config; $overlib_content = '
    '.$text.'
    '; - foreach (array('day','week','month','year') as $period) - { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= escape_quotes(generate_graph_tag($graph_array)); + foreach (array('day', 'week', 'month', 'year') as $period) { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= escape_quotes(generate_graph_tag($graph_array)); } + $overlib_content .= '
    '; return $overlib_content; -} +}//end generate_overlib_content() -function get_percentage_colours($percentage) -{ - $background = array(); - if ($percentage > '90') { $background['left']='c4323f'; $background['right']='C96A73'; } - elseif ($percentage > '75') { $background['left']='bf5d5b'; $background['right']='d39392'; } - elseif ($percentage > '50') { $background['left']='bf875b'; $background['right']='d3ae92'; } - elseif ($percentage > '25') { $background['left']='5b93bf'; $background['right']='92b7d3'; } - else { $background['left']='9abf5b'; $background['right']='bbd392'; } - return($background); - -} - -function generate_minigraph_image($device, $start, $end, $type, $legend = 'no', $width = 275, $height = 100, $sep = '&', $class = "minigraph-image") -{ - return ''; -} - -function generate_device_url($device, $vars=array()) -{ - return generate_url(array('page' => 'device', 'device' => $device['device_id']), $vars); -} - -function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end=0, $escape_text=1, $overlib=1) -{ - global $config; - - if (!$start) { $start = $config['time']['day']; } - if (!$end) { $end = $config['time']['now']; } - - $class = devclass($device); - if (!$text) { $text = $device['hostname']; } - - if (isset($config['os'][$device['os']]['over'])) - { - $graphs = $config['os'][$device['os']]['over']; - } - elseif (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) - { - $graphs = $config['os'][$device['os_group']]['over']; - } - else - { - $graphs = $config['os']['default']['over']; - } - - $url = generate_device_url($device, $vars); - - // beginning of overlib box contains large hostname followed by hardware & OS details - $contents = "
    ".$device['hostname'].""; - if ($device['hardware']) { $contents .= " - ".$device['hardware']; } - if ($device['os']) { $contents .= " - ".mres($config['os'][$device['os']]['text']); } - if ($device['version']) { $contents .= " ".mres($device['version']); } - if ($device['features']) { $contents .= " (".mres($device['features']).")"; } - if (isset($device['location'])) { $contents .= " - " . htmlentities($device['location']); } - $contents .= "
    "; - - foreach ($graphs as $entry) - { - $graph = $entry['graph']; - $graphhead = $entry['text']; - $contents .= '
    '; - $contents .= ''.$graphhead.'
    '; - $contents .= generate_minigraph_image($device, $start, $end, $graph); - $contents .= generate_minigraph_image($device, $config['time']['week'], $end, $graph); - $contents .= '
    '; - } - - if ($escape_text) { $text = htmlentities($text); } - if ($overlib == 0) { - $link = $contents; - } else { - $link = overlib_link($url, $text, escape_quotes($contents), $class); - } - - if (device_permitted($device['device_id'])) - { - return $link; - } else { - return $device['hostname']; - } -} - -function overlib_link($url, $text, $contents, $class) -{ - global $config; - - $contents = str_replace("\"", "\'", $contents); - $output = '"; - } - $output .= $text.""; - - return $output; -} - -function generate_graph_popup($graph_array) -{ - global $config; - - // Take $graph_array and print day,week,month,year graps in overlib, hovered over graph - - $original_from = $graph_array['from']; - - $graph = generate_graph_tag($graph_array); - $content = "
    ".$graph_array['popup_title']."
    "; - $content .= "
    "; - $graph_array['legend'] = "yes"; - $graph_array['height'] = "100"; - $graph_array['width'] = "340"; - $graph_array['from'] = $config['time']['day']; - $content .= generate_graph_tag($graph_array); - $graph_array['from'] = $config['time']['week']; - $content .= generate_graph_tag($graph_array); - $graph_array['from'] = $config['time']['month']; - $content .= generate_graph_tag($graph_array); - $graph_array['from'] = $config['time']['year']; - $content .= generate_graph_tag($graph_array); - $content .= "
    "; - - $graph_array['from'] = $original_from; - - $graph_array['link'] = generate_url($graph_array, array('page' => 'graphs', 'height' => NULL, 'width' => NULL, 'bg' => NULL)); - -# $graph_array['link'] = "graphs/type=" . $graph_array['type'] . "/id=" . $graph_array['id']; - - return overlib_link($graph_array['link'], $graph, $content, NULL); -} - -function print_graph_popup($graph_array) -{ - echo(generate_graph_popup($graph_array)); -} - -function permissions_cache($user_id) -{ - $permissions = array(); - foreach (dbFetchRows("SELECT * FROM devices_perms WHERE user_id = '".$user_id."'") as $device) - { - $permissions['device'][$device['device_id']] = 1; - } - foreach (dbFetchRows("SELECT * FROM ports_perms WHERE user_id = '".$user_id."'") as $port) - { - $permissions['port'][$port['port_id']] = 1; - } - foreach (dbFetchRows("SELECT * FROM bill_perms WHERE user_id = '".$user_id."'") as $bill) - { - $permissions['bill'][$bill['bill_id']] = 1; - } - - return $permissions; -} - -function bill_permitted($bill_id) -{ - global $permissions; - - if ($_SESSION['userlevel'] >= "5") { - $allowed = TRUE; - } elseif ($permissions['bill'][$bill_id]) { - $allowed = TRUE; - } else { - $allowed = FALSE; - } - - return $allowed; -} - -function port_permitted($port_id, $device_id = NULL) -{ - global $permissions; - - if (!is_numeric($device_id)) { $device_id = get_device_id_by_port_id($port_id); } - - if ($_SESSION['userlevel'] >= "5") - { - $allowed = TRUE; - } elseif (device_permitted($device_id)) { - $allowed = TRUE; - } elseif ($permissions['port'][$port_id]) { - $allowed = TRUE; - } else { - $allowed = FALSE; - } - - return $allowed; -} - -function application_permitted($app_id, $device_id = NULL) -{ - global $permissions; - - if (is_numeric($app_id)) - { - if (!$device_id) { $device_id = get_device_id_by_app_id ($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; +function get_percentage_colours($percentage) { + $background = array(); + if ($percentage > '90') { + $background['left'] = 'c4323f'; + $background['right'] = 'C96A73'; } - } else { - $allowed = FALSE; - } - return $allowed; -} + else if ($percentage > '75') { + $background['left'] = 'bf5d5b'; + $background['right'] = 'd39392'; + } -function device_permitted($device_id) -{ - global $permissions; + else if ($percentage > '50') { + $background['left'] = 'bf875b'; + $background['right'] = 'd3ae92'; + } - if ($_SESSION['userlevel'] >= "5") - { - $allowed = true; - } elseif ($permissions['device'][$device_id]) { - $allowed = true; - } else { - $allowed = false; - } + else if ($percentage > '25') { + $background['left'] = '5b93bf'; + $background['right'] = '92b7d3'; + } - return $allowed; -} + else { + $background['left'] = '9abf5b'; + $background['right'] = 'bbd392'; + } -function print_graph_tag($args) -{ - echo(generate_graph_tag($args)); -} + return ($background); -function generate_graph_tag($args) -{ - $urlargs = array(); - foreach ($args as $key => $arg) - { - $urlargs[] = $key."=".urlencode($arg); - } +}//end get_percentage_colours() + + +function generate_minigraph_image($device, $start, $end, $type, $legend='no', $width=275, $height=100, $sep='&', $class='minigraph-image') { + return ''; + +}//end generate_minigraph_image() + + +function generate_device_url($device, $vars=array()) { + return generate_url(array('page' => 'device', 'device' => $device['device_id']), $vars); + +}//end generate_device_url() + + +function generate_device_link($device, $text=null, $vars=array(), $start=0, $end=0, $escape_text=1, $overlib=1) { + global $config; + + if (!$start) { + $start = $config['time']['day']; + } + + if (!$end) { + $end = $config['time']['now']; + } + + $class = devclass($device); + if (!$text) { + $text = $device['hostname']; + } + + if (isset($config['os'][$device['os']]['over'])) { + $graphs = $config['os'][$device['os']]['over']; + } + else if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) { + $graphs = $config['os'][$device['os_group']]['over']; + } + else { + $graphs = $config['os']['default']['over']; + } + + $url = generate_device_url($device, $vars); + + // beginning of overlib box contains large hostname followed by hardware & OS details + $contents = '
    '.$device['hostname'].''; + if ($device['hardware']) { + $contents .= ' - '.$device['hardware']; + } + + if ($device['os']) { + $contents .= ' - '.mres($config['os'][$device['os']]['text']); + } + + if ($device['version']) { + $contents .= ' '.mres($device['version']); + } + + if ($device['features']) { + $contents .= ' ('.mres($device['features']).')'; + } + + if (isset($device['location'])) { + $contents .= ' - '.htmlentities($device['location']); + } + + $contents .= '
    '; + + foreach ($graphs as $entry) { + $graph = $entry['graph']; + $graphhead = $entry['text']; + $contents .= '
    '; + $contents .= ''.$graphhead.'
    '; + $contents .= generate_minigraph_image($device, $start, $end, $graph); + $contents .= generate_minigraph_image($device, $config['time']['week'], $end, $graph); + $contents .= '
    '; + } + + if ($escape_text) { + $text = htmlentities($text); + } + + if ($overlib == 0) { + $link = $contents; + } + else { + $link = overlib_link($url, $text, escape_quotes($contents), $class); + } + + if (device_permitted($device['device_id'])) { + return $link; + } + else { + return $device['hostname']; + } + +}//end generate_device_link() + + +function overlib_link($url, $text, $contents, $class) { + global $config; + + $contents = str_replace('"', "\'", $contents); + $output = ''; + } + + $output .= $text.''; + + return $output; + +}//end overlib_link() + + +function generate_graph_popup($graph_array) { + global $config; + + // Take $graph_array and print day,week,month,year graps in overlib, hovered over graph + $original_from = $graph_array['from']; + + $graph = generate_graph_tag($graph_array); + $content = '
    '.$graph_array['popup_title'].'
    '; + $content .= "
    "; + $graph_array['legend'] = 'yes'; + $graph_array['height'] = '100'; + $graph_array['width'] = '340'; + $graph_array['from'] = $config['time']['day']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['week']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['month']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['year']; + $content .= generate_graph_tag($graph_array); + $content .= '
    '; + + $graph_array['from'] = $original_from; + + $graph_array['link'] = generate_url($graph_array, array('page' => 'graphs', 'height' => null, 'width' => null, 'bg' => null)); + + // $graph_array['link'] = "graphs/type=" . $graph_array['type'] . "/id=" . $graph_array['id']; + return overlib_link($graph_array['link'], $graph, $content, null); + +}//end generate_graph_popup() + + +function print_graph_popup($graph_array) { + echo generate_graph_popup($graph_array); + +}//end print_graph_popup() + + +function permissions_cache($user_id) { + $permissions = array(); + foreach (dbFetchRows("SELECT * FROM devices_perms WHERE user_id = '".$user_id."'") as $device) { + $permissions['device'][$device['device_id']] = 1; + } + + foreach (dbFetchRows("SELECT * FROM ports_perms WHERE user_id = '".$user_id."'") as $port) { + $permissions['port'][$port['port_id']] = 1; + } + + foreach (dbFetchRows("SELECT * FROM bill_perms WHERE user_id = '".$user_id."'") as $bill) { + $permissions['bill'][$bill['bill_id']] = 1; + } + + return $permissions; + +}//end permissions_cache() + + +function bill_permitted($bill_id) { + global $permissions; + + if ($_SESSION['userlevel'] >= '5') { + $allowed = true; + } + else if ($permissions['bill'][$bill_id]) { + $allowed = true; + } + else { + $allowed = false; + } + + return $allowed; + +}//end bill_permitted() + + +function port_permitted($port_id, $device_id=null) { + global $permissions; + + if (!is_numeric($device_id)) { + $device_id = get_device_id_by_port_id($port_id); + } + + if ($_SESSION['userlevel'] >= '5') { + $allowed = true; + } + else if (device_permitted($device_id)) { + $allowed = true; + } + else if ($permissions['port'][$port_id]) { + $allowed = true; + } + else { + $allowed = false; + } + + return $allowed; + +}//end port_permitted() + + +function application_permitted($app_id, $device_id=null) { + global $permissions; + + if (is_numeric($app_id)) { + if (!$device_id) { + $device_id = get_device_id_by_app_id($app_id); + } + + if ($_SESSION['userlevel'] >= '5') { + $allowed = true; + } + else if (device_permitted($device_id)) { + $allowed = true; + } + else if ($permissions['application'][$app_id]) { + $allowed = true; + } + else { + $allowed = false; + } + } + else { + $allowed = false; + } + + return $allowed; + +}//end application_permitted() + + +function device_permitted($device_id) { + global $permissions; + + if ($_SESSION['userlevel'] >= '5') { + $allowed = true; + } + else if ($permissions['device'][$device_id]) { + $allowed = true; + } + else { + $allowed = false; + } + + return $allowed; + +}//end device_permitted() + + +function print_graph_tag($args) { + echo generate_graph_tag($args); + +}//end print_graph_tag() + + +function generate_graph_tag($args) { + $urlargs = array(); + foreach ($args as $key => $arg) { + $urlargs[] = $key.'='.urlencode($arg); + } + + return ''; + +}//end generate_graph_tag() - return ''; -} function generate_graph_js_state($args) { - // we are going to assume we know roughly what the graph url looks like here. - // TODO: Add sensible defaults - $from = (is_numeric($args['from']) ? $args['from'] : 0); - $to = (is_numeric($args['to']) ? $args['to'] : 0); - $width = (is_numeric($args['width']) ? $args['width'] : 0); - $height = (is_numeric($args['height']) ? $args['height'] : 0); - $legend = str_replace("'", "", $args['legend']); + // we are going to assume we know roughly what the graph url looks like here. + // TODO: Add sensible defaults + $from = (is_numeric($args['from']) ? $args['from'] : 0); + $to = (is_numeric($args['to']) ? $args['to'] : 0); + $width = (is_numeric($args['width']) ? $args['width'] : 0); + $height = (is_numeric($args['height']) ? $args['height'] : 0); + $legend = str_replace("'", '', $args['legend']); - $state = << document.graphFrom = $from; document.graphTo = $to; @@ -364,504 +450,662 @@ document.graphLegend = '$legend'; STATE; - return $state; -} + return $state; -function print_percentage_bar($width, $height, $percent, $left_text, $left_colour, $left_background, $right_text, $right_colour, $right_background) -{ +}//end generate_graph_js_state() - if ($percent > "100") { $size_percent = "100"; } else { $size_percent = $percent; } - $output = ' -
    -
    -
    -
    -
    - '.$left_text.' - '.$right_text.' -
    -'; +function print_percentage_bar($width, $height, $percent, $left_text, $left_colour, $left_background, $right_text, $right_colour, $right_background) { + if ($percent > '100') { + $size_percent = '100'; + } + else { + $size_percent = $percent; + } - return $output; -} + $output = ' +
    +
    +
    +
    +
    + '.$left_text.' + '.$right_text.' +
    + '; -function generate_entity_link($type, $entity, $text = NULL, $graph_type=NULL) -{ - global $config, $entity_cache; + return $output; - if (is_numeric($entity)) - { - $entity = get_entity_by_id_cache($type, $entity); - } +}//end print_percentage_bar() + + +function generate_entity_link($type, $entity, $text=null, $graph_type=null) { + global $config, $entity_cache; + + if (is_numeric($entity)) { + $entity = get_entity_by_id_cache($type, $entity); + } + + switch ($type) { + case 'port': + $link = generate_port_link($entity, $text, $graph_type); + break; + + case 'storage': + if (empty($text)) { + $text = $entity['storage_descr']; + } + + $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'storage')); + break; - switch($type) - { - case "port": - $link = generate_port_link($entity, $text, $graph_type); - break; - case "storage": - if (empty($text)) { $text = $entity['storage_descr']; } - $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'storage')); - break; default: - $link = $entity[$type.'_id']; - } + $link = $entity[$type.'_id']; + } - return($link); + return ($link); -} +}//end generate_entity_link() -function generate_port_link($port, $text = NULL, $type = NULL, $overlib = 1, $single_graph = 0) -{ - global $config; - $graph_array = array(); - $port = ifNameDescr($port); - if (!$text) { $text = fixIfName($port['label']); } - if ($type) { $port['graph_type'] = $type; } - if (!isset($port['graph_type'])) { $port['graph_type'] = 'port_bits'; } +function generate_port_link($port, $text=null, $type=null, $overlib=1, $single_graph=0) { + global $config; - $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + $graph_array = array(); + $port = ifNameDescr($port); + if (!$text) { + $text = fixIfName($port['label']); + } - if (!isset($port['hostname'])) { $port = array_merge($port, device_by_id_cache($port['device_id'])); } + if ($type) { + $port['graph_type'] = $type; + } - $content = "
    ".$port['hostname']." - " . fixifName($port['label']) . "
    "; - if ($port['ifAlias']) { $content .= $port['ifAlias']."
    "; } - $content .= "
    "; - $graph_array['type'] = $port['graph_type']; - $graph_array['legend'] = "yes"; - $graph_array['height'] = "100"; - $graph_array['width'] = "340"; - $graph_array['to'] = $config['time']['now']; - $graph_array['from'] = $config['time']['day']; - $graph_array['id'] = $port['port_id']; - $content .= generate_graph_tag($graph_array); - if ($single_graph == 0) { - $graph_array['from'] = $config['time']['week']; - $content .= generate_graph_tag($graph_array); - $graph_array['from'] = $config['time']['month']; - $content .= generate_graph_tag($graph_array); - $graph_array['from'] = $config['time']['year']; - $content .= generate_graph_tag($graph_array); - } - $content .= "
    "; + if (!isset($port['graph_type'])) { + $port['graph_type'] = 'port_bits'; + } - $url = generate_port_url($port); + $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - if ($overlib == 0) { - return $content; - } elseif (port_permitted($port['port_id'], $port['device_id'])) { - return overlib_link($url, $text, $content, $class); - } else { - return fixifName($text); - } -} + if (!isset($port['hostname'])) { + $port = array_merge($port, device_by_id_cache($port['device_id'])); + } -function generate_port_url($port, $vars=array()) -{ - return generate_url(array('page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['port_id']), $vars); -} + $content = '
    '.$port['hostname'].' - '.fixifName($port['label']).'
    '; + if ($port['ifAlias']) { + $content .= $port['ifAlias'].'
    '; + } + + $content .= "
    "; + $graph_array['type'] = $port['graph_type']; + $graph_array['legend'] = 'yes'; + $graph_array['height'] = '100'; + $graph_array['width'] = '340'; + $graph_array['to'] = $config['time']['now']; + $graph_array['from'] = $config['time']['day']; + $graph_array['id'] = $port['port_id']; + $content .= generate_graph_tag($graph_array); + if ($single_graph == 0) { + $graph_array['from'] = $config['time']['week']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['month']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['year']; + $content .= generate_graph_tag($graph_array); + } + + $content .= '
    '; + + $url = generate_port_url($port); + + if ($overlib == 0) { + return $content; + } + else if (port_permitted($port['port_id'], $port['device_id'])) { + return overlib_link($url, $text, $content, $class); + } + else { + return fixifName($text); + } + +}//end generate_port_link() + + +function generate_port_url($port, $vars=array()) { + return generate_url(array('page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['port_id']), $vars); + +}//end generate_port_url() + + +function generate_peer_url($peer, $vars=array()) { + return generate_url(array('page' => 'device', 'device' => $peer['device_id'], 'tab' => 'routing', 'proto' => 'bgp'), $vars); + +}//end generate_peer_url() -function generate_peer_url($peer, $vars=array()) -{ - return generate_url(array('page' => 'device', 'device' => $peer['device_id'], 'tab' => 'routing', 'proto' => 'bgp'), $vars); -} function generate_bill_url($bill, $vars=array()) { - return generate_url(array('page' => 'bill', 'bill_id' => $bill['bill_id']), $vars); -} + return generate_url(array('page' => 'bill', 'bill_id' => $bill['bill_id']), $vars); -function generate_port_image($args) -{ - if (!$args['bg']) { $args['bg'] = "FFFFFF"; } - return ""; -} +}//end generate_bill_url() -function generate_port_thumbnail($port) -{ - global $config; - $port['graph_type'] = 'port_bits'; - $port['from'] = $config['time']['day']; - $port['to'] = $config['time']['now']; - $port['width'] = 150; - $port['height'] = 21; - return generate_port_image($port); -} -function print_port_thumbnail($args) -{ - echo(generate_port_link($args, generate_port_image($args))); -} +function generate_port_image($args) { + if (!$args['bg']) { + $args['bg'] = 'FFFFFF'; + } -function print_optionbar_start ($height = 0, $width = 0, $marginbottom = 5) -{ - echo(' + return ""; + +}//end generate_port_image() + + +function generate_port_thumbnail($port) { + global $config; + $port['graph_type'] = 'port_bits'; + $port['from'] = $config['time']['day']; + $port['to'] = $config['time']['now']; + $port['width'] = 150; + $port['height'] = 21; + return generate_port_image($port); + +}//end generate_port_thumbnail() + + +function print_port_thumbnail($args) { + echo generate_port_link($args, generate_port_image($args)); + +}//end print_port_thumbnail() + + +function print_optionbar_start($height=0, $width=0, $marginbottom=5) { + echo '
    -'); -} + '; -function print_optionbar_end() -{ - echo('
    '); -} +}//end print_optionbar_start() -function geteventicon($message) -{ - if ($message == "Device status changed to Down") { $icon = "server_connect.png"; } - if ($message == "Device status changed to Up") { $icon = "server_go.png"; } - if ($message == "Interface went down" || $message == "Interface changed state to Down") { $icon = "if-disconnect.png"; } - if ($message == "Interface went up" || $message == "Interface changed state to Up") { $icon = "if-connect.png"; } - if ($message == "Interface disabled") { $icon = "if-disable.png"; } - if ($message == "Interface enabled") { $icon = "if-enable.png"; } - if (isset($icon)) { return $icon; } else { return false; } -} -function overlibprint($text) -{ - return "onmouseover=\"return overlib('" . $text . "');\" onmouseout=\"return nd();\""; -} +function print_optionbar_end() { + echo '
    '; -function humanmedia($media) -{ - array_preg_replace($rewrite_iftype, $media); - return $media; -} +}//end print_optionbar_end() -function humanspeed($speed) -{ - $speed = formatRates($speed); - if ($speed == "") { $speed = "-"; } - return $speed; -} -function devclass($device) -{ - if (isset($device['status']) && $device['status'] == '0') { $class = "list-device-down"; } else { $class = "list-device"; } - if (isset($device['ignore']) && $device['ignore'] == '1') - { - $class = "list-device-ignored"; - if (isset($device['status']) && $device['status'] == '1') { $class = "list-device-ignored-up"; } - } - if (isset($device['disabled']) && $device['disabled'] == '1') { $class = "list-device-disabled"; } - - return $class; -} - -function getlocations() -{ - $ignore_dev_location = array(); - $locations = array(); - # Fetch override locations, not through get_dev_attrib, this would be a huge number of queries - $rows = dbFetchRows("SELECT attrib_type,attrib_value,device_id FROM devices_attribs WHERE attrib_type LIKE 'override_sysLocation%' ORDER BY attrib_type"); - foreach ($rows as $row) - { - if ($row['attrib_type'] == 'override_sysLocation_bool' && $row['attrib_value'] == 1) - { - $ignore_dev_location[$row['device_id']] = 1; +function geteventicon($message) { + if ($message == 'Device status changed to Down') { + $icon = 'server_connect.png'; } - # We can do this because of the ORDER BY, "bool" will be handled before "string" - elseif ($row['attrib_type'] == 'override_sysLocation_string' && (isset($ignore_dev_location[$row['device_id']]) && $ignore_dev_location[$row['device_id']] == 1)) - { - if (!in_array($row['attrib_value'],$locations)) { $locations[] = $row['attrib_value']; } + + if ($message == 'Device status changed to Up') { + $icon = 'server_go.png'; } - } - # Fetch regular locations - if ($_SESSION['userlevel'] >= '5') - { - $rows = dbFetchRows("SELECT D.device_id,location FROM devices AS D GROUP BY location ORDER BY location"); - } else { - $rows = dbFetchRows("SELECT D.device_id,location FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? GROUP BY location ORDER BY location", array($_SESSION['user_id'])); - } - - foreach ($rows as $row) - { - # Only add it as a location if it wasn't overridden (and not already there) - if ($row['location'] != '' && !isset($ignore_dev_location[$row['device_id']])) - { - if (!in_array($row['location'],$locations)) { $locations[] = $row['location']; } + if ($message == 'Interface went down' || $message == 'Interface changed state to Down') { + $icon = 'if-disconnect.png'; } - } - sort($locations); - return $locations; -} - -function foldersize($path) -{ - $total_size = 0; - $files = scandir($path); - $total_files = 0; - - foreach ($files as $t) - { - if (is_dir(rtrim($path, '/') . '/' . $t)) - { - if ($t<>"." && $t<>"..") - { - $size = foldersize(rtrim($path, '/') . '/' . $t); - $total_size += $size; - } - } else { - $size = filesize(rtrim($path, '/') . '/' . $t); - $total_size += $size; - $total_files++; + if ($message == 'Interface went up' || $message == 'Interface changed state to Up') { + $icon = 'if-connect.png'; } - } - return array($total_size, $total_files); -} - -function generate_ap_link($args, $text = NULL, $type = NULL) -{ - global $config; - - $args = ifNameDescr($args); - if (!$text) { $text = fixIfName($args['label']); } - if ($type) { $args['graph_type'] = $type; } - if (!isset($args['graph_type'])) { $args['graph_type'] = 'port_bits'; } - - if (!isset($args['hostname'])) { $args = array_merge($args, device_by_id_cache($args['device_id'])); } - - $content = "
    ".$args['text']." - " . fixifName($args['label']) . "
    "; - if ($args['ifAlias']) { $content .= $args['ifAlias']."
    "; } - $content .= "
    "; - $graph_array = array(); - $graph_array['type'] = $args['graph_type']; - $graph_array['legend'] = "yes"; - $graph_array['height'] = "100"; - $graph_array['width'] = "340"; - $graph_array['to'] = $config['time']['now']; - $graph_array['from'] = $config['time']['day']; - $graph_array['id'] = $args['accesspoint_id']; - $content .= generate_graph_tag($graph_array); - $graph_array['from'] = $config['time']['week']; - $content .= generate_graph_tag($graph_array); - $graph_array['from'] = $config['time']['month']; - $content .= generate_graph_tag($graph_array); - $graph_array['from'] = $config['time']['year']; - $content .= generate_graph_tag($graph_array); - $content .= "
    "; - - - $url = generate_ap_url($args); - if (port_permitted($args['interface_id'], $args['device_id'])) { - return overlib_link($url, $text, $content, $class); - } else { - return fixifName($text); - } -} - -function generate_ap_url($ap, $vars=array()) -{ - return generate_url(array('page' => 'device', 'device' => $ap['device_id'], 'tab' => 'accesspoint', 'ap' => $ap['accesspoint_id']), $vars); -} - -function report_this($message) -{ - global $config; - return '

    '.$message.' Please report this to the '.$config['project_name'].' developers.

    '; -} - -function report_this_text($message) -{ - global $config; - return $message.'\nPlease report this to the '.$config['project_name'].' developers at '.$config['project_issues'].'\n'; -} - -# Find all the files in the given directory that match the pattern -function get_matching_files($dir, $match = "/\.php$/") -{ - global $config; - - $list = array(); - if ($handle = opendir($dir)) - { - while (false !== ($file = readdir($handle))) - { - if ($file != "." && $file != ".." && preg_match($match, $file) === 1) - { - $list[] = $file; - } + if ($message == 'Interface disabled') { + $icon = 'if-disable.png'; } - closedir($handle); - } - return $list; -} -# Include all the files in the given directory that match the pattern -function include_matching_files($dir, $match = "/\.php$/") -{ - foreach (get_matching_files($dir, $match) as $file) { - include_once($file); - } -} + if ($message == 'Interface enabled') { + $icon = 'if-enable.png'; + } -function generate_pagination($count,$limit,$page,$links = 2) { - $end_page = ceil($count / $limit); - $start = (($page - $links) > 0) ? $page - $links : 1; - $end = (($page + $links) < $end_page) ? $page + $links : $end_page; - $return = '
      '; - $link_class = ($page == 1) ? "disabled" : ""; - $return .= "
    • «
    • "; - $return .= ""; + if (isset($icon)) { + return $icon; + } + else { + return false; + } - if($start > 1) { +}//end geteventicon() + + +function overlibprint($text) { + return "onmouseover=\"return overlib('".$text."');\" onmouseout=\"return nd();\""; + +}//end overlibprint() + + +function humanmedia($media) { + array_preg_replace($rewrite_iftype, $media); + return $media; + +}//end humanmedia() + + +function humanspeed($speed) { + $speed = formatRates($speed); + if ($speed == '') { + $speed = '-'; + } + + return $speed; + +}//end humanspeed() + + +function devclass($device) { + if (isset($device['status']) && $device['status'] == '0') { + $class = 'list-device-down'; + } + else { + $class = 'list-device'; + } + + if (isset($device['ignore']) && $device['ignore'] == '1') { + $class = 'list-device-ignored'; + if (isset($device['status']) && $device['status'] == '1') { + $class = 'list-device-ignored-up'; + } + } + + if (isset($device['disabled']) && $device['disabled'] == '1') { + $class = 'list-device-disabled'; + } + + return $class; + +}//end devclass() + + +function getlocations() { + $ignore_dev_location = array(); + $locations = array(); + // Fetch override locations, not through get_dev_attrib, this would be a huge number of queries + $rows = dbFetchRows("SELECT attrib_type,attrib_value,device_id FROM devices_attribs WHERE attrib_type LIKE 'override_sysLocation%' ORDER BY attrib_type"); + foreach ($rows as $row) { + if ($row['attrib_type'] == 'override_sysLocation_bool' && $row['attrib_value'] == 1) { + $ignore_dev_location[$row['device_id']] = 1; + } //end if + else if ($row['attrib_type'] == 'override_sysLocation_string' && (isset($ignore_dev_location[$row['device_id']]) && $ignore_dev_location[$row['device_id']] == 1)) { + if (!in_array($row['attrib_value'], $locations)) { + $locations[] = $row['attrib_value']; + } + } + } + + // Fetch regular locations + if ($_SESSION['userlevel'] >= '5') { + $rows = dbFetchRows('SELECT D.device_id,location FROM devices AS D GROUP BY location ORDER BY location'); + } + else { + $rows = dbFetchRows('SELECT D.device_id,location FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? GROUP BY location ORDER BY location', array($_SESSION['user_id'])); + } + + foreach ($rows as $row) { + // Only add it as a location if it wasn't overridden (and not already there) + if ($row['location'] != '' && !isset($ignore_dev_location[$row['device_id']])) { + if (!in_array($row['location'], $locations)) { + $locations[] = $row['location']; + } + } + } + + sort($locations); + return $locations; + +}//end getlocations() + + +function foldersize($path) { + $total_size = 0; + $files = scandir($path); + $total_files = 0; + + foreach ($files as $t) { + if (is_dir(rtrim($path, '/').'/'.$t)) { + if ($t <> '.' && $t <> '..') { + $size = foldersize(rtrim($path, '/').'/'.$t); + $total_size += $size; + } + } + else { + $size = filesize(rtrim($path, '/').'/'.$t); + $total_size += $size; + $total_files++; + } + } + + return array( + $total_size, + $total_files, + ); + +}//end foldersize() + + +function generate_ap_link($args, $text=null, $type=null) { + global $config; + + $args = ifNameDescr($args); + if (!$text) { + $text = fixIfName($args['label']); + } + + if ($type) { + $args['graph_type'] = $type; + } + + if (!isset($args['graph_type'])) { + $args['graph_type'] = 'port_bits'; + } + + if (!isset($args['hostname'])) { + $args = array_merge($args, device_by_id_cache($args['device_id'])); + } + + $content = '
      '.$args['text'].' - '.fixifName($args['label']).'
      '; + if ($args['ifAlias']) { + $content .= $args['ifAlias'].'
      '; + } + + $content .= "
      "; + $graph_array = array(); + $graph_array['type'] = $args['graph_type']; + $graph_array['legend'] = 'yes'; + $graph_array['height'] = '100'; + $graph_array['width'] = '340'; + $graph_array['to'] = $config['time']['now']; + $graph_array['from'] = $config['time']['day']; + $graph_array['id'] = $args['accesspoint_id']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['week']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['month']; + $content .= generate_graph_tag($graph_array); + $graph_array['from'] = $config['time']['year']; + $content .= generate_graph_tag($graph_array); + $content .= '
      '; + + $url = generate_ap_url($args); + if (port_permitted($args['interface_id'], $args['device_id'])) { + return overlib_link($url, $text, $content, $class); + } + else { + return fixifName($text); + } + +}//end generate_ap_link() + + +function generate_ap_url($ap, $vars=array()) { + return generate_url(array('page' => 'device', 'device' => $ap['device_id'], 'tab' => 'accesspoint', 'ap' => $ap['accesspoint_id']), $vars); + +}//end generate_ap_url() + + +function report_this($message) { + global $config; + return '

      '.$message.' Please report this to the '.$config['project_name'].' developers.

      '; + +}//end report_this() + + +function report_this_text($message) { + global $config; + return $message.'\nPlease report this to the '.$config['project_name'].' developers at '.$config['project_issues'].'\n'; + +}//end report_this_text() + + +// Find all the files in the given directory that match the pattern + + +function get_matching_files($dir, $match='/\.php$/') { + global $config; + + $list = array(); + if ($handle = opendir($dir)) { + while (false !== ($file = readdir($handle))) { + if ($file != '.' && $file != '..' && preg_match($match, $file) === 1) { + $list[] = $file; + } + } + + closedir($handle); + } + + return $list; + +}//end get_matching_files() + + +// Include all the files in the given directory that match the pattern + + +function include_matching_files($dir, $match='/\.php$/') { + foreach (get_matching_files($dir, $match) as $file) { + include_once $file; + } + +}//end include_matching_files() + + +function generate_pagination($count, $limit, $page, $links=2) { + $end_page = ceil($count / $limit); + $start = (($page - $links) > 0) ? ($page - $links) : 1; + $end = (($page + $links) < $end_page) ? ($page + $links) : $end_page; + $return = '
        '; + $link_class = ($page == 1) ? 'disabled' : ''; + $return .= "
      • «
      • "; + $return .= ""; + + if ($start > 1) { $return .= "
      • 1
      • "; $return .= "
      • ...
      • "; } - for($x=$start;$x<=$end;$x++) { - $link_class = ($page == $x) ? "active" : ""; - $return .= ""; + for ($x = $start; $x <= $end; $x++) { + $link_class = ($page == $x) ? 'active' : ''; + $return .= ""; } - if($end < $end_page) { + if ($end < $end_page) { $return .= "
      • ...
      • "; $return .= "
      • $end_page
      • "; } - $link_class = ($page == $end_page) ? "disabled" : ""; - $return .= ""; - $return .= ""; - $return .= '
      '; - return($return); -} + $link_class = ($page == $end_page) ? 'disabled' : ''; + $return .= ""; + $return .= ""; + $return .= '
    '; + return ($return); + +}//end generate_pagination() + function is_admin() { if ($_SESSION['userlevel'] >= '10') { $allowed = true; - } else { + } + else { $allowed = false; } + return $allowed; -} + +}//end is_admin() + function is_read() { if ($_SESSION['userlevel'] == '5') { $allowed = true; - } else { + } + else { $allowed = false; } + return $allowed; -} + +}//end is_read() + function demo_account() { print_error("You are logged in as a demo account, this page isn't accessible to you"); -} + +}//end demo_account() + function get_client_ip() { - if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $client_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; - } else { + } + else { $client_ip = $_SERVER['REMOTE_ADDR']; } + return $client_ip; -} + +}//end get_client_ip() + function shorten_interface_type($string) { - return str_ireplace( - array('FastEthernet','TenGigabitEthernet','GigabitEthernet','Port-Channel','Ethernet'), - array('Fa','Te','Gi','Po','Eth'), - $string - ); -} + array( + 'FastEthernet', + 'TenGigabitEthernet', + 'GigabitEthernet', + 'Port-Channel', + 'Ethernet', + ), + array( + 'Fa', + 'Te', + 'Gi', + 'Po', + 'Eth', + ), + $string + ); + +}//end shorten_interface_type() + function clean_bootgrid($string) { - - $output = str_replace(array("\r","\n"), "", $string); + $output = str_replace(array("\r", "\n"), '', $string); $output = addslashes($output); return $output; -} -//Insert new config items -function add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc) { +}//end clean_bootgrid() + + +// Insert new config items +function add_config_item($new_conf_name, $new_conf_value, $new_conf_type, $new_conf_desc) { if (dbInsert(array('config_name' => $new_conf_name, 'config_value' => $new_conf_value, 'config_default' => $new_conf_value, 'config_type' => $new_conf_type, 'config_desc' => $new_conf_desc, 'config_group' => '500_Custom Settings', 'config_sub_group' => '01_Custom settings', 'config_hidden' => '0', 'config_disabled' => '0'), 'config')) { $db_inserted = 1; - } else { + } + else { $db_inserted = 0; } - return($db_inserted); -} + + return ($db_inserted); + +}//end add_config_item() + function get_config_by_group($group) { $group = array($group); $items = array(); foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_group` = '?'", array($group)) as $config_item) { $val = $config_item['config_value']; - if (filter_var($val,FILTER_VALIDATE_INT)) { + if (filter_var($val, FILTER_VALIDATE_INT)) { $val = (int) $val; - } elseif (filter_var($val,FILTER_VALIDATE_FLOAT)) { + } + else if (filter_var($val, FILTER_VALIDATE_FLOAT)) { $val = (float) $val; - } elseif (filter_var($val,FILTER_VALIDATE_BOOLEAN)) { - $val =(boolean) $val; } - if ($val === TRUE) { - $config_item += array('config_checked'=>'checked'); + else if (filter_var($val, FILTER_VALIDATE_BOOLEAN)) { + $val = (boolean) $val; } + + if ($val === true) { + $config_item += array('config_checked' => 'checked'); + } + $items[$config_item['config_name']] = $config_item; } + return $items; -} + +}//end get_config_by_group() + function get_config_like_name($name) { - $name = array($name); + $name = array($name); $items = array(); foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_name` LIKE '%?%'", array($name)) as $config_item) { $items[$config_item['config_name']] = $config_item; } + return $items; -} + +}//end get_config_like_name() + function get_config_by_name($name) { - $config_item = dbFetchRow("SELECT * FROM `config` WHERE `config_name` = ?", array($name)); - return $config_item; -} + $config_item = dbFetchRow('SELECT * FROM `config` WHERE `config_name` = ?', array($name)); + return $config_item; -function set_config_name($name,$config_value) { +}//end get_config_by_name() + + +function set_config_name($name, $config_value) { return dbUpdate(array('config_value' => $config_value), 'config', '`config_name`=?', array($name)); -} + +}//end set_config_name() + function get_url() { // http://stackoverflow.com/questions/2820723/how-to-get-base-url-with-php // http://stackoverflow.com/users/184600/ma%C4%8Dek return sprintf( - "%s://%s%s", + '%s://%s%s', isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', $_SERVER['SERVER_NAME'], $_SERVER['REQUEST_URI'] ); -} + +}//end get_url() + function alert_details($details) { - if( !is_array($details) ) { - $details = json_decode(gzuncompress($details),true); + if (!is_array($details)) { + $details = json_decode(gzuncompress($details), true); } - $fault_detail = ''; - foreach( $details['rule'] as $o=>$tmp_alerts ) { - $fallback = true; - $fault_detail .= "#".($o+1).": "; - if( $tmp_alerts['bill_id'] ) { - $fault_detail .= ''.$tmp_alerts['bill_name'].'; '; - $fallback = false; - } - if( $tmp_alerts['port_id'] ) { - $fault_detail .= generate_port_link($tmp_alerts).'; '; - $fallback = false; - } - if( $fallback === true ) { - foreach( $tmp_alerts as $k=>$v ) { - if (!empty($v) && $k != 'device_id' && (stristr($k,'id') || stristr($k,'desc') || stristr($k,'msg')) && substr_count($k,'_') <= 1) { - $fault_detail .= "$k => '$v', "; - } - } - $fault_detail = rtrim($fault_detail,", "); - } - $fault_detail .= "
    "; - } - return $fault_detail; -} -?> + $fault_detail = ''; + foreach ($details['rule'] as $o => $tmp_alerts) { + $fallback = true; + $fault_detail .= '#'.($o + 1).': '; + if ($tmp_alerts['bill_id']) { + $fault_detail .= ''.$tmp_alerts['bill_name'].'; '; + $fallback = false; + } + + if ($tmp_alerts['port_id']) { + $fault_detail .= generate_port_link($tmp_alerts).'; '; + $fallback = false; + } + + if ($fallback === true) { + foreach ($tmp_alerts as $k => $v) { + if (!empty($v) && $k != 'device_id' && (stristr($k, 'id') || stristr($k, 'desc') || stristr($k, 'msg')) && substr_count($k, '_') <= 1) { + $fault_detail .= "$k => '$v', "; + } + } + + $fault_detail = rtrim($fault_detail, ', '); + } + + $fault_detail .= '
    '; + }//end foreach + + return $fault_detail; + +}//end alert_details() diff --git a/html/includes/geshi/geshi/ios.php b/html/includes/geshi/geshi/ios.php index dc6ccc508..ab343e2d5 100644 --- a/html/includes/geshi/geshi/ios.php +++ b/html/includes/geshi/geshi/ios.php @@ -1,172 +1,170 @@ 'IOS', -'COMMENT_SINGLE' => array(1 => '!'), -'CASE_KEYWORDS' => GESHI_CAPS_LOWER, -'OOLANG' => false, -'NUMBERS' => GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX, -'KEYWORDS' => array( - 1 => array( - 'no', 'shutdown' - ), -# 2 => array( -# 'router', 'interface', 'service', 'config-register', 'upgrade', 'version', 'hostname', 'boot-start-marker', 'boot', 'boot-end-marker', 'enable', 'aaa', 'clock', 'ip', -# 'logging', 'access-list', 'route-map', 'snmp-server', 'mpls', 'speed', 'media-type', 'negotiation', 'timestamps', 'prefix-list', 'network', 'mask', 'unsuppress-map', -# 'neighbor', 'remote-as', 'ebgp-multihop', 'update-source', 'description', 'peer-group', 'policy-map', 'class-map', 'class', 'match', 'access-group', 'bandwidth', 'username', -# 'password', 'send-community', 'next-hop-self', 'route-reflector-client', 'ldp', 'discovery', 'advertise-labels', 'label', 'protocol', 'login', 'debug', 'log', 'duplex', 'router-id', -# 'authentication', 'mode', 'maximum-paths', 'address-family', 'set', 'local-preference', 'community', 'trap-source', 'location', 'host', 'tacacs-server', 'session-id', -# 'flow-export', 'destination', 'source', 'in', 'out', 'permit', 'deny', 'control-plane', 'line', 'con' ,'aux', 'vty', 'access-class', 'ntp', 'server', 'end', 'source-interface', -# 'key', 'chain', 'key-string', 'redundancy', 'match-any', 'queue-limit', 'encapsulation', 'pvc', 'vbr-nrt', 'address', 'bundle-enable', 'atm', 'sonet', 'clns', 'route-cache', -# 'default-information', 'redistribute', 'log-adjacency-changes', 'metric', 'spf-interval', 'prc-interval', 'lsp-refresh-interval', 'max-lsp-lifetime', 'set-overload-bit', -# 'on-startup', 'wait-for-bgp', 'system', 'flash', 'timezone', 'subnet-zero', 'cef', 'flow-cache', 'timeout', 'active', 'domain', 'lookup', 'dhcp', 'use', 'vrf', 'hello', 'interval', -# 'priority', 'ilmi-keepalive', 'buffered', 'debugging', 'fpd', 'secret', 'accounting', 'exec', 'group', 'local', 'recurring', 'source-route', 'call', 'rsvp-sync', 'scripting', -# 'mtu', 'passive-interface', 'area' , 'distribute-list', 'metric-style', 'is-type', 'originate', 'activate', 'both', 'auto-summary', 'synchronization', 'aggregate-address', 'le', 'ge', -# 'bgp-community', 'route', 'exit-address-family', 'standard', 'file', 'verify', 'domain-name', 'domain-lookup', 'route-target', 'export', 'import', 'map', 'rd', 'mfib', 'vtp', 'mls', -# 'hardware-switching', 'replication-mode', 'ingress', 'flow', 'error', 'action', 'slb', 'purge', 'share-global', 'routing', 'traffic-eng', 'tunnels', 'propagate-ttl', 'switchport', 'vlan', -# 'portfast', 'counters', 'max', 'age', 'ethernet', 'evc', 'uni', 'count', 'oam', 'lmi', 'gmt', 'netflow', 'pseudowire-class', 'spanning-tree', 'name', 'circuit-type' -# ), -# 3 => array( -# 'isis', 'ospf', 'eigrp', 'rip', 'igrp', 'bgp', 'ipv4', 'unicast', 'multicast', 'ipv6', 'connected', 'static', 'subnets', 'tcl' -# ), -# 4 => array( -# 'point-to-point', 'aal5snap', 'rj45', 'auto', 'full', 'half', 'precedence', 'percent', 'datetime', 'msec', 'locatime', 'summer-time', 'md5', 'wait-for-bgp', 'wide', -# 'level-1', 'level-2', 'log-neighbor-changes', 'directed-request', 'password-encryption', 'common', 'origin-as', 'bgp-nexthop', 'random-detect', 'localtime', 'sso', 'stm-1', -# 'dot1q', 'isl', 'new-model', 'always', 'summary-only', 'freeze', 'global', 'forwarded', 'access', 'trunk', 'edge', 'transparent' -# ), -), - -'REGEXPS' => array ( - 1 => array( - GESHI_SEARCH => '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', - GESHI_REPLACE => '\\1', - GESHI_BEFORE => '', - ), - 2 => array( - GESHI_SEARCH => '(255\.\d{1,3}\.\d{1,3}\.\d{1,3})', - GESHI_REPLACE => '\\1', - GESHI_BEFORE => '', - ), - 3 => array( - GESHI_SEARCH => '(source|interface|update-source|router-id) ([A-Za-z0-9\/\:\-\.]+)', - GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ', - ), - 4 => array( - GESHI_SEARCH => '(neighbor) ([\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}]+|[a-zA-Z0-9\-\_]+)', - GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ', - ), - 5 => array( - GESHI_SEARCH => '(distribute-map|access-group|policy-map|class-map\ match-any|ip\ access-list\ extended|match\ community|community-list\ standard|community-list\ expanded|ip\ access-list\ standard|router\ bgp|remote-as|key\ chain|service-policy\ input|service-policy\ output|class|login\ authentication|authentication\ key-chain|username|import\ map|export\ map|domain-name|hostname|route-map|access-class|ip\ vrf\ forwarding|ip\ vrf|vtp\ domain|name|pseudowire-class|pw-class|prefix-list|vrf) ([A-Za-z0-9\-\_\.]+)', - GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ', - ), - 6 => array( - GESHI_SEARCH => '(password|key-string|key) ([0-9]) (.+)', - GESHI_REPLACE => '\\2 \\3', - GESHI_BEFORE => '\\1 ', - ), - 7 => array( - GESHI_SEARCH => '(enable) ([a-z]+) ([0-9]) (.+)', - GESHI_REPLACE => '\\3 \\4', - GESHI_BEFORE => '\\1 \\2 ', - ), - 8 => array( - GESHI_SEARCH => '(description|location|contact|remark) (.+)', - GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ', - ), - 9 => array( - GESHI_SEARCH => '([0-9\.\_\*]+\:[0-9\.\_\*]+)', - GESHI_REPLACE => '\\1', - ), - 10 => array( - GESHI_SEARCH => '(boot) ([a-z]+) (.+)', - GESHI_REPLACE => '\\3', - GESHI_BEFORE => '\\1 \\2 ' - ), - 11 => array( - GESHI_SEARCH => '(net) ([0-9a-z\.]+)', - GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ' - ), - 12 => array( - GESHI_SEARCH => '(access-list|RO|RW) ([0-9]+)', - GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ' - ), - 13 => array( - GESHI_SEARCH => '(vlan) ([0-9]+)', - GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ' - ), - 14 => array( - GESHI_SEARCH => '(encapsulation|speed|duplex|mtu|metric|media-type|negotiation|transport\ input|bgp-community|set\ as-path\ prepend|maximum-prefix|version|local-preference|continue|redistribute|cluster-id|vtp\ mode|label\ protocol|spanning-tree\ mode) (.+)', - GESHI_REPLACE => '\\2', - GESHI_BEFORE => '\\1 ' +$language_data = array( + 'LANG_NAME' => 'IOS', + 'COMMENT_SINGLE' => array(1 => '!'), + 'CASE_KEYWORDS' => GESHI_CAPS_LOWER, + 'OOLANG' => false, + 'NUMBERS' => GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX, + 'KEYWORDS' => array( + 1 => array( + 'no', + 'shutdown', + ), + // 2 => array( + // 'router', 'interface', 'service', 'config-register', 'upgrade', 'version', 'hostname', 'boot-start-marker', 'boot', 'boot-end-marker', 'enable', 'aaa', 'clock', 'ip', + // 'logging', 'access-list', 'route-map', 'snmp-server', 'mpls', 'speed', 'media-type', 'negotiation', 'timestamps', 'prefix-list', 'network', 'mask', 'unsuppress-map', + // 'neighbor', 'remote-as', 'ebgp-multihop', 'update-source', 'description', 'peer-group', 'policy-map', 'class-map', 'class', 'match', 'access-group', 'bandwidth', 'username', + // 'password', 'send-community', 'next-hop-self', 'route-reflector-client', 'ldp', 'discovery', 'advertise-labels', 'label', 'protocol', 'login', 'debug', 'log', 'duplex', 'router-id', + // 'authentication', 'mode', 'maximum-paths', 'address-family', 'set', 'local-preference', 'community', 'trap-source', 'location', 'host', 'tacacs-server', 'session-id', + // 'flow-export', 'destination', 'source', 'in', 'out', 'permit', 'deny', 'control-plane', 'line', 'con' ,'aux', 'vty', 'access-class', 'ntp', 'server', 'end', 'source-interface', + // 'key', 'chain', 'key-string', 'redundancy', 'match-any', 'queue-limit', 'encapsulation', 'pvc', 'vbr-nrt', 'address', 'bundle-enable', 'atm', 'sonet', 'clns', 'route-cache', + // 'default-information', 'redistribute', 'log-adjacency-changes', 'metric', 'spf-interval', 'prc-interval', 'lsp-refresh-interval', 'max-lsp-lifetime', 'set-overload-bit', + // 'on-startup', 'wait-for-bgp', 'system', 'flash', 'timezone', 'subnet-zero', 'cef', 'flow-cache', 'timeout', 'active', 'domain', 'lookup', 'dhcp', 'use', 'vrf', 'hello', 'interval', + // 'priority', 'ilmi-keepalive', 'buffered', 'debugging', 'fpd', 'secret', 'accounting', 'exec', 'group', 'local', 'recurring', 'source-route', 'call', 'rsvp-sync', 'scripting', + // 'mtu', 'passive-interface', 'area' , 'distribute-list', 'metric-style', 'is-type', 'originate', 'activate', 'both', 'auto-summary', 'synchronization', 'aggregate-address', 'le', 'ge', + // 'bgp-community', 'route', 'exit-address-family', 'standard', 'file', 'verify', 'domain-name', 'domain-lookup', 'route-target', 'export', 'import', 'map', 'rd', 'mfib', 'vtp', 'mls', + // 'hardware-switching', 'replication-mode', 'ingress', 'flow', 'error', 'action', 'slb', 'purge', 'share-global', 'routing', 'traffic-eng', 'tunnels', 'propagate-ttl', 'switchport', 'vlan', + // 'portfast', 'counters', 'max', 'age', 'ethernet', 'evc', 'uni', 'count', 'oam', 'lmi', 'gmt', 'netflow', 'pseudowire-class', 'spanning-tree', 'name', 'circuit-type' + // ), + // 3 => array( + // 'isis', 'ospf', 'eigrp', 'rip', 'igrp', 'bgp', 'ipv4', 'unicast', 'multicast', 'ipv6', 'connected', 'static', 'subnets', 'tcl' + // ), + // 4 => array( + // 'point-to-point', 'aal5snap', 'rj45', 'auto', 'full', 'half', 'precedence', 'percent', 'datetime', 'msec', 'locatime', 'summer-time', 'md5', 'wait-for-bgp', 'wide', + // 'level-1', 'level-2', 'log-neighbor-changes', 'directed-request', 'password-encryption', 'common', 'origin-as', 'bgp-nexthop', 'random-detect', 'localtime', 'sso', 'stm-1', + // 'dot1q', 'isl', 'new-model', 'always', 'summary-only', 'freeze', 'global', 'forwarded', 'access', 'trunk', 'edge', 'transparent' + // ), ), -), - -'STYLES' => array( - 'REGEXPS' => array( - 0 => 'color: #ff0000;', - 1 => 'color: #0000cc;', # x.x.x.x - 2 => 'color: #000099; font-style: italic', # 255.x.x.x - 3 => 'color: #000000; font-weight: bold; font-style: italic;', # interface xxx - 4 => 'color: #ff0000;', # neighbor x.x.x.x - 5 => 'color: #000099;', # variable names - 6 => 'color: #cc0000;', - 7 => 'color: #cc0000;', # passwords - 8 => 'color: #555555;', # description - 9 => 'color: #990099;', # communities - 10 => 'color: #cc0000; font-style: italic;', # no/shut - 11 => 'color: #000099;', # net numbers - 12 => 'color: #000099;', # acls - 13 => 'color: #000099;', # acls - 14 => 'color: #990099;', # warnings - ), - 'KEYWORDS' => array( - 1 => 'color: #cc0000; font-weight: bold;', # no/shut - 2 => 'color: #000000;', # commands - 3 => 'color: #000000; font-weight: bold;', # proto/service - 4 => 'color: #000000;', # options - 5 => 'color: #ff0000;' - ), - 'COMMENTS' => array( - 1 => 'color: #808080; font-style: italic;' - ), - 'ESCAPE_CHAR' => array( - 0 => 'color: #000099; font-weight: bold;' - ), - 'BRACKETS' => array( - 0 => 'color: #66cc66;' - ), - 'STRINGS' => array( - 0 => 'color: #ff0000;' - ), - 'NUMBERS' => array( - 0 => 'color: #cc0000;' - ), - 'METHODS' => array( - 0 => 'color: #006600;' - ), - 'SYMBOLS' => array( - 0 => 'color: #66cc66;' - ), - 'SCRIPT' => array( - 0 => '', - 1 => '', - 2 => '', - 3 => '' - ) - -) + 'REGEXPS' => array( + 1 => array( + GESHI_SEARCH => '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', + GESHI_REPLACE => '\\1', + GESHI_BEFORE => '', + ), + 2 => array( + GESHI_SEARCH => '(255\.\d{1,3}\.\d{1,3}\.\d{1,3})', + GESHI_REPLACE => '\\1', + GESHI_BEFORE => '', + ), + 3 => array( + GESHI_SEARCH => '(source|interface|update-source|router-id) ([A-Za-z0-9\/\:\-\.]+)', + GESHI_REPLACE => '\\2', + GESHI_BEFORE => '\\1 ', + ), + 4 => array( + GESHI_SEARCH => '(neighbor) ([\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}]+|[a-zA-Z0-9\-\_]+)', + GESHI_REPLACE => '\\2', + GESHI_BEFORE => '\\1 ', + ), + 5 => array( + GESHI_SEARCH => '(distribute-map|access-group|policy-map|class-map\ match-any|ip\ access-list\ extended|match\ community|community-list\ standard|community-list\ expanded|ip\ access-list\ standard|router\ bgp|remote-as|key\ chain|service-policy\ input|service-policy\ output|class|login\ authentication|authentication\ key-chain|username|import\ map|export\ map|domain-name|hostname|route-map|access-class|ip\ vrf\ forwarding|ip\ vrf|vtp\ domain|name|pseudowire-class|pw-class|prefix-list|vrf) ([A-Za-z0-9\-\_\.]+)', + GESHI_REPLACE => '\\2', + GESHI_BEFORE => '\\1 ', + ), + 6 => array( + GESHI_SEARCH => '(password|key-string|key) ([0-9]) (.+)', + GESHI_REPLACE => '\\2 \\3', + GESHI_BEFORE => '\\1 ', + ), + 7 => array( + GESHI_SEARCH => '(enable) ([a-z]+) ([0-9]) (.+)', + GESHI_REPLACE => '\\3 \\4', + GESHI_BEFORE => '\\1 \\2 ', + ), + 8 => array( + GESHI_SEARCH => '(description|location|contact|remark) (.+)', + GESHI_REPLACE => '\\2', + GESHI_BEFORE => '\\1 ', + ), + 9 => array( + GESHI_SEARCH => '([0-9\.\_\*]+\:[0-9\.\_\*]+)', + GESHI_REPLACE => '\\1', + ), + 10 => array( + GESHI_SEARCH => '(boot) ([a-z]+) (.+)', + GESHI_REPLACE => '\\3', + GESHI_BEFORE => '\\1 \\2 ', + ), + 11 => array( + GESHI_SEARCH => '(net) ([0-9a-z\.]+)', + GESHI_REPLACE => '\\2', + GESHI_BEFORE => '\\1 ', + ), + 12 => array( + GESHI_SEARCH => '(access-list|RO|RW) ([0-9]+)', + GESHI_REPLACE => '\\2', + GESHI_BEFORE => '\\1 ', + ), + 13 => array( + GESHI_SEARCH => '(vlan) ([0-9]+)', + GESHI_REPLACE => '\\2', + GESHI_BEFORE => '\\1 ', + ), + 14 => array( + GESHI_SEARCH => '(encapsulation|speed|duplex|mtu|metric|media-type|negotiation|transport\ input|bgp-community|set\ as-path\ prepend|maximum-prefix|version|local-preference|continue|redistribute|cluster-id|vtp\ mode|label\ protocol|spanning-tree\ mode) (.+)', + GESHI_REPLACE => '\\2', + GESHI_BEFORE => '\\1 ', + ), + ), + 'STYLES' => array( + 'REGEXPS' => array( + 0 => 'color: #ff0000;', + 1 => 'color: #0000cc;', + // x.x.x.x + 2 => 'color: #000099; font-style: italic', + // 255.x.x.x + 3 => 'color: #000000; font-weight: bold; font-style: italic;', + // interface xxx + 4 => 'color: #ff0000;', + // neighbor x.x.x.x + 5 => 'color: #000099;', + // variable names + 6 => 'color: #cc0000;', + 7 => 'color: #cc0000;', + // passwords + 8 => 'color: #555555;', + // description + 9 => 'color: #990099;', + // communities + 10 => 'color: #cc0000; font-style: italic;', + // no/shut + 11 => 'color: #000099;', + // net numbers + 12 => 'color: #000099;', + // acls + 13 => 'color: #000099;', + // acls + 14 => 'color: #990099;', + // warnings + ), + 'KEYWORDS' => array( + 1 => 'color: #cc0000; font-weight: bold;', + // no/shut + 2 => 'color: #000000;', + // commands + 3 => 'color: #000000; font-weight: bold;', + // proto/service + 4 => 'color: #000000;', + // options + 5 => 'color: #ff0000;', + ), + 'COMMENTS' => array(1 => 'color: #808080; font-style: italic;'), + 'ESCAPE_CHAR' => array(0 => 'color: #000099; font-weight: bold;'), + 'BRACKETS' => array(0 => 'color: #66cc66;'), + 'STRINGS' => array(0 => 'color: #ff0000;'), + 'NUMBERS' => array(0 => 'color: #cc0000;'), + 'METHODS' => array(0 => 'color: #006600;'), + 'SYMBOLS' => array(0 => 'color: #66cc66;'), + 'SCRIPT' => array( + 0 => '', + 1 => '', + 2 => '', + 3 => '', + ), + ), ); - -?> diff --git a/html/includes/graphs/accesspoints/channel.inc.php b/html/includes/graphs/accesspoints/channel.inc.php index 03b0dd24c..d68824fa1 100644 --- a/html/includes/graphs/accesspoints/channel.inc.php +++ b/html/includes/graphs/accesspoints/channel.inc.php @@ -1,25 +1,21 @@ diff --git a/html/includes/graphs/application/apache_bits.inc.php b/html/includes/graphs/application/apache_bits.inc.php index fabf9453b..b6767533e 100644 --- a/html/includes/graphs/application/apache_bits.inc.php +++ b/html/includes/graphs/application/apache_bits.inc.php @@ -2,27 +2,24 @@ $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$apache_rrd = $config['rrd_dir'] . "/" . $device['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; +if (is_file($apache_rrd)) { + $rrd_filename = $apache_rrd; } -$ds = "kbyte"; +$ds = 'kbyte'; -$colour_area = "CDEB8B"; -$colour_line = "006600"; +$colour_area = 'CDEB8B'; +$colour_line = '006600'; -$colour_area_max = "FFEE99"; +$colour_area_max = 'FFEE99'; -$graph_max = 1; +$graph_max = 1; $multiplier = 8; -$unit_text = "Kbps"; +$unit_text = 'Kbps'; -include("includes/graphs/generic_simplex.inc.php"); - -?> +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/apache_cpu.inc.php b/html/includes/graphs/application/apache_cpu.inc.php index bb49d3f63..e136a6ed1 100644 --- a/html/includes/graphs/application/apache_cpu.inc.php +++ b/html/includes/graphs/application/apache_cpu.inc.php @@ -2,26 +2,23 @@ $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$apache_rrd = $config['rrd_dir'] . "/" . $device['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; +if (is_file($apache_rrd)) { + $rrd_filename = $apache_rrd; } -$ds = "cpu"; +$ds = 'cpu'; -$colour_area = "F0E68C"; -$colour_line = "FF4500"; +$colour_area = 'F0E68C'; +$colour_line = 'FF4500'; -$colour_area_max = "FFEE99"; +$colour_area_max = 'FFEE99'; $graph_max = 1; -$unit_text = "% Used"; +$unit_text = '% Used'; -include("includes/graphs/generic_simplex.inc.php"); - -?> +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/apache_hits.inc.php b/html/includes/graphs/application/apache_hits.inc.php index 0f0d4832c..5e1a74cea 100644 --- a/html/includes/graphs/application/apache_hits.inc.php +++ b/html/includes/graphs/application/apache_hits.inc.php @@ -2,26 +2,23 @@ $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$apache_rrd = $config['rrd_dir'] . "/" . $device['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; +if (is_file($apache_rrd)) { + $rrd_filename = $apache_rrd; } -$ds = "access"; +$ds = 'access'; -$colour_area = "B0C4DE"; -$colour_line = "191970"; +$colour_area = 'B0C4DE'; +$colour_line = '191970'; -$colour_area_max = "FFEE99"; +$colour_area_max = 'FFEE99'; $graph_max = 1; -$unit_text = "Hits/sec"; +$unit_text = 'Hits/sec'; -include("includes/graphs/generic_simplex.inc.php"); - -?> +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/apache_scoreboard.inc.php b/html/includes/graphs/application/apache_scoreboard.inc.php index bf9237f4a..fe216efe7 100644 --- a/html/includes/graphs/application/apache_scoreboard.inc.php +++ b/html/includes/graphs/application/apache_scoreboard.inc.php @@ -2,39 +2,69 @@ $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-apache-'.$app['app_id'].'.rrd'; -$array = array('sb_reading' => array('descr' => 'Reading', 'colour' => '750F7DFF'), - 'sb_writing' => array('descr' => 'Writing', 'colour' => '00FF00FF'), - 'sb_wait' => array('descr' => 'Waiting', 'colour' => '4444FFFF'), - 'sb_start' => array('descr' => 'Starting', 'colour' => '157419FF'), - 'sb_keepalive' => array('descr' => 'Keepalive', 'colour' => 'FF0000FF'), - 'sb_dns' => array('descr' => 'DNS', 'colour' => '6DC8FEFF'), - 'sb_closing' => array('descr' => 'Closing', 'colour' => 'FFAB00FF'), - 'sb_logging' => array('descr' => 'Logging', 'colour' => 'FFFF00FF'), - 'sb_graceful' => array('descr' => 'Graceful', 'colour' => 'FF5576FF'), - 'sb_idle' => array('descr' => 'Idle', 'colour' => 'FF4105FF'), +$array = array( + 'sb_reading' => array( + 'descr' => 'Reading', + 'colour' => '750F7DFF', + ), + 'sb_writing' => array( + 'descr' => 'Writing', + 'colour' => '00FF00FF', + ), + 'sb_wait' => array( + 'descr' => 'Waiting', + 'colour' => '4444FFFF', + ), + 'sb_start' => array( + 'descr' => 'Starting', + 'colour' => '157419FF', + ), + 'sb_keepalive' => array( + 'descr' => 'Keepalive', + 'colour' => 'FF0000FF', + ), + 'sb_dns' => array( + 'descr' => 'DNS', + 'colour' => '6DC8FEFF', + ), + 'sb_closing' => array( + 'descr' => 'Closing', + 'colour' => 'FFAB00FF', + ), + 'sb_logging' => array( + 'descr' => 'Logging', + 'colour' => 'FFFF00FF', + ), + 'sb_graceful' => array( + 'descr' => 'Graceful', + 'colour' => 'FF5576FF', + ), + 'sb_idle' => array( + 'descr' => 'Idle', + 'colour' => 'FF4105FF', + ), ); $i = 0; -if (is_file($rrd_filename)) -{ - foreach ($array as $ds => $vars) - { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = $vars['descr']; - $rrd_list[$i]['ds'] = $ds; - $rrd_list[$i]['colour'] = $vars['colour']; - $i++; - } -} else { echo("file missing: $file"); } +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $file"; +} -$colours = "mixed"; +$colours = 'mixed'; $nototal = 1; -$unit_text = "Workers"; +$unit_text = 'Workers'; -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); - -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/bind_queries.inc.php b/html/includes/graphs/application/bind_queries.inc.php index 985e720e7..3df1abf45 100644 --- a/html/includes/graphs/application/bind_queries.inc.php +++ b/html/includes/graphs/application/bind_queries.inc.php @@ -1,19 +1,21 @@ +/* + * Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * Bind9 Query Graph * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -22,29 +24,40 @@ * @subpackage Graphs */ -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; $i = 0; $scale_min = 0; $nototal = 1; -$unit_text = "Query/sec"; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-bind-".$app['app_id'].".rrd"; -$array = array( 'any', 'a', 'aaaa', 'cname', 'mx', 'ns', 'ptr', 'soa', 'srv', 'spf' ); -$colours = "merged"; +$unit_text = 'Query/sec'; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-bind-'.$app['app_id'].'.rrd'; +$array = array( + 'any', + 'a', + 'aaaa', + 'cname', + 'mx', + 'ns', + 'ptr', + 'soa', + 'srv', + 'spf', +); +$colours = 'merged'; $rrd_list = array(); $config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']); -if( is_file($rrd_filename) ) { - foreach( $array as $ds ) { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = strtoupper($ds); - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { - echo "file missing: $file"; +if (is_file($rrd_filename)) { + foreach ($array as $ds) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = strtoupper($ds); + $rrd_list[$i]['ds'] = $ds; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/drbd_disk_bits.inc.php b/html/includes/graphs/application/drbd_disk_bits.inc.php index 767246ce8..d3458c72a 100644 --- a/html/includes/graphs/application/drbd_disk_bits.inc.php +++ b/html/includes/graphs/application/drbd_disk_bits.inc.php @@ -2,21 +2,18 @@ $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$drbd_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-drbd-".$app['app_instance'].".rrd"; +$drbd_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-drbd-'.$app['app_instance'].'.rrd'; -if (is_file($drbd_rrd)) -{ - $rrd_filename = $drbd_rrd; +if (is_file($drbd_rrd)) { + $rrd_filename = $drbd_rrd; } -$ds_in = "dr"; -$ds_out = "dw"; +$ds_in = 'dr'; +$ds_out = 'dw'; -$multiplier = "8"; -$format = "bytes"; +$multiplier = '8'; +$format = 'bytes'; -include("includes/graphs/generic_data.inc.php"); - -?> +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/application/drbd_network_bits.inc.php b/html/includes/graphs/application/drbd_network_bits.inc.php index 37c1d9db0..d20c1b304 100644 --- a/html/includes/graphs/application/drbd_network_bits.inc.php +++ b/html/includes/graphs/application/drbd_network_bits.inc.php @@ -2,20 +2,17 @@ $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$drbd_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-drbd-".$app['app_instance'].".rrd"; +$drbd_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-drbd-'.$app['app_instance'].'.rrd'; -if (is_file($drbd_rrd)) -{ - $rrd_filename = $drbd_rrd; +if (is_file($drbd_rrd)) { + $rrd_filename = $drbd_rrd; } -$ds_in = "nr"; -$ds_out = "ns"; +$ds_in = 'nr'; +$ds_out = 'ns'; -$multiplier = "8"; +$multiplier = '8'; -include("includes/graphs/generic_data.inc.php"); - -?> +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/application/drbd_unsynced.inc.php b/html/includes/graphs/application/drbd_unsynced.inc.php index 03293e136..f2a551ba8 100644 --- a/html/includes/graphs/application/drbd_unsynced.inc.php +++ b/html/includes/graphs/application/drbd_unsynced.inc.php @@ -2,27 +2,24 @@ $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$drbd_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-drbd-".$app['app_instance'].".rrd"; +$drbd_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-drbd-'.$app['app_instance'].'.rrd'; -if (is_file($drbd_rrd)) -{ - $rrd_filename = $drbd_rrd; +if (is_file($drbd_rrd)) { + $rrd_filename = $drbd_rrd; } -$ds = "oos"; +$ds = 'oos'; -$colour_area = "CDEB8B"; -$colour_line = "006600"; +$colour_area = 'CDEB8B'; +$colour_line = '006600'; -$colour_area_max = "FFEE99"; +$colour_area_max = 'FFEE99'; -$graph_max = 1; +$graph_max = 1; $multiplier = 8; -$unit_text = "Bytes"; +$unit_text = 'Bytes'; -include("includes/graphs/generic_simplex.inc.php"); - -?> +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/memcached_bits.inc.php b/html/includes/graphs/application/memcached_bits.inc.php index 2fadf3e16..c377e301b 100644 --- a/html/includes/graphs/application/memcached_bits.inc.php +++ b/html/includes/graphs/application/memcached_bits.inc.php @@ -1,13 +1,11 @@ +require 'includes/graphs/generic_data.inc.php'; diff --git a/html/includes/graphs/application/mysql_command_counters.inc.php b/html/includes/graphs/application/mysql_command_counters.inc.php index 5ca5d7d68..19182d0a6 100644 --- a/html/includes/graphs/application/mysql_command_counters.inc.php +++ b/html/includes/graphs/application/mysql_command_counters.inc.php @@ -5,43 +5,43 @@ require 'includes/graphs/common.inc.php'; $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd'; $array = array( - 'CDe' => array( - 'descr' => 'Delete', - 'colour' => '22FF22', - ), - 'CIt' => array( - 'descr' => 'Insert', - 'colour' => '0022FF', - ), - 'CISt' => array( - 'descr' => 'Insert Select', - 'colour' => 'FF0000', - ), - 'CLd' => array( - 'descr' => 'Load Data', - 'colour' => '00AAAA', - ), - 'CRe' => array( - 'descr' => 'Replace', - 'colour' => 'FF00FF', - ), - 'CRSt' => array( - 'descr' => 'Replace Select', - 'colour' => 'FFA500', - ), - 'CSt' => array( - 'descr' => 'Select', - 'colour' => 'CC0000', - ), - 'CUe' => array( - 'descr' => 'Update', - 'colour' => '0000CC', - ), - 'CUMi' => array( - 'descr' => 'Update Multiple', - 'colour' => '0080C0', - ), - ); + 'CDe' => array( + 'descr' => 'Delete', + 'colour' => '22FF22', + ), + 'CIt' => array( + 'descr' => 'Insert', + 'colour' => '0022FF', + ), + 'CISt' => array( + 'descr' => 'Insert Select', + 'colour' => 'FF0000', + ), + 'CLd' => array( + 'descr' => 'Load Data', + 'colour' => '00AAAA', + ), + 'CRe' => array( + 'descr' => 'Replace', + 'colour' => 'FF00FF', + ), + 'CRSt' => array( + 'descr' => 'Replace Select', + 'colour' => 'FFA500', + ), + 'CSt' => array( + 'descr' => 'Select', + 'colour' => 'CC0000', + ), + 'CUe' => array( + 'descr' => 'Update', + 'colour' => '0000CC', + ), + 'CUMi' => array( + 'descr' => 'Update Multiple', + 'colour' => '0080C0', + ), +); $i = 0; if (is_file($rrd_filename)) { @@ -52,7 +52,8 @@ if (is_file($rrd_filename)) { // $rrd_list[$i]['colour'] = $vars['colour']; $i++; } -} else { +} +else { echo "file missing: $file"; } diff --git a/html/includes/graphs/application/ntpdserver_packets.inc.php b/html/includes/graphs/application/ntpdserver_packets.inc.php index 6eee73cab..b3d906aa3 100644 --- a/html/includes/graphs/application/ntpdserver_packets.inc.php +++ b/html/includes/graphs/application/ntpdserver_packets.inc.php @@ -7,15 +7,15 @@ $nototal = (($width < 224) ? 1 : 0); $unit_text = 'Packets'; $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpdserver-'.$app['app_id'].'.rrd'; $array = array( - 'packets_drop' => array( - 'descr' => 'Dropped', - 'colour' => '880000FF', - ), - 'packets_ignore' => array( - 'descr' => 'Ignored', - 'colour' => 'FF8800FF', - ), - ); + 'packets_drop' => array( + 'descr' => 'Dropped', + 'colour' => '880000FF', + ), + 'packets_ignore' => array( + 'descr' => 'Ignored', + 'colour' => 'FF8800FF', + ), +); $i = 0; diff --git a/html/includes/graphs/application/shoutcast_multi_bits.inc.php b/html/includes/graphs/application/shoutcast_multi_bits.inc.php index 69b7b482b..d526863ae 100644 --- a/html/includes/graphs/application/shoutcast_multi_bits.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_bits.inc.php @@ -25,8 +25,7 @@ $files = array(); $i = 0; if ($handle = opendir($rrddir)) { - while (false !== ($file = readdir($handle))) - { + while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { if (eregi('app-shoutcast-'.$app['app_id'], $file)) { array_push($files, $file); diff --git a/html/includes/graphs/application/shoutcast_multi_stats.inc.php b/html/includes/graphs/application/shoutcast_multi_stats.inc.php index 3d901e14b..ea01630bf 100644 --- a/html/includes/graphs/application/shoutcast_multi_stats.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_stats.inc.php @@ -13,8 +13,7 @@ $i = 0; $x = 0; if ($handle = opendir($rrddir)) { - while (false !== ($file = readdir($handle))) - { + while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { if (eregi('app-shoutcast-'.$app['app_id'], $file)) { array_push($files, $file); diff --git a/html/includes/graphs/application/tinydns_dnssec.inc.php b/html/includes/graphs/application/tinydns_dnssec.inc.php index 14b4c8136..a3a0bf110 100644 --- a/html/includes/graphs/application/tinydns_dnssec.inc.php +++ b/html/includes/graphs/application/tinydns_dnssec.inc.php @@ -1,19 +1,21 @@ +/* + * Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * TinyDNS DNSSec Graph * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -22,28 +24,31 @@ * @subpackage Graphs */ -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; $i = 0; $scale_min = 0; $nototal = 1; -$unit_text = "Query/sec"; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd"; -//$array = explode(":","hinfo:rp:sig:key:axfr:total"); -$array = array( "key", "sig" ); -$colours = "mixed"; -$rrd_list = array(); +$unit_text = 'Query/sec'; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-tinydns-'.$app['app_id'].'.rrd'; +// $array = explode(":","hinfo:rp:sig:key:axfr:total"); +$array = array( + 'key', + 'sig', +); +$colours = 'mixed'; +$rrd_list = array(); -if( is_file($rrd_filename) ) { - foreach( $array as $ds ) { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = strtoupper($ds); - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { - echo "file missing: $file"; +if (is_file($rrd_filename)) { + foreach ($array as $ds) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = strtoupper($ds); + $rrd_list[$i]['ds'] = $ds; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/tinydns_errors.inc.php b/html/includes/graphs/application/tinydns_errors.inc.php index 6cec421c9..5673c635e 100644 --- a/html/includes/graphs/application/tinydns_errors.inc.php +++ b/html/includes/graphs/application/tinydns_errors.inc.php @@ -1,19 +1,21 @@ +/* + Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * TinyDNS Error Graph * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -22,27 +24,32 @@ * @subpackage Graphs */ -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; $i = 0; $scale_min = 0; $nototal = 1; -$unit_text = "Query/sec"; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd"; -$array = array( "notauth", "notimpl", "badclass", "noquery" ); -$colours = "oranges"; +$unit_text = 'Query/sec'; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-tinydns-'.$app['app_id'].'.rrd'; +$array = array( + 'notauth', + 'notimpl', + 'badclass', + 'noquery', +); +$colours = 'oranges'; $rrd_list = array(); -if( is_file($rrd_filename) ) { - foreach( $array as $ds ) { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = strtoupper($ds); - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { - echo "file missing: $file"; +if (is_file($rrd_filename)) { + foreach ($array as $ds) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = strtoupper($ds); + $rrd_list[$i]['ds'] = $ds; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/tinydns_other.inc.php b/html/includes/graphs/application/tinydns_other.inc.php index b7c08f88e..3d4178994 100644 --- a/html/includes/graphs/application/tinydns_other.inc.php +++ b/html/includes/graphs/application/tinydns_other.inc.php @@ -1,19 +1,21 @@ +/* + Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * TinyDNS Other Graph * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -22,27 +24,32 @@ * @subpackage Graphs */ -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; $i = 0; $scale_min = 0; $nototal = 1; -$unit_text = "Query/sec"; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd"; -$array = array( "other", "hinfo", "rp", "axfr" ); -$colours = "mixed"; +$unit_text = 'Query/sec'; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-tinydns-'.$app['app_id'].'.rrd'; +$array = array( + 'other', + 'hinfo', + 'rp', + 'axfr', +); +$colours = 'mixed'; $rrd_list = array(); -if( is_file($rrd_filename) ) { - foreach( $array as $ds ) { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = strtoupper($ds); - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { - echo "file missing: $file"; +if (is_file($rrd_filename)) { + foreach ($array as $ds) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = strtoupper($ds); + $rrd_list[$i]['ds'] = $ds; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/application/tinydns_queries.inc.php b/html/includes/graphs/application/tinydns_queries.inc.php index 2d2b03ebe..b35a32bc0 100644 --- a/html/includes/graphs/application/tinydns_queries.inc.php +++ b/html/includes/graphs/application/tinydns_queries.inc.php @@ -1,19 +1,21 @@ +/* + * Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * TinyDNS Query Graph * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -22,30 +24,40 @@ * @subpackage Graphs */ -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; $i = 0; $scale_min = 0; $nototal = 1; -$unit_text = "Query/sec"; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd"; -//$array = explode(":","hinfo:rp:sig:key:axfr:total"); -$array = array( "any", "a", "aaaa", "cname", "mx", "ns", "ptr", "soa", "txt" ); -$colours = "merged"; -$rrd_list = array(); +$unit_text = 'Query/sec'; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-tinydns-'.$app['app_id'].'.rrd'; +// $array = explode(":","hinfo:rp:sig:key:axfr:total"); +$array = array( + 'any', + 'a', + 'aaaa', + 'cname', + 'mx', + 'ns', + 'ptr', + 'soa', + 'txt', +); +$colours = 'merged'; +$rrd_list = array(); $config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']); -if( is_file($rrd_filename) ) { - foreach( $array as $ds ) { - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = strtoupper($ds); - $rrd_list[$i]['ds'] = $ds; - $i++; - } -} else { - echo "file missing: $file"; +if (is_file($rrd_filename)) { + foreach ($array as $ds) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = strtoupper($ds); + $rrd_list[$i]['ds'] = $ds; + $i++; + } +} +else { + echo "file missing: $file"; } -include("includes/graphs/generic_multi_simplex_seperated.inc.php"); -?> +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/common.inc.php b/html/includes/graphs/common.inc.php index a46b35384..9dbc97b80 100644 --- a/html/includes/graphs/common.inc.php +++ b/html/includes/graphs/common.inc.php @@ -1,34 +1,105 @@ = "5" || $auth) -{ - $id = mres($vars['id']); - $title = generate_device_link($device); - $auth = TRUE; +if ($_SESSION['userlevel'] >= '5' || $auth) { + $id = mres($vars['id']); + $title = generate_device_link($device); + $auth = true; } - -?> diff --git a/html/includes/graphs/customer/bits.inc.php b/html/includes/graphs/customer/bits.inc.php index e279c8691..f66f91df0 100644 --- a/html/includes/graphs/customer/bits.inc.php +++ b/html/includes/graphs/customer/bits.inc.php @@ -1,39 +1,35 @@ +require 'includes/graphs/generic_multi_bits_separated.inc.php'; diff --git a/html/includes/graphs/device/asa_conns.inc.php b/html/includes/graphs/device/asa_conns.inc.php index 5ac548631..296598700 100644 --- a/html/includes/graphs/device/asa_conns.inc.php +++ b/html/includes/graphs/device/asa_conns.inc.php @@ -1,32 +1,29 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * LibreNMS + * + * Copyright (c) 2014 Neil Lathwood + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ -$scale_min = "0"; +$scale_min = '0'; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/asa_conns.rrd"; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/asa_conns.rrd'; $rrd_options .= " DEF:connections=$rrd_filename:connections:AVERAGE"; $rrd_options .= " DEF:connections_max=$rrd_filename:connections:MAX"; $rrd_options .= " DEF:connections_min=$rrd_filename:connections:MIN"; -$rrd_options .= " AREA:connections_min"; +$rrd_options .= ' AREA:connections_min'; -$rrd_options .= " LINE1.5:connections#cc0000:'" . rrdtool_escape('Current connections')."'"; -$rrd_options .= " GPRINT:connections_min:MIN:%4.0lf"; -$rrd_options .= " GPRINT:connections:LAST:%4.0lf"; -$rrd_options .= " GPRINT:connections_max:MAX:%4.0lf\\\\l"; - - -?> +$rrd_options .= " LINE1.5:connections#cc0000:'".rrdtool_escape('Current connections')."'"; +$rrd_options .= ' GPRINT:connections_min:MIN:%4.0lf'; +$rrd_options .= ' GPRINT:connections:LAST:%4.0lf'; +$rrd_options .= ' GPRINT:connections_max:MAX:%4.0lf\\\\l'; diff --git a/html/includes/graphs/device/auth.inc.php b/html/includes/graphs/device/auth.inc.php index 79027e7bf..1ed6b7b33 100644 --- a/html/includes/graphs/device/auth.inc.php +++ b/html/includes/graphs/device/auth.inc.php @@ -1,10 +1,7 @@ diff --git a/html/includes/graphs/device/bits.inc.php b/html/includes/graphs/device/bits.inc.php index 64d4c0398..eaeed92f4 100644 --- a/html/includes/graphs/device/bits.inc.php +++ b/html/includes/graphs/device/bits.inc.php @@ -1,73 +1,62 @@ +// include("includes/graphs/generic_multi_bits_separated.inc.php"); +// include("includes/graphs/generic_multi_data_separated.inc.php"); diff --git a/html/includes/graphs/device/charge.inc.php b/html/includes/graphs/device/charge.inc.php index 237803fa8..66c6ed5ae 100644 --- a/html/includes/graphs/device/charge.inc.php +++ b/html/includes/graphs/device/charge.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/cipsec_flow_stats.inc.php b/html/includes/graphs/device/cipsec_flow_stats.inc.php index 2e69d2a79..e721b722f 100644 --- a/html/includes/graphs/device/cipsec_flow_stats.inc.php +++ b/html/includes/graphs/device/cipsec_flow_stats.inc.php @@ -1,85 +1,82 @@ \ No newline at end of file +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/collectd.inc.php b/html/includes/graphs/device/collectd.inc.php index 05ce8b3cb..7de642433 100644 --- a/html/includes/graphs/device/collectd.inc.php +++ b/html/includes/graphs/device/collectd.inc.php @@ -1,4 +1,5 @@ - * @@ -16,27 +17,32 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -require('includes/collectd/config.php'); -require('includes/collectd/functions.php'); -require('includes/collectd/definitions.php'); +require 'includes/collectd/config.php'; +require 'includes/collectd/functions.php'; +require 'includes/collectd/definitions.php'; + function makeTextBlock($text, $fontfile, $fontsize, $width) { - // TODO: handle explicit line-break! - $words = explode(' ', $text); - $lines = array($words[0]); - $currentLine = 0; - foreach ($words as $word) { - $lineSize = imagettfbbox($fontsize, 0, $fontfile, $lines[$currentLine] . ' ' . $word); - if ($lineSize[2] - $lineSize[0] < $width) { - $lines[$currentLine] .= ' ' . $word; - } else { - $currentLine++; - $lines[$currentLine] = $word; + // TODO: handle explicit line-break! + $words = explode(' ', $text); + $lines = array($words[0]); + $currentLine = 0; + foreach ($words as $word) { + $lineSize = imagettfbbox($fontsize, 0, $fontfile, $lines[$currentLine].' '.$word); + if (($lineSize[2] - $lineSize[0]) < $width) { + $lines[$currentLine] .= ' '.$word; + } + else { + $currentLine++; + $lines[$currentLine] = $word; + } } - } - error_log(sprintf('Handles message "%s", %d words => %d/%d lines', $text, count($words), $currentLine, count($lines))); - return implode("\n", $lines); -} + + error_log(sprintf('Handles message "%s", %d words => %d/%d lines', $text, count($words), $currentLine, count($lines))); + return implode("\n", $lines); + +}//end makeTextBlock() + /** * No RRD files found that could match request @@ -46,124 +52,150 @@ function makeTextBlock($text, $fontfile, $fontsize, $width) { * @msg Complete error message to display in place of graph content */ function error($code, $code_msg, $title, $msg) { - global $config; + global $config; - header(sprintf("HTTP/1.0 %d %s", $code, $code_msg)); - header("Pragma: no-cache"); - header("Expires: Mon, 01 Jan 2008 00:00:00 CET"); - header("Content-Type: image/png"); - $w = $config['rrd_width']+81; - $h = $config['rrd_height']+79; + header(sprintf('HTTP/1.0 %d %s', $code, $code_msg)); + header('Pragma: no-cache'); + header('Expires: Mon, 01 Jan 2008 00:00:00 CET'); + header('Content-Type: image/png'); + $w = ($config['rrd_width'] + 81); + $h = ($config['rrd_height'] + 79); - $png = imagecreate($w, $h); - $c_bkgnd = imagecolorallocate($png, 240, 240, 240); - $c_fgnd = imagecolorallocate($png, 255, 255, 255); - $c_blt = imagecolorallocate($png, 208, 208, 208); - $c_brb = imagecolorallocate($png, 160, 160, 160); - $c_grln = imagecolorallocate($png, 114, 114, 114); - $c_grarr = imagecolorallocate($png, 128, 32, 32); - $c_txt = imagecolorallocate($png, 0, 0, 0); - $c_etxt = imagecolorallocate($png, 64, 0, 0); + $png = imagecreate($w, $h); + $c_bkgnd = imagecolorallocate($png, 240, 240, 240); + $c_fgnd = imagecolorallocate($png, 255, 255, 255); + $c_blt = imagecolorallocate($png, 208, 208, 208); + $c_brb = imagecolorallocate($png, 160, 160, 160); + $c_grln = imagecolorallocate($png, 114, 114, 114); + $c_grarr = imagecolorallocate($png, 128, 32, 32); + $c_txt = imagecolorallocate($png, 0, 0, 0); + $c_etxt = imagecolorallocate($png, 64, 0, 0); - if (function_exists('imageantialias')) - imageantialias($png, true); - imagefilledrectangle($png, 0, 0, $w, $h, $c_bkgnd); - imagefilledrectangle($png, 51, 33, $w-31, $h-47, $c_fgnd); - imageline($png, 51, 30, 51, $h-43, $c_grln); - imageline($png, 48, $h-46, $w-28, $h-46, $c_grln); - imagefilledpolygon($png, array(49, 30, 51, 26, 53, 30), 3, $c_grarr); - imagefilledpolygon($png, array($w-28, $h-48, $w-24, $h-46, $w-28, $h-44), 3, $c_grarr); - imageline($png, 0, 0, $w, 0, $c_blt); - imageline($png, 0, 1, $w, 1, $c_blt); - imageline($png, 0, 0, 0, $h, $c_blt); - imageline($png, 1, 0, 1, $h, $c_blt); - imageline($png, $w-1, 0, $w-1, $h, $c_brb); - imageline($png, $w-2, 1, $w-2, $h, $c_brb); - imageline($png, 1, $h-2, $w, $h-2, $c_brb); - imageline($png, 0, $h-1, $w, $h-1, $c_brb); + if (function_exists('imageantialias')) { + imageantialias($png, true); + } - imagestring($png, 4, ceil(($w-strlen($title)*imagefontwidth(4)) / 2), 10, $title, $c_txt); - imagestring($png, 5, 60, 35, sprintf('%s [%d]', $code_msg, $code), $c_etxt); - if (function_exists('imagettfbbox') && is_file($config['error_font'])) { - // Detailled error message - $fmt_msg = makeTextBlock($msg, $errorfont, 10, $w-86); - $fmtbox = imagettfbbox(12, 0, $errorfont, $fmt_msg); - imagettftext($png, 10, 0, 55, 35+3+imagefontwidth(5)-$fmtbox[7]+$fmtbox[1], $c_txt, $errorfont, $fmt_msg); - } else { - imagestring($png, 4, 53, 35+6+imagefontwidth(5), $msg, $c_txt); - } + imagefilledrectangle($png, 0, 0, $w, $h, $c_bkgnd); + imagefilledrectangle($png, 51, 33, ($w - 31), ($h - 47), $c_fgnd); + imageline($png, 51, 30, 51, ($h - 43), $c_grln); + imageline($png, 48, ($h - 46), ($w - 28), ($h - 46), $c_grln); + imagefilledpolygon($png, array(49, 30, 51, 26, 53, 30), 3, $c_grarr); + imagefilledpolygon($png, array($w - 28, $h - 48, $w - 24, $h - 46, $w - 28, $h - 44), 3, $c_grarr); + imageline($png, 0, 0, $w, 0, $c_blt); + imageline($png, 0, 1, $w, 1, $c_blt); + imageline($png, 0, 0, 0, $h, $c_blt); + imageline($png, 1, 0, 1, $h, $c_blt); + imageline($png, ($w - 1), 0, ($w - 1), $h, $c_brb); + imageline($png, ($w - 2), 1, ($w - 2), $h, $c_brb); + imageline($png, 1, ($h - 2), $w, ($h - 2), $c_brb); + imageline($png, 0, ($h - 1), $w, ($h - 1), $c_brb); + + imagestring($png, 4, ceil(($w - strlen($title) * imagefontwidth(4)) / 2), 10, $title, $c_txt); + imagestring($png, 5, 60, 35, sprintf('%s [%d]', $code_msg, $code), $c_etxt); + if (function_exists('imagettfbbox') && is_file($config['error_font'])) { + // Detailled error message + $fmt_msg = makeTextBlock($msg, $errorfont, 10, ($w - 86)); + $fmtbox = imagettfbbox(12, 0, $errorfont, $fmt_msg); + imagettftext($png, 10, 0, 55, (35 + 3 + imagefontwidth(5) - $fmtbox[7] + $fmtbox[1]), $c_txt, $errorfont, $fmt_msg); + } + else { + imagestring($png, 4, 53, (35 + 6 + imagefontwidth(5)), $msg, $c_txt); + } + + imagepng($png); + imagedestroy($png); + +}//end error() - imagepng($png); - imagedestroy($png); -} /** * No RRD files found that could match request */ function error404($title, $msg) { - return error(404, "Not found", $title, $msg); -} + return error(404, 'Not found', $title, $msg); + +}//end error404() + function error500($title, $msg) { - return error(500, "Not found", $title, $msg); -} + return error(500, 'Not found', $title, $msg); + +}//end error500() + /** * Incomplete / invalid request */ function error400($title, $msg) { - return error(400, "Bad request", $title, $msg); -} + return error(400, 'Bad request', $title, $msg); + +}//end error400() + // Process input arguments -#$host = read_var('host', $_GET, null); -$host = $device['hostname']; -if (is_null($host)) - return error400("?/?-?/?", "Missing host name"); -else if (!is_string($host)) - return error400("?/?-?/?", "Expecting exactly 1 host name"); -else if (strlen($host) == 0) - return error400("?/?-?/?", "Host name may not be blank"); +// $host = read_var('host', $_GET, null); +$host = $device['hostname']; +if (is_null($host)) { + return error400('?/?-?/?', 'Missing host name'); +} +else if (!is_string($host)) { + return error400('?/?-?/?', 'Expecting exactly 1 host name'); +} +else if (strlen($host) == 0) { + return error400('?/?-?/?', 'Host name may not be blank'); +} -$plugin = read_var('c_plugin', $_GET, null); -if (is_null($plugin)) - return error400($host.'/?-?/?', "Missing plugin name"); -else if (!is_string($plugin)) - return error400($host.'/?-?/?', "Plugin name must be a string"); -else if (strlen($plugin) == 0) - return error400($host.'/?-?/?', "Plugin name may not be blank"); +$plugin = read_var('c_plugin', $_GET, null); +if (is_null($plugin)) { + return error400($host.'/?-?/?', 'Missing plugin name'); +} +else if (!is_string($plugin)) { + return error400($host.'/?-?/?', 'Plugin name must be a string'); +} +else if (strlen($plugin) == 0) { + return error400($host.'/?-?/?', 'Plugin name may not be blank'); +} -$pinst = read_var('c_plugin_instance', $_GET, ''); -if (!is_string($pinst)) - return error400($host.'/'.$plugin.'-?/?', "Plugin instance name must be a string"); +$pinst = read_var('c_plugin_instance', $_GET, ''); +if (!is_string($pinst)) { + return error400($host.'/'.$plugin.'-?/?', 'Plugin instance name must be a string'); +} -$type = read_var('c_type', $_GET, ''); -if (is_null($type)) - return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Missing type name"); -else if (!is_string($type)) - return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Type name must be a string"); -else if (strlen($type) == 0) - return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Type name may not be blank"); +$type = read_var('c_type', $_GET, ''); +if (is_null($type)) { + return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', 'Missing type name'); +} +else if (!is_string($type)) { + return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', 'Type name must be a string'); +} +else if (strlen($type) == 0) { + return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', 'Type name may not be blank'); +} -$tinst = read_var('c_type_instance', $_GET, ''); +$tinst = read_var('c_type_instance', $_GET, ''); $graph_identifier = $host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/'.$type.(strlen($tinst) ? '-'.$tinst : '-*'); -$timespan = read_var('timespan', $_GET, $config['timespan'][0]['name']); +$timespan = read_var('timespan', $_GET, $config['timespan'][0]['name']); $timespan_ok = false; -foreach ($config['timespan'] as &$ts) - if ($ts['name'] == $timespan) - $timespan_ok = true; -if (!$timespan_ok) - return error400($graph_identifier, "Unknown timespan requested"); +foreach ($config['timespan'] as &$ts) { + if ($ts['name'] == $timespan) { + $timespan_ok = true; + } +} -$logscale = (boolean)read_var('logarithmic', $_GET, false); -$tinylegend = (boolean)read_var('tinylegend', $_GET, false); +if (!$timespan_ok) { + return error400($graph_identifier, 'Unknown timespan requested'); +} + +$logscale = (boolean) read_var('logarithmic', $_GET, false); +$tinylegend = (boolean) read_var('tinylegend', $_GET, false); // Check that at least 1 RRD exists for the specified request $all_tinst = collectd_list_tinsts($host, $plugin, $pinst, $type); -if (count($all_tinst) == 0) - return error404($graph_identifier, "No rrd file found for graphing"); +if (count($all_tinst) == 0) { + return error404($graph_identifier, 'No rrd file found for graphing'); +} // Now that we are read, do the bulk work load_graph_definitions($logscale, $tinylegend); @@ -171,57 +203,83 @@ load_graph_definitions($logscale, $tinylegend); $pinst = strlen($pinst) == 0 ? null : $pinst; $tinst = strlen($tinst) == 0 ? null : $tinst; -$opts = array(); +$opts = array(); $opts['timespan'] = $timespan; -if ($logscale) - $opts['logarithmic'] = 1; -if ($tinylegend) - $opts['tinylegend'] = 1; +if ($logscale) { + $opts['logarithmic'] = 1; +} + +if ($tinylegend) { + $opts['tinylegend'] = 1; +} $rrd_cmd = false; if (isset($MetaGraphDefs[$type])) { - $identifiers = array(); - foreach ($all_tinst as &$atinst) - $identifiers[] = collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, $atinst); - collectd_flush($identifiers); - $rrd_cmd = $MetaGraphDefs[$type]($host, $plugin, $pinst, $type, $all_tinst, $opts); -} else { - if (!in_array(is_null($tinst) ? '' : $tinst, $all_tinst)) - return error404($host.'/'.$plugin.(!is_null($pinst) ? '-'.$pinst : '').'/'.$type.(!is_null($tinst) ? '-'.$tinst : ''), "No rrd file found for graphing"); - collectd_flush(collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, is_null($tinst) ? '' : $tinst)); - if (isset($GraphDefs[$type])) - $rrd_cmd = collectd_draw_generic($timespan, $host, $plugin, $pinst, $type, $tinst); - else - $rrd_cmd = collectd_draw_rrd($host, $plugin, $pinst, $type, $tinst); + $identifiers = array(); + foreach ($all_tinst as &$atinst) { + $identifiers[] = collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, $atinst); + } + + collectd_flush($identifiers); + $rrd_cmd = $MetaGraphDefs[$type]($host, $plugin, $pinst, $type, $all_tinst, $opts); +} +else { + if (!in_array(is_null($tinst) ? '' : $tinst, $all_tinst)) { + return error404($host.'/'.$plugin.(!is_null($pinst) ? '-'.$pinst : '').'/'.$type.(!is_null($tinst) ? '-'.$tinst : ''), 'No rrd file found for graphing'); + } + + collectd_flush(collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, is_null($tinst) ? '' : $tinst)); + if (isset($GraphDefs[$type])) { + $rrd_cmd = collectd_draw_generic($timespan, $host, $plugin, $pinst, $type, $tinst); + } + else { + $rrd_cmd = collectd_draw_rrd($host, $plugin, $pinst, $type, $tinst); + } } -if(isset($rrd_cmd)) -{ - if ($_GET['from']) { $from = mres($_GET['from']); } - if ($_GET['to']) { $to = mres($_GET['to']); } - $rrd_cmd .= " -s " . $from . " -e " . $to; +if (isset($rrd_cmd)) { + if ($_GET['from']) { + $from = mres($_GET['from']); + } + + if ($_GET['to']) { + $to = mres($_GET['to']); + } + + $rrd_cmd .= ' -s '.$from.' -e '.$to; } -if ($_GET['legend'] == "no") { $rrd_cmd .= " -g "; } +if ($_GET['legend'] == 'no') { + $rrd_cmd .= ' -g '; +} -if ($height < "99") { $rrd_cmd .= " --only-graph "; } -if ($width <= "300") { $rrd_cmd .= " --font LEGEND:7:" . $config['mono_font'] . " --font AXIS:6:" . $config['mono_font'] . " "; } -else { $rrd_cmd .= " --font LEGEND:8:" . $config['mono_font'] . " --font AXIS:7:" . $config['mono_font'] . " "; } +if ($height < '99') { + $rrd_cmd .= ' --only-graph '; +} + +if ($width <= '300') { + $rrd_cmd .= ' --font LEGEND:7:'.$config['mono_font'].' --font AXIS:6:'.$config['mono_font'].' '; +} +else { + $rrd_cmd .= ' --font LEGEND:8:'.$config['mono_font'].' --font AXIS:7:'.$config['mono_font'].' '; +} if (isset($_GET['debug'])) { - header('Content-Type: text/plain; charset=utf-8'); - printf("Would have executed:\n%s\n", $rrd_cmd); - return 0; -} else if ($rrd_cmd) { - header('Content-Type: image/png'); - header('Cache-Control: max-age=60'); - $rt = 0; - passthru($rrd_cmd, $rt); - if ($rt != 0) - return error500($graph_identifier, "RRD failed to generate the graph: ".$rt); - return $rt; -} else { - return error500($graph_identifier, "Failed to tell RRD how to generate the graph"); + header('Content-Type: text/plain; charset=utf-8'); + printf("Would have executed:\n%s\n", $rrd_cmd); + return 0; } +else if ($rrd_cmd) { + header('Content-Type: image/png'); + header('Cache-Control: max-age=60'); + $rt = 0; + passthru($rrd_cmd, $rt); + if ($rt != 0) { + return error500($graph_identifier, 'RRD failed to generate the graph: '.$rt); + } -?> + return $rt; +} +else { + return error500($graph_identifier, 'Failed to tell RRD how to generate the graph'); +} diff --git a/html/includes/graphs/device/diskio_bits.inc.php b/html/includes/graphs/device/diskio_bits.inc.php index 32f61ffe4..efe305efd 100644 --- a/html/includes/graphs/device/diskio_bits.inc.php +++ b/html/includes/graphs/device/diskio_bits.inc.php @@ -1,17 +1,15 @@ +require 'includes/graphs/generic_multi_bits_separated.inc.php'; diff --git a/html/includes/graphs/device/diskio_ops.inc.php b/html/includes/graphs/device/diskio_ops.inc.php index 5b1593258..3c788f69f 100644 --- a/html/includes/graphs/device/diskio_ops.inc.php +++ b/html/includes/graphs/device/diskio_ops.inc.php @@ -1,19 +1,17 @@ +require 'includes/graphs/generic_multi_seperated.inc.php'; diff --git a/html/includes/graphs/device/fdb_count.inc.php b/html/includes/graphs/device/fdb_count.inc.php index 484ac9b89..83dd72186 100644 --- a/html/includes/graphs/device/fdb_count.inc.php +++ b/html/includes/graphs/device/fdb_count.inc.php @@ -1,19 +1,17 @@ diff --git a/html/includes/graphs/device/load.inc.php b/html/includes/graphs/device/load.inc.php index a8b27356c..31a2e9c12 100644 --- a/html/includes/graphs/device/load.inc.php +++ b/html/includes/graphs/device/load.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/mib.inc.php b/html/includes/graphs/device/mib.inc.php index 7f76f3bbe..08241e922 100644 --- a/html/includes/graphs/device/mib.inc.php +++ b/html/includes/graphs/device/mib.inc.php @@ -13,24 +13,25 @@ */ $rrd_list = array(); -$prefix = rrd_name($device['hostname'], array($subtype, ""), ""); -foreach (glob($prefix."*.rrd") as $filename) { +$prefix = rrd_name($device['hostname'], array($subtype, ''), ''); +foreach (glob($prefix.'*.rrd') as $filename) { // find out what * expanded to - $globpart = str_replace($prefix, '', $filename); // take off the prefix - $instance = substr($globpart, 0, -4); // take off ".rrd" - - $ds = array(); - $mibparts = explode("-", $subtype); - $mibvar = end($mibparts); - $ds['ds'] = name_shorten($mibvar); - $ds['descr'] = "$mibvar-$instance"; + $globpart = str_replace($prefix, '', $filename); + // take off the prefix + $instance = substr($globpart, 0, -4); + // take off ".rrd" + $ds = array(); + $mibparts = explode('-', $subtype); + $mibvar = end($mibparts); + $ds['ds'] = name_shorten($mibvar); + $ds['descr'] = "$mibvar-$instance"; $ds['filename'] = $filename; - $rrd_list[] = $ds; + $rrd_list[] = $ds; } $colours = 'mixed'; -$scale_min = "0"; +$scale_min = '0'; $nototal = 0; $simple_rrd = true; -include("includes/graphs/generic_multi_line.inc.php"); +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/netstat_ip_forward.inc.php b/html/includes/graphs/device/netstat_ip_forward.inc.php index 30402f5c9..e4f5b04d4 100644 --- a/html/includes/graphs/device/netstat_ip_forward.inc.php +++ b/html/includes/graphs/device/netstat_ip_forward.inc.php @@ -1,23 +1,21 @@ array()); -$i=0; -foreach ($stats as $stat => $array) -{ - $i++; - $rrd_list[$i]['filename'] = $rrd_filename; - $rrd_list[$i]['descr'] = str_replace("ip", "", $stat); - $rrd_list[$i]['ds'] = $stat; +$i = 0; +foreach ($stats as $stat => $array) { + $i++; + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = str_replace('ip', '', $stat); + $rrd_list[$i]['ds'] = $stat; } -$colours='mixed'; +$colours = 'mixed'; -$scale_min = "0"; -$nototal = 1; -$simple_rrd = TRUE; - -include("includes/graphs/generic_multi_line.inc.php"); +$scale_min = '0'; +$nototal = 1; +$simple_rrd = true; +require 'includes/graphs/generic_multi_line.inc.php'; diff --git a/html/includes/graphs/device/ping_perf.inc.php b/html/includes/graphs/device/ping_perf.inc.php index cbbb48d62..2e1e49b60 100644 --- a/html/includes/graphs/device/ping_perf.inc.php +++ b/html/includes/graphs/device/ping_perf.inc.php @@ -1,27 +1,25 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * LibreNMS + * + * Copyright (c) 2014 Neil Lathwood + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ -$scale_min = "0"; +$scale_min = '0'; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ping-perf.rrd"; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/ping-perf.rrd'; -$rrd_options .= " DEF:ping=".$rrd_filename.":ping:AVERAGE"; +$rrd_options .= ' DEF:ping='.$rrd_filename.':ping:AVERAGE'; $rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'"; -$rrd_options .= " LINE1.25:ping#36393D:Ping"; -$rrd_options .= " GPRINT:ping:LAST:%6.2lf GPRINT:ping:AVERAGE:%6.2lf"; +$rrd_options .= ' LINE1.25:ping#36393D:Ping'; +$rrd_options .= ' GPRINT:ping:LAST:%6.2lf GPRINT:ping:AVERAGE:%6.2lf'; $rrd_options .= " GPRINT:ping:MAX:%6.2lf 'GPRINT:ping:AVERAGE:%6.2lf\\n'"; - -?> diff --git a/html/includes/graphs/device/poller_perf.inc.php b/html/includes/graphs/device/poller_perf.inc.php index 1ce7689d6..b8dae8037 100644 --- a/html/includes/graphs/device/poller_perf.inc.php +++ b/html/includes/graphs/device/poller_perf.inc.php @@ -1,27 +1,25 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * LibreNMS + * + * Copyright (c) 2014 Neil Lathwood + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ -$scale_min = "0"; +$scale_min = '0'; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/poller-perf.rrd"; +$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/poller-perf.rrd'; -$rrd_options .= " DEF:poller=".$rrd_filename.":poller:AVERAGE"; +$rrd_options .= ' DEF:poller='.$rrd_filename.':poller:AVERAGE'; $rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'"; -$rrd_options .= " LINE1.25:poller#36393D:Poller"; -$rrd_options .= " GPRINT:poller:LAST:%6.2lf GPRINT:poller:AVERAGE:%6.2lf"; +$rrd_options .= ' LINE1.25:poller#36393D:Poller'; +$rrd_options .= ' GPRINT:poller:LAST:%6.2lf GPRINT:poller:AVERAGE:%6.2lf'; $rrd_options .= " GPRINT:poller:MAX:%6.2lf 'GPRINT:poller:AVERAGE:%6.2lf\\n'"; - -?> diff --git a/html/includes/graphs/device/sensor.inc.php b/html/includes/graphs/device/sensor.inc.php index bf75c8287..38b91b211 100644 --- a/html/includes/graphs/device/sensor.inc.php +++ b/html/includes/graphs/device/sensor.inc.php @@ -1,51 +1,58 @@ "300") { $descr_len = "40"; } else { $descr_len = "22"; } - -$rrd_options .= " -E "; -$iter = "1"; -$rrd_options .= " COMMENT:'".str_pad($unit_long,$descr_len)." Cur Min Max\\n'"; - -foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_index`", array($class, $device['device_id'])) as $sensor) -{ - // FIXME generic colour function - switch ($iter) - { - case "1": - $colour= "CC0000"; - break; - case "2": - $colour= "008C00"; - break; - case "3": - $colour= "4096EE"; - break; - case "4": - $colour= "73880A"; - break; - case "5": - $colour= "D01F3C"; - break; - case "6": - $colour= "36393D"; - break; - case "7": - default: - $colour= "FF0084"; - unset($iter); - break; - } - - $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], $descr_len),0,$descr_len); - $rrd_file = get_sensor_rrd($device, $sensor); - $rrd_options .= " DEF:sensor" . $sensor['sensor_id'] . "=$rrd_file:sensor:AVERAGE "; - $rrd_options .= " LINE1:sensor" . $sensor['sensor_id'] . "#" . $colour . ":'" . str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed'])) . "'"; - $rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":LAST:%4.1lf".$unit." "; - $rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":MIN:%4.1lf".$unit." "; - $rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":MAX:%4.1lf".$unit."\\\l "; - $iter++; +if ($_GET['width'] > '300') { + $descr_len = '40'; +} +else { + $descr_len = '22'; } -?> +$rrd_options .= ' -E '; +$iter = '1'; +$rrd_options .= " COMMENT:'".str_pad($unit_long, $descr_len)." Cur Min Max\\n'"; + +foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_index`', array($class, $device['device_id'])) as $sensor) { + // FIXME generic colour function + switch ($iter) { + case '1': + $colour = 'CC0000'; + break; + + case '2': + $colour = '008C00'; + break; + + case '3': + $colour = '4096EE'; + break; + + case '4': + $colour = '73880A'; + break; + + case '5': + $colour = 'D01F3C'; + break; + + case '6': + $colour = '36393D'; + break; + + case '7': + default: + $colour = 'FF0084'; + unset($iter); + break; + }//end switch + + $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], $descr_len), 0, $descr_len); + $rrd_file = get_sensor_rrd($device, $sensor); + $rrd_options .= ' DEF:sensor'.$sensor['sensor_id']."=$rrd_file:sensor:AVERAGE "; + $rrd_options .= ' LINE1:sensor'.$sensor['sensor_id'].'#'.$colour.":'".str_replace(':', '\:', str_replace('\*', '*', $sensor['sensor_descr_fixed']))."'"; + $rrd_options .= ' GPRINT:sensor'.$sensor['sensor_id'].':LAST:%4.1lf'.$unit.' '; + $rrd_options .= ' GPRINT:sensor'.$sensor['sensor_id'].':MIN:%4.1lf'.$unit.' '; + $rrd_options .= ' GPRINT:sensor'.$sensor['sensor_id'].':MAX:%4.1lf'.$unit.'\\\l '; + $iter++; +}//end foreach diff --git a/html/includes/graphs/device/siklu_rfAverageCinr.inc.php b/html/includes/graphs/device/siklu_rfAverageCinr.inc.php index a34a1b6b4..17a5b5ee0 100644 --- a/html/includes/graphs/device/siklu_rfAverageCinr.inc.php +++ b/html/includes/graphs/device/siklu_rfAverageCinr.inc.php @@ -1,15 +1,14 @@ = "450") { $descr_len = "48"; } else { $descr_len = "21"; } -$descr_len = intval($_GET['width'] / 8) * 0.8; +// if ($_GET['width'] >= "450") { $descr_len = "48"; } else { $descr_len = "21"; } +$descr_len = (intval(($_GET['width'] / 8)) * 0.8); $unit_long = 'milliseconds'; -$unit = 'ms'; +$unit = 'ms'; -$rrd_options .= " -l 0 -E "; -$rrd_options .= " COMMENT:'".str_pad($unit_long,$descr_len)." Cur Min Max\\n'"; +$rrd_options .= ' -l 0 -E '; +$rrd_options .= " COMMENT:'".str_pad($unit_long, $descr_len)." Cur Min Max\\n'"; -$name = ""; -if ($sla['tag']) - $name .= $sla['tag']; -if ($sla['owner']) - $name .= " (Owner: ". $sla['owner'] .")"; +$name = ''; +if ($sla['tag']) { + $name .= $sla['tag']; +} -$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("sla-" . $sla['sla_nr'] . ".rrd"); +if ($sla['owner']) { + $name .= ' (Owner: '.$sla['owner'].')'; +} + +$rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('sla-'.$sla['sla_nr'].'.rrd'); $rrd_options .= " DEF:rtt=$rrd_file:rtt:AVERAGE "; -$rrd_options .= " VDEF:avg=rtt,AVERAGE "; -$rrd_options .= " LINE1:avg#CCCCFF:'".str_pad('Average',$descr_len-3)."':dashes"; -$rrd_options .= " GPRINT:rtt:AVERAGE:%4.1lf".$unit."\\\l "; -$rrd_options .= " LINE1:rtt#CC0000:'" . rrdtool_escape($descr,$descr_len-3) . "'"; -$rrd_options .= " GPRINT:rtt:LAST:%4.1lf".$unit." "; -$rrd_options .= " GPRINT:rtt:MIN:%4.1lf".$unit." "; -$rrd_options .= " GPRINT:rtt:MAX:%4.1lf".$unit."\\\l "; - -?> +$rrd_options .= ' VDEF:avg=rtt,AVERAGE '; +$rrd_options .= " LINE1:avg#CCCCFF:'".str_pad('Average', ($descr_len - 3))."':dashes"; +$rrd_options .= ' GPRINT:rtt:AVERAGE:%4.1lf'.$unit.'\\\l '; +$rrd_options .= " LINE1:rtt#CC0000:'".rrdtool_escape($descr, ($descr_len - 3))."'"; +$rrd_options .= ' GPRINT:rtt:LAST:%4.1lf'.$unit.' '; +$rrd_options .= ' GPRINT:rtt:MIN:%4.1lf'.$unit.' '; +$rrd_options .= ' GPRINT:rtt:MAX:%4.1lf'.$unit.'\\\l '; diff --git a/html/includes/graphs/device/state.inc.php b/html/includes/graphs/device/state.inc.php index 56b059e01..a8ae9041c 100644 --- a/html/includes/graphs/device/state.inc.php +++ b/html/includes/graphs/device/state.inc.php @@ -1,9 +1,7 @@ +require 'includes/graphs/device/sensor.inc.php'; diff --git a/html/includes/graphs/device/toner.inc.php b/html/includes/graphs/device/toner.inc.php index 6a974b64a..9ba469cc0 100644 --- a/html/includes/graphs/device/toner.inc.php +++ b/html/includes/graphs/device/toner.inc.php @@ -11,8 +11,7 @@ foreach (dbFetchRows('SELECT * FROM toner where device_id = ?', array($device['d if ($colour['left'] == null) { // FIXME generic colour function - switch ($iter) - { + switch ($iter) { case '1': $colour['left'] = '000000'; break; diff --git a/html/includes/graphs/device/ubnt_airfiber_Capacity.inc.php b/html/includes/graphs/device/ubnt_airfiber_Capacity.inc.php index 6174a0e18..63a8083e8 100644 --- a/html/includes/graphs/device/ubnt_airfiber_Capacity.inc.php +++ b/html/includes/graphs/device/ubnt_airfiber_Capacity.inc.php @@ -1,24 +1,22 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/device/ucd_cpu.inc.php b/html/includes/graphs/device/ucd_cpu.inc.php index 3068bba69..af7fc5e9f 100644 --- a/html/includes/graphs/device/ucd_cpu.inc.php +++ b/html/includes/graphs/device/ucd_cpu.inc.php @@ -1,33 +1,31 @@ diff --git a/html/includes/graphs/device/ucd_interrupts.inc.php b/html/includes/graphs/device/ucd_interrupts.inc.php index 92665285d..1054df1d2 100644 --- a/html/includes/graphs/device/ucd_interrupts.inc.php +++ b/html/includes/graphs/device/ucd_interrupts.inc.php @@ -1,19 +1,17 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/generic_data.inc.php b/html/includes/graphs/generic_data.inc.php index a85a6c760..e13fce80c 100644 --- a/html/includes/graphs/generic_data.inc.php +++ b/html/includes/graphs/generic_data.inc.php @@ -2,130 +2,134 @@ // Draw generic bits graph // args: ds_in, ds_out, rrd_filename, bg, legend, from, to, width, height, inverse, previous +require 'includes/graphs/common.inc.php'; -include("includes/graphs/common.inc.php"); - -if ($rrd_filename) { $rrd_filename_out = $rrd_filename; $rrd_filename_in = $rrd_filename; } -if ($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } - -if ($multiplier) -{ - $rrd_options .= " DEF:p".$out."octets=".$rrd_filename_out.":".$ds_out.":AVERAGE"; - $rrd_options .= " DEF:p".$in."octets=".$rrd_filename_in.":".$ds_in.":AVERAGE"; - $rrd_options .= " DEF:p".$out."octets_max=".$rrd_filename_out.":".$ds_out.":MAX"; - $rrd_options .= " DEF:p".$in."octets_max=".$rrd_filename_in.":".$ds_in.":MAX"; - $rrd_options .= " CDEF:inoctets=pinoctets,$multiplier,*"; - $rrd_options .= " CDEF:outoctets=poutoctets,$multiplier,*"; - $rrd_options .= " CDEF:inoctets_max=pinoctets_max,$multiplier,*"; - $rrd_options .= " CDEF:outoctets_max=poutoctets_max,$multiplier,*"; -} else { - $rrd_options .= " DEF:".$out."octets=".$rrd_filename_out.":".$ds_out.":AVERAGE"; - $rrd_options .= " DEF:".$in."octets=".$rrd_filename_in.":".$ds_in.":AVERAGE"; - $rrd_options .= " DEF:".$out."octets_max=".$rrd_filename_out.":".$ds_out.":MAX"; - $rrd_options .= " DEF:".$in."octets_max=".$rrd_filename_in.":".$ds_in.":MAX"; +if ($rrd_filename) { + $rrd_filename_out = $rrd_filename; + $rrd_filename_in = $rrd_filename; } -if($_GET['previous'] == "yes") -{ - if ($multiplier) - { - $rrd_options .= " DEF:p".$out."octetsX=".$rrd_filename_out.":".$ds_out.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " DEF:p".$in."octetsX=".$rrd_filename_in.":".$ds_in.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " SHIFT:p".$out."octetsX:$period"; - $rrd_options .= " SHIFT:p".$in."octetsX:$period"; - $rrd_options .= " CDEF:inoctetsX=pinoctetsX,$multiplier,*"; - $rrd_options .= " CDEF:outoctetsX=poutoctetsX,$multiplier,*"; - } else { - $rrd_options .= " DEF:".$out."octetsX=".$rrd_filename_out.":".$ds_out.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " DEF:".$in."octetsX=".$rrd_filename_in.":".$ds_in.":AVERAGE:start=".$prev_from.":end=".$from; - $rrd_options .= " SHIFT:".$out."octetsX:$period"; - $rrd_options .= " SHIFT:".$in."octetsX:$period"; - } - - $rrd_options .= " CDEF:octetsX=inoctetsX,outoctetsX,+"; - $rrd_options .= " CDEF:doutoctetsX=outoctetsX,-1,*"; - $rrd_options .= " CDEF:outbitsX=outoctetsX,8,*"; - #$rrd_options .= " CDEF:outbits_maxX=outoctets_maxX,8,*"; - #$rrd_options .= " CDEF:doutoctets_maxX=outoctets_maxX,-1,*"; - $rrd_options .= " CDEF:doutbitsX=doutoctetsX,8,*"; - #$rrd_options .= " CDEF:doutbits_maxX=doutoctets_maxX,8,*"; - - $rrd_options .= " CDEF:inbitsX=inoctetsX,8,*"; - #$rrd_options .= " CDEF:inbits_maxX=inoctets_maxX,8,*"; - $rrd_options .= " VDEF:totinX=inoctetsX,TOTAL"; - $rrd_options .= " VDEF:totoutX=outoctetsX,TOTAL"; - $rrd_options .= " VDEF:totX=octetsX,TOTAL"; - +if ($inverse) { + $in = 'out'; + $out = 'in'; +} +else { + $in = 'in'; + $out = 'out'; } -$rrd_options .= " CDEF:octets=inoctets,outoctets,+"; -$rrd_options .= " CDEF:doutoctets=outoctets,-1,*"; -$rrd_options .= " CDEF:outbits=outoctets,8,*"; -$rrd_options .= " CDEF:outbits_max=outoctets_max,8,*"; -$rrd_options .= " CDEF:doutoctets_max=outoctets_max,-1,*"; -$rrd_options .= " CDEF:doutbits=doutoctets,8,*"; -$rrd_options .= " CDEF:doutbits_max=doutoctets_max,8,*"; +if ($multiplier) { + $rrd_options .= ' DEF:p'.$out.'octets='.$rrd_filename_out.':'.$ds_out.':AVERAGE'; + $rrd_options .= ' DEF:p'.$in.'octets='.$rrd_filename_in.':'.$ds_in.':AVERAGE'; + $rrd_options .= ' DEF:p'.$out.'octets_max='.$rrd_filename_out.':'.$ds_out.':MAX'; + $rrd_options .= ' DEF:p'.$in.'octets_max='.$rrd_filename_in.':'.$ds_in.':MAX'; + $rrd_options .= " CDEF:inoctets=pinoctets,$multiplier,*"; + $rrd_options .= " CDEF:outoctets=poutoctets,$multiplier,*"; + $rrd_options .= " CDEF:inoctets_max=pinoctets_max,$multiplier,*"; + $rrd_options .= " CDEF:outoctets_max=poutoctets_max,$multiplier,*"; +} +else { + $rrd_options .= ' DEF:'.$out.'octets='.$rrd_filename_out.':'.$ds_out.':AVERAGE'; + $rrd_options .= ' DEF:'.$in.'octets='.$rrd_filename_in.':'.$ds_in.':AVERAGE'; + $rrd_options .= ' DEF:'.$out.'octets_max='.$rrd_filename_out.':'.$ds_out.':MAX'; + $rrd_options .= ' DEF:'.$in.'octets_max='.$rrd_filename_in.':'.$ds_in.':MAX'; +} -$rrd_options .= " CDEF:inbits=inoctets,8,*"; -$rrd_options .= " CDEF:inbits_max=inoctets_max,8,*"; +if ($_GET['previous'] == 'yes') { + if ($multiplier) { + $rrd_options .= ' DEF:p'.$out.'octetsX='.$rrd_filename_out.':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' DEF:p'.$in.'octetsX='.$rrd_filename_in.':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' SHIFT:p'.$out."octetsX:$period"; + $rrd_options .= ' SHIFT:p'.$in."octetsX:$period"; + $rrd_options .= " CDEF:inoctetsX=pinoctetsX,$multiplier,*"; + $rrd_options .= " CDEF:outoctetsX=poutoctetsX,$multiplier,*"; + } + else { + $rrd_options .= ' DEF:'.$out.'octetsX='.$rrd_filename_out.':'.$ds_out.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' DEF:'.$in.'octetsX='.$rrd_filename_in.':'.$ds_in.':AVERAGE:start='.$prev_from.':end='.$from; + $rrd_options .= ' SHIFT:'.$out."octetsX:$period"; + $rrd_options .= ' SHIFT:'.$in."octetsX:$period"; + } + + $rrd_options .= ' CDEF:octetsX=inoctetsX,outoctetsX,+'; + $rrd_options .= ' CDEF:doutoctetsX=outoctetsX,-1,*'; + $rrd_options .= ' CDEF:outbitsX=outoctetsX,8,*'; + // $rrd_options .= " CDEF:outbits_maxX=outoctets_maxX,8,*"; + // $rrd_options .= " CDEF:doutoctets_maxX=outoctets_maxX,-1,*"; + $rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*'; + // $rrd_options .= " CDEF:doutbits_maxX=doutoctets_maxX,8,*"; + $rrd_options .= ' CDEF:inbitsX=inoctetsX,8,*'; + // $rrd_options .= " CDEF:inbits_maxX=inoctets_maxX,8,*"; + $rrd_options .= ' VDEF:totinX=inoctetsX,TOTAL'; + $rrd_options .= ' VDEF:totoutX=outoctetsX,TOTAL'; + $rrd_options .= ' VDEF:totX=octetsX,TOTAL'; +}//end if + +$rrd_options .= ' CDEF:octets=inoctets,outoctets,+'; +$rrd_options .= ' CDEF:doutoctets=outoctets,-1,*'; +$rrd_options .= ' CDEF:outbits=outoctets,8,*'; +$rrd_options .= ' CDEF:outbits_max=outoctets_max,8,*'; +$rrd_options .= ' CDEF:doutoctets_max=outoctets_max,-1,*'; +$rrd_options .= ' CDEF:doutbits=doutoctets,8,*'; +$rrd_options .= ' CDEF:doutbits_max=doutoctets_max,8,*'; + +$rrd_options .= ' CDEF:inbits=inoctets,8,*'; +$rrd_options .= ' CDEF:inbits_max=inoctets_max,8,*'; if ($config['rrdgraph_real_95th']) { - $rrd_options .= " CDEF:highbits=inoctets,outoctets,MAX,8,*"; - $rrd_options .= " VDEF:95thhigh=highbits,95,PERCENT"; + $rrd_options .= ' CDEF:highbits=inoctets,outoctets,MAX,8,*'; + $rrd_options .= ' VDEF:95thhigh=highbits,95,PERCENT'; } -$rrd_options .= " VDEF:totin=inoctets,TOTAL"; -$rrd_options .= " VDEF:totout=outoctets,TOTAL"; -$rrd_options .= " VDEF:tot=octets,TOTAL"; +$rrd_options .= ' VDEF:totin=inoctets,TOTAL'; +$rrd_options .= ' VDEF:totout=outoctets,TOTAL'; +$rrd_options .= ' VDEF:tot=octets,TOTAL'; -$rrd_options .= " VDEF:95thin=inbits,95,PERCENT"; -$rrd_options .= " VDEF:95thout=outbits,95,PERCENT"; -$rrd_options .= " VDEF:d95thout=doutbits,5,PERCENT"; +$rrd_options .= ' VDEF:95thin=inbits,95,PERCENT'; +$rrd_options .= ' VDEF:95thout=outbits,95,PERCENT'; +$rrd_options .= ' VDEF:d95thout=doutbits,5,PERCENT'; -if($format == "octets" || $format == "bytes") -{ - $units = "Bps"; - $format = "octets"; -} else { - $units = "bps"; - $format = "bits"; +if ($format == 'octets' || $format == 'bytes') { + $units = 'Bps'; + $format = 'octets'; +} +else { + $units = 'bps'; + $format = 'bits'; } $rrd_options .= " COMMENT:'bps Now Ave Max 95th %\\n'"; -$rrd_options .= " AREA:in".$format."_max#D7FFC7:"; -$rrd_options .= " AREA:in".$format."#90B040:"; -$rrd_options .= " LINE:in".$format."#608720:'In '"; -#$rrd_options .= " LINE1.25:in".$format."#006600:'In '"; -$rrd_options .= " GPRINT:in".$format.":LAST:%6.2lf%s"; -$rrd_options .= " GPRINT:in".$format.":AVERAGE:%6.2lf%s"; -$rrd_options .= " GPRINT:in".$format."_max:MAX:%6.2lf%s"; +$rrd_options .= ' AREA:in'.$format.'_max#D7FFC7:'; +$rrd_options .= ' AREA:in'.$format.'#90B040:'; +$rrd_options .= ' LINE:in'.$format."#608720:'In '"; +// $rrd_options .= " LINE1.25:in".$format."#006600:'In '"; +$rrd_options .= ' GPRINT:in'.$format.':LAST:%6.2lf%s'; +$rrd_options .= ' GPRINT:in'.$format.':AVERAGE:%6.2lf%s'; +$rrd_options .= ' GPRINT:in'.$format.'_max:MAX:%6.2lf%s'; $rrd_options .= " GPRINT:95thin:%6.2lf%s\\\\n"; -$rrd_options .= " AREA:dout".$format."_max#E0E0FF:"; -$rrd_options .= " AREA:dout".$format."#8080C0:"; -$rrd_options .= " LINE:dout".$format."#606090:'Out'"; -#$rrd_options .= " LINE1.25:dout".$format."#000099:Out"; -$rrd_options .= " GPRINT:out".$format.":LAST:%6.2lf%s"; -$rrd_options .= " GPRINT:out".$format.":AVERAGE:%6.2lf%s"; -$rrd_options .= " GPRINT:out".$format."_max:MAX:%6.2lf%s"; +$rrd_options .= ' AREA:dout'.$format.'_max#E0E0FF:'; +$rrd_options .= ' AREA:dout'.$format.'#8080C0:'; +$rrd_options .= ' LINE:dout'.$format."#606090:'Out'"; +// $rrd_options .= " LINE1.25:dout".$format."#000099:Out"; +$rrd_options .= ' GPRINT:out'.$format.':LAST:%6.2lf%s'; +$rrd_options .= ' GPRINT:out'.$format.':AVERAGE:%6.2lf%s'; +$rrd_options .= ' GPRINT:out'.$format.'_max:MAX:%6.2lf%s'; $rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n"; if ($config['rrdgraph_real_95th']) { - $rrd_options .= " HRULE:95thhigh#FF0000:\"Highest\""; - $rrd_options .= " GPRINT:95thhigh:\"%30.2lf%s\\n\""; + $rrd_options .= ' HRULE:95thhigh#FF0000:"Highest"'; + $rrd_options .= " GPRINT:95thhigh:\"%30.2lf%s\\n\""; } $rrd_options .= " GPRINT:tot:'Total %6.2lf%s'"; $rrd_options .= " GPRINT:totin:'(In %6.2lf%s'"; $rrd_options .= " GPRINT:totout:'Out %6.2lf%s)\\\\l'"; -$rrd_options .= " LINE1:95thin#aa0000"; -$rrd_options .= " LINE1:d95thout#aa0000"; +$rrd_options .= ' LINE1:95thin#aa0000'; +$rrd_options .= ' LINE1:d95thout#aa0000'; -if($_GET['previous'] == "yes") -{ - $rrd_options .= " LINE1.25:in".$format."X#009900:'Prev In \\\\n'"; - $rrd_options .= " LINE1.25:dout".$format."X#000099:'Prev Out'"; +if ($_GET['previous'] == 'yes') { + $rrd_options .= ' LINE1.25:in'.$format."X#009900:'Prev In \\\\n'"; + $rrd_options .= ' LINE1.25:dout'.$format."X#000099:'Prev Out'"; } - -?> diff --git a/html/includes/graphs/generic_multi_bits_separated.inc.php b/html/includes/graphs/generic_multi_bits_separated.inc.php index 5eaa70908..181f0ae4d 100644 --- a/html/includes/graphs/generic_multi_bits_separated.inc.php +++ b/html/includes/graphs/generic_multi_bits_separated.inc.php @@ -1,133 +1,152 @@ "500") -{ - $descr_len=18; -} else { - $descr_len=8; - $descr_len += round(($width - 260) / 9.5); +if ($width > '500') { + $descr_len = 18; +} +else { + $descr_len = 8; + $descr_len += round(($width - 260) / 9.5); } -$unit_text = "Bits/sec"; +$unit_text = 'Bits/sec'; if (!$noagg || !$nodetails) { - if($width > "500") { - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." Current Average Maximum '"; - if (!$nototal) { $rrd_options .= " COMMENT:'Total '"; } - $rrd_options .= " COMMENT:'\l'"; - } else { - $nototal=TRUE; - $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." Now Ave Max\l'"; - } + if ($width > '500') { + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." Current Average Maximum '"; + if (!$nototal) { + $rrd_options .= " COMMENT:'Total '"; + } + + $rrd_options .= " COMMENT:'\l'"; + } + else { + $nototal = true; + $rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." Now Ave Max\l'"; + } } -if(!isset($multiplier)) { $multiplier = "8"; } +if (!isset($multiplier)) { + $multiplier = '8'; +} -foreach ($rrd_list as $rrd) -{ - if (!$config['graph_colours'][$colours_in][$iter] || !$config['graph_colours'][$colours_out][$iter]) { $iter = 0; } - - $colour_in=$config['graph_colours'][$colours_in][$iter]; - $colour_out=$config['graph_colours'][$colours_out][$iter]; - - if (!$nodetails) { - if (isset($rrd['descr_in'])) { - $descr = rrdtool_escape($rrd['descr_in'], $descr_len) . " In"; - } else { - $descr = rrdtool_escape($rrd['descr'], $descr_len) . " In"; +foreach ($rrd_list as $rrd) { + if (!$config['graph_colours'][$colours_in][$iter] || !$config['graph_colours'][$colours_out][$iter]) { + $iter = 0; } - $descr_out = rrdtool_escape($rrd['descr_out'], $descr_len) . " Out"; - $descr = str_replace("'", "", $descr); // FIXME does this mean ' should be filtered in rrdtool_escape? probably... - $descr_out = str_replace("'", "", $descr_out); - } - $rrd_options .= " DEF:".$in.$i."=".$rrd['filename'].":".$ds_in.":AVERAGE "; - $rrd_options .= " DEF:".$out.$i."=".$rrd['filename'].":".$ds_out.":AVERAGE "; - $rrd_options .= " CDEF:inB".$i."=in".$i.",$multiplier,* "; - $rrd_options .= " CDEF:outB".$i."=out".$i.",$multiplier,*"; - $rrd_options .= " CDEF:outB".$i."_neg=outB".$i.",-1,*"; - $rrd_options .= " CDEF:octets".$i."=inB".$i.",outB".$i.",+"; + $colour_in = $config['graph_colours'][$colours_in][$iter]; + $colour_out = $config['graph_colours'][$colours_out][$iter]; - if (!$nototal) { - $rrd_options .= " VDEF:totin".$i."=inB".$i.",TOTAL"; - $rrd_options .= " VDEF:totout".$i."=outB".$i.",TOTAL"; - $rrd_options .= " VDEF:tot".$i."=octets".$i.",TOTAL"; - } + if (!$nodetails) { + if (isset($rrd['descr_in'])) { + $descr = rrdtool_escape($rrd['descr_in'], $descr_len).' In'; + } + else { + $descr = rrdtool_escape($rrd['descr'], $descr_len).' In'; + } - if ($i) { $stack="STACK"; } + $descr_out = rrdtool_escape($rrd['descr_out'], $descr_len).' Out'; + $descr = str_replace("'", '', $descr); + // FIXME does this mean ' should be filtered in rrdtool_escape? probably... + $descr_out = str_replace("'", '', $descr_out); + } + + $rrd_options .= ' DEF:'.$in.$i.'='.$rrd['filename'].':'.$ds_in.':AVERAGE '; + $rrd_options .= ' DEF:'.$out.$i.'='.$rrd['filename'].':'.$ds_out.':AVERAGE '; + $rrd_options .= ' CDEF:inB'.$i.'=in'.$i.",$multiplier,* "; + $rrd_options .= ' CDEF:outB'.$i.'=out'.$i.",$multiplier,*"; + $rrd_options .= ' CDEF:outB'.$i.'_neg=outB'.$i.',-1,*'; + $rrd_options .= ' CDEF:octets'.$i.'=inB'.$i.',outB'.$i.',+'; - $rrd_options .= " AREA:inB".$i."#" . $colour_in . ":'" . $descr . "':$stack"; - if (!$nodetails) { - $rrd_options .= " GPRINT:inB".$i.":LAST:%6.2lf%s$units"; - $rrd_options .= " GPRINT:inB".$i.":AVERAGE:%6.2lf%s$units"; - $rrd_options .= " GPRINT:inB".$i.":MAX:%6.2lf%s$units"; if (!$nototal) { - $rrd_options .= " GPRINT:totin".$i.":%6.2lf%s$total_units"; + $rrd_options .= ' VDEF:totin'.$i.'=inB'.$i.',TOTAL'; + $rrd_options .= ' VDEF:totout'.$i.'=outB'.$i.',TOTAL'; + $rrd_options .= ' VDEF:tot'.$i.'=octets'.$i.',TOTAL'; } - $rrd_options .= "\l"; - } - $rrd_options .= " 'HRULE:0#" . $colour_out.":".$descr_out."'"; - $rrd_optionsb .= " 'AREA:outB".$i."_neg#" . $colour_out . "::$stack'"; - - if (!$nodetails) { - $rrd_options .= " GPRINT:outB".$i.":LAST:%6.2lf%s$units"; - $rrd_options .= " GPRINT:outB".$i.":AVERAGE:%6.2lf%s$units"; - $rrd_options .= " GPRINT:outB".$i.":MAX:%6.2lf%s$units"; - if (!$nototal) { - $rrd_options .= " GPRINT:totout".$i.":%6.2lf%s$total_unit"; + if ($i) { + $stack = 'STACK'; } - $rrd_options .= "\l"; - } - $rrd_options .= " 'COMMENT:\l'"; + $rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."':$stack"; + if (!$nodetails) { + $rrd_options .= ' GPRINT:inB'.$i.":LAST:%6.2lf%s$units"; + $rrd_options .= ' GPRINT:inB'.$i.":AVERAGE:%6.2lf%s$units"; + $rrd_options .= ' GPRINT:inB'.$i.":MAX:%6.2lf%s$units"; + if (!$nototal) { + $rrd_options .= ' GPRINT:totin'.$i.":%6.2lf%s$total_units"; + } - if ($i >= 1) { - $aggr_in .= ","; - $aggr_out .= ","; - } - if ($i > 1) { - $aggr_in .= "ADDNAN,"; - $aggr_out .= "ADDNAN,"; - } - $aggr_in .= $in.$i ; - $aggr_out .= $out.$i ; + $rrd_options .= '\l'; + } - $i++; $iter++; + $rrd_options .= " 'HRULE:0#".$colour_out.':'.$descr_out."'"; + $rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out."::$stack'"; + + if (!$nodetails) { + $rrd_options .= ' GPRINT:outB'.$i.":LAST:%6.2lf%s$units"; + $rrd_options .= ' GPRINT:outB'.$i.":AVERAGE:%6.2lf%s$units"; + $rrd_options .= ' GPRINT:outB'.$i.":MAX:%6.2lf%s$units"; + if (!$nototal) { + $rrd_options .= ' GPRINT:totout'.$i.":%6.2lf%s$total_unit"; + } + + $rrd_options .= '\l'; + } + + $rrd_options .= " 'COMMENT:\l'"; + + if ($i >= 1) { + $aggr_in .= ','; + $aggr_out .= ','; + } + + if ($i > 1) { + $aggr_in .= 'ADDNAN,'; + $aggr_out .= 'ADDNAN,'; + } + + $aggr_in .= $in.$i; + $aggr_out .= $out.$i; + + $i++; + $iter++; } -if (!$noagg){ - $rrd_options .= " CDEF:aggr".$in."bytes=" . $aggr_in.",ADDNAN"; - $rrd_options .= " CDEF:aggr".$out."bytes=" . $aggr_out.",ADDNAN"; - $rrd_options .= " CDEF:aggrinbits=aggrinbytes,".$multiplier.",*"; - $rrd_options .= " CDEF:aggroutbits=aggroutbytes,".$multiplier.",*"; - $rrd_options .= " VDEF:totalin=aggrinbytes,TOTAL"; - $rrd_options .= " VDEF:totalout=aggroutbytes,TOTAL"; - $rrd_options .= " COMMENT:' \\\\n'"; - $rrd_options .= " COMMENT:'".substr(str_pad("Aggregate In", $descr_len+5),0,$descr_len+5)."'"; - $rrd_options .= " GPRINT:aggrinbits:LAST:%6.2lf%s$units"; - $rrd_options .= " GPRINT:aggrinbits:AVERAGE:%6.2lf%s$units"; - $rrd_options .= " GPRINT:aggrinbits:MAX:%6.2lf%s$units"; - if (!$nototal) { - $rrd_options .= " GPRINT:totalin:%6.2lf%s$total_units"; - } - $rrd_options .= "\\\\n"; - $rrd_options .= " COMMENT:'".substr(str_pad("Aggregate Out", $descr_len+5),0,$descr_len+5)."'"; - $rrd_options .= " GPRINT:aggroutbits:LAST:%6.2lf%s$units"; - $rrd_options .= " GPRINT:aggroutbits:AVERAGE:%6.2lf%s$units"; - $rrd_options .= " GPRINT:aggroutbits:MAX:%6.2lf%s$units"; - if (!$nototal) { - $rrd_options .= " GPRINT:totalout:%6.2lf%s$total_units"; - } - $rrd_options .= "\\\\n"; +if (!$noagg) { + $rrd_options .= ' CDEF:aggr'.$in.'bytes='.$aggr_in.',ADDNAN'; + $rrd_options .= ' CDEF:aggr'.$out.'bytes='.$aggr_out.',ADDNAN'; + $rrd_options .= ' CDEF:aggrinbits=aggrinbytes,'.$multiplier.',*'; + $rrd_options .= ' CDEF:aggroutbits=aggroutbytes,'.$multiplier.',*'; + $rrd_options .= ' VDEF:totalin=aggrinbytes,TOTAL'; + $rrd_options .= ' VDEF:totalout=aggroutbytes,TOTAL'; + $rrd_options .= " COMMENT:' \\\\n'"; + $rrd_options .= " COMMENT:'".substr(str_pad('Aggregate In', ($descr_len + 5)), 0, ($descr_len + 5))."'"; + $rrd_options .= " GPRINT:aggrinbits:LAST:%6.2lf%s$units"; + $rrd_options .= " GPRINT:aggrinbits:AVERAGE:%6.2lf%s$units"; + $rrd_options .= " GPRINT:aggrinbits:MAX:%6.2lf%s$units"; + if (!$nototal) { + $rrd_options .= " GPRINT:totalin:%6.2lf%s$total_units"; + } + + $rrd_options .= "\\\\n"; + $rrd_options .= " COMMENT:'".substr(str_pad('Aggregate Out', ($descr_len + 5)), 0, ($descr_len + 5))."'"; + $rrd_options .= " GPRINT:aggroutbits:LAST:%6.2lf%s$units"; + $rrd_options .= " GPRINT:aggroutbits:AVERAGE:%6.2lf%s$units"; + $rrd_options .= " GPRINT:aggroutbits:MAX:%6.2lf%s$units"; + if (!$nototal) { + $rrd_options .= " GPRINT:totalout:%6.2lf%s$total_units"; + } + + $rrd_options .= "\\\\n"; } -if ($custom_graph) { $rrd_options .= $custom_graph; } +if ($custom_graph) { + $rrd_options .= $custom_graph; +} $rrd_options .= $rrd_optionsb; -$rrd_options .= " HRULE:0#999999"; - -?> +$rrd_options .= ' HRULE:0#999999'; diff --git a/html/includes/graphs/generic_multi_seperated.inc.php b/html/includes/graphs/generic_multi_seperated.inc.php index d6cf17271..e672b143b 100644 --- a/html/includes/graphs/generic_multi_seperated.inc.php +++ b/html/includes/graphs/generic_multi_seperated.inc.php @@ -1,185 +1,195 @@ +$rrd_options .= ' HRULE:0#999999'; diff --git a/html/includes/graphs/global/bits.inc.php b/html/includes/graphs/global/bits.inc.php index 674229ecf..763a9d103 100644 --- a/html/includes/graphs/global/bits.inc.php +++ b/html/includes/graphs/global/bits.inc.php @@ -6,8 +6,7 @@ $i = 0; foreach (dbFetchRows('SELECT * FROM `ports` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY P.ifInOctets_rate DESC') as $port) { $ignore = 0; if (is_array($config['device_traffic_iftype'])) { - foreach ($config['device_traffic_iftype'] as $iftype) - { + foreach ($config['device_traffic_iftype'] as $iftype) { if (preg_match($iftype.'i', $port['ifType'])) { $ignore = 1; } @@ -15,8 +14,7 @@ foreach (dbFetchRows('SELECT * FROM `ports` AS P, `devices` AS D WHERE D.device_ } if (is_array($config['device_traffic_descr'])) { - foreach ($config['device_traffic_descr'] as $ifdescr) - { + foreach ($config['device_traffic_descr'] as $ifdescr) { if (preg_match($ifdescr.'i', $port['ifDescr']) || preg_match($ifdescr.'i', $port['ifName']) || preg_match($ifdescr.'i', $port['portName'])) { $ignore = 1; } diff --git a/html/includes/graphs/graph.inc.php b/html/includes/graphs/graph.inc.php index 6ba9de57a..19e99c9b6 100644 --- a/html/includes/graphs/graph.inc.php +++ b/html/includes/graphs/graph.inc.php @@ -1,188 +1,199 @@ $value) -{ - $vars[$name] = $value; +foreach ($_GET as $name => $value) { + $vars[$name] = $value; } preg_match('/^(?P[A-Za-z0-9]+)_(?P.+)/', $vars['type'], $graphtype); -if(is_numeric($vars['device'])) -{ - $device = device_by_id_cache($vars['device']); -} elseif(!empty($vars['device'])) { - $device = device_by_name($vars['device']); +if (is_numeric($vars['device'])) { + $device = device_by_id_cache($vars['device']); +} +else if (!empty($vars['device'])) { + $device = device_by_name($vars['device']); } // FIXME -- remove these - $width = $vars['width']; $height = $vars['height']; $title = $vars['title']; $vertical = $vars['vertical']; $legend = $vars['legend']; -$from = (isset($vars['from']) ? $vars['from'] : time() - 60*60*24); -$to = (isset($vars['to']) ? $vars['to'] : time()); +$from = (isset($vars['from']) ? $vars['from'] : time() - 60 * 60 * 24); +$to = (isset($vars['to']) ? $vars['to'] : time()); -if ($from < 0) { $from = $to + $from; } +if ($from < 0) { + $from = ($to + $from); +} -$period = $to - $from; +$period = ($to - $from); -$prev_from = $from - $period; +$prev_from = ($from - $period); -$graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; +$graphfile = $config['temp_dir'].'/'.strgen().'.png'; -$type = $graphtype['type']; +$type = $graphtype['type']; $subtype = $graphtype['subtype']; if ($auth !== true && $auth != 1) { $auth = is_client_authorized($_SERVER['REMOTE_ADDR']); } -include($config['install_dir'] . "/html/includes/graphs/$type/auth.inc.php"); -if ($auth === true && is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php")) { - include($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php"); +require $config['install_dir']."/html/includes/graphs/$type/auth.inc.php"; + +if ($auth === true && is_file($config['install_dir']."/html/includes/graphs/$type/$subtype.inc.php")) { + include $config['install_dir']."/html/includes/graphs/$type/$subtype.inc.php"; } -elseif ($auth === true && is_mib_graph($type, $subtype)) { - include($config['install_dir'] . "/html/includes/graphs/$type/mib.inc.php"); +else if ($auth === true && is_mib_graph($type, $subtype)) { + include $config['install_dir']."/html/includes/graphs/$type/mib.inc.php"; } else { - graph_error("$type*$subtype ");//Graph Template Missing"); + graph_error("$type*$subtype "); + // Graph Template Missing"); } -function graph_error($string) -{ - global $vars, $config, $debug, $graphfile; - $vars['bg'] = "FFBBBB"; +function graph_error($string) { + global $vars, $config, $debug, $graphfile; - include("includes/graphs/common.inc.php"); + $vars['bg'] = 'FFBBBB'; - $rrd_options .= " HRULE:0#555555"; - $rrd_options .= " --title='".$string."'"; + include 'includes/graphs/common.inc.php'; - rrdtool_graph($graphfile, $rrd_options); + $rrd_options .= ' HRULE:0#555555'; + $rrd_options .= " --title='".$string."'"; - if ($height > "99") { - shell_exec($rrd_cmd); - if ($debug) { echo("
    ".$rrd_cmd."
    "); } - if (is_file($graphfile) && !$debug) - { - header('Content-type: image/png'); - $fd = fopen($graphfile,'r'); fpassthru($fd); fclose($fd); - unlink($graphfile); - exit(); + rrdtool_graph($graphfile, $rrd_options); + + if ($height > '99') { + shell_exec($rrd_cmd); + if ($debug) { + echo '
    '.$rrd_cmd.'
    '; + } + + if (is_file($graphfile) && !$debug) { + header('Content-type: image/png'); + $fd = fopen($graphfile, 'r'); + fpassthru($fd); + fclose($fd); + unlink($graphfile); + exit(); + } } - } else { - if (!$debug) { header('Content-type: image/png'); } - $im = imagecreate($width, $height); - $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); - exit(); - } + else { + if (!$debug) { + header('Content-type: image/png'); + } + + $im = imagecreate($width, $height); + $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); + exit(); + } + } if ($error_msg) { - // We have an error :( - - graph_error($graph_error); - -} elseif ($auth === null) { - // We are unauthenticated :( - - if ($width < 200) - { - graph_error("No Auth"); - } else { - graph_error("No Authorisation"); - } -} else { - #$rrd_options .= " HRULE:0#999999"; - if ($no_file) - { - if ($width < 200) - { - graph_error("No RRD"); - } else { - graph_error("Missing RRD Datafile"); - } - } elseif($command_only) { - echo("
    "); - echo("

    RRDTool Command

    "); - echo("rrdtool graph $graphfile $rrd_options"); - echo(""); - $return = rrdtool_graph($graphfile, $rrd_options); - echo("

    "); - echo("

    RRDTool Output

    $return"); - unlink($graphfile); - echo("
    "); - } else { - - if ($rrd_options) - { - rrdtool_graph($graphfile, $rrd_options); - if ($debug) { echo($rrd_cmd); } - if (is_file($graphfile)) - { - if (!$debug) - { - header('Content-type: image/png'); - if ($config['trim_tobias']) - { - list($w, $h, $type, $attr) = getimagesize($graphfile); - $src_im = imagecreatefrompng($graphfile); - $src_x = '0'; // begin x - $src_y = '0'; // begin y - $src_w = $w-12; // width - $src_h = $h; // height - $dst_x = '0'; // destination x - $dst_y = '0'; // destination y - $dst_im = imagecreatetruecolor($src_w, $src_h); - imagesavealpha($dst_im, true); - $white = imagecolorallocate($dst_im, 255, 255, 255); - $trans_colour = imagecolorallocatealpha($dst_im, 0, 0, 0, 127); - imagefill($dst_im, 0, 0, $trans_colour); - imagecopy($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h); - imagepng($dst_im); - imagedestroy($dst_im); - } else { - $fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd); - } - - } else { - echo(`ls -l $graphfile`); - echo('graph'); - } - unlink($graphfile); - } - else - { - if ($width < 200) - { - graph_error("Draw Error"); - } - else - { - graph_error("Error Drawing Graph"); - } - } - } - else - { - if ($width < 200) - { - graph_error("Def Error"); - } else { - graph_error("Graph Definition Error"); - } - } - } + // We have an error :( + graph_error($graph_error); } +else if ($auth === null) { + // We are unauthenticated :( + if ($width < 200) { + graph_error('No Auth'); + } + else { + graph_error('No Authorisation'); + } +} +else { + // $rrd_options .= " HRULE:0#999999"; + if ($no_file) { + if ($width < 200) { + graph_error('No RRD'); + } + else { + graph_error('Missing RRD Datafile'); + } + } + else if ($command_only) { + echo "
    "; + echo "

    RRDTool Command

    "; + echo "rrdtool graph $graphfile $rrd_options"; + echo ''; + $return = rrdtool_graph($graphfile, $rrd_options); + echo '

    '; + echo "

    RRDTool Output

    $return"; + unlink($graphfile); + echo '
    '; + } + else { + if ($rrd_options) { + rrdtool_graph($graphfile, $rrd_options); + if ($debug) { + echo $rrd_cmd; + } -?> + if (is_file($graphfile)) { + if (!$debug) { + header('Content-type: image/png'); + if ($config['trim_tobias']) { + list($w, $h, $type, $attr) = getimagesize($graphfile); + $src_im = imagecreatefrompng($graphfile); + $src_x = '0'; + // begin x + $src_y = '0'; + // begin y + $src_w = ($w - 12); + // width + $src_h = $h; + // height + $dst_x = '0'; + // destination x + $dst_y = '0'; + // destination y + $dst_im = imagecreatetruecolor($src_w, $src_h); + imagesavealpha($dst_im, true); + $white = imagecolorallocate($dst_im, 255, 255, 255); + $trans_colour = imagecolorallocatealpha($dst_im, 0, 0, 0, 127); + imagefill($dst_im, 0, 0, $trans_colour); + imagecopy($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h); + imagepng($dst_im); + imagedestroy($dst_im); + } + else { + $fd = fopen($graphfile, 'r'); + fpassthru($fd); + fclose($fd); + } + } + else { + echo `ls -l $graphfile`; + echo 'graph'; + } + unlink($graphfile); + } + else { + if ($width < 200) { + graph_error('Draw Error'); + } + else { + graph_error('Error Drawing Graph'); + } + } + } + else { + if ($width < 200) { + graph_error('Def Error'); + } + else { + graph_error('Graph Definition Error'); + } + } + } +} diff --git a/html/includes/graphs/location/bits.inc.php b/html/includes/graphs/location/bits.inc.php index 501b39c74..53b0a656e 100644 --- a/html/includes/graphs/location/bits.inc.php +++ b/html/includes/graphs/location/bits.inc.php @@ -6,12 +6,10 @@ $ds_out = 'OUTOCTETS'; $i = 1; foreach ($devices as $device) { - foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ?', array($device['device_id'])) as $int) - { + foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ?', array($device['device_id'])) as $int) { $ignore = 0; if (is_array($config['device_traffic_iftype'])) { - foreach ($config['device_traffic_iftype'] as $iftype) - { + foreach ($config['device_traffic_iftype'] as $iftype) { if (preg_match($iftype.'i', $int['ifType'])) { $ignore = 1; } @@ -19,8 +17,7 @@ foreach ($devices as $device) { } if (is_array($config['device_traffic_descr'])) { - foreach ($config['device_traffic_descr'] as $ifdescr) - { + foreach ($config['device_traffic_descr'] as $ifdescr) { if (preg_match($ifdescr.'i', $int['ifDescr']) || preg_match($ifdescr.'i', $int['ifName']) || preg_match($ifdescr.'i', $int['portName'])) { $ignore = 1; } diff --git a/html/includes/graphs/mempool/auth.inc.php b/html/includes/graphs/mempool/auth.inc.php index 142952551..bd507b89c 100644 --- a/html/includes/graphs/mempool/auth.inc.php +++ b/html/includes/graphs/mempool/auth.inc.php @@ -1,17 +1,13 @@ diff --git a/html/includes/graphs/munin/auth.inc.php b/html/includes/graphs/munin/auth.inc.php index cf894de65..df77b06e7 100644 --- a/html/includes/graphs/munin/auth.inc.php +++ b/html/includes/graphs/munin/auth.inc.php @@ -1,20 +1,16 @@ +if (is_numeric($mplug['device_id']) && ($auth || device_permitted($mplug['device_id']))) { + $device = &$mplug; + $title = generate_device_link($device); + $plugfile = $config['rrd_dir'].'/'.$device['hostname'].'/munin/'.$mplug['mplug_type']; + $title .= ' :: Plugin :: '.$mplug['mplug_type'].' - '.$mplug['mplug_title']; + $auth = true; +} diff --git a/html/includes/graphs/munin/graph.inc.php b/html/includes/graphs/munin/graph.inc.php index 21521c60a..9b634813b 100644 --- a/html/includes/graphs/munin/graph.inc.php +++ b/html/includes/graphs/munin/graph.inc.php @@ -43,7 +43,7 @@ foreach ($dbq as $ds) { $colour = $config['graph_colours']['mixed'][$c_i]; $c_i++; - } + } else { $colour = $ds['colour']; } diff --git a/html/includes/graphs/port/auth.inc.php b/html/includes/graphs/port/auth.inc.php index a11959eb3..68114f8c4 100644 --- a/html/includes/graphs/port/auth.inc.php +++ b/html/includes/graphs/port/auth.inc.php @@ -1,20 +1,17 @@ diff --git a/html/includes/graphs/port/nupkts.inc.php b/html/includes/graphs/port/nupkts.inc.php index e26f5e449..6b8d11b2d 100644 --- a/html/includes/graphs/port/nupkts.inc.php +++ b/html/includes/graphs/port/nupkts.inc.php @@ -1,7 +1,7 @@ diff --git a/html/includes/graphs/processor/usage.inc.php b/html/includes/graphs/processor/usage.inc.php index 3812a1432..5954685d7 100644 --- a/html/includes/graphs/processor/usage.inc.php +++ b/html/includes/graphs/processor/usage.inc.php @@ -1,19 +1,17 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/rserver/auth.inc.php b/html/includes/graphs/rserver/auth.inc.php index d179370bc..d166efd19 100644 --- a/html/includes/graphs/rserver/auth.inc.php +++ b/html/includes/graphs/rserver/auth.inc.php @@ -1,6 +1,6 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/rserver/failed.inc.php b/html/includes/graphs/rserver/failed.inc.php index 291cdd396..60f544bba 100644 --- a/html/includes/graphs/rserver/failed.inc.php +++ b/html/includes/graphs/rserver/failed.inc.php @@ -2,7 +2,7 @@ $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; $graph_max = 1; @@ -16,6 +16,4 @@ $colour_area_max = "FFEE99"; $nototal = 1; $unit_text = "Conns"; -include("includes/graphs/generic_simplex.inc.php"); - -?> +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/rserver/total.inc.php b/html/includes/graphs/rserver/total.inc.php index e4efdc81f..9d39f6bce 100644 --- a/html/includes/graphs/rserver/total.inc.php +++ b/html/includes/graphs/rserver/total.inc.php @@ -2,20 +2,18 @@ $scale_min = 0; -include("includes/graphs/common.inc.php"); +require 'includes/graphs/common.inc.php'; $graph_max = 1; -$ds = "RserverTotalConns"; +$ds = 'RserverTotalConns'; -$colour_area = "B0C4DE"; -$colour_line = "191970"; +$colour_area = 'B0C4DE'; +$colour_line = '191970'; -$colour_area_max = "FFEE99"; +$colour_area_max = 'FFEE99'; $nototal = 1; -$unit_text = "Conns"; +$unit_text = 'Conns'; -include("includes/graphs/generic_simplex.inc.php"); - -?> +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/sensor/charge.inc.php b/html/includes/graphs/sensor/charge.inc.php index 331d4ff1a..e400153ae 100644 --- a/html/includes/graphs/sensor/charge.inc.php +++ b/html/includes/graphs/sensor/charge.inc.php @@ -1,9 +1,9 @@ +if (is_numeric($sensor['sensor_limit'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit'].'#999999::dashes'; +} + +if (is_numeric($sensor['sensor_limit_low'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; +} diff --git a/html/includes/graphs/sensor/current.inc.php b/html/includes/graphs/sensor/current.inc.php index b496c002a..f1ca4abdd 100644 --- a/html/includes/graphs/sensor/current.inc.php +++ b/html/includes/graphs/sensor/current.inc.php @@ -19,5 +19,5 @@ if (is_numeric($sensor['sensor_limit'])) { } if (is_numeric($sensor['sensor_limit_low'])) { - $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; } diff --git a/html/includes/graphs/sensor/dbm.inc.php b/html/includes/graphs/sensor/dbm.inc.php index 5880ddafc..32d6a57fc 100644 --- a/html/includes/graphs/sensor/dbm.inc.php +++ b/html/includes/graphs/sensor/dbm.inc.php @@ -19,5 +19,5 @@ if (is_numeric($sensor['sensor_limit'])) { } if (is_numeric($sensor['sensor_limit_low'])) { - $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; } diff --git a/html/includes/graphs/sensor/load.inc.php b/html/includes/graphs/sensor/load.inc.php index 095f0eb2e..050f58a0b 100644 --- a/html/includes/graphs/sensor/load.inc.php +++ b/html/includes/graphs/sensor/load.inc.php @@ -1,22 +1,25 @@ +if (is_numeric($sensor['sensor_limit_low'])) { + $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; +} diff --git a/html/includes/graphs/sensor/state.inc.php b/html/includes/graphs/sensor/state.inc.php index 281b1932f..e04e7dc29 100644 --- a/html/includes/graphs/sensor/state.inc.php +++ b/html/includes/graphs/sensor/state.inc.php @@ -1,17 +1,21 @@ \ No newline at end of file +$rrd_options .= ' CDEF:percent=status,100,*'; +$rrd_options .= ' CDEF:down=status,1,LT,status,UNKN,IF'; +$rrd_options .= ' CDEF:percentdown=down,100,*'; +$rrd_options .= ' AREA:percent#CCFFCC'; +$rrd_options .= ' AREA:percentdown#FFCCCC'; +$rrd_options .= " LINE1.5:percent#009900:'".$service_text."'"; +// Ugly hack :( +$rrd_options .= ' LINE1.5:percentdown#cc0000'; +$rrd_options .= ' GPRINT:status:LAST:%3.0lf'; +$rrd_options .= ' GPRINT:percent:AVERAGE:%3.5lf%%\\\\l'; diff --git a/html/includes/graphs/storage/auth.inc.php b/html/includes/graphs/storage/auth.inc.php index 0e2671304..47f8189aa 100644 --- a/html/includes/graphs/storage/auth.inc.php +++ b/html/includes/graphs/storage/auth.inc.php @@ -1,18 +1,14 @@ diff --git a/html/includes/graphs/toner/auth.inc.php b/html/includes/graphs/toner/auth.inc.php index 928b7af38..72222f18f 100644 --- a/html/includes/graphs/toner/auth.inc.php +++ b/html/includes/graphs/toner/auth.inc.php @@ -1,18 +1,14 @@ diff --git a/html/includes/graphs/toner/usage.inc.php b/html/includes/graphs/toner/usage.inc.php index 3849b279c..2b617eb8b 100644 --- a/html/includes/graphs/toner/usage.inc.php +++ b/html/includes/graphs/toner/usage.inc.php @@ -1,24 +1,24 @@ +$rrd_options .= ' AREA:toner'.$toner['toner_id'].'#'.$background['right'].':'; +$rrd_options .= ' GPRINT:toner'.$toner['toner_id'].":LAST:'%5.0lf%%'"; +$rrd_options .= ' GPRINT:toner'.$toner['toner_id'].':MAX:%5.0lf%%\\\\l'; diff --git a/html/includes/graphs/vserver/auth.inc.php b/html/includes/graphs/vserver/auth.inc.php index 2d16279db..4cb444871 100644 --- a/html/includes/graphs/vserver/auth.inc.php +++ b/html/includes/graphs/vserver/auth.inc.php @@ -1,6 +1,6 @@ +require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/hostbox-menu.inc.php b/html/includes/hostbox-menu.inc.php index 702941a31..03a9bb277 100644 --- a/html/includes/hostbox-menu.inc.php +++ b/html/includes/hostbox-menu.inc.php @@ -12,33 +12,33 @@ * the source code distribution for details. */ -echo(''); - if (device_permitted($device['device_id'])) { - echo ('
    -
    '); - echo ' View device '; - echo ('
    -
    '); - echo ' View alerts '; - echo '
    '; - if ($_SESSION['userlevel'] >= "7") { - echo ('
    - Edit device -
    '); - } - echo ('
    -
    -
    - telnet -
    -
    - ssh -
    -
    - https -
    -
    '); +echo ''; +if (device_permitted($device['device_id'])) { + echo '
    +
    '; + echo ' View device '; + echo '
    +
    '; + echo ' View alerts '; + echo '
    '; + if ($_SESSION['userlevel'] >= '7') { + echo '
    + Edit device +
    '; } -echo(''); -?> + echo '
    +
    +
    + telnet +
    +
    + ssh +
    +
    + https +
    +
    '; +}//end if + +echo ''; diff --git a/html/includes/hostbox-public.inc.php b/html/includes/hostbox-public.inc.php index 47b4d23cc..ac3037688 100644 --- a/html/includes/hostbox-public.inc.php +++ b/html/includes/hostbox-public.inc.php @@ -1,61 +1,73 @@ -* -* This program is free software: you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation, either version 3 of the License, or (at your -* option) any later version. Please see LICENSE.txt at the top level of -* the source code distribution for details. + * This file is part of LibreNMS + * + * Copyright (c) 2014 Bohdan Sanders + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ ?> - - ' . $image . ' - ' . generate_device_link($device) . '' - ); +echo ' + + '.$image.' + '.generate_device_link($device).''; -echo(''); -if ($port_count) { echo(' '.$port_count); } -echo('
    '); -if ($sensor_count) { echo(' '.$sensor_count); } -echo(''); -echo(' ' . $device['hardware'] . ' ' . $device['features'] . ''); -echo(' ' . formatUptime($device['uptime'], 'short') . '
    '); +echo ''; +if ($port_count) { + echo ' '.$port_count; +} -if (get_dev_attrib($device,'override_sysLocation_bool')) { $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); } -echo(' ' . truncate($device['location'],32, '') . ''); +echo '
    '; +if ($sensor_count) { + echo ' '.$sensor_count; +} -echo(' '); +echo ''; +echo ' '.$device['hardware'].' '.$device['features'].''; +echo ' '.formatUptime($device['uptime'], 'short').'
    '; -?> +if (get_dev_attrib($device, 'override_sysLocation_bool')) { + $device['location'] = get_dev_attrib($device, 'override_sysLocation_string'); +} + +echo ' '.truncate($device['location'], 32, '').''; + +echo ' '; diff --git a/html/includes/javascript-interfacepicker.inc.php b/html/includes/javascript-interfacepicker.inc.php index 7fcdf11a9..c5a8c932f 100644 --- a/html/includes/javascript-interfacepicker.inc.php +++ b/html/includes/javascript-interfacepicker.inc.php @@ -24,4 +24,3 @@ function createInterfaces(index) } - diff --git a/html/includes/jpgraph/src/contour_dev/findpolygon.php b/html/includes/jpgraph/src/contour_dev/findpolygon.php index 4d105280f..675c74c2e 100644 --- a/html/includes/jpgraph/src/contour_dev/findpolygon.php +++ b/html/includes/jpgraph/src/contour_dev/findpolygon.php @@ -98,16 +98,20 @@ class Findpolygon { array_pop($b); } - $n1 = count($a); $n2 = count($b); - if( $n1 != $n2 ) + $n1 = count($a); + $n2 = count($b); + if( $n1 != $n2 ) { return false; + } $i=0; - while( ($i < $n2) && ($a[0] != $b[$i]) ) + while( ($i < $n2) && ($a[0] != $b[$i]) ) { ++$i; + } - if( $i >= $n2 ) + if( $i >= $n2 ) { return false; + } $j=0; if( $forward ) { diff --git a/html/includes/jpgraph/src/contour_dev/tri-quad.php b/html/includes/jpgraph/src/contour_dev/tri-quad.php index 7281f8e36..826d1bf01 100644 --- a/html/includes/jpgraph/src/contour_dev/tri-quad.php +++ b/html/includes/jpgraph/src/contour_dev/tri-quad.php @@ -59,11 +59,14 @@ class ContCanvas { function DrawLinePolygons($p,$color='red') { $this->shape->SetColor($color); for ($i = 0 ; $i < count($p) ; $i++) { - $x1 = $p[$i][0][0]; $y1 = $p[$i][0][1]; + $x1 = $p[$i][0][0]; + $y1 = $p[$i][0][1]; for ($j = 1 ; $j < count($p[$i]) ; $j++) { - $x2=$p[$i][$j][0]; $y2 = $p[$i][$j][1]; + $x2=$p[$i][$j][0]; + $y2 = $p[$i][$j][1]; $this->shape->Line($x1, $y1, $x2, $y2); - $x1=$x2; $y1=$y2; + $x1=$x2; + $y1=$y2; } } } @@ -138,7 +141,7 @@ class SingleTestTriangle { //$this->g->InitFrame(); self::$t = new Text(); - self::$t->SetColor('black'); + self::$t->SetColor('black'); self::$t->SetFont(FF_ARIAL,FS_BOLD,9); self::$t->SetAlign('center','center'); } @@ -487,7 +490,8 @@ class SingleTestTriangle { $pl1 = array($x1p,$y1p,$x4p,$y4p); $colorl2 = $this->GetColor($v2p); $pl2 = array($x2p,$y2p,$x3p,$y3p); - $vl1 = $v1p; $vl2 = $v2p; + $vl1 = $v1p; + $vl2 = $v2p; } else { @@ -505,7 +509,8 @@ class SingleTestTriangle { $pl1 = array($x1p,$y1p,$x2p,$y2p); $colorl2 = $this->GetColor($v4p); $pl2 = array($x4p,$y4p,$x3p,$y3p); - $vl1 = $v1p; $vl2 = $v4p; + $vl1 = $v1p; + $vl2 = $v4p; } } else { @@ -526,7 +531,8 @@ class SingleTestTriangle { $pl1 = array($x1p,$y1p,$x2p,$y2p); $colorl2 = $this->GetColor($v4p); $pl2 = array($x4p,$y4p,$x3p,$y3p); - $vl1 = $v1p; $vl2 = $v4p; + $vl1 = $v1p; + $vl2 = $v4p; } else { //( $v1p == $v4p ) // "\" @@ -543,7 +549,8 @@ class SingleTestTriangle { $pl1 = array($x1p,$y1p,$x4p,$y4p); $colorl2 = $this->GetColor($v2p); $pl2 = array($x2p,$y2p,$x3p,$y3p); - $vl1 = $v1p; $vl2 = $v2p; + $vl1 = $v1p; + $vl2 = $v2p; } } $this->FillPolygon($color1,$p1); @@ -730,9 +737,12 @@ class SingleTestTriangle { } function Fill($v1,$v2,$v3,$maxdepth) { - $x1=0; $y1=1; - $x2=1; $y2=0; - $x3=1; $y3=1; + $x1=0; + $y1=1; + $x2=1; + $y2=0; + $x3=1; + $y3=1; self::$maxdepth = $maxdepth; $this->TriFill($v1, $v2, $v3, $x1, $y1, $x2, $y2, $x3, $y3, 0); } diff --git a/html/includes/modal/alert_schedule.inc.php b/html/includes/modal/alert_schedule.inc.php index 7c6b7b628..b726a219f 100644 --- a/html/includes/modal/alert_schedule.inc.php +++ b/html/includes/modal/alert_schedule.inc.php @@ -223,5 +223,3 @@ $(function () { diff --git a/html/includes/modal/new_alert_rule.inc.php b/html/includes/modal/new_alert_rule.inc.php index cce990eb4..5d4ff6076 100644 --- a/html/includes/modal/new_alert_rule.inc.php +++ b/html/includes/modal/new_alert_rule.inc.php @@ -391,5 +391,3 @@ $( "#suggest, #value" ).blur(function() { diff --git a/html/includes/modal/new_device_group.inc.php b/html/includes/modal/new_device_group.inc.php index aa5717b28..d1dc5d6f4 100644 --- a/html/includes/modal/new_device_group.inc.php +++ b/html/includes/modal/new_device_group.inc.php @@ -246,5 +246,3 @@ $( "#name, #suggest, #value" ).blur(function() { diff --git a/html/includes/modal/poller_groups.inc.php b/html/includes/modal/poller_groups.inc.php index c966da6ac..ccbfe2245 100644 --- a/html/includes/modal/poller_groups.inc.php +++ b/html/includes/modal/poller_groups.inc.php @@ -13,7 +13,9 @@ if(is_admin() === false) { echo ('ERROR: You need to be admin'); -} else { +} +else { + ?> '-1', 'rule' => '%macros.device_down = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Devices up/down'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%devices.uptime < "300" && %macros.device = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Device rebooted'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerState != "established" && %macros.device_up = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session down'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session establised'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.port_down = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Port status up/down'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.port_usage_perc >= "80"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Port utilisation over threshold'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor over limit'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor under limit'); - foreach( $default_rules as $add_rule ) { - dbInsert($add_rule,'alert_rules'); +if (isset($_POST['create-default'])) { + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%macros.device_down = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Devices up/down', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%devices.uptime < "300" && %macros.device = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Device rebooted', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%bgpPeers.bgpPeerState != "established" && %macros.device_up = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'BGP Session down', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'BGP Session establised', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%macros.port_down = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Port status up/down', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%macros.port_usage_perc >= "80"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Port utilisation over threshold', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Sensor over limit', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Sensor under limit', + ); + foreach ($default_rules as $add_rule) { + dbInsert($add_rule, 'alert_rules'); } -} - -require_once('includes/modal/new_alert_rule.inc.php'); -require_once('includes/modal/delete_alert_rule.inc.php'); +}//end if +require_once 'includes/modal/new_alert_rule.inc.php'; +require_once 'includes/modal/delete_alert_rule.inc.php'; ?>
    0) { +if (isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} else { +} +else { $results = 50; } echo '
    - - +
    + @@ -49,126 +103,150 @@ echo '
    - '; + '; -echo (' - + '); -$rulei=1; -$count_query = "SELECT COUNT(id)"; -$full_query = "SELECT *"; -$sql = ''; -$param = array(); -if(isset($device['device_id']) && $device['device_id'] > 0) { - $sql = 'WHERE (device_id=? OR device_id="-1")'; +echo ''; + +$rulei = 1; +$count_query = 'SELECT COUNT(id)'; +$full_query = 'SELECT *'; +$sql = ''; +$param = array(); +if (isset($device['device_id']) && $device['device_id'] > 0) { + $sql = 'WHERE (device_id=? OR device_id="-1")'; $param = array($device['device_id']); } -$query = " FROM alert_rules $sql ORDER BY device_id,id"; -$count_query = $count_query . $query; -$count = dbFetchCell($count_query,$param); -if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { + +$query = " FROM alert_rules $sql ORDER BY device_id,id"; +$count_query = $count_query.$query; +$count = dbFetchCell($count_query, $param); +if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} else { +} +else { $page_number = $_POST['page_number']; } -$start = ($page_number - 1) * $results; -$full_query = $full_query . $query . " LIMIT $start,$results"; -foreach( dbFetchRows($full_query, $param) as $rule ) { - $sub = dbFetchRows("SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1", array($rule['id'])); - $ico = "ok"; - $col = "success"; - $extra = ""; - if( sizeof($sub) == 1 ) { - $sub = $sub[0]; - if( (int) $sub['state'] === 0 ) { - $ico = "ok"; - $col = "success"; - } elseif( (int) $sub['state'] === 1 ) { - $ico = "remove"; - $col = "danger"; - $extra = "danger"; - } elseif( (int) $sub['state'] === 2 ) { - $ico = "time"; - $col = "default"; - $extra = "warning"; - } - } - $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; - if( $rule['disabled'] ) { - $ico = "pause"; - $col = ""; - $extra = "active"; - } else { - $alert_checked = 'checked'; +$start = (($page_number - 1) * $results); +$full_query = $full_query.$query." LIMIT $start,$results"; + +foreach (dbFetchRows($full_query, $param) as $rule) { + $sub = dbFetchRows('SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1', array($rule['id'])); + $ico = 'ok'; + $col = 'success'; + $extra = ''; + if (sizeof($sub) == 1) { + $sub = $sub[0]; + if ((int) $sub['state'] === 0) { + $ico = 'ok'; + $col = 'success'; } - $rule_extra = json_decode($rule['extra'],TRUE); - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + else if ((int) $sub['state'] === 2) { + $ico = 'time'; + $col = 'default'; + $extra = 'warning'; } - echo ""; - echo ""; - echo ""; - echo "\r\n"; + } + + $alert_checked = ''; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; + if ($rule['disabled']) { + $ico = 'pause'; + $col = ''; + $extra = 'active'; + } + else { + $alert_checked = 'checked'; + } + + $rule_extra = json_decode($rule['extra'], true); + echo ""; + echo ''; + echo ''; + echo "'; + echo ''; + echo ""; + } + + echo ''; + echo ''; + echo ''; + echo "\r\n"; +}//end foreach + +if (($count % $results) > 0) { + echo ' + + '; } -if($count % $results > 0) { - echo(' - - '); -} echo '
    # Name RuleExtra Enabled Action
    '); +echo ''; if ($_SESSION['userlevel'] >= '10') { - echo(''); + echo ''; } -echo ('
    #".((int) $rulei++)."".$rule['name'].""; - if($rule_extra['invert'] === true) { - echo "Inverted "; + else if ((int) $sub['state'] === 1) { + $ico = 'remove'; + $col = 'danger'; + $extra = 'danger'; } - echo "".htmlentities($rule['rule'])."".$rule['severity']." "; - if($rule_extra['mute'] === true) { - echo "Max: ".$rule_extra['count']."
    Delay: ".$rule_extra['delay']."
    Interval: ".$rule_extra['interval']."
    "; - if ($_SESSION['userlevel'] >= '10') { - echo ""; - } - echo ""; - if ($_SESSION['userlevel'] >= '10') { - echo " "; - echo ""; - } - echo "
    #'.((int) $rulei++).''.$rule['name'].'"; + if ($rule_extra['invert'] === true) { + echo 'Inverted '; + } + + echo ''.htmlentities($rule['rule']).''.$rule['severity'].' "; + if ($rule_extra['mute'] === true) { + echo "Max: '.$rule_extra['count'].'
    Delay: '.$rule_extra['delay'].'
    Interval: '.$rule_extra['interval'].'
    '; + if ($_SESSION['userlevel'] >= '10') { + echo ""; + } + + echo ''; + if ($_SESSION['userlevel'] >= '10') { + echo " "; + echo ""; + } + + echo '
    '.generate_pagination($count, $results, $page_number).'
    '. generate_pagination($count,$results,$page_number) .'
    - - - -
    '; + + + + '; -if($count < 1) { +if ($count < 1) { if ($_SESSION['userlevel'] >= '10') { echo '
    -
    -
    -

    - -

    -
    -
    -
    '; +
    +
    +

    + +

    +
    +
    + '; } } @@ -180,19 +258,19 @@ $('#ack-alert').click('', function(e) { var alert_id = $(this).data("alert_id"); $.ajax({ type: "POST", - url: "/ajax_form.php", - data: { type: "ack-alert", alert_id: alert_id }, - success: function(msg){ - $("#message").html('
    '+msg+'
    '); - if(msg.indexOf("ERROR:") <= -1) { - setTimeout(function() { - location.reload(1); - }, 1000); - } - }, - error: function(){ - $("#message").html('
    An error occurred acking this alert.
    '); - } + url: "/ajax_form.php", + data: { type: "ack-alert", alert_id: alert_id }, + success: function(msg){ + $("#message").html('
    '+msg+'
    '); + if(msg.indexOf("ERROR:") <= -1) { + setTimeout(function() { + location.reload(1); + }, 1000); + } + }, + error: function(){ + $("#message").html('
    An error occurred acking this alert.
    '); + } }); }); @@ -206,42 +284,42 @@ $('input[name="alert-rule"]').on('switchChange.bootstrapSwitch', function(event var orig_class = $(this).data("orig_class"); $.ajax({ type: 'POST', - url: '/ajax_form.php', - data: { type: "update-alert-rule", alert_id: alert_id, state: state }, - dataType: "html", - success: function(msg) { - if(msg.indexOf("ERROR:") <= -1) { - if(state) { - $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).removeClass('text-default'); - $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); - $('#row_'+alert_id).removeClass('active'); - $('#row_'+alert_id).addClass(orig_class); + url: '/ajax_form.php', + data: { type: "update-alert-rule", alert_id: alert_id, state: state }, + dataType: "html", + success: function(msg) { + if(msg.indexOf("ERROR:") <= -1) { + if(state) { + $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).removeClass('text-default'); + $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); + $('#row_'+alert_id).removeClass('active'); + $('#row_'+alert_id).addClass(orig_class); + } else { + $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); + $('#alert-rule-'+alert_id).addClass('text-default'); + $('#row_'+alert_id).removeClass('warning'); + $('#row_'+alert_id).addClass('active'); + } } else { - $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); - $('#alert-rule-'+alert_id).addClass('text-default'); - $('#row_'+alert_id).removeClass('warning'); - $('#row_'+alert_id).addClass('active'); + $("#message").html('
    '+msg+'
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); + } + }, + error: function() { + $("#message").html('
    This alert could not be updated.
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); } - } else { - $("#message").html('
    '+msg+'
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); - } - }, - error: function() { - $("#message").html('
    This alert could not be updated.
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); - } }); }); function updateResults(results) { - $('#results_amount').val(results.value); - $('#page_number').val(1); - $('#result_form').submit(); + $('#results_amount').val(results.value); + $('#page_number').val(1); + $('#result_form').submit(); } function changePage(page,e) { diff --git a/html/includes/print-alert-templates.php b/html/includes/print-alert-templates.php index 16a3afdd0..8ad6e8265 100644 --- a/html/includes/print-alert-templates.php +++ b/html/includes/print-alert-templates.php @@ -1,6 +1,6 @@ @@ -10,17 +10,17 @@ $no_refresh = TRUE;
    0) { +if (isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} else { +} +else { $results = 50; } @@ -34,37 +34,49 @@ echo '
    '; if ($_SESSION['userlevel'] >= '10') { - echo(''); + echo ''; } echo ' '); -$count_query = "SELECT COUNT(id)"; -$full_query = "SELECT *"; +echo ''; -$query = " FROM `alert_templates`"; +$count_query = 'SELECT COUNT(id)'; +$full_query = 'SELECT *'; -$count_query = $count_query . $query; -$count = dbFetchCell($count_query,$param); -if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { +$query = ' FROM `alert_templates`'; + +$count_query = $count_query.$query; +$count = dbFetchCell($count_query, $param); +if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} else { +} +else { $page_number = $_POST['page_number']; } -$start = ($page_number - 1) * $results; -$full_query = $full_query . $query . " LIMIT $start,$results"; -foreach( dbFetchRows($full_query, $param) as $template ) { +$start = (($page_number - 1) * $results); +$full_query = $full_query.$query." LIMIT $start,$results"; + +foreach (dbFetchRows($full_query, $param) as $template) { echo ' '.$template['name'].' '; @@ -73,14 +85,15 @@ foreach( dbFetchRows($full_query, $param) as $template ) { echo " "; echo ""; } + echo ' '; } -if($count % $results > 0) { - echo(' - '. generate_pagination($count,$results,$page_number) .' - '); +if (($count % $results) > 0) { + echo ' + '.generate_pagination($count, $results, $page_number).' + '; } echo ' diff --git a/html/includes/print-alerts.inc.php b/html/includes/print-alerts.inc.php index dcbab4b3d..d9758a0f3 100644 --- a/html/includes/print-alerts.inc.php +++ b/html/includes/print-alerts.inc.php @@ -1,49 +1,49 @@ - - ' . $alert_entry['time_logged'] . ' - '); +echo ' + + '.$alert_entry['time_logged'].' + '; if (!isset($alert_entry['device'])) { - $dev = device_by_id_cache($alert_entry['device_id']); - echo(" - " . generate_device_link($dev, shorthost($dev['hostname'])) . " - "); + $dev = device_by_id_cache($alert_entry['device_id']); + echo ' + '.generate_device_link($dev, shorthost($dev['hostname'])).' + '; } -echo("".htmlspecialchars($alert_entry['name']) . ""); +echo ''.htmlspecialchars($alert_entry['name']).''; -if ($alert_state!='') { - if ($alert_state=='0') { - $glyph_icon = 'ok'; +if ($alert_state != '') { + if ($alert_state == '0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - elseif ($alert_state=='1') { - $glyph_icon = 'remove'; + else if ($alert_state == '1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - elseif ($alert_state=='2') { - $glyph_icon = 'info-sign'; + else if ($alert_state == '2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - elseif ($alert_state=='3') { - $glyph_icon = 'arrow-down'; + else if ($alert_state == '3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - elseif ($alert_state=='4') { - $glyph_icon = 'arrow-up'; + else if ($alert_state == '4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - } - echo(" $text"); -} + $text = 'Better'; + }//end if + echo " $text"; +}//end if -echo(""); +echo ''; diff --git a/html/includes/print-debug.php b/html/includes/print-debug.php index f35cd05bf..7fdbbcc6d 100644 --- a/html/includes/print-debug.php +++ b/html/includes/print-debug.php @@ -1,6 +1,6 @@ @@ -14,25 +14,23 @@ @@ -52,26 +50,25 @@ foreach ($sql_debug as $sql_error) { @@ -97,10 +95,12 @@ if ($_SESSION['userlevel'] >= '10') { if (is_admin() === TRUE || is_read() === TRUE) { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; -} else { +} +else { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`"; $param[] = $_SESSION['user_id']; } + foreach (dbFetchRows($sql,$param) as $devtype) { if (empty($devtype['type'])) { $devtype['type'] = 'generic'; @@ -108,9 +108,10 @@ foreach (dbFetchRows($sql,$param) as $devtype) { echo('
  • ' . ucfirst($devtype['type']) . '
  • '); } -require_once('../includes/device-groups.inc.php'); +require_once '../includes/device-groups.inc.php'; + foreach( GetDeviceGroups() as $group ) { - echo '
  • '.ucfirst($group['name']).'
  • '; + echo '
  • '.ucfirst($group['name']).'
  • '; } unset($group); @@ -118,29 +119,24 @@ unset($group); '); if ($_SESSION['userlevel'] >= '10') { -if ($config['show_locations']) -{ - - echo(' + if ($config['show_locations']) { + echo(' - '); -} - echo(' + '); + } + echo('
  • Manage Groups
  • Add Device
  • @@ -155,8 +151,7 @@ if ($config['show_locations'])
  • Alerts ('.$service_alerts.')
  • '); } -if ($_SESSION['userlevel'] >= '10') -{ - echo(' +if ($_SESSION['userlevel'] >= '10') { + echo('
  • Add Service
  • Edit Service
  • @@ -197,36 +190,53 @@ if ($_SESSION['userlevel'] >= '10') 0) -{ - echo('
  • Errored ('.$ports['errored'].')
  • '); +if ($ports['errored'] > 0) { + echo('
  • Errored ('.$ports['errored'].')
  • '); } -if ($ports['ignored'] > 0) -{ - echo('
  • Ignored ('.$ports['ignored'].')
  • '); +if ($ports['ignored'] > 0) { + echo('
  • Ignored ('.$ports['ignored'].')
  • '); } if ($config['enable_billing']) { - echo('
  • Traffic Bills
  • '); $ifbreak = 1; + echo('
  • Traffic Bills
  • '); + $ifbreak = 1; } if ($config['enable_pseudowires']) { - echo('
  • Pseudowires
  • '); $ifbreak = 1; + echo('
  • Pseudowires
  • '); + $ifbreak = 1; } ?> = '5') -{ - echo(' '); - if ($config['int_customers']) { echo('
  • Customers
  • '); $ifbreak = 1; } - if ($config['int_l2tp']) { echo('
  • L2TP
  • '); $ifbreak = 1; } - if ($config['int_transit']) { echo('
  • Transit
  • '); $ifbreak = 1; } - if ($config['int_peering']) { echo('
  • Peering
  • '); $ifbreak = 1; } - if ($config['int_peering'] && $config['int_transit']) { echo('
  • Peering + Transit
  • '); $ifbreak = 1; } - if ($config['int_core']) { echo('
  • Core
  • '); $ifbreak = 1; } +if ($_SESSION['userlevel'] >= '5') { + echo(' '); + if ($config['int_customers']) { + echo('
  • Customers
  • '); + $ifbreak = 1; + } + if ($config['int_l2tp']) { + echo('
  • L2TP
  • '); + $ifbreak = 1; + } + if ($config['int_transit']) { + echo('
  • Transit
  • '); + $ifbreak = 1; + } + if ($config['int_peering']) { + echo('
  • Peering
  • '); + $ifbreak = 1; + } + if ($config['int_peering'] && $config['int_transit']) { + echo('
  • Peering + Transit
  • '); + $ifbreak = 1; + } + if ($config['int_core']) { + echo('
  • Core
  • '); + $ifbreak = 1; + } if (is_array($config['custom_descr']) === FALSE) { $config['custom_descr'] = array($config['custom_descr']); } @@ -239,21 +249,18 @@ if ($_SESSION['userlevel'] >= '5') } if ($ifbreak) { - echo(' '); + echo(' '); } -if (isset($interface_alerts)) -{ - echo('
  • Alerts ('.$interface_alerts.')
  • '); +if (isset($interface_alerts)) { + echo('
  • Alerts ('.$interface_alerts.')
  • '); } $deleted_ports = 0; -foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) -{ - if (port_permitted($interface['port_id'], $interface['device_id'])) - { - $deleted_ports++; - } +foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { + if (port_permitted($interface['port_id'], $interface['device_id'])) { + $deleted_ports++; + } } ?> @@ -261,7 +268,9 @@ foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`delete
  • Disabled
  • Deleted ('.$deleted_ports.')'); } +if ($deleted_ports) { + echo('
  • Deleted ('.$deleted_ports.')
  • '); +} ?> @@ -270,9 +279,8 @@ if ($deleted_ports) { echo('
  • Processor
  • Storage
  • '); +if ($menu_sensors) { + $sep = 0; + echo(' '); } $icons = array('fanspeed'=>'tachometer','humidity'=>'tint','temperature'=>'fire','current'=>'bolt','frequency'=>'line-chart','power'=>'power-off','voltage'=>'bolt','charge'=>'plus-square','dbm'=>'sun-o', 'load'=>'spinner','state'=>'bullseye'); -foreach (array('fanspeed','humidity','temperature') as $item) -{ - if (isset($menu_sensors[$item])) - { +foreach (array('fanspeed','humidity','temperature') as $item) { + if (isset($menu_sensors[$item])) { + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) { + echo(' '); + $sep = 0; +} + +foreach (array('current','frequency','power','voltage') as $item) { + if (isset($menu_sensors[$item])) { + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) { + echo(' '); + $sep = 0; +} + +foreach (array_keys($menu_sensors) as $item) { echo('
  • '.nicecase($item).'
  • '); unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) -{ - echo(' '); - $sep = 0; -} - -foreach (array('current','frequency','power','voltage') as $item) -{ - if (isset($menu_sensors[$item])) - { - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) -{ - echo(' '); - $sep = 0; -} - -foreach (array_keys($menu_sensors) as $item) -{ - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; } ?> @@ -337,27 +337,24 @@ foreach (array_keys($menu_sensors) as $item) $app_count = dbFetchCell("SELECT COUNT(`app_id`) FROM `applications`"); -if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") -{ +if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") { ?> + = '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") -{ +if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") { ?> @@ -440,16 +427,11 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { = '10') -{ - if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { - echo(' - - '); - } - echo(' -
  • Plugin Admin
  • - '); +if ($_SESSION['userlevel'] >= '10') { + if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { + echo(''); + } + echo('
  • Plugin Admin
  • '); } ?> @@ -457,9 +439,8 @@ if ($_SESSION['userlevel'] >= '10') @@ -476,50 +457,42 @@ if(is_file("includes/print-menubar-custom.inc.php"))
    -"); \ No newline at end of file +"; diff --git a/html/includes/print-service-edit.inc.php b/html/includes/print-service-edit.inc.php index 0954649d6..d0ad23a56 100644 --- a/html/includes/print-service-edit.inc.php +++ b/html/includes/print-service-edit.inc.php @@ -1,35 +1,33 @@ Edit Service
    - - + +
    - +
    - +
    - +
    -
    "); - -} \ No newline at end of file +"; +}//end if diff --git a/html/includes/print-syslog.inc.php b/html/includes/print-syslog.inc.php index 09467dd7c..1a7564920 100644 --- a/html/includes/print-syslog.inc.php +++ b/html/includes/print-syslog.inc.php @@ -1,23 +1,18 @@ "); +if (device_permitted($entry['device_id'])) { + echo ''; - // Stop shortening hostname. Issue #61 - //$entry['hostname'] = shorthost($entry['hostname'], 20); - - if ($vars['page'] != "device") - { - echo("" . $entry['date'] . ""); - echo("".generate_device_link($entry).""); - echo("" . $entry['program'] . " : " . htmlspecialchars($entry['msg']) . ""); - } else { - echo("" . $entry['date'] . "   " . $entry['program'] . "   " . htmlspecialchars($entry['msg']) . ""); - } - - echo(""); + // Stop shortening hostname. Issue #61 + // $entry['hostname'] = shorthost($entry['hostname'], 20); + if ($vars['page'] != 'device') { + echo ''.$entry['date'].''; + echo ''.generate_device_link($entry).''; + echo ''.$entry['program'].' : '.htmlspecialchars($entry['msg']).''; + } + else { + echo ''.$entry['date'].'   '.$entry['program'].'   '.htmlspecialchars($entry['msg']).''; + } + echo ''; } - -?> diff --git a/html/includes/reports/alert-log.pdf.inc.php b/html/includes/reports/alert-log.pdf.inc.php index 5ee0e91ea..d293b474b 100644 --- a/html/includes/reports/alert-log.pdf.inc.php +++ b/html/includes/reports/alert-log.pdf.inc.php @@ -1,65 +1,83 @@ AddPage('L'); +$where = '1'; +if (is_numeric($_GET['device_id'])) { + $where .= ' AND E.device_id = ?'; + $param[] = $_GET['device_id']; +} - $where = "1"; - if (is_numeric($_GET['device_id'])) { - $where .= ' AND E.device_id = ?'; - $param[] = $_GET['device_id']; - } - if ($_GET['string']) { - $where .= " AND R.rule LIKE ?"; - $param[] = "%".$_GET['string']."%"; - } +if ($_GET['string']) { + $where .= ' AND R.rule LIKE ?'; + $param[] = '%'.$_GET['string'].'%'; +} - if ($_SESSION['userlevel'] >= '5') { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; - } else { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; - $param[] = $_SESSION['user_id']; - } +if ($_SESSION['userlevel'] >= '5') { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; +} +else { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; + $param[] = $_SESSION['user_id']; +} - if (isset($_GET['start']) && is_numeric($_GET['start'])) { - $start = mres($_GET['start']); - } else { - $start = 0; - } +if (isset($_GET['start']) && is_numeric($_GET['start'])) { + $start = mres($_GET['start']); +} +else { + $start = 0; +} - if (isset($_GET['results']) && is_numeric($_GET['results'])) { - $numresults = mres($_GET['results']); - } else { - $numresults = 250; - } +if (isset($_GET['results']) && is_numeric($_GET['results'])) { + $numresults = mres($_GET['results']); +} +else { + $numresults = 250; +} - $full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; +$full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; - foreach (dbFetchRows($full_query, $param) as $alert_entry) { - $hostname = gethostbyid(mres($alert_entry['device_id'])); - $alert_state = $alert_entry['state']; +foreach (dbFetchRows($full_query, $param) as $alert_entry) { + $hostname = gethostbyid(mres($alert_entry['device_id'])); + $alert_state = $alert_entry['state']; - if ($alert_state!='') { - if ($alert_state=='0') { - $glyph_color = 'green'; - $text = 'Ok'; - } elseif ($alert_state=='1') { - $glyph_color = 'red'; - $text = 'Alert'; - } elseif ($alert_state=='2') { - $glyph_color = 'lightgrey'; - $text = 'Ack'; - } elseif ($alert_state=='3') { - $glyph_color = 'orange'; - $text = 'Worse'; - } elseif ($alert_state=='4') { - $glyph_color = 'khaki'; - $text = 'Better'; - } - $data[] = array($alert_entry['time_logged'],$hostname,htmlspecialchars($alert_entry['name']),$text); + if ($alert_state != '') { + if ($alert_state == '0') { + $glyph_color = 'green'; + $text = 'Ok'; + } + else if ($alert_state == '1') { + $glyph_color = 'red'; + $text = 'Alert'; + } + else if ($alert_state == '2') { + $glyph_color = 'lightgrey'; + $text = 'Ack'; + } + else if ($alert_state == '3') { + $glyph_color = 'orange'; + $text = 'Worse'; + } + else if ($alert_state == '4') { + $glyph_color = 'khaki'; + $text = 'Better'; } - } -$header = array('Datetime', 'Device', 'Log', 'Status'); + $data[] = array( + $alert_entry['time_logged'], + $hostname, + htmlspecialchars($alert_entry['name']), + $text, + ); + }//end if +}//end foreach + +$header = array( + 'Datetime', + 'Device', + 'Log', + 'Status', +); $table = << @@ -74,17 +92,19 @@ EOD; foreach ($data as $log) { if ($log[3] == 'Alert') { $tr_col = '#d39392'; - } else { + } + else { $tr_col = '#bbd392'; } + $table .= ' - + '.$log[0].' '.$log[1].' '.$log[2].' '.$log[3].' - - '; + + '; } $table .= << $value) -{ - if ($value != "") - { - switch ($var) - { - case 'hostname': - $where .= " AND D.hostname LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'location': - $where .= " AND D.location LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'device_id': - $where .= " AND D.device_id = ?"; - $param[] = $value; - break; - case 'deleted': - case 'ignore': - if ($value == 1) - { - $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; - } - break; - case 'disable': - case 'ifSpeed': - if (is_numeric($value)) - { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'errors': - if ($value == 1) - { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - case 'state': - if ($value == "down") - { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; - $param[] = "up"; - $param[] = "down"; - } elseif($value == "up") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = "up"; - $param[] = "up"; - } elseif($value == "admindown") { - $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; - $param[] = "down"; - } - break; - } - } -} +foreach ($vars as $var => $value) { + if ($value != '') { + switch ($var) { + case 'hostname': + $where .= ' AND D.hostname LIKE ?'; + $param[] = '%'.$value.'%'; + break; -$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ".$query_sort; + case 'location': + $where .= ' AND D.location LIKE ?'; + $param[] = '%'.$value.'%'; + break; + + case 'device_id': + $where .= ' AND D.device_id = ?'; + $param[] = $value; + break; + + case 'deleted': + case 'ignore': + if ($value == 1) { + $where .= ' AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0'; + } + break; + + case 'disable': + case 'ifSpeed': + if (is_numeric($value)) { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = '%'.$value.'%'; + break; + + case 'errors': + if ($value == 1) { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + + case 'state': + if ($value == 'down') { + $where .= 'AND I.ifAdminStatus = ? AND I.ifOperStatus = ?'; + $param[] = 'up'; + $param[] = 'down'; + } + else if ($value == 'up') { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = 'up'; + $param[] = 'up'; + } + else if ($value == 'admindown') { + $where .= 'AND I.ifAdminStatus = ? AND D.ignore = 0'; + $param[] = 'down'; + } + break; + }//end switch + }//end if +}//end foreach + +$query = 'SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id '.$where.' '.$query_sort; $row = 1; -list($format, $subformat) = explode("_", $vars['format']); +list($format, $subformat) = explode('_', $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) -{ - case 'traffic': +switch ($vars['sort']) { +case 'traffic': $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); break; - case 'traffic_in': + +case 'traffic_in': $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); break; - case 'traffic_out': + +case 'traffic_out': $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); break; - case 'packets': + +case 'packets': $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); break; - case 'packets_in': + +case 'packets_in': $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); break; - case 'packets_out': + +case 'packets_out': $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); break; - case 'errors': + +case 'errors': $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); break; - case 'speed': + +case 'speed': $ports = array_sort($ports, 'ifSpeed', SORT_DESC); break; - case 'port': + +case 'port': $ports = array_sort($ports, 'ifDescr', SORT_ASC); break; - case 'media': + +case 'media': $ports = array_sort($ports, 'ifType', SORT_ASC); break; - case 'descr': + +case 'descr': $ports = array_sort($ports, 'ifAlias', SORT_ASC); break; - case 'device': - default: - $ports = array_sort($ports, 'hostname', SORT_ASC); -} -$csv[] = array('Device','Port','Speed','Down','Up','Media','Description'); -foreach( $ports as $port ) { - if( port_permitted($port['port_id'], $port['device_id']) ) { - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); - $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); - $port = ifLabel($port, $device); - $csv[] = array($port['hostname'],fixIfName($port['label']),$speed,$port['in_rate'],$port['out_rate'],$type,$port['ifAlias']); - } +case 'device': +default: + $ports = array_sort($ports, 'hostname', SORT_ASC); +}//end switch + +$csv[] = array( + 'Device', + 'Port', + 'Speed', + 'Down', + 'Up', + 'Media', + 'Description', +); +foreach ($ports as $port) { + if (port_permitted($port['port_id'], $port['device_id'])) { + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); + $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); + $port = ifLabel($port, $device); + $csv[] = array( + $port['hostname'], + fixIfName($port['label']), + $speed, + $port['in_rate'], + $port['out_rate'], + $type, + $port['ifAlias'], + ); + } } -?> diff --git a/html/includes/service-add.inc.php b/html/includes/service-add.inc.php index 3bc9eca63..cf1433b27 100644 --- a/html/includes/service-add.inc.php +++ b/html/includes/service-add.inc.php @@ -5,6 +5,6 @@ $updated = '1'; $service_id = add_service(mres($_POST['device']), mres($_POST['type']), mres($_POST['descr']), mres($_POST['ip']), mres($_POST['params'])); if ($service_id) { - $message .= $message_break . "Service added (".$service_id.")!"; - $message_break .= "
    "; -} \ No newline at end of file + $message .= $message_break.'Service added ('.$service_id.')!'; + $message_break .= '
    '; +} diff --git a/html/includes/table/address-search.inc.php b/html/includes/table/address-search.inc.php index a50d06afc..25eb75360 100644 --- a/html/includes/table/address-search.inc.php +++ b/html/includes/table/address-search.inc.php @@ -2,56 +2,64 @@ $param = array(); -if (is_admin() === FALSE && is_read() === FALSE) { - $perms_sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; - $param[] = array($_SESSION['user_id']); +if (is_admin() === false && is_read() === false) { + $perms_sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; + $param[] = array($_SESSION['user_id']); } -list($address,$prefix) = explode("/", $_POST['address']); +list($address,$prefix) = explode('/', $_POST['address']); if ($_POST['search_type'] == 'ipv4') { - $sql = " FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D"; + $sql = ' FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D'; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id $where "; if (!empty($address)) { $sql .= " AND ipv4_address LIKE '%".$address."%'"; } + if (!empty($prefix)) { - $sql .= " AND ipv4_prefixlen='?'"; + $sql .= " AND ipv4_prefixlen='?'"; $param[] = array($prefix); } -} elseif ($_POST['search_type'] == 'ipv6') { - $sql = " FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D"; +} +else if ($_POST['search_type'] == 'ipv6') { + $sql = ' FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D'; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id $where "; if (!empty($address)) { $sql .= " AND (ipv6_address LIKE '%".$address."%' OR ipv6_compressed LIKE '%".$address."%')"; } + if (!empty($prefix)) { $sql .= " AND ipv6_prefixlen = '$prefix'"; } -} elseif ($_POST['search_type'] == 'mac') { - $sql = " FROM `ports` AS I, `devices` AS D"; - $sql .= $perms_sql; - $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%' $where "; } +else if ($_POST['search_type'] == 'mac') { + $sql = ' FROM `ports` AS I, `devices` AS D'; + $sql .= $perms_sql; + $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address']))."%' $where "; +}//end if if (is_numeric($_POST['device_id'])) { - $sql .= " AND I.device_id = ?"; + $sql .= ' AND I.device_id = ?'; $param[] = array($_POST['device_id']); } + if ($_POST['interface']) { - $sql .= " AND I.ifDescr LIKE '?'"; + $sql .= " AND I.ifDescr LIKE '?'"; $param[] = array($_POST['interface']); } if ($_POST['search_type'] == 'ipv4') { $count_sql = "SELECT COUNT(`ipv4_address_id`) $sql"; -} elseif ($_POST['search_type'] == 'ipv6') { - $count_sql = "SELECT COUNT(`ipv6_address_id`) $sql"; -} elseif ($_POST['search_type'] == 'mac') { - $count_sql = "SELECT COUNT(`port_id`) $sql"; } -$total = dbFetchCell($count_sql,$param); +else if ($_POST['search_type'] == 'ipv6') { + $count_sql = "SELECT COUNT(`ipv6_address_id`) $sql"; +} +else if ($_POST['search_type'] == 'mac') { + $count_sql = "SELECT COUNT(`port_id`) $sql"; +} + +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -63,7 +71,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -75,31 +83,42 @@ $sql = "SELECT *,`I`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $interface) { $speed = humanspeed($interface['ifSpeed']); - $type = humanmedia($interface['ifType']); + $type = humanmedia($interface['ifType']); if ($_POST['search_type'] == 'ipv6') { - list($prefix, $length) = explode("/", $interface['ipv6_network']); - $address = Net_IPv6::compress($interface['ipv6_address']) . '/'.$length; - } elseif ($_POST['search_type'] == 'mac') { + list($prefix, $length) = explode('/', $interface['ipv6_network']); + $address = Net_IPv6::compress($interface['ipv6_address']).'/'.$length; + } + else if ($_POST['search_type'] == 'mac') { $address = formatMac($interface['ifPhysAddress']); - } else { - list($prefix, $length) = explode("/", $interface['ipv4_network']); - $address = $interface['ipv4_address'] . '/' .$length; + } + else { + list($prefix, $length) = explode('/', $interface['ipv4_network']); + $address = $interface['ipv4_address'].'/'.$length; } if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) { - $error_img = generate_port_link($interface,"Interface Errors",errors); - } else { - $error_img = ""; + $error_img = generate_port_link($interface, "Interface Errors", errors); } - if (port_permitted($interface['port_id'])) { - $interface = ifLabel ($interface, $interface); - $response[] = array('hostname'=>generate_device_link($interface), - 'interface'=>generate_port_link($interface) . ' ' . $error_img, - 'address'=>$address, - 'description'=>$interface['ifAlias']); + else { + $error_img = ''; } -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + if (port_permitted($interface['port_id'])) { + $interface = ifLabel($interface, $interface); + $response[] = array( + 'hostname' => generate_device_link($interface), + 'interface' => generate_port_link($interface).' '.$error_img, + 'address' => $address, + 'description' => $interface['ifAlias'], + ); + } +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/alert-schedule.inc.php b/html/includes/table/alert-schedule.inc.php index 635e67be9..5d2bfa9b8 100644 --- a/html/includes/table/alert-schedule.inc.php +++ b/html/includes/table/alert-schedule.inc.php @@ -16,8 +16,9 @@ $where = 1; if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_schedule` AS S WHERE $where"; -} else { - $sql = " FROM `alert_schedule` AS S WHERE $where"; +} +else { + $sql = " FROM `alert_schedule` AS S WHERE $where"; $param[] = $_SESSION['user_id']; } @@ -26,7 +27,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -38,7 +39,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -48,20 +49,29 @@ if ($rowCount != -1) { $sql = "SELECT `S`.`schedule_id`, DATE_FORMAT(`S`.`start`, '".$config['dateformat']['mysql']['compact']."') AS `start`, DATE_FORMAT(`S`.`end`, '".$config['dateformat']['mysql']['compact']."') AS `end`, `S`.`title` $sql"; -foreach (dbFetchRows($sql,$param) as $schedule) { +foreach (dbFetchRows($sql, $param) as $schedule) { $status = 0; if ($schedule['end'] < date('dS M Y H:i::s')) { $status = 1; } + if (date('dS M Y H:i::s') >= $schedule['start'] && date('dS M Y H:i::s') < $schedule['end']) { $status = 2; } - $response[] = array('title'=>$schedule['title'], - 'start'=>$schedule['start'], - 'end'=>$schedule['end'], - 'id'=>$schedule['schedule_id'], - 'status'=>$status); + + $response[] = array( + 'title' => $schedule['title'], + 'start' => $schedule['start'], + 'end' => $schedule['end'], + 'id' => $schedule['schedule_id'], + 'status' => $status, + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/alertlog.inc.php b/html/includes/table/alertlog.inc.php index 0c8e515e6..8b4d94d3e 100644 --- a/html/includes/table/alertlog.inc.php +++ b/html/includes/table/alertlog.inc.php @@ -3,14 +3,15 @@ $where = 1; if (is_numeric($_POST['device_id'])) { - $where .= ' AND E.device_id = ?'; + $where .= ' AND E.device_id = ?'; $param[] = $_POST['device_id']; } if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where"; -} else { - $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; +} +else { + $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; $param[] = array($_SESSION['user_id']); } @@ -19,7 +20,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`E`.`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -31,7 +32,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -42,42 +43,49 @@ if ($rowCount != -1) { $sql = "SELECT D.device_id,name AS alert,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate,details $sql"; $rulei = 0; -foreach (dbFetchRows($sql,$param) as $alertlog) { - $dev = device_by_id_cache($alertlog['device_id']); +foreach (dbFetchRows($sql, $param) as $alertlog) { + $dev = device_by_id_cache($alertlog['device_id']); $fault_detail = alert_details($alertlog['details']); - $alert_state = $alertlog['state']; - if ($alert_state=='0') { - $glyph_icon = 'ok'; + $alert_state = $alertlog['state']; + if ($alert_state == '0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - elseif ($alert_state=='1') { - $glyph_icon = 'remove'; + else if ($alert_state == '1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - elseif ($alert_state=='2') { - $glyph_icon = 'info-sign'; + else if ($alert_state == '2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - elseif ($alert_state=='3') { - $glyph_icon = 'arrow-down'; + else if ($alert_state == '3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - elseif ($alert_state=='4') { - $glyph_icon = 'arrow-up'; + else if ($alert_state == '4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - } - $response[] = array('id'=>$rulei++, - 'time_logged'=>$alertlog['humandate'], - 'details'=>'', - 'hostname'=>'
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', - 'alert'=>htmlspecialchars($alertlog['alert']), - 'status'=>" $text"); -} + $text = 'Better'; + }//end if + $response[] = array( + 'id' => $rulei++, + 'time_logged' => $alertlog['humandate'], + 'details' => '', + 'hostname' => '
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', + 'alert' => htmlspecialchars($alertlog['alert']), + 'status' => " $text", + ); +}//end foreach -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); -echo _json_encode($output); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); +echo _json_encode($output); diff --git a/html/includes/table/alerts.inc.php b/html/includes/table/alerts.inc.php index 799404b1a..2efab5d1f 100644 --- a/html/includes/table/alerts.inc.php +++ b/html/includes/table/alerts.inc.php @@ -10,18 +10,18 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { $sql_search .= " AND (`timestamp` LIKE '%$searchPhrase%' OR `rule` LIKE '%$searchPhrase%' OR `name` LIKE '%$searchPhrase%' OR `hostname` LIKE '%$searchPhrase%')"; } -$sql = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`"; +$sql = ' FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`'; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } $sql .= " RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE $where AND `state` IN (1,2,3,4) $sql_search"; $count_sql = "SELECT COUNT(`alerts`.`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -33,7 +33,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -43,76 +43,86 @@ if ($rowCount != -1) { $sql = "SELECT `alerts`.*, `devices`.`hostname` AS `hostname`,`alert_rules`.`rule` AS `rule`, `alert_rules`.`name` AS `name`, `alert_rules`.`severity` AS `severity` $sql"; -$rulei = 0; +$rulei = 0; $format = $_POST['format']; -foreach (dbFetchRows($sql,$param) as $alert) { - $log = dbFetchCell("SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1", array($alert['rule_id'],$alert['device_id'])); +foreach (dbFetchRows($sql, $param) as $alert) { + $log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', array($alert['rule_id'], $alert['device_id'])); $fault_detail = alert_details($log); - $ico = "ok"; - $col = "green"; - $extra = ""; - $msg = ""; - if ( (int) $alert['state'] === 0 ) { - $ico = "ok"; - $col = "green"; - $extra = "success"; - $msg = "ok"; - } elseif ( (int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { - $ico = "volume-up"; - $col = "red"; - $extra = "danger"; - $msg = "alert"; - if ( (int) $alert['state'] === 3) { - $msg = "worse"; - } elseif ( (int) $alert['state'] === 4) { - $msg = "better"; - } - } elseif ( (int) $alert['state'] === 2) { - $ico = "volume-off"; - $col = "#800080"; - $extra = "warning"; - $msg = "muted"; + $ico = 'ok'; + $col = 'green'; + $extra = ''; + $msg = ''; + if ((int) $alert['state'] === 0) { + $ico = 'ok'; + $col = 'green'; + $extra = 'success'; + $msg = 'ok'; } + else if ((int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { + $ico = 'volume-up'; + $col = 'red'; + $extra = 'danger'; + $msg = 'alert'; + if ((int) $alert['state'] === 3) { + $msg = 'worse'; + } + else if ((int) $alert['state'] === 4) { + $msg = 'better'; + } + } + else if ((int) $alert['state'] === 2) { + $ico = 'volume-off'; + $col = '#800080'; + $extra = 'warning'; + $msg = 'muted'; + }//end if $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; $severity = $alert['severity']; if ($alert['state'] == 3) { - $severity .= " +"; - } elseif ($alert['state'] == 4) { - $severity .= " -"; + $severity .= ' +'; + } + else if ($alert['state'] == 4) { + $severity .= ' -'; } $ack_ico = 'volume-up'; $ack_col = 'success'; - if($alert['state'] == 2) { + if ($alert['state'] == 2) { $ack_ico = 'volume-off'; $ack_col = 'danger'; - } + } $hostname = ' -
    - '.generate_device_link($alert).' -
    '.$fault_detail.'
    -
    '; +
    + '.generate_device_link($alert).' +
    '.$fault_detail.'
    +
    '; - $response[] = array('id'=>$rulei++, - 'rule'=>"".htmlentities($alert['name'])."", - 'details'=>'', - 'hostname'=>$hostname, - 'timestamp'=>($alert['timestamp'] ? $alert['timestamp'] : "N/A"), - 'severity'=>$severity, - 'ack_col'=>$ack_col, - 'state'=>$alert['state'], - 'alert_id'=>$alert['id'], - 'ack_ico'=>$ack_ico, - 'extra'=>$extra, - 'msg'=>$msg); + $response[] = array( + 'id' => $rulei++, + 'rule' => ''.htmlentities($alert['name']).'', + 'details' => '', + 'hostname' => $hostname, + 'timestamp' => ($alert['timestamp'] ? $alert['timestamp'] : 'N/A'), + 'severity' => $severity, + 'ack_col' => $ack_col, + 'state' => $alert['state'], + 'alert_id' => $alert['id'], + 'ack_ico' => $ack_ico, + 'extra' => $extra, + 'msg' => $msg, + ); +}//end foreach -} - -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index dd5c6225e..090476048 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -2,32 +2,33 @@ $param = array(); -$sql .= " FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D "; +$sql .= ' FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D '; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } $sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where "; -if (isset($_POST['searchby']) && $_POST['searchby'] == "ip") { - $sql .= " AND `ipv4_address` LIKE ?"; - $param[] = "%".trim($_POST['address'])."%"; -} elseif (isset($_POST['searchby']) && $_POST['searchby'] == "mac") { - $sql .= " AND `mac_address` LIKE ?"; - $param[] = "%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"; +if (isset($_POST['searchby']) && $_POST['searchby'] == 'ip') { + $sql .= ' AND `ipv4_address` LIKE ?'; + $param[] = '%'.trim($_POST['address']).'%'; +} +else if (isset($_POST['searchby']) && $_POST['searchby'] == 'mac') { + $sql .= ' AND `mac_address` LIKE ?'; + $param[] = '%'.str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address'])).'%'; } if (is_numeric($_POST['device_id'])) { - $sql .= " AND P.device_id = ?"; + $sql .= ' AND P.device_id = ?'; $param[] = $_POST['device_id']; } $count_sql = "SELECT COUNT(`M`.`port_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -39,7 +40,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -51,39 +52,53 @@ $sql = "SELECT *,`P`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $entry) { if (!$ignore) { - if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) { - $error_img = generate_port_link($entry,"Interface Errors",port_errors); - } else { - $error_img = ""; + $error_img = generate_port_link($entry, "Interface Errors", port_errors); + } + else { + $error_img = ''; } - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($entry['ipv4_address'])); - if ($arp_host) { - $arp_name = generate_device_link($arp_host); - } else { - unset($arp_name); - } - if ($arp_host) { - $arp_if = generate_port_link($arp_host); - } else { - unset($arp_if); - } - if ($arp_host['device_id'] == $entry['device_id']) { - $arp_name = "Localhost"; - } - if ($arp_host['port_id'] == $entry['port_id']) { - $arp_if = "Local port"; - } - $response[] = array('mac_address'=>formatMac($entry['mac_address']), - 'ipv4_address'=>$entry['ipv4_address'], - 'hostname'=>generate_device_link($entry), - 'interface'=>generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, - 'remote_device'=>$arp_name, - 'remote_interface'=>$arp_if); - } - unset($ignore); -} + $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($entry['ipv4_address'])); + if ($arp_host) { + $arp_name = generate_device_link($arp_host); + } + else { + unset($arp_name); + } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + if ($arp_host) { + $arp_if = generate_port_link($arp_host); + } + else { + unset($arp_if); + } + + if ($arp_host['device_id'] == $entry['device_id']) { + $arp_name = 'Localhost'; + } + + if ($arp_host['port_id'] == $entry['port_id']) { + $arp_if = 'Local port'; + } + + $response[] = array( + 'mac_address' => formatMac($entry['mac_address']), + 'ipv4_address' => $entry['ipv4_address'], + 'hostname' => generate_device_link($entry), + 'interface' => generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))).' '.$error_img, + 'remote_device' => $arp_name, + 'remote_interface' => $arp_if, + ); + }//end if + + unset($ignore); +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/devices.inc.php b/html/includes/table/devices.inc.php index 25cf21bd5..129e198f2 100644 --- a/html/includes/table/devices.inc.php +++ b/html/includes/table/devices.inc.php @@ -3,11 +3,11 @@ $where = 1; $param = array(); -$sql = " FROM `devices`"; +$sql = ' FROM `devices`'; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } @@ -17,48 +17,87 @@ if (!empty($_POST['location'])) { $sql .= " WHERE $where "; -if (!empty($_POST['hostname'])) { $sql .= " AND hostname LIKE ?"; $param[] = "%".$_POST['hostname']."%"; } -if (!empty($_POST['os'])) { $sql .= " AND os = ?"; $param[] = $_POST['os']; } -if (!empty($_POST['version'])) { $sql .= " AND version = ?"; $param[] = $_POST['version']; } -if (!empty($_POST['hardware'])) { $sql .= " AND hardware = ?"; $param[] = $_POST['hardware']; } -if (!empty($_POST['features'])) { $sql .= " AND features = ?"; $param[] = $_POST['features']; } -if (!empty($_POST['type'])) { - if ($_POST['type'] == 'generic') { - $sql .= " AND ( type = ? OR type = '')"; $param[] = $_POST['type']; - } else { - $sql .= " AND type = ?"; $param[] = $_POST['type']; - } +if (!empty($_POST['hostname'])) { + $sql .= ' AND hostname LIKE ?'; + $param[] = '%'.$_POST['hostname'].'%'; } -if (!empty($_POST['state'])) { - $sql .= " AND status= ?"; - if( is_numeric($_POST['state']) ) { - $param[] = $_POST['state']; - } else { - $param[] = str_replace(array('up','down'),array(1,0),$_POST['state']); + +if (!empty($_POST['os'])) { + $sql .= ' AND os = ?'; + $param[] = $_POST['os']; +} + +if (!empty($_POST['version'])) { + $sql .= ' AND version = ?'; + $param[] = $_POST['version']; +} + +if (!empty($_POST['hardware'])) { + $sql .= ' AND hardware = ?'; + $param[] = $_POST['hardware']; +} + +if (!empty($_POST['features'])) { + $sql .= ' AND features = ?'; + $param[] = $_POST['features']; +} + +if (!empty($_POST['type'])) { + if ($_POST['type'] == 'generic') { + $sql .= " AND ( type = ? OR type = '')"; + $param[] = $_POST['type']; + } + else { + $sql .= ' AND type = ?'; + $param[] = $_POST['type']; } } -if (!empty($_POST['disabled'])) { $sql .= " AND disabled= ?"; $param[] = $_POST['disabled']; } -if (!empty($_POST['ignore'])) { $sql .= " AND `ignore`= ?"; $param[] = $_POST['ignore']; } -if (!empty($_POST['location']) && $_POST['location'] == "Unset") { $location_filter = ''; } + +if (!empty($_POST['state'])) { + $sql .= ' AND status= ?'; + if (is_numeric($_POST['state'])) { + $param[] = $_POST['state']; + } + else { + $param[] = str_replace(array('up', 'down'), array(1, 0), $_POST['state']); + } +} + +if (!empty($_POST['disabled'])) { + $sql .= ' AND disabled= ?'; + $param[] = $_POST['disabled']; +} + +if (!empty($_POST['ignore'])) { + $sql .= ' AND `ignore`= ?'; + $param[] = $_POST['ignore']; +} + +if (!empty($_POST['location']) && $_POST['location'] == 'Unset') { + $location_filter = ''; +} + if (!empty($_POST['location'])) { - $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; + $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; $param[] = mres($_POST['location']); $param[] = mres($_POST['location']); } -if( !empty($_POST['group']) ) { - require_once('../includes/device-groups.inc.php'); - $sql .= " AND ( "; - foreach( GetDevicesFromGroup($_POST['group']) as $dev ) { - $sql .= "`devices`.`device_id` = ? OR "; + +if (!empty($_POST['group'])) { + include_once '../includes/device-groups.inc.php'; + $sql .= ' AND ( '; + foreach (GetDevicesFromGroup($_POST['group']) as $dev) { + $sql .= '`devices`.`device_id` = ? OR '; $param[] = $dev['device_id']; } - $sql = substr($sql, 0, strlen($sql)-3); - $sql .= " )"; + + $sql = substr($sql, 0, (strlen($sql) - 3)); + $sql .= ' )'; } $count_sql = "SELECT COUNT(`devices`.`device_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -70,7 +109,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -81,99 +120,124 @@ if ($rowCount != -1) { $sql = "SELECT DISTINCT(`devices`.`device_id`),`devices`.* $sql"; if (!isset($_POST['format'])) { - $_POST['format'] = "list_detail"; + $_POST['format'] = 'list_detail'; } -list($format, $subformat) = explode("_", $_POST['format']); + +list($format, $subformat) = explode('_', $_POST['format']); foreach (dbFetchRows($sql, $param) as $device) { - if (isset($bg) && $bg == $list_colour_b) { - $bg = $list_colour_a; - } else { - $bg = $list_colour_b; - } + if (isset($bg) && $bg == $list_colour_b) { + $bg = $list_colour_a; + } + else { + $bg = $list_colour_b; + } - if ($device['status'] == '0') { - $extra = "danger"; - $msg = $device['status_reason']; - } else { - $extra = "success"; - $msg = "up"; - } - if ($device['ignore'] == '1') { - $extra = "default"; - $msg = "ignored"; - if ($device['status'] == '1') { - $extra = "warning"; - $msg = "ignored"; - } - } - if ($device['disabled'] == '1') { - $extra = "default"; - $msg = "disabled"; - } + if ($device['status'] == '0') { + $extra = 'danger'; + $msg = $device['status_reason']; + } + else { + $extra = 'success'; + $msg = 'up'; + } - $type = strtolower($device['os']); - $image = getImage($device); - - if ($device['os'] == "ios") { - formatCiscoHardware($device, true); - } + if ($device['ignore'] == '1') { + $extra = 'default'; + $msg = 'ignored'; + if ($device['status'] == '1') { + $extra = 'warning'; + $msg = 'ignored'; + } + } - $device['os_text'] = $config['os'][$device['os']]['text']; - $port_count = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?", array($device['device_id'])); - $sensor_count = dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?", array($device['device_id'])); + if ($device['disabled'] == '1') { + $extra = 'default'; + $msg = 'disabled'; + } - if (get_dev_attrib($device,'override_sysLocation_bool')) { - $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); - } + $type = strtolower($device['os']); + $image = getImage($device); - $actions = ('
    -
    '); - $actions .= ' View device '; - $actions .= ('
    -
    '); - $actions .= ' View alerts '; - $actions .= '
    '; - if ($_SESSION['userlevel'] >= "7") { - $actions .= ('
    - Edit device -
    '); - } - $actions .= ('
    -
    -
    - telnet -
    -
    - ssh -
    -
    - https -
    -
    '); + if ($device['os'] == 'ios') { + formatCiscoHardware($device, true); + } - $hostname = generate_device_link($device); - $platform = $device['hardware'] . '
    ' . $device['features']; - $os = $device['os_text'] . '
    ' . $device['version']; - if (extension_loaded('mbstring')) { - $location = mb_substr($device['location'], 0, 32, 'utf8'); - } else { - $location = truncate($device['location'], 32, ''); - } - $uptime = formatUptime($device['uptime'], 'short') . '
    ' . $location; - if ($subformat == "detail") { - $hostname .= '
    ' . $device['sysName']; - if ($port_count) { - $col_port = ' '.$port_count . '
    '; - } - if ($sensor_count) { - $col_port .= ' '.$sensor_count; - } - } else { + $device['os_text'] = $config['os'][$device['os']]['text']; + $port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id'])); + $sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id'])); - } - $response[] = array('extra'=>$extra,'msg'=>$msg,'icon'=>$image,'hostname'=>$hostname,'ports'=>$col_port,'hardware'=>$platform,'os'=>$os,'uptime'=>$uptime,'actions'=>$actions); -} + if (get_dev_attrib($device, 'override_sysLocation_bool')) { + $device['location'] = get_dev_attrib($device, 'override_sysLocation_string'); + } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + $actions = ('
    +
    '); + $actions .= ' View device '; + $actions .= ('
    +
    '); + $actions .= ' View alerts '; + $actions .= '
    '; + if ($_SESSION['userlevel'] >= '7') { + $actions .= ('
    + Edit device +
    '); + } + + $actions .= ('
    +
    +
    + telnet +
    +
    + ssh +
    +
    + https +
    +
    '); + + $hostname = generate_device_link($device); + $platform = $device['hardware'].'
    '.$device['features']; + $os = $device['os_text'].'
    '.$device['version']; + if (extension_loaded('mbstring')) { + $location = mb_substr($device['location'], 0, 32, 'utf8'); + } + else { + $location = truncate($device['location'], 32, ''); + } + + $uptime = formatUptime($device['uptime'], 'short').'
    '.$location; + if ($subformat == 'detail') { + $hostname .= '
    '.$device['sysName']; + if ($port_count) { + $col_port = ' '.$port_count.'
    '; + } + + if ($sensor_count) { + $col_port .= ' '.$sensor_count; + } + } + else { + } + + $response[] = array( + 'extra' => $extra, + 'msg' => $msg, + 'icon' => $image, + 'hostname' => $hostname, + 'ports' => $col_port, + 'hardware' => $platform, + 'os' => $os, + 'uptime' => $uptime, + 'actions' => $actions, + ); +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/eventlog.inc.php b/html/includes/table/eventlog.inc.php index d5e5e7d60..9cae42296 100644 --- a/html/includes/table/eventlog.inc.php +++ b/html/includes/table/eventlog.inc.php @@ -1,23 +1,22 @@ = '5') { $sql = " FROM `eventlog` AS E LEFT JOIN `devices` AS `D` ON `E`.`host`=`D`.`device_id` WHERE $where"; -} else { - $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; +} +else { + $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -26,7 +25,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(datetime) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -38,7 +37,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -48,22 +47,28 @@ if ($rowCount != -1) { $sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate $sql"; -foreach (dbFetchRows($sql,$param) as $eventlog) { +foreach (dbFetchRows($sql, $param) as $eventlog) { $dev = device_by_id_cache($eventlog['host']); - if ($eventlog['type'] == "interface") { + if ($eventlog['type'] == 'interface') { $this_if = ifLabel(getifbyid($eventlog['reference'])); - $type = "".generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).""; - } else { - $type = "System"; + $type = ''.generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).''; } - - $response[] = array('datetime'=>$eventlog['humandate'], - 'hostname'=>generate_device_link($dev, shorthost($dev['hostname'])), - 'type'=>$type, - 'message'=>htmlspecialchars($eventlog['message'])); + else { + $type = 'System'; + } + + $response[] = array( + 'datetime' => $eventlog['humandate'], + 'hostname' => generate_device_link($dev, shorthost($dev['hostname'])), + 'type' => $type, + 'message' => htmlspecialchars($eventlog['message']), + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); - -?> diff --git a/html/includes/table/inventory.inc.php b/html/includes/table/inventory.inc.php index 6c5b92823..2e4c0b928 100644 --- a/html/includes/table/inventory.inc.php +++ b/html/includes/table/inventory.inc.php @@ -1,14 +1,15 @@ = '5') { $sql = " FROM entPhysical AS E, devices AS D WHERE $where AND D.device_id = E.device_id"; -} else { - $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; +} +else { + $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -17,32 +18,32 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } if (isset($_POST['string']) && strlen($_POST['string'])) { - $sql .= " AND E.entPhysicalDescr LIKE ?"; - $param[] = "%".$_POST['string']."%"; + $sql .= ' AND E.entPhysicalDescr LIKE ?'; + $param[] = '%'.$_POST['string'].'%'; } if (isset($_POST['device_string']) && strlen($_POST['device_string'])) { - $sql .= " AND D.hostname LIKE ?"; - $param[] = "%".$_POST['device_string']."%"; + $sql .= ' AND D.hostname LIKE ?'; + $param[] = '%'.$_POST['device_string'].'%'; } if (isset($_POST['part']) && strlen($_POST['part'])) { - $sql .= " AND E.entPhysicalModelName = ?"; - $param[] = $_POST['part']; + $sql .= ' AND E.entPhysicalModelName = ?'; + $param[] = $_POST['part']; } if (isset($_POST['serial']) && strlen($_POST['serial'])) { - $sql .= " AND E.entPhysicalSerialNum LIKE ?"; - $param[] = "%".$_POST['serial']."%"; + $sql .= ' AND E.entPhysicalSerialNum LIKE ?'; + $param[] = '%'.$_POST['serial'].'%'; } if (isset($_POST['device']) && is_numeric($_POST['device'])) { - $sql .= " AND D.device_id = ?"; - $param[] = $_POST['device']; + $sql .= ' AND D.device_id = ?'; + $param[] = $_POST['device']; } $count_sql = "SELECT COUNT(`entPhysical_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -54,7 +55,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -65,12 +66,19 @@ if ($rowCount != -1) { $sql = "SELECT `D`.`device_id` AS `device_id`, `D`.`hostname` AS `hostname`,`entPhysicalDescr` AS `description`, `entPhysicalName` AS `name`, `entPhysicalModelName` AS `model`, `entPhysicalSerialNum` AS `serial` $sql"; foreach (dbFetchRows($sql, $param) as $invent) { - $response[] = array('hostname'=>generate_device_link($invent, shortHost($invent['hostname'])), - 'description'=>$invent['description'], - 'name'=>$invent['name'], - 'model'=>$invent['model'], - 'serial'=>$invent['serial']); + $response[] = array( + 'hostname' => generate_device_link($invent, shortHost($invent['hostname'])), + 'description' => $invent['description'], + 'name' => $invent['name'], + 'model' => $invent['model'], + 'serial' => $invent['serial'], + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, + ); echo _json_encode($output); diff --git a/html/includes/table/mempool.inc.php b/html/includes/table/mempool.inc.php index d3968a531..2afb80edc 100644 --- a/html/includes/table/mempool.inc.php +++ b/html/includes/table/mempool.inc.php @@ -1,72 +1,88 @@ generate_device_link($mempool), - 'mempool_descr' => $mempool['mempool_descr'], - 'graph' => $mini_graph, - 'mempool_used' => $bar_link, - 'mempool_perc' => $perc . "%"); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'mempool_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'mempool_used' => $graph_data[3], - 'mempool_perc' => ''); - } # endif graphs -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); +$sql = "SELECT * $sql"; +foreach (dbFetchRows($sql, $param) as $mempool) { + $perc = round($mempool['mempool_perc'], 0); + $total = formatStorage($mempool['mempool_total']); + $free = formatStorage($mempool['mempool_free']); + $used = formatStorage($mempool['mempool_used']); + $graph_array['type'] = $graph_type; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = '20'; + $graph_array['width'] = '80'; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; + $link = 'graphs/id='.$graph_array['id'].'/type='.$graph_array['type'].'/from='.$graph_array['from'].'/to='.$graph_array['to'].'/'; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + $background = get_percentage_colours($perc); + $bar_link = overlib_link($link, print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $free, 'ffffff', $background['right']), generate_graph_tag($graph_array_zoom), null); + + $response[] = array( + 'hostname' => generate_device_link($mempool), + 'mempool_descr' => $mempool['mempool_descr'], + 'graph' => $mini_graph, + 'mempool_used' => $bar_link, + 'mempool_perc' => $perc.'%', + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'mempool_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'mempool_used' => $graph_data[3], + 'mempool_perc' => '', + ); + } //end if +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $count, +); echo _json_encode($output); diff --git a/html/includes/table/poll-log.inc.php b/html/includes/table/poll-log.inc.php index 3a0ca3213..3579759b6 100644 --- a/html/includes/table/poll-log.inc.php +++ b/html/includes/table/poll-log.inc.php @@ -1,11 +1,12 @@ " 'graphs', 'group' => 'poller')). "'>" .$device['hostname']. "", - 'last_polled' => $device['last_polled'], - 'last_polled_timetaken' => $device['last_polled_timetaken']); + $response[] = array( + 'hostname' => " 'graphs', 'group' => 'poller'))."'>".$device['hostname'].'', + 'last_polled' => $device['last_polled'], + 'last_polled_timetaken' => $device['last_polled_timetaken'], + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); - -?> diff --git a/html/includes/table/processor.inc.php b/html/includes/table/processor.inc.php index a7b3d9745..bcedd6196 100644 --- a/html/includes/table/processor.inc.php +++ b/html/includes/table/processor.inc.php @@ -1,67 +1,83 @@ generate_device_link($processor), - 'processor_descr' => $processor['processor_descr'], - 'graph' => $mini_graph, - 'processor_usage' => $bar_link); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $processor['processor_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'processor_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'processor_usage' => $graph_data[3]); - } # endif graphs -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$sql = "SELECT * $sql"; +foreach (dbFetchRows($sql, $param) as $processor) { + $perc = round($processor['processor_usage'], 0); + $graph_array['type'] = $graph_type; + $graph_array['id'] = $processor['processor_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = '20'; + $graph_array['width'] = '80'; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; + $link = 'graphs/id='.$graph_array['id'].'/type='.$graph_array['type'].'/from='.$graph_array['from'].'/to='.$graph_array['to'].'/'; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + $background = get_percentage_colours($perc); + $bar_link = overlib_link($link, print_percentage_bar(400, 20, $perc, $perc.'%', 'ffffff', $background['left'], (100 - $perc).'%', 'ffffff', $background['right']), generate_graph_tag($graph_array_zoom), null); + + $response[] = array( + 'hostname' => generate_device_link($processor), + 'processor_descr' => $processor['processor_descr'], + 'graph' => $mini_graph, + 'processor_usage' => $bar_link, + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $processor['processor_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'processor_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'processor_usage' => $graph_data[3], + ); + } //end if +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/storage.inc.php b/html/includes/table/storage.inc.php index a912ba1d2..3d301456f 100644 --- a/html/includes/table/storage.inc.php +++ b/html/includes/table/storage.inc.php @@ -1,14 +1,14 @@ generate_device_link($drive), + 'storage_descr' => $drive['storage_descr'], + 'graph' => $mini_graph, + 'storage_used' => $bar_link, + 'storage_perc' => $perc.'%', + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; - $response[] = array('hostname' => generate_device_link($drive), - 'storage_descr' => $drive['storage_descr'], - 'graph' => $mini_graph, - 'storage_used' => $bar_link, - 'storage_perc' => $perc . "%"); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'storage_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'storage_used' => $graph_data[3], + 'storage_perc' => '', + ); + } //end if +}//end foreach - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'storage_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'storage_used' => $graph_data[3], - 'storage_perc' => ''); - - } # endif graphs -} - -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $count, +); echo _json_encode($output); diff --git a/html/includes/table/syslog.inc.php b/html/includes/table/syslog.inc.php index 81df05d28..987aac65a 100644 --- a/html/includes/table/syslog.inc.php +++ b/html/includes/table/syslog.inc.php @@ -1,46 +1,44 @@ = ?"; - $param[] = $_POST['from']; -} -if( !empty($_POST['to']) ) { - $where .= " AND timestamp <= ?"; - $param[] = $_POST['to']; +if (!empty($_POST['from'])) { + $where .= ' AND timestamp >= ?'; + $param[] = $_POST['from']; } -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "FROM syslog AS S"; - $sql .= " WHERE ".$where; -} else { - $sql = "FROM syslog AS S, devices_perms AS P"; - $sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?"; - $sql .= $where; - $param = array_merge(array($_SESSION['user_id']), $param); +if (!empty($_POST['to'])) { + $where .= ' AND timestamp <= ?'; + $param[] = $_POST['to']; +} + +if ($_SESSION['userlevel'] >= '5') { + $sql = 'FROM syslog AS S'; + $sql .= ' WHERE '.$where; +} +else { + $sql = 'FROM syslog AS S, devices_perms AS P'; + $sql .= 'WHERE S.device_id = P.device_id AND P.user_id = ?'; + $sql .= $where; + $param = array_merge(array($_SESSION['user_id']), $param); } $count_sql = "SELECT COUNT(timestamp) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -52,7 +50,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -62,14 +60,20 @@ if ($rowCount != -1) { $sql = "SELECT S.*, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date $sql"; -foreach (dbFetchRows($sql,$param) as $syslog) { - $dev = device_by_id_cache($syslog['device_id']); - $response[] = array('timestamp'=>$syslog['date'], - 'device_id'=>generate_device_link($dev, shorthost($dev['hostname'])), - 'program'=>$syslog['program'], - 'msg'=>htmlspecialchars($syslog['msg'])); +foreach (dbFetchRows($sql, $param) as $syslog) { + $dev = device_by_id_cache($syslog['device_id']); + $response[] = array( + 'timestamp' => $syslog['date'], + 'device_id' => generate_device_link($dev, shorthost($dev['hostname'])), + 'program' => $syslog['program'], + 'msg' => htmlspecialchars($syslog['msg']), + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); -?> diff --git a/html/includes/vars.inc.php b/html/includes/vars.inc.php index 788915f69..477f056b4 100644 --- a/html/includes/vars.inc.php +++ b/html/includes/vars.inc.php @@ -1,40 +1,38 @@ $get_var) -{ - if (strstr($key, "opt")) - { - list($name, $value) = explode("|", $get_var); - if (!isset($value)) { $value = "yes"; } - $vars[$name] = $value; - } +foreach ($_GET as $key => $get_var) { + if (strstr($key, 'opt')) { + list($name, $value) = explode('|', $get_var); + if (!isset($value)) { + $value = 'yes'; + } + + $vars[$name] = $value; + } } $segments = explode('/', trim($_SERVER['REQUEST_URI'], '/')); -foreach ($segments as $pos => $segment) -{ - $segment = urldecode($segment); - if ($pos == "0") - { - $vars['page'] = $segment; - } else { - list($name, $value) = explode("=", $segment); - if ($value == "" || !isset($value)) - { - $vars[$name] = yes; - } else { - $vars[$name] = $value; +foreach ($segments as $pos => $segment) { + $segment = urldecode($segment); + if ($pos == '0') { + $vars['page'] = $segment; + } + else { + list($name, $value) = explode('=', $segment); + if ($value == '' || !isset($value)) { + $vars[$name] = yes; + } + else { + $vars[$name] = $value; + } } - } } -foreach ($_GET as $name => $value) -{ - $vars[$name] = $value; +foreach ($_GET as $name => $value) { + $vars[$name] = $value; } -foreach ($_POST as $name => $value) -{ - $vars[$name] = $value; +foreach ($_POST as $name => $value) { + $vars[$name] = $value; } diff --git a/html/index.php b/html/index.php index 57fff1b57..a3de9ba0c 100644 --- a/html/index.php +++ b/html/index.php @@ -14,7 +14,8 @@ if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) { $_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']); -} else { +} +else { $_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''); } @@ -31,40 +32,40 @@ function catchFatal() { } } -if (strpos($_SERVER['PATH_INFO'], "debug")) -{ - $debug = "1"; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 1); - ini_set('log_errors', 1); - ini_set('error_reporting', E_ALL); - set_error_handler('logErrors'); - register_shutdown_function('catchFatal'); -} else { - $debug = FALSE; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 0); - ini_set('log_errors', 0); - ini_set('error_reporting', 0); +if (strpos($_SERVER['PATH_INFO'], "debug")) { + $debug = "1"; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 1); + ini_set('log_errors', 1); + ini_set('error_reporting', E_ALL); + set_error_handler('logErrors'); + register_shutdown_function('catchFatal'); +} +else { + $debug = FALSE; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 0); + ini_set('log_errors', 0); + ini_set('error_reporting', 0); } // Set variables $msg_box = array(); // Check for install.inc.php -if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') -{ - // no config.php does so let's redirect to the install - header('Location: /install.php'); - exit; +if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') { + // no config.php does so let's redirect to the install + header('Location: /install.php'); + exit; } -include("../includes/defaults.inc.php"); -include("../config.php"); -include_once("../includes/definitions.inc.php"); -include("../includes/functions.php"); -include("includes/functions.inc.php"); -include("includes/vars.inc.php"); -include('includes/plugins.inc.php'); +require '../includes/defaults.inc.php'; +require '../config.php'; +require_once '../includes/definitions.inc.php'; +require '../includes/functions.php'; +require 'includes/functions.inc.php'; +require 'includes/vars.inc.php'; +require 'includes/plugins.inc.php'; + Plugins::start(); $runtime_start = utime(); @@ -74,30 +75,33 @@ ob_start(); ini_set('allow_url_fopen', 0); ini_set('display_errors', 0); -include("includes/authenticate.inc.php"); +require 'includes/authenticate.inc.php'; -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { $_SESSION['widescreen'] = 1; } -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { unset($_SESSION['widescreen']); } +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { + $_SESSION['widescreen'] = 1; +} +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { + unset($_SESSION['widescreen']); +} # Load the settings for Multi-Tenancy. -if (isset($config['branding']) && is_array($config['branding'])) -{ - if ($config['branding'][$_SERVER['SERVER_NAME']]) - { - foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) - { - eval("\$config['" . $confitem . "'] = \$confval;"); +if (isset($config['branding']) && is_array($config['branding'])) { + if ($config['branding'][$_SERVER['SERVER_NAME']]) { + foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } } - } else { - foreach ($config['branding']['default'] as $confitem => $confval) - { - eval("\$config['" . $confitem . "'] = \$confval;"); + else { + foreach ($config['branding']['default'] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } } - } } # page_title_prefix is displayed, unless page_title is set -if (isset($config['page_title'])) { $config['page_title_prefix'] = $config['page_title']; } +if (isset($config['page_title'])) { + $config['page_title_prefix'] = $config['page_title']; +} ?> @@ -119,7 +123,8 @@ if (empty($config['favicon'])) { ' . "\n"); } ?> @@ -169,14 +174,13 @@ if (empty($config['favicon'])) { body { padding-top: 0px !important; - padding-bottom: 0px !important; }"; + padding-bottom: 0px !important; }"; } @@ -188,50 +192,47 @@ if ((isset($vars['bare']) && $vars['bare'] != "yes") || !isset($vars['bare'])) { "); - print_r($_GET); - print_r($vars); - echo(""); +if (isset($devel) || isset($vars['devel'])) { + echo("
    ");
    +    print_r($_GET);
    +    print_r($vars);
    +    echo("
    "); } -if ($_SESSION['authenticated']) -{ - // Authenticated. Print a page. - if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) - { - include("pages/" . $vars['page'] . ".inc.php"); - } else { - if (isset($config['front_page']) && is_file($config['front_page'])) - { - include($config['front_page']); - } else { - include("pages/front/default.php"); +if ($_SESSION['authenticated']) { + // Authenticated. Print a page. + if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) { + require "pages/" . $vars['page'] . ".inc.php"; + } + else { + if (isset($config['front_page']) && is_file($config['front_page'])) { + require $config['front_page']; + } + else { + require 'pages/front/default.php'; + } } - } -} else { - // Not Authenticated. Show status page if enabled - if ( $config['public_status'] === true ) - { - if (isset($vars['page']) && strstr("login", $vars['page'])) - { - include("pages/logon.inc.php"); - } else { - echo '
    '; - include("pages/public.inc.php"); - echo '
    '; - echo ''; +} +else { + // Not Authenticated. Show status page if enabled + if ( $config['public_status'] === true ) { + if (isset($vars['page']) && strstr("login", $vars['page'])) { + require 'pages/logon.inc.php'; + } + else { + echo '
    '; + require 'pages/public.inc.php'; + echo '
    '; + echo ''; + } + } + else { + require 'pages/logon.inc.php'; } - } - else - { - include("pages/logon.inc.php"); - } } ?> @@ -239,37 +240,42 @@ if ($_SESSION['authenticated']) MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. - ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. - ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. - ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); +if ($config['page_gen']) { + echo('
    MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. + ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. + ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. + ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); - $fullsize = memory_get_usage(); - unset($cache); - $cachesize = $fullsize - memory_get_usage(); - if ($cachesize < 0) { $cachesize = 0; } // Silly PHP! + $fullsize = memory_get_usage(); + unset($cache); + $cachesize = $fullsize - memory_get_usage(); + if ($cachesize < 0) { + $cachesize = 0; + } // Silly PHP! - echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); - echo('
    Generated in ' . $gentime . ' seconds.'); + echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); + echo('
    Generated in ' . $gentime . ' seconds.'); } -if (isset($pagetitle) && is_array($pagetitle)) -{ - # if prefix is set, put it in front - if ($config['page_title_prefix']) { array_unshift($pagetitle,$config['page_title_prefix']); } +if (isset($pagetitle) && is_array($pagetitle)) { + # if prefix is set, put it in front + if ($config['page_title_prefix']) { + array_unshift($pagetitle,$config['page_title_prefix']); + } - # if suffix is set, put it in the back - if ($config['page_title_suffix']) { $pagetitle[] = $config['page_title_suffix']; } + # if suffix is set, put it in the back + if ($config['page_title_suffix']) { + $pagetitle[] = $config['page_title_suffix']; + } - # create and set the title - $title = join(" - ",$pagetitle); - echo(""); + # create and set the title + $title = join(" - ",$pagetitle); + echo(""); } ?> @@ -295,23 +301,21 @@ if(dbFetchCell("SELECT COUNT(`device_id`) FROM `devices` WHERE `last_polled` <= } if(is_array($msg_box)) { - echo(""); + echo(""); } if (is_array($sql_debug) && is_array($php_debug) && $_SESSION['authenticated'] === TRUE) { - - include_once "includes/print-debug.php"; - + require_once "includes/print-debug.php"; } if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { @@ -367,7 +371,8 @@ if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { }); '); -} else { +} +else { echo(' +}//end if diff --git a/html/pages/alert-stats.inc.php b/html/pages/alert-stats.inc.php index d392f1dd2..ab9a0c57f 100644 --- a/html/pages/alert-stats.inc.php +++ b/html/pages/alert-stats.inc.php @@ -1,12 +1,13 @@ -* This program is free software: you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation, either version 3 of the License, or (at your -* option) any later version. Please see LICENSE.txt at the top level of -* the source code distribution for details. -*/ -require_once('includes/print-graph-alerts.inc.php'); + * LibreNMS + * + * Copyright (c) 2015 Søren Friis Rosiak + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +require_once 'includes/print-graph-alerts.inc.php'; diff --git a/html/pages/alerts.inc.php b/html/pages/alerts.inc.php index bcc97a32a..91526b69f 100644 --- a/html/pages/alerts.inc.php +++ b/html/pages/alerts.inc.php @@ -1,19 +1,17 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * LibreNMS + * + * Copyright (c) 2014 Neil Lathwood + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ $device['device_id'] = '-1'; -require_once('includes/print-alerts.php'); +require_once 'includes/print-alerts.php'; unset($device['device_id']); - -?> diff --git a/html/pages/api-access.inc.php b/html/pages/api-access.inc.php index a1b6e5a52..6b8a885a7 100644 --- a/html/pages/api-access.inc.php +++ b/html/pages/api-access.inc.php @@ -12,22 +12,22 @@ * the source code distribution for details. */ -if ($_SESSION['userlevel'] >= '10') -{ -if(empty($_POST['token'])) { +if ($_SESSION['userlevel'] >= '10') { +if (empty($_POST['token'])) { $_POST['token'] = bin2hex(openssl_random_pseudo_bytes(16)); } + ?> -'); - if($_SESSION['api_token'] === TRUE) - { - echo(" - "); + "; unset($_SESSION['api_token']); - } -echo(' +} + +echo '
    @@ -127,19 +125,17 @@ echo(' Disabled Remove -'); +'; - foreach (dbFetchRows("SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id") as $api) - { - if($api['disabled'] == '1') - { - $api_disabled = 'checked'; +foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id') as $api) { + if ($api['disabled'] == '1') { + $api_disabled = 'checked'; } - else - { - $api_disabled = ''; + else { + $api_disabled = ''; } - echo(' + + echo ' '.$api['username'].' '.$api['token_hash'].' @@ -147,14 +143,14 @@ echo(' -'); - } +'; +} - echo(' + echo '
    -'); +'; ?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/api-docs.inc.php b/html/pages/api-docs.inc.php index c260b73ce..d3bd68b84 100644 --- a/html/pages/api-docs.inc.php +++ b/html/pages/api-docs.inc.php @@ -17,8 +17,7 @@
    here.'); +print_error('Documentation for the API has now been moved to GitHub, you can go straight to the API Wiki from here.'); ?>
    - diff --git a/html/pages/apps.inc.php b/html/pages/apps.inc.php index 1a20acc41..cfd2378dd 100644 --- a/html/pages/apps.inc.php +++ b/html/pages/apps.inc.php @@ -1,54 +1,91 @@ Apps » "); +echo "Apps » "; unset($sep); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'apps'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'apps', +); -foreach ($app_list as $app) -{ - echo($sep); +foreach ($app_list as $app) { + echo $sep; -# if (!$vars['app']) { $vars['app'] = $app['app_type']; } + // if (!$vars['app']) { $vars['app'] = $app['app_type']; } + if ($vars['app'] == $app['app_type']) { + echo ""; + // echo(''); + } + else { + // echo(''); + } - if ($vars['app'] == $app['app_type']) - { - echo(""); - #echo(''); - } else { - #echo(''); - } - echo(generate_link(nicecase($app['app_type']),array('page'=>'apps','app'=>$app['app_type']))); - if ($vars['app'] == $app['app_type']) { echo(""); } - $sep = " | "; + echo generate_link(nicecase($app['app_type']), array('page' => 'apps', 'app' => $app['app_type'])); + if ($vars['app'] == $app['app_type']) { + echo ''; + } + + $sep = ' | '; } print_optionbar_end(); -if($vars['app']) -{ - if (is_file("pages/apps/".mres($vars['app']).".inc.php")) - { - include("pages/apps/".mres($vars['app']).".inc.php"); - } else { - include("pages/apps/default.inc.php"); - } -} else { - include("pages/apps/overview.inc.php"); +if ($vars['app']) { + if (is_file('pages/apps/'.mres($vars['app']).'.inc.php')) { + include 'pages/apps/'.mres($vars['app']).'.inc.php'; + } + else { + include 'pages/apps/default.inc.php'; + } +} +else { + include 'pages/apps/overview.inc.php'; } -$pagetitle[] = "Apps"; -?> +$pagetitle[] = 'Apps'; diff --git a/html/pages/apps/default.inc.php b/html/pages/apps/default.inc.php index e33367405..bf752de29 100644 --- a/html/pages/apps/default.inc.php +++ b/html/pages/apps/default.inc.php @@ -1,45 +1,41 @@ '.nicecase($vars['app']).''); -echo(''); -$app_devices = dbFetchRows("SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?", array($vars['app'])); +echo '

    '.nicecase($vars['app']).'

    '; +echo '
    '; +$app_devices = dbFetchRows('SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?', array($vars['app'])); -foreach ($app_devices as $app_device) -{ - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''); - echo(''); -} + echo ''; + echo ''; +}//end foreach -echo('
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab'=>'apps','app'=>$vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '); +foreach ($app_devices as $app_device) { + echo '
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab' => 'apps', 'app' => $vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '; - foreach ($graphs[$vars['app']] as $graph_type) - { - $graph_array['type'] = "application_".$vars['app']."_".$graph_type; - $graph_array['id'] = $app_device['app_id']; - $graph_array_zoom['type'] = "application_".$vars['app']."_".$graph_type; - $graph_array_zoom['id'] = $app_device['app_id']; + foreach ($graphs[$vars['app']] as $graph_type) { + $graph_array['type'] = 'application_'.$vars['app'].'_'.$graph_type; + $graph_array['id'] = $app_device['app_id']; + $graph_array_zoom['type'] = 'application_'.$vars['app'].'_'.$graph_type; + $graph_array_zoom['id'] = $app_device['app_id']; - $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'],'tab'=>'apps','app'=>$vars['app'])); + $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'], 'tab' => 'apps', 'app' => $vars['app'])); - echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); - } + echo overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + } - echo('
    '); - -?> +echo ''; diff --git a/html/pages/authlog.inc.php b/html/pages/authlog.inc.php index 64b4080ad..3cffbbea9 100644 --- a/html/pages/authlog.inc.php +++ b/html/pages/authlog.inc.php @@ -1,37 +1,37 @@ = '10') -{ - echo(""); +if ($_SESSION['userlevel'] >= '10') { + echo '
    '; - foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) - { - if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } + foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) { + if ($bg == $list_colour_a) { + $bg = $list_colour_b; + } + else { + $bg = $list_colour_a; + } - echo(" - - - - - - "); - } + echo " + + + + + + '; + }//end foreach - $pagetitle[] = "Authlog"; + $pagetitle[] = 'Authlog'; - echo("
    - " . $entry['datetime'] . " - - ".$entry['user']." - - ".$entry['address']." - - ".$entry['result']." -
    + ".$entry['datetime'].' + + '.$entry['user'].' + + '.$entry['address'].' + + '.$entry['result'].' +
    "); + echo ''; } -else -{ - include("includes/error-no-perm.inc.php"); -} - -?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index 13b640057..03faf35c1 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -2,255 +2,274 @@ $bill_id = mres($vars['bill_id']); -if ($_SESSION['userlevel'] >= "10") -{ - include("pages/bill/actions.inc.php"); +if ($_SESSION['userlevel'] >= '10') { + include 'pages/bill/actions.inc.php'; } -if (bill_permitted($bill_id)) -{ - $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); +if (bill_permitted($bill_id)) { + $bill_data = dbFetchRow('SELECT * FROM bills WHERE bill_id = ?', array($bill_id)); - $bill_name = $bill_data['bill_name']; + $bill_name = $bill_data['bill_name']; - $today = str_replace("-", "", dbFetchCell("SELECT CURDATE()")); - $yesterday = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)")); - $tomorrow = str_replace("-", "", dbFetchCell("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)")); - $last_month = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)")); + $today = str_replace('-', '', dbFetchCell('SELECT CURDATE()')); + $yesterday = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)')); + $tomorrow = str_replace('-', '', dbFetchCell('SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)')); + $last_month = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)')); - $rightnow = $today . date(His); - $before = $yesterday . date(His); - $lastmonth = $last_month . date(His); + $rightnow = $today.date(His); + $before = $yesterday.date(His); + $lastmonth = $last_month.date(His); - $bill_name = $bill_data['bill_name']; - $dayofmonth = $bill_data['bill_day']; + $bill_name = $bill_data['bill_name']; + $dayofmonth = $bill_data['bill_day']; - $day_data = getDates($dayofmonth); + $day_data = getDates($dayofmonth); - $datefrom = $day_data['0']; - $dateto = $day_data['1']; - $lastfrom = $day_data['2']; - $lastto = $day_data['3']; + $datefrom = $day_data['0']; + $dateto = $day_data['1']; + $lastfrom = $day_data['2']; + $lastto = $day_data['3']; - $rate_95th = $bill_data['rate_95th']; - $dir_95th = $bill_data['dir_95th']; - $total_data = $bill_data['total_data']; - $rate_average = $bill_data['rate_average']; + $rate_95th = $bill_data['rate_95th']; + $dir_95th = $bill_data['dir_95th']; + $total_data = $bill_data['total_data']; + $rate_average = $bill_data['rate_average']; - if ($rate_95th > $paid_kb) - { - $over = $rate_95th - $paid_kb; - $bill_text = $over . "Kbit excess."; - $bill_color = "#cc0000"; - } - else - { - $under = $paid_kb - $rate_95th; - $bill_text = $under . "Kbit headroom."; - $bill_color = "#0000cc"; - } - - $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); - $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); - $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); - $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); - - $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); - $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); - # Speeds up loading for other included pages by setting it before progessing of mysql data! - - $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D - WHERE B.bill_id = ? AND P.port_id = B.port_id - AND D.device_id = P.device_id", array($bill_id)); - - echo("

    - Bill : " . $bill_data['bill_name'] . "

    "); - - print_optionbar_start(); - - echo("Bill » "); - - if (!$vars['view']) { $vars['view'] = "quick"; } - - if ($vars['view'] == "quick") { echo(""); } - echo('Quick Graphs'); - if ($vars['view'] == "quick") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "accurate") { echo(""); } - echo('Accurate Graphs'); - if ($vars['view'] == "accurate") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "transfer") { echo(""); } - echo('Transfer Graphs'); - if ($vars['view'] == "transfer") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "history") { echo(""); } - echo('Historical Usage'); - if ($vars['view'] == "history") { echo(""); } - - if ($_SESSION['userlevel'] >= "10") - { - echo(" | "); - if ($vars['view'] == "edit") { echo(""); } - echo('Edit'); - if ($vars['view'] == "edit") { echo(""); } - - echo(" | "); - if ($vars['view'] == "delete") { echo(""); } - echo('Delete'); - if ($vars['view'] == "delete") { echo(""); } - - echo(" | "); - if ($vars['view'] == "reset") { echo(""); } - echo('Reset'); - if ($vars['view'] == "reset") { echo(""); } - } - - echo(''); - - print_optionbar_end(); - - if ($vars['view'] == "edit" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/edit.inc.php"); - } - elseif ($vars['view'] == "delete" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/delete.inc.php"); - } - elseif ($vars['view'] == "reset" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/reset.inc.php"); - } - elseif ($vars['view'] == "history") - { - include("pages/bill/history.inc.php"); - } - elseif ($vars['view'] == "transfer") - { - include("pages/bill/transfer.inc.php"); - } - elseif ($vars['view'] == "quick" || $vars['view'] == "accurate") { - - echo("

    Billed Ports

    "); - - // Collected Earlier - foreach ($ports as $port) - { - echo(generate_port_link($port) . " on " . generate_device_link($port) . "
    "); + if ($rate_95th > $paid_kb) { + $over = ($rate_95th - $paid_kb); + $bill_text = $over.'Kbit excess.'; + $bill_color = '#cc0000'; + } + else { + $under = ($paid_kb - $rate_95th); + $bill_text = $under.'Kbit headroom.'; + $bill_color = '#0000cc'; } - echo("

    Bill Summary

    "); + $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); + $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); + $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); + $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); - if ($bill_data['bill_type'] == "quota") - { - // The Customer is billed based on a pre-paid quota with overage in xB + $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); + $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); + // Speeds up loading for other included pages by setting it before progessing of mysql data! + $ports = dbFetchRows( + 'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D + WHERE B.bill_id = ? AND P.port_id = B.port_id + AND D.device_id = P.device_id', + array($bill_id) + ); - echo("

    Quota Bill

    "); + echo '

    + Bill : '.$bill_data['bill_name'].'

    '; - $percent = round(($total_data) / $bill_data['bill_quota'] * 100, 2); - $unit = "MB"; - $total_data = round($total_data, 2); - echo("Billing Period from " . $fromtext . " to " . $totext); - echo("
    Transferred ".format_bytes_billing($total_data)." of ".format_bytes_billing($bill_data['bill_quota'])." (".$percent."%)"); - echo("
    Average rate " . formatRates($rate_average)); + print_optionbar_start(); - $background = get_percentage_colours($percent); + echo "Bill » "; - echo("

    ".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); - - $type="&ave=yes"; - } - elseif ($bill_data['bill_type'] == "cdr") - { - // The customer is billed based on a CDR with 95th%ile overage - - echo("

    CDR / 95th Bill

    "); - - $unit = "kbps"; - $cdr = $bill_data['bill_cdr']; - $rate_95th = round($rate_95th, 2); - - $percent = round(($rate_95th) / $cdr * 100, 2); - - $type="&95th=yes"; - - echo("" . $fromtext . " to " . $totext . " -
    Measured ".format_si($rate_95th)."bps of ".format_si($cdr)."bps (".$percent."%) @ 95th %ile"); - - $background = get_percentage_colours($percent); - - echo("

    ".print_percentage_bar (350, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); - - # echo("

    Billing Period : " . $fromtext . " to " . $totext . "
    - # " . $paidrate_text . "
    - # " . $total_data . "MB transfered in the current billing cycle.
    - # " . $rate_average . "Kbps Average during the current billing cycle.

    - # " . $rate_95th . "Kbps @ 95th Percentile. (" . $dir_95th . ") (" . $bill_text . ") - # - #
    "); + if (!$vars['view']) { + $vars['view'] = 'quick'; } - $lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"); - $yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"); - $rightnow = date(U); - - if ($vars['view'] == "accurate") { - - $bi = ""; - - $li = ""; - - $di = ""; - - $mi = ""; - + if ($vars['view'] == 'quick') { + echo ""; } - if ($null) - { - echo(" - @@ -268,39 +287,32 @@ if (bill_permitted($bill_id)) - "); + "; + }//end if - } - - if ($_GET['all']) - { - $ai = ""; - echo("

    Entire Data View

    $ai"); - } - elseif ($_GET['custom']) - { - $cg = ""; - echo("

    Custom Graph

    $cg"); - } - else - { - echo("

    Billing View

    $bi"); -# echo("

    Previous Bill View

    $li"); - echo("

    24 Hour View

    $di"); - echo("

    Monthly View

    $mi"); -# echo("
    Graph All Data (SLOW)"); - } - } # End if details + if ($_GET['all']) { + $ai = ''; + echo "

    Entire Data View

    $ai"; + } + else if ($_GET['custom']) { + $cg = ''; + echo "

    Custom Graph

    $cg"; + } + else { + echo "

    Billing View

    $bi"; + // echo("

    Previous Bill View

    $li"); + echo "

    24 Hour View

    $di"; + echo "

    Monthly View

    $mi"; + // echo("
    Graph All Data (SLOW)"); + }//end if + } //end if } -else -{ - include("includes/error-no-perm.inc.php"); -} - -?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/bill/actions.inc.php b/html/pages/bill/actions.inc.php index d55c2944c..29afb6d3b 100644 --- a/html/pages/bill/actions.inc.php +++ b/html/pages/bill/actions.inc.php @@ -1,8 +1,7 @@ = 1) { + $quota = array( + 'type' => 'tb', + 'select_tb' => ' selected', + 'data' => $tmp['tb'], + ); + } + else if (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) { + $quota = array( + 'type' => 'gb', + 'select_gb' => ' selected', + 'data' => $tmp['gb'], + ); + } + else if (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) { + $quota = array( + 'type' => 'mb', + 'select_mb' => ' selected', + 'data' => $tmp['mb'], + ); + } +}//end if -if ($bill_data['bill_type'] == "quota") { - $data = $bill_data['bill_quota']; - $tmp['mb'] = $data / $base / $base; - $tmp['gb'] = $data / $base / $base / $base; - $tmp['tb'] = $data / $base / $base / $base / $base; - if ($tmp['tb']>=1) { $quota = array("type" => "tb", "select_tb" => " selected", "data" => $tmp['tb']); } - elseif (($tmp['gb']>=1) and ($tmp['gb']<$base)) { $quota = array("type" => "gb", "select_gb" => " selected", "data" => $tmp['gb']); } - elseif (($tmp['mb']>=1) and ($tmp['mb']<$base)) { $quota = array("type" => "mb", "select_mb" => " selected", "data" => $tmp['mb']); } -} -if ($bill_data['bill_type'] == "cdr") { - $data = $bill_data['bill_cdr']; - $tmp['kbps'] = $data / $base; - $tmp['mbps'] = $data / $base / $base; - $tmp['gbps'] = $data / $base / $base / $base; - if ($tmp['gbps']>=1) { $cdr = array("type" => "gbps", "select_gbps" => " selected", "data" => $tmp['gbps']); } - elseif (($tmp['mbps']>=1) and ($tmp['mbps']<$base)) { $cdr = array("type" => "mbps", "select_mbps" => " selected", "data" => $tmp['mbps']); } - elseif (($tmp['kbps']>=1) and ($tmp['kbps']<$base)) { $cdr = array("type" => "kbps", "select_kbps" => " selected", "data" => $tmp['kbps']); } -} +if ($bill_data['bill_type'] == 'cdr') { + $data = $bill_data['bill_cdr']; + $tmp['kbps'] = ($data / $base); + $tmp['mbps'] = ($data / $base / $base); + $tmp['gbps'] = ($data / $base / $base / $base); + if ($tmp['gbps'] >= 1) { + $cdr = array( + 'type' => 'gbps', + 'select_gbps' => ' selected', + 'data' => $tmp['gbps'], + ); + } + else if (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) { + $cdr = array( + 'type' => 'mbps', + 'select_mbps' => ' selected', + 'data' => $tmp['mbps'], + ); + } + else if (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) { + $cdr = array( + 'type' => 'kbps', + 'select_kbps' => ' selected', + 'data' => $tmp['kbps'], + ); + } +}//end if ?>
    - +

    Bill Properties

    - " /> +
    @@ -51,17 +86,35 @@ if ($bill_data['bill_type'] == "cdr") {
    - -
    - /> + />
    - /> + />
    diff --git a/html/pages/device/edit/health.inc.php b/html/pages/device/edit/health.inc.php index 3d7d21352..922bb36c7 100644 --- a/html/pages/device/edit/health.inc.php +++ b/html/pages/device/edit/health.inc.php @@ -30,156 +30,158 @@ $sensor['sensor_id'], 'sensor_limit' => $sensor['sensor_limit'], 'sensor_limit_low' => $sensor['sensor_limit_low'], 'sensor_alert' => $sensor['sensor_alert']); - if($sensor['sensor_alert'] == 1) - { - $alert_status = 'checked'; - } - else - { - $alert_status = ''; - } - if ($sensor['sensor_custom'] == 'No') { - $custom = 'disabled'; - } else { - $custom = ''; - } - echo(' - - '.$sensor['sensor_class'].' - '.$sensor['sensor_type'].' - '.$sensor['sensor_descr'].' - '.$sensor['sensor_current'].' - -
    +foreach (dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND sensor_deleted='0'", array($device['device_id'])) as $sensor) { + $rollback[] = array( + 'sensor_id' => $sensor['sensor_id'], + 'sensor_limit' => $sensor['sensor_limit'], + 'sensor_limit_low' => $sensor['sensor_limit_low'], + 'sensor_alert' => $sensor['sensor_alert'], + ); + if ($sensor['sensor_alert'] == 1) { + $alert_status = 'checked'; + } + else { + $alert_status = ''; + } + + if ($sensor['sensor_custom'] == 'No') { + $custom = 'disabled'; + } + else { + $custom = ''; + } + + echo ' + + '.$sensor['sensor_class'].' + '.$sensor['sensor_type'].' + '.$sensor['sensor_descr'].' + '.$sensor['sensor_current'].' + +
    -
    - - -
    +
    + + +
    -
    - - - - - +
    + + + + + Clear custom - - -'); + + + '; } - ?>
    - - - - '); +foreach ($rollback as $reset_data) { + echo ' + + + + + '; } ?>
    - diff --git a/html/pages/device/edit/ipmi.inc.php b/html/pages/device/edit/ipmi.inc.php index f3971ca41..0aff50bdd 100644 --- a/html/pages/device/edit/ipmi.inc.php +++ b/html/pages/device/edit/ipmi.inc.php @@ -1,31 +1,45 @@ "7") - { - $ipmi_hostname = mres($_POST['ipmi_hostname']); - $ipmi_username = mres($_POST['ipmi_username']); - $ipmi_password = mres($_POST['ipmi_password']); +if ($_POST['editing']) { + if ($_SESSION['userlevel'] > '7') { + $ipmi_hostname = mres($_POST['ipmi_hostname']); + $ipmi_username = mres($_POST['ipmi_username']); + $ipmi_password = mres($_POST['ipmi_password']); - if ($ipmi_hostname != '') { set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); } else { del_dev_attrib($device, 'ipmi_hostname'); } - if ($ipmi_username != '') { set_dev_attrib($device, 'ipmi_username', $ipmi_username); } else { del_dev_attrib($device, 'ipmi_username'); } - if ($ipmi_password != '') { set_dev_attrib($device, 'ipmi_password', $ipmi_password); } else { del_dev_attrib($device, 'ipmi_password'); } + if ($ipmi_hostname != '') { + set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); + } + else { + del_dev_attrib($device, 'ipmi_hostname'); + } - $update_message = "Device IPMI data updated."; - $updated = 1; - } - else - { - include("includes/error-no-perm.inc.php"); - } + if ($ipmi_username != '') { + set_dev_attrib($device, 'ipmi_username', $ipmi_username); + } + else { + del_dev_attrib($device, 'ipmi_username'); + } + + if ($ipmi_password != '') { + set_dev_attrib($device, 'ipmi_password', $ipmi_password); + } + else { + del_dev_attrib($device, 'ipmi_password'); + } + + $update_message = 'Device IPMI data updated.'; + $updated = 1; + } + else { + include 'includes/error-no-perm.inc.php'; + }//end if +}//end if + +if ($updated && $update_message) { + print_message($update_message); } - -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +else if ($update_message) { + print_error($update_message); } ?> @@ -37,19 +51,19 @@ if ($updated && $update_message)
    - +
    - +
    - +
    diff --git a/html/pages/device/edit/modules.inc.php b/html/pages/device/edit/modules.inc.php index 36a53b3f1..319617162 100644 --- a/html/pages/device/edit/modules.inc.php +++ b/html/pages/device/edit/modules.inc.php @@ -17,68 +17,57 @@ $module_status) -{ - echo(' +foreach ($config['poller_modules'] as $module => $module_status) { + echo(' '.$module.' -'); + '); - if($module_status == 1) - { - echo('Enabled'); - } - else - { - echo('Disabled'); - } + if($module_status == 1) { + echo('Enabled'); + } + else { + echo('Disabled'); + } - echo(' + echo(' -'); + '); - if (isset($attribs['poll_'.$module])) - { - if ($attribs['poll_'.$module]) - { - echo('Enabled'); - $module_checked = 'checked'; + if (isset($attribs['poll_'.$module])) { + if ($attribs['poll_'.$module]) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - else - { - echo('Disabled'); - $module_checked = ''; + else { + if($module_status == 1) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - } - else - { - if($module_status == 1) - { - echo('Enabled'); - $module_checked = 'checked'; - } - else - { - echo('Disabled'); - $module_checked = ''; - } - } - echo(' + echo(' -'); + '); - echo(' - -'); + echo(''); - echo(' + echo(' -'); + '); } ?> @@ -96,71 +85,56 @@ foreach ($config['poller_modules'] as $module => $module_status) $module_status) -{ - - echo(' +foreach ($config['discovery_modules'] as $module => $module_status) { + echo(' '.$module.' -'); + '); - if($module_status == 1) - { - echo('Enabled'); - } - else - { - echo('Disabled'); - } + if($module_status == 1) { + echo('Enabled'); + } + else { + echo('Disabled'); + } - echo(' + echo(' - -'); + '); - if (isset($attribs['discover_'.$module])) - { - if($attribs['discover_'.$module]) - { - echo('Enabled'); - $module_checked = 'checked'; + if (isset($attribs['discover_'.$module])) { + if($attribs['discover_'.$module]) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - else - { - echo('Disabled'); - $module_checked = ''; + else { + if($module_status == 1) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - } - else - { - if($module_status == 1) - { - echo('Enabled'); - $module_checked = 'checked'; - } - else - { - echo('Disabled'); - $module_checked = ''; - } - } - echo(' + echo(' - -'); + '); - echo(' - -'); + echo(''); - echo(' + echo(' - -'); + '); } echo(' diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index b382cf05a..d8dc562e4 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -1,28 +1,26 @@ '); +echo '
    '; -if ($_POST['ignoreport']) -{ - if ($_SESSION['userlevel'] == '10') - { - include("includes/port-edit.inc.php"); - } +if ($_POST['ignoreport']) { + if ($_SESSION['userlevel'] == '10') { + include 'includes/port-edit.inc.php'; + } } -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +if ($updated && $update_message) { + print_message($update_message); +} +else if ($update_message) { + print_error($update_message); } -echo("
    +echo "
    - "); + "; -echo(" +echo "
    @@ -41,14 +39,14 @@ echo("
    Index Name
    -"); +"; ?> '; + echo ''; + echo ''; + echo ''; - echo(""); - echo(""); - echo(""); - echo(""); + // Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled + // - as to draw the attention to a possible problem. + $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; + $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; + $outofsync = $dowecare ? " class='red'" : ''; - # Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled - # - as to draw the attention to a possible problem. - $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; - $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; - $outofsync = $dowecare ? " class='red'" : ""; + echo "'; - echo(""); + echo '"); + echo '"); - echo(""); + echo "\n"; - echo("\n"); + $row++; +}//end foreach - $row++; -} - -echo('
    '.$port['ifIndex'].''.$port['label'].''.$port['ifAdminStatus'].'
    ". $port['ifIndex']."".$port['label'] . "". $port['ifAdminStatus']."'.$port['ifOperStatus'].'". $port['ifOperStatus']."'; + echo "'; + echo ""); - echo(""); - echo(""); - echo("'; + echo "'; + echo ""); - echo(""); - echo(""); - echo("".$port['ifAlias'] . "
    '); -echo('
    '); -echo('
    '); - -?> +echo ''; +echo ''; +echo '
    '; diff --git a/html/pages/device/edit/services.inc.php b/html/pages/device/edit/services.inc.php index e6969a9fe..1f2bc1d30 100644 --- a/html/pages/device/edit/services.inc.php +++ b/html/pages/device/edit/services.inc.php @@ -1,29 +1,28 @@ = '10') { - include("includes/service-add.inc.php"); + include 'includes/service-add.inc.php'; } } if ($_POST['delsrv']) { if ($_SESSION['userlevel'] >= '10') { - include("includes/service-delete.inc.php"); + include 'includes/service-delete.inc.php'; } } if ($_POST['confirm-editsrv']) { - echo "yeah"; + echo 'yeah'; if ($_SESSION['userlevel'] >= '10') { - include("includes/service-edit.inc.php"); + include 'includes/service-edit.inc.php'; } } - if ($handle = opendir($config['install_dir'] . "/includes/services/")) { + if ($handle = opendir($config['install_dir'].'/includes/services/')) { while (false !== ($file = readdir($handle))) { - if ($file != "." && $file != ".." && !strstr($file, ".")) { + if ($file != '.' && $file != '..' && !strstr($file, '.')) { $servicesform .= ""; } } @@ -31,17 +30,17 @@ if (is_admin() === TRUE || is_read() === TRUE) { closedir($handle); } - $dev = device_by_id_cache($device['device_id']); - $devicesform = ""; + $dev = device_by_id_cache($device['device_id']); + $devicesform = "'; if ($updated) { - print_message("Device Settings Saved"); + print_message('Device Settings Saved'); } - if (dbFetchCell("SELECT COUNT(*) from `services` WHERE `device_id` = ?", array($device['device_id'])) > '0') { - $i = "1"; - foreach (dbFetchRows("select * from services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $service) { - $existform .= ""; + if (dbFetchCell('SELECT COUNT(*) from `services` WHERE `device_id` = ?', array($device['device_id'])) > '0') { + $i = '1'; + foreach (dbFetchRows('select * from services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $service) { + $existform .= "'; } } @@ -49,28 +48,29 @@ if (is_admin() === TRUE || is_read() === TRUE) { if ($existform) { echo '
    '; - if ($_POST['editsrv'] == "yes") { - include_once "includes/print-service-edit.inc.php"; - } else { + if ($_POST['editsrv'] == 'yes') { + include_once 'includes/print-service-edit.inc.php'; + } + else { echo " -

    Edit / Delete Service

    -
    +

    Edit / Delete Service

    +
    -
    - -
    - -
    -
    -
    -
    - -
    -
    +
    + +
    +
    - "; +
    +
    +
    + +
    +
    +
    + "; } echo '
    '; @@ -78,8 +78,8 @@ if (is_admin() === TRUE || is_read() === TRUE) { echo '
    '; - require_once "includes/print-service-add.inc.php"; - -} else { - include("includes/error-no-perm.inc.php"); -} \ No newline at end of file + include_once 'includes/print-service-add.inc.php'; +} +else { + include 'includes/error-no-perm.inc.php'; +} diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php index 9e8a5b7b0..59c6bf4cd 100644 --- a/html/pages/device/edit/snmp.inc.php +++ b/html/pages/device/edit/snmp.inc.php @@ -1,225 +1,240 @@ "7") - { - $community = mres($_POST['community']); - $snmpver = mres($_POST['snmpver']); - $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = "udp"; - $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; - $timeout = mres($_POST['timeout']); - $retries = mres($_POST['retries']); - $poller_group = mres($_POST['poller_group']); - $v3 = array ( - 'authlevel' => mres($_POST['authlevel']), - 'authname' => mres($_POST['authname']), - 'authpass' => mres($_POST['authpass']), - 'authalgo' => mres($_POST['authalgo']), - 'cryptopass' => mres($_POST['cryptopass']), - 'cryptoalgo' => mres($_POST['cryptoalgo']) - ); +if ($_POST['editing']) { + if ($_SESSION['userlevel'] > '7') { + $community = mres($_POST['community']); + $snmpver = mres($_POST['snmpver']); + $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = 'udp'; + $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; + $timeout = mres($_POST['timeout']); + $retries = mres($_POST['retries']); + $poller_group = mres($_POST['poller_group']); + $v3 = array( + 'authlevel' => mres($_POST['authlevel']), + 'authname' => mres($_POST['authname']), + 'authpass' => mres($_POST['authpass']), + 'authalgo' => mres($_POST['authalgo']), + 'cryptopass' => mres($_POST['cryptopass']), + 'cryptoalgo' => mres($_POST['cryptoalgo']), + ); - #FIXME needs better feedback - $update = array( - 'community' => $community, - 'snmpver' => $snmpver, - 'port' => $port, - 'transport' => $transport, - 'poller_group' => $poller_group - ); + // FIXME needs better feedback + $update = array( + 'community' => $community, + 'snmpver' => $snmpver, + 'port' => $port, + 'transport' => $transport, + 'poller_group' => $poller_group, + ); - if ($_POST['timeout']) { $update['timeout'] = $timeout; } - else { $update['timeout'] = array('NULL'); } - if ($_POST['retries']) { $update['retries'] = $retries; } - else { $update['retries'] = array('NULL'); } - - $update = array_merge($update, $v3); - - $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); - if (isSNMPable($device_tmp)) { - $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id'])); - - if ($rows_updated > 0) { - $update_message = $rows_updated . " 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; + if ($_POST['timeout']) { + $update['timeout'] = $timeout; + } + else { + $update['timeout'] = array('NULL'); } - } else { - $update_message = "Could not connect to device with new SNMP details"; - $updated = 0; - } - } -} -$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id'])); + if ($_POST['retries']) { + $update['retries'] = $retries; + } + else { + $update['retries'] = array('NULL'); + } + + $update = array_merge($update, $v3); + + $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); + if (isSNMPable($device_tmp)) { + $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id'])); + + if ($rows_updated > 0) { + $update_message = $rows_updated.' Device record updated.'; + $updated = 1; + } + else if ($rows_updated = '-1') { + $update_message = 'Device record unchanged. No update necessary.'; + $updated = -1; + } + else { + $update_message = 'Device record update error.'; + $updated = 0; + } + } + else { + $update_message = 'Could not connect to device with new SNMP details'; + $updated = 0; + } + }//end if +}//end if + +$device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id'])); $descr = $device['purpose']; -echo('
    -
    '); -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +echo '
    +
    '; +if ($updated && $update_message) { + print_message($update_message); +} +else if ($update_message) { + print_error($update_message); } -echo('
    -
    '); -echo(" -
    - -
    +echo '
    +
    '; + +echo " + + +
    - +
    - +
    - "; foreach ($config['snmp']['transports'] as $transport) { - echo(""); + + echo '>'.$transport.''; } -echo(" + +echo "
    -
    -
    +
    +
    - +
    - +
    -
    -
    +
    +
    - +
    - -
    - -
    + +
    +
    -
    -
    +
    +
    +
    - +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    +
    -
    "); +
    +
    '; -if ($config['distributed_poller'] === TRUE) { - echo(' -
    - -
    - + + '; - foreach (dbFetchRows("SELECT `id`,`group_name` FROM `poller_groups`") as $group) { - echo ''; + + echo '>'.$group['group_name'].''; } - echo(' - -
    -
    - '); -} + echo ' + +
    +
    + '; +}//end if -echo(' - - -'); +echo ' + + + '; ?> diff --git a/html/pages/device/entphysical.inc.php b/html/pages/device/entphysical.inc.php index af167b4dd..7b5d956fa 100644 --- a/html/pages/device/entphysical.inc.php +++ b/html/pages/device/entphysical.inc.php @@ -1,13 +1,11 @@ "; @@ -33,7 +31,8 @@ function printEntPhysical($ent, $level, $class) if (count($sensor)) { $link = " href='device/device=".$device['device_id'].'/tab=health/metric='.$sensor['sensor_class']."/' onmouseover=\"return overlib('', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\""; } - } else { + } + else { unset($link); } diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index a275e71e3..e4bd13d84 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -1,70 +1,68 @@ 'device', + 'device' => $device['device_id'], + 'tab' => 'graphs', +); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'graphs'); +$bg = '#ffffff'; -$bg="#ffffff"; - -echo('
    '); +echo '
    '; print_optionbar_start(); -echo("Graphs » "); +echo "Graphs » "; -foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph", array($device['device_id'])) as $graph) -{ - $section = $config['graph_types']['device'][$graph['graph']]['section']; - if ($section != "") { - $graph_enable[$section][$graph['graph']] = $graph['graph']; - } +foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph', array($device['device_id'])) as $graph) { + $section = $config['graph_types']['device'][$graph['graph']]['section']; + if ($section != '') { + $graph_enable[$section][$graph['graph']] = $graph['graph']; + } } // These are standard graphs we should have for all systems $graph_enable['poller']['poller_perf'] = 'device_poller_perf'; -$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; +$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; -$sep = ""; -foreach ($graph_enable as $section => $nothing) -{ - if (isset($graph_enable) && is_array($graph_enable[$section])) - { - $type = strtolower($section); - if (!$vars['group']) { $vars['group'] = $type; } - echo($sep); - if ($vars['group'] == $type) - { - echo(''); +$sep = ''; +foreach ($graph_enable as $section => $nothing) { + if (isset($graph_enable) && is_array($graph_enable[$section])) { + $type = strtolower($section); + if (!$vars['group']) { + $vars['group'] = $type; + } + + echo $sep; + if ($vars['group'] == $type) { + echo ''; + } + + echo generate_link(ucwords($type), $link_array, array('group' => $type)); + if ($vars['group'] == $type) { + echo ''; + } + + $sep = ' | '; } - echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); - if ($vars['group'] == $type) - { - echo(""); - } - $sep = " | "; - } } -unset ($sep); + +unset($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -#foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) -{ - $graph_array = array(); - if ($graph_enable[$graph]) - { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = "device_" . $graph; +// foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) { + $graph_array = array(); + if ($graph_enable[$graph]) { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = 'device_'.$graph; - include("includes/print-device-graph.php"); - } + include 'includes/print-device-graph.php'; + } } -$pagetitle[] = "Graphs"; - -?> +$pagetitle[] = 'Graphs'; diff --git a/html/pages/device/graphs/netstats_ip_forward.inc.php b/html/pages/device/graphs/netstats_ip_forward.inc.php index cc728ac77..eda137a78 100644 --- a/html/pages/device/graphs/netstats_ip_forward.inc.php +++ b/html/pages/device/graphs/netstats_ip_forward.inc.php @@ -1,11 +1,8 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'health'); +if ($storage) { + $datas[] = 'storage'; +} + +if ($diskio) { + $datas[] = 'diskio'; +} + +if ($charge) { + $datas[] = 'charge'; +} + +if ($temperatures) { + $datas[] = 'temperature'; +} + +if ($humidity) { + $datas[] = 'humidity'; +} + +if ($fans) { + $datas[] = 'fanspeed'; +} + +if ($volts) { + $datas[] = 'voltage'; +} + +if ($freqs) { + $datas[] = 'frequency'; +} + +if ($current) { + $datas[] = 'current'; +} + +if ($power) { + $datas[] = 'power'; +} + +if ($dBm) { + $datas[] = 'dbm'; +} + +if ($states) { + $datas[] = 'state'; +} + +if ($load) { + $datas[] = 'load'; +} + +$type_text['overview'] = 'Overview'; +$type_text['charge'] = 'Battery Charge'; +$type_text['temperature'] = 'Temperature'; +$type_text['humidity'] = 'Humidity'; +$type_text['mempool'] = 'Memory'; +$type_text['storage'] = 'Disk Usage'; +$type_text['diskio'] = 'Disk I/O'; +$type_text['processor'] = 'Processor'; +$type_text['voltage'] = 'Voltage'; +$type_text['fanspeed'] = 'Fanspeed'; +$type_text['frequency'] = 'Frequency'; +$type_text['current'] = 'Current'; +$type_text['power'] = 'Power'; +$type_text['dbm'] = 'dBm'; +$type_text['state'] = 'State'; +$type_text['load'] = 'Load'; + +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'health', +); print_optionbar_start(); -echo("Health » "); +echo "Health » "; -if (!$vars['metric']) { $vars['metric'] = "overview"; } +if (!$vars['metric']) { + $vars['metric'] = 'overview'; +} unset($sep); -foreach ($datas as $type) -{ - echo($sep); +foreach ($datas as $type) { + echo $sep; - if ($vars['metric'] == $type) - { echo(''); } - echo(generate_link($type_text[$type],$link_array,array('metric'=>$type))); - if ($vars['metric'] == $type) { echo(""); } - $sep = " | "; + if ($vars['metric'] == $type) { + echo ''; + } + + echo generate_link($type_text[$type], $link_array, array('metric' => $type)); + if ($vars['metric'] == $type) { + echo ''; + } + + $sep = ' | '; } print_optionbar_end(); -if (is_file("pages/device/health/".mres($vars['metric']).".inc.php")) -{ - include("pages/device/health/".mres($vars['metric']).".inc.php"); -} else { +if (is_file('pages/device/health/'.mres($vars['metric']).'.inc.php')) { + include 'pages/device/health/'.mres($vars['metric']).'.inc.php'; +} +else { + foreach ($datas as $type) { + if ($type != 'overview') { + $graph_title = $type_text[$type]; + $graph_array['type'] = 'device_'.$type; - foreach ($datas as $type) - { - if ($type != "overview") - { - - $graph_title = $type_text[$type]; - $graph_array['type'] = "device_".$type; - - include("includes/print-device-graph.php"); + include 'includes/print-device-graph.php'; + } } - } } -$pagetitle[] = "Health"; - -?> +$pagetitle[] = 'Health'; diff --git a/html/pages/device/health/charge.inc.php b/html/pages/device/health/charge.inc.php index 7282247bf..0750ae593 100644 --- a/html/pages/device/health/charge.inc.php +++ b/html/pages/device/health/charge.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/current.inc.php b/html/pages/device/health/current.inc.php index 0fa318a9b..70bd4dc42 100644 --- a/html/pages/device/health/current.inc.php +++ b/html/pages/device/health/current.inc.php @@ -4,6 +4,4 @@ $class = "current"; $unit = "A"; $graph_type = "sensor_current"; -include("sensors.inc.php"); - -?> +require 'sensors.inc.php'; diff --git a/html/pages/device/health/humidity.inc.php b/html/pages/device/health/humidity.inc.php index 93b4772a3..ffef7afa6 100644 --- a/html/pages/device/health/humidity.inc.php +++ b/html/pages/device/health/humidity.inc.php @@ -4,6 +4,4 @@ $class = "humidity"; $unit = "%"; $graph_type = "sensor_humidity"; -include("sensors.inc.php"); - -?> +require 'sensors.inc.php'; diff --git a/html/pages/device/health/load.inc.php b/html/pages/device/health/load.inc.php index 399237aae..18f5b5f5c 100644 --- a/html/pages/device/health/load.inc.php +++ b/html/pages/device/health/load.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/mempool.inc.php b/html/pages/device/health/mempool.inc.php index 6630c3147..613aa1250 100644 --- a/html/pages/device/health/mempool.inc.php +++ b/html/pages/device/health/mempool.inc.php @@ -1,66 +1,72 @@ "); -echo(""); +echo "
    "; +echo '
    '; $i = '1'; -#FIXME css alternating colours +// FIXME css alternating colours +foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($device['device_id'])) as $mempool) { + if (!is_integer($i / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } -foreach (dbFetchRows("SELECT * FROM `mempools` WHERE device_id = ?", array($device['device_id'])) as $mempool) -{ - if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if ($debug) { + print_r($state); + } - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $mempool = array_merge($mempool, $state); } - unset($state); - } + if (is_array($state)) { + $mempool = array_merge($mempool, $state); + } - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + unset($state); + } - $mempool_url = "graphs/id=".$mempool['mempool_id']."/type=mempool_usage/"; - $mini_url = "graph.php?id=".$mempool['mempool_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; - $mempool_popup .= "
    "; - $mempool_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + $mempool_url = 'graphs/id='.$mempool['mempool_id'].'/type=mempool_usage/'; + $mini_url = 'graph.php?id='.$mempool['mempool_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); + $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; + $mempool_popup .= "
    "; + $mempool_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; - $perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100); + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); - $background = get_percentage_colours($percent); - $right_background = $background['right']; - $left_background = $background['left']; + $perc = round(($mempool['mempool_used'] / $mempool['mempool_total'] * 100)); - echo(" - - - - "); + $background = get_percentage_colours($percent); + $right_background = $background['right']; + $left_background = $background['left']; - echo(" + + + + '; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; + echo ""); + include 'includes/print-graphrow.inc.php'; - $i++; -} + echo ''; -echo("
    " . $text_descr . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free , "ffffff", $right_background)." - ".$perc."%
    "); + echo "
    ".$text_descr." + ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $left_background, $free, 'ffffff', $right_background).' + '.$perc.'%
    "; - include("includes/print-graphrow.inc.php"); + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; - echo("
    "); -echo("
    "); + $i++; +}//end foreach -?> +echo ''; +echo '
    '; diff --git a/html/pages/device/health/processor.inc.php b/html/pages/device/health/processor.inc.php index bde4a3b3f..725e37c21 100644 --- a/html/pages/device/health/processor.inc.php +++ b/html/pages/device/health/processor.inc.php @@ -1,46 +1,43 @@ "); -echo(""); +echo "
    "; +echo '
    '; $i = '1'; -foreach (dbFetchRows("SELECT * FROM `processors` WHERE device_id = ?", array($device['device_id'])) as $proc) -{ - $proc_url = "graphs/id=".$proc['processor_id']."/type=processor_usage/"; +foreach (dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', array($device['device_id'])) as $proc) { + $proc_url = 'graphs/id='.$proc['processor_id'].'/type=processor_usage/'; - $mini_url = "graph.php?id=".$proc['processor_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; + $mini_url = 'graph.php?id='.$proc['processor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; - $text_descr = $proc['processor_descr']; + $text_descr = $proc['processor_descr']; - $text_descr = rewrite_entity_descr($text_descr); + $text_descr = rewrite_entity_descr($text_descr); - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; - $percent = round($proc['processor_usage']); + $percent = round($proc['processor_usage']); - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo(" - + echo (" + - "); + '); - echo("
    " . $text_descr . "
    ".$text_descr." - ".print_percentage_bar (400, 20, $percent, $percent."%", "ffffff", $background['left'], (100 - $percent)."%" , "ffffff", $background['right'])." + ".print_percentage_bar(400, 20, $percent, $percent.'%', 'ffffff', $background['left'], (100 - $percent).'%', 'ffffff', $background['right']).'
    "); + echo "
    "; - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; - include("includes/print-graphrow.inc.php"); -} + include 'includes/print-graphrow.inc.php'; +}//end foreach -echo("
    "); -echo(""); - -?> +echo ''; +echo ''; diff --git a/html/pages/device/health/state.inc.php b/html/pages/device/health/state.inc.php index 546396219..9781248be 100644 --- a/html/pages/device/health/state.inc.php +++ b/html/pages/device/health/state.inc.php @@ -1,7 +1,7 @@ "); +echo ''; -echo(" +echo ' - "); + '; $row = 1; -foreach (dbFetchRows("SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr", array($device['device_id'])) as $drive) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } +foreach (dbFetchRows('SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr', array($device['device_id'])) as $drive) { + if (is_integer($row / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - $total = $drive['storage_size']; - $used = $drive['storage_used']; - $free = $drive['storage_free']; - $perc = round($drive['storage_perc'], 0); - $used = formatStorage($used); - $total = formatStorage($total); - $free = formatStorage($free); + $total = $drive['storage_size']; + $used = $drive['storage_used']; + $free = $drive['storage_free']; + $perc = round($drive['storage_perc'], 0); + $used = formatStorage($used); + $total = formatStorage($total); + $free = formatStorage($free); - $fs_url = "graphs/id=".$drive['storage_id']."/type=storage_usage/"; + $fs_url = 'graphs/id='.$drive['storage_id'].'/type=storage_usage/'; - $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$drive['storage_descr']; - $fs_popup .= "
    "; - $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; + $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$drive['storage_descr']; + $fs_popup .= "
    "; + $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo(""); + echo "'; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; - echo(""); + echo ''; - $row++; -} + $row++; +}//end foreach -echo("
    Drive Usage Free
    " . $drive['storage_descr'] . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $perc . "%", "ffffff", $background['right'])." - " . $free . "
    ".$drive['storage_descr']." + ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $perc.'%', 'ffffff', $background['right']).' + '.$free.'
    "); + echo "
    "; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    "); - -?> +echo ''; diff --git a/html/pages/device/hrdevice.inc.php b/html/pages/device/hrdevice.inc.php index 68928187b..d16a0ba83 100644 --- a/html/pages/device/hrdevice.inc.php +++ b/html/pages/device/hrdevice.inc.php @@ -1,70 +1,69 @@ '); +echo ''; // FIXME missing heading +foreach (dbFetchRows('SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`', array($device['device_id'])) as $hrdevice) { + echo "'; -foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`", array($device['device_id'])) as $hrdevice) -{ - echo(""); + if ($hrdevice['hrDeviceType'] == 'hrDeviceProcessor') { + $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); + $proc_url = 'device/device='.$device['device_id'].'/tab=health/metric=processor/'; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$hrdevice['hrDeviceDescr']; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; + echo "'; - if ($hrdevice['hrDeviceType'] == "hrDeviceProcessor") - { - $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); - $proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/"; - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$hrdevice['hrDeviceDescr']; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - echo(""); + $graph_array['height'] = '20'; + $graph_array['width'] = '100'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc_id; + $graph_array['type'] = 'processor_usage'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; - $graph_array['height'] = "20"; - $graph_array['width'] = "100"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc_id; - $graph_array['type'] = 'processor_usage'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; + $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); - $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); - - echo(''); - } - elseif ($hrdevice['hrDeviceType'] == "hrDeviceNetwork") - { - $int = str_replace("network interface ", "", $hrdevice['hrDeviceDescr']); - $interface = dbFetchRow("SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?", array($device['device_id'], $int)); - if ($interface['ifIndex']) - { - echo(""); - - $graph_array['height'] = "20"; - $graph_array['width'] = "100"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $interface['port_id']; - $graph_array['type'] = 'port_bits'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; - - // FIXME click on graph should also link to port, but can't use generate_port_link here... - $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); - - echo(""); - } else { - echo(""); - echo(""); + echo ''; } - } else { - echo(""); - echo(""); - } + else if ($hrdevice['hrDeviceType'] == 'hrDeviceNetwork') { + $int = str_replace('network interface ', '', $hrdevice['hrDeviceDescr']); + $interface = dbFetchRow('SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?', array($device['device_id'], $int)); + if ($interface['ifIndex']) { + echo ''; - echo(""); - echo(""); - echo(""); -} + $graph_array['height'] = '20'; + $graph_array['width'] = '100'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $interface['port_id']; + $graph_array['type'] = 'port_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; -echo('
    ".$hrdevice['hrDeviceIndex'].'
    ".$hrdevice['hrDeviceIndex']."".$hrdevice['hrDeviceDescr'].'".$hrdevice['hrDeviceDescr']."'.$mini_graph.'".generate_port_link($interface)."$mini_graph".stripslashes($hrdevice['hrDeviceDescr'])."'.$mini_graph.'".stripslashes($hrdevice['hrDeviceDescr'])."'.generate_port_link($interface).'".$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus']."".$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad']."
    '); + // FIXME click on graph should also link to port, but can't use generate_port_link here... + $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); -$pagetitle[] = "Inventory"; + echo "$mini_graph"; + } + else { + echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; + echo ''; + } + } + else { + echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; + echo ''; + }//end if -?> + echo ''.$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus'].''; + echo ''.$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad'].''; + echo ''; +}//end foreach + +echo ''; + +$pagetitle[] = 'Inventory'; diff --git a/html/pages/device/loadbalancer/ace_rservers.inc.php b/html/pages/device/loadbalancer/ace_rservers.inc.php index 52f1773c7..c8b4b2acd 100644 --- a/html/pages/device/loadbalancer/ace_rservers.inc.php +++ b/html/pages/device/loadbalancer/ace_rservers.inc.php @@ -33,10 +33,10 @@ echo ' Graphs: '; // "pkts" => "Packets", // "errors" => "Errors"); $graph_types = array( - 'curr' => 'CurrentConns', - 'failed' => 'FailedConns', - 'total' => 'TotalConns', - ); + 'curr' => 'CurrentConns', + 'failed' => 'FailedConns', + 'total' => 'TotalConns', +); foreach ($graph_types as $type => $descr) { echo "$type_sep"; @@ -66,7 +66,8 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = if ($rserver['StateDescr'] == 'Server is now operational') { $rserver_class = 'green'; - } else { + } + else { $rserver_class = 'red'; } @@ -87,7 +88,7 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = $graph_array['id'] = $rserver['rserver_id']; $graph_array['type'] = $graph_type; - include 'includes/print-graphrow.inc.php'; + require 'includes/print-graphrow.inc.php'; // include("includes/print-interface-graphs.inc.php"); echo ' diff --git a/html/pages/device/loadbalancer/ace_vservers.inc.php b/html/pages/device/loadbalancer/ace_vservers.inc.php index 65032709c..68ebd1d3f 100644 --- a/html/pages/device/loadbalancer/ace_vservers.inc.php +++ b/html/pages/device/loadbalancer/ace_vservers.inc.php @@ -2,84 +2,101 @@ print_optionbar_start(); -echo("Serverfarms » "); +echo "Serverfarms » "; -#$auth = TRUE; +// $auth = TRUE; +$menu_options = array('basic' => 'Basic'); -$menu_options = array('basic' => 'Basic', - ); +if (!$_GET['opta']) { + $_GET['opta'] = 'basic'; +} -if (!$_GET['opta']) { $_GET['opta'] = "basic"; } +$sep = ''; +foreach ($menu_options as $option => $text) { + if ($_GET['type'] == $option) { + echo ""; + } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - if ($_GET['type'] == $option) { echo(""); } - echo(''.$text.''); - if ($_GET['type'] == $option) { echo(""); } - echo(" | "); + echo ''.$text.''; + if ($_GET['type'] == $option) { + echo ''; + } + + echo ' | '; } unset($sep); -echo(' Graphs: '); +echo ' Graphs: '; -$graph_types = array("bits" => "Bits", - "pkts" => "Packets", - "conns" => "Connections"); +$graph_types = array( + 'bits' => 'Bits', + 'pkts' => 'Packets', + 'conns' => 'Connections', +); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($_GET['opte'] == $type) { echo(""); } - echo(''.$descr.''); - echo(''.$text.''); - if ($_GET['opte'] == $type) { echo(""); } +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($_GET['opte'] == $type) { + echo ""; + } - $type_sep = " | "; + echo ''.$descr.''; + echo ''.$text.''; + if ($_GET['opte'] == $type) { + echo ''; + } + + $type_sep = ' | '; } print_optionbar_end(); -echo("
    "); -$i = "0"; -foreach (dbFetchRows("SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`", array($device['device_id'])) as $vserver) -{ -if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } +echo "
    "; +$i = '0'; +foreach (dbFetchRows('SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`', array($device['device_id'])) as $vserver) { + if (is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } -if($vserver['serverstate'] == "inService") { $vserver_class="green"; } else { $vserver_class="red"; } + if ($vserver['serverstate'] == 'inService') { + $vserver_class = 'green'; + } + else { + $vserver_class = 'red'; + } -echo(""); -#echo(""); -echo(""); -#echo(""); -echo(""); -echo(""); - if ($_GET['type'] == "graphs") - { - echo(''); - echo(""; + // echo(""); + echo ''; + // echo(""); + echo "'; + echo ''; + if ($_GET['type'] == 'graphs') { + echo ''; + echo ' - "); - } + echo ' + + '; + } -echo(""); -echo(""); + echo ''; + echo ''; - $i++; -} + $i++; +}//end foreach -echo("
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "" . $vserver['classmap'] . "" . $rserver['farm_id'] . "" . $vserver['serverstate'] . "
    "); - $graph_type = "vserver_" . $_GET['opte']; + echo "
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "'.$vserver['classmap'].'" . $rserver['farm_id'] . "".$vserver['serverstate'].'
    '; + $graph_type = 'vserver_'.$_GET['opte']; -$graph_array['height'] = "100"; -$graph_array['width'] = "215"; -$graph_array['to'] = $config['time']['now']; -$graph_array['id'] = $vserver['classmap_id']; -$graph_array['type'] = $graph_type; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $vserver['classmap_id']; + $graph_array['type'] = $graph_type; -include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(" -
    "); - -?> +echo ''; diff --git a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php index a67d755b9..91abc8204 100644 --- a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php +++ b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php @@ -1,6 +1,6 @@ VServer
    » "); // echo('All'); diff --git a/html/pages/device/logs.inc.php b/html/pages/device/logs.inc.php index 0b8481a68..11fd6914b 100644 --- a/html/pages/device/logs.inc.php +++ b/html/pages/device/logs.inc.php @@ -1,41 +1,43 @@ Logging » "); +echo 'Logging » '; -if ($vars['section'] == "eventlog") { - echo(''); +if ($vars['section'] == 'eventlog') { + echo ''; } -echo(generate_link("Event Log" , $vars, array('section'=>'eventlog'))); -if ($vars['section'] == "eventlog") { - echo(""); + +echo generate_link('Event Log', $vars, array('section' => 'eventlog')); +if ($vars['section'] == 'eventlog') { + echo ''; } if (isset($config['enable_syslog']) && $config['enable_syslog'] == 1) { - echo(" | "); + echo ' | '; - if ($vars['section'] == "syslog") { - echo(''); + if ($vars['section'] == 'syslog') { + echo ''; } - echo(generate_link("Syslog" , $vars, array('section'=>'syslog'))); - if ($vars['section'] == "syslog") { - echo(""); + + echo generate_link('Syslog', $vars, array('section' => 'syslog')); + if ($vars['section'] == 'syslog') { + echo ''; } } -switch ($vars['section']) -{ - case 'syslog': - case 'eventlog': - include('pages/device/logs/'.$vars['section'].'.inc.php'); - break; - default: - print_optionbar_end(); - echo(report_this('Unknown section '.$vars['section'])); - break; -} +switch ($vars['section']) { + case 'syslog': + case 'eventlog': + include 'pages/device/logs/'.$vars['section'].'.inc.php'; + break; -?> + default: + print_optionbar_end(); + echo report_this('Unknown section '.$vars['section']); + break; +} diff --git a/html/pages/device/logs/eventlog.inc.php b/html/pages/device/logs/eventlog.inc.php index aec8bdd98..7d5204f1c 100644 --- a/html/pages/device/logs/eventlog.inc.php +++ b/html/pages/device/logs/eventlog.inc.php @@ -2,51 +2,49 @@
    +echo '
    Eventlog entries
    - '); +
    '; -foreach ($entries as $entry) -{ - include("includes/print-event.inc.php"); +foreach ($entries as $entry) { + include 'includes/print-event.inc.php'; } -echo('
    -
    '); +echo ' + '; -$pagetitle[] = "Events"; - -?> +$pagetitle[] = 'Events'; diff --git a/html/pages/device/logs/syslog.inc.php b/html/pages/device/logs/syslog.inc.php index 7aae3b8e0..1284ad157 100644 --- a/html/pages/device/logs/syslog.inc.php +++ b/html/pages/device/logs/syslog.inc.php @@ -3,53 +3,54 @@
    +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? $where"; +$sql .= ' ORDER BY timestamp DESC LIMIT 1000'; +echo '
    Syslog entries
    - '); -foreach (dbFetchRows($sql, $param) as $entry) { include("includes/print-syslog.inc.php"); } -echo('
    -
    '); -$pagetitle[] = "Syslog"; + '; +foreach (dbFetchRows($sql, $param) as $entry) { + include 'includes/print-syslog.inc.php'; +} -?> +echo '
    + '; +$pagetitle[] = 'Syslog'; diff --git a/html/pages/device/map.inc.php b/html/pages/device/map.inc.php index 522de36a5..918f62e7f 100644 --- a/html/pages/device/map.inc.php +++ b/html/pages/device/map.inc.php @@ -12,8 +12,6 @@ * the source code distribution for details. */ -$pagetitle[] = "Map"; +$pagetitle[] = 'Map'; -require_once "includes/print-map.inc.php"; - -?> +require_once 'includes/print-map.inc.php'; diff --git a/html/pages/device/munin.inc.php b/html/pages/device/munin.inc.php index 67fd22d6e..e12279687 100644 --- a/html/pages/device/munin.inc.php +++ b/html/pages/device/munin.inc.php @@ -1,75 +1,72 @@ 'device', + 'device' => $device['device_id'], + 'tab' => 'munin', +); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'munin'); +$bg = '#ffffff'; -$bg="#ffffff"; - -echo('
    '); +echo '
    '; print_optionbar_start(); -echo("Munin » "); +echo "Munin » "; -$sep = ""; +$sep = ''; -foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", array($device['device_id'])) as $mplug) -{ -# if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; +foreach (dbFetchRows('SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type', array($device['device_id'])) as $mplug) { + // if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; } -foreach ($graph_enable as $section => $nothing) -{ - if (isset($graph_enable) && is_array($graph_enable[$section])) - { - $type = strtolower($section); - if (!$vars['group']) { $vars['group'] = $type; } - echo($sep); - if ($vars['group'] == $type) - { - echo(''); +foreach ($graph_enable as $section => $nothing) { + if (isset($graph_enable) && is_array($graph_enable[$section])) { + $type = strtolower($section); + if (!$vars['group']) { + $vars['group'] = $type; + } + + echo $sep; + if ($vars['group'] == $type) { + echo ''; + } + + echo generate_link(ucwords($type), $link_array, array('group' => $type)); + if ($vars['group'] == $type) { + echo ''; + } + + $sep = ' | '; } - echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); - if ($vars['group'] == $type) - { - echo(""); - } - $sep = " | "; - } } -unset ($sep); +unset($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -#foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) -{ - $graph_array = array(); - if ($graph_enable[$graph]) - { - if (!empty($entry['plugin'])) - { - $graph_title = $entry['title']; - $graph_array['type'] = "munin_graph"; - $graph_array['device'] = $device['device_id']; - $graph_array['plugin'] = $entry['plugin']; - } else { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = "device_" . $graph; - } +// foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) { + $graph_array = array(); + if ($graph_enable[$graph]) { + if (!empty($entry['plugin'])) { + $graph_title = $entry['title']; + $graph_array['type'] = 'munin_graph'; + $graph_array['device'] = $device['device_id']; + $graph_array['plugin'] = $entry['plugin']; + } + else { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = 'device_'.$graph; + } - include("includes/print-device-graph.php"); - } + include 'includes/print-device-graph.php'; + } } -$pagetitle[] = "Graphs"; - -?> +$pagetitle[] = 'Graphs'; diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index aac3b2ca2..13227e013 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -12,8 +12,18 @@ $services['up'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WH $services['down'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_status` = '0' AND `service_ignore` = '0'", array($device['device_id'])); $services['disabled'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_ignore` = '1'", array($device['device_id'])); -if ($services['down']) { $services_colour = $warn_colour_a; } else { $services_colour = $list_colour_a; } -if ($ports['down']) { $ports_colour = $warn_colour_a; } else { $ports_colour = $list_colour_a; } +if ($services['down']) { + $services_colour = $warn_colour_a; +} +else { + $services_colour = $list_colour_a; +} +if ($ports['down']) { + $ports_colour = $warn_colour_a; +} +else { + $ports_colour = $list_colour_a; +} echo('
    @@ -25,39 +35,41 @@ echo('
    '); -include("includes/dev-overview-data.inc.php"); +require 'includes/dev-overview-data.inc.php'; Plugins::call('device_overview_container',array($device)); -include("overview/ports.inc.php"); +require 'overview/ports.inc.php'; echo('
    '); // Right Pane -include("overview/processors.inc.php"); -include("overview/mempools.inc.php"); -include("overview/storage.inc.php"); +require 'overview/processors.inc.php'; +require 'overview/mempools.inc.php'; +require 'overview/storage.inc.php'; -if(is_array($entity_state['group']['c6kxbar'])) { include("overview/c6kxbar.inc.php"); } +if(is_array($entity_state['group']['c6kxbar'])) { + require 'overview/c6kxbar.inc.php'; +} -include("overview/toner.inc.php"); -include("overview/sensors/charge.inc.php"); -include("overview/sensors/temperatures.inc.php"); -include("overview/sensors/humidity.inc.php"); -include("overview/sensors/fanspeeds.inc.php"); -include("overview/sensors/dbm.inc.php"); -include("overview/sensors/voltages.inc.php"); -include("overview/sensors/current.inc.php"); -include("overview/sensors/power.inc.php"); -include("overview/sensors/frequencies.inc.php"); -include("overview/sensors/load.inc.php"); -include("overview/sensors/state.inc.php"); -include("overview/eventlog.inc.php"); -include("overview/services.inc.php"); -include("overview/syslog.inc.php"); +require 'overview/toner.inc.php'; +require 'overview/sensors/charge.inc.php'; +require 'overview/sensors/temperatures.inc.php'; +require 'overview/sensors/humidity.inc.php'; +require 'overview/sensors/fanspeeds.inc.php'; +require 'overview/sensors/dbm.inc.php'; +require 'overview/sensors/voltages.inc.php'; +require 'overview/sensors/current.inc.php'; +require 'overview/sensors/power.inc.php'; +require 'overview/sensors/frequencies.inc.php'; +require 'overview/sensors/load.inc.php'; +require 'overview/sensors/state.inc.php'; +require 'overview/eventlog.inc.php'; +require 'overview/services.inc.php'; +require 'overview/syslog.inc.php'; echo('
    '); -#include("overview/current.inc.php"); +#require 'overview/current.inc.php"); ?> diff --git a/html/pages/device/overview/c6kxbar.inc.php b/html/pages/device/overview/c6kxbar.inc.php index 14f5d54e4..eb04e0a7d 100644 --- a/html/pages/device/overview/c6kxbar.inc.php +++ b/html/pages/device/overview/c6kxbar.inc.php @@ -1,102 +1,99 @@ -
    -
    -
    -
    '); -echo(''); -echo(" Catalyst 6k Crossbar"); -echo('
    - '); +echo '
    +
    +
    +
    +
    '; +echo ''; +echo " Catalyst 6k Crossbar"; +echo '
    +
    '; -foreach ($entity_state['group']['c6kxbar'] as $index => $entry) -{ - // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> - $entity = dbFetchRow("SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?", array($device['device_id'], $index+1)); +foreach ($entity_state['group']['c6kxbar'] as $index => $entry) { + // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> + $entity = dbFetchRow('SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?', array($device['device_id'], $index + 1)); - echo(" + echo " - - "); + echo ' + '; - foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) - { - if (is_numeric($subindex)) - { - if ($fabric['cc6kxbarModuleChannelFabStatus'] == "ok") - { - $fabric['mode_class'] = "green"; - } else { - $fabric['mode_class'] = "red"; - } + foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) { + if (is_numeric($subindex)) { + if ($fabric['cc6kxbarModuleChannelFabStatus'] == 'ok') { + $fabric['mode_class'] = 'green'; + } + else { + $fabric['mode_class'] = 'red'; + } - $percent_in = $fabric['cc6kxbarStatisticsInUtil']; - $background_in = get_percentage_colours($percent_in); + $percent_in = $fabric['cc6kxbarStatisticsInUtil']; + $background_in = get_percentage_colours($percent_in); - $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; - $background_out = get_percentage_colours($percent_out); + $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; + $background_out = get_percentage_colours($percent_out); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['mod'] = $index; - $graph_array['chan'] = $subindex; - $graph_array['type'] = "c6kxbar_util"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['mod'] = $index; + $graph_array['chan'] = $subindex; + $graph_array['type'] = 'c6kxbar_util'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $text_descr = $entity['entPhysicalName'] . " - Fabric " . $subindex; + $text_descr = $entity['entPhysicalName'].' - Fabric '.$subindex; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); + echo (' + + + - - - - - - - "); - } - } -} - -echo("
    ".$entity['entPhysicalName'].""); + "; - switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) - { - case "busmode": - # echo 'Bus'; + switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) { + case 'busmode': + // echo 'Bus'; break; - case "crossbarmode": + + case 'crossbarmode': echo 'Crossbar'; break; - case "dcefmode": + + case 'dcefmode': echo 'DCEF'; break; - default: + + default: echo $entry['']['cc6kxbarModuleModeSwitchingMode']; } - echo("
    Fabric '.$subindex." - Fabric ".$subindex."". - - $fabric['cc6kxbarModuleChannelFabStatus']."".formatRates($fabric['cc6kxbarModuleChannelSpeed']*1000000)."".overlib_link($link, $minigraph, $overlib_content)."".print_percentage_bar (125, 20, $percent_in, "Ingress", "ffffff", $background['left'], $percent_in . "%", "ffffff", $background['right'])."".print_percentage_bar (125, 20, $percent_out, "Egress", "ffffff", $background['left'], $percent_out . "%", "ffffff", $background['right'])."
    "); -echo("
    "); -echo("
    "); -echo("
    "); -echo("
    "); - -?> +echo ' '; +echo '
    '; +echo ' '; +echo ' '; +echo ''; diff --git a/html/pages/device/overview/eventlog.inc.php b/html/pages/device/overview/eventlog.inc.php index ff235aa4a..d55511813 100644 --- a/html/pages/device/overview/eventlog.inc.php +++ b/html/pages/device/overview/eventlog.inc.php @@ -1,25 +1,22 @@ '); - echo('
    +echo '
    '; +echo '
    -
    '); -echo(''); -echo(" Recent Events"); -echo('
    - '); +
    '; +echo ''; +echo " Recent Events"; +echo '
    +
    '; $eventlog = dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` WHERE `host` = ? ORDER BY `datetime` DESC LIMIT 0,10", array($device['device_id'])); -foreach ($eventlog as $entry) -{ - include("includes/print-event-short.inc.php"); +foreach ($eventlog as $entry) { + include 'includes/print-event-short.inc.php'; } -echo("
    "); -echo('
    '); -echo('
    '); -echo('
    '); -echo('
    '); - -?> +echo ''; +echo '
    '; +echo ''; +echo ''; +echo ''; diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index 6194c37c0..36bc05cd5 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -1,75 +1,71 @@ +if (count($sensors)) { + echo '
    -
    -
    -
    '); - echo(' ' . $sensor_type . ''); - echo('
    - '); - foreach ($sensors as $sensor) - { - if ($config['memcached']['enable'] === TRUE) - { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - } +
    +
    +
    '; + echo ' '.$sensor_type.''; + echo '
    +
    '; + foreach ($sensors as $sensor) { + if ($config['memcached']['enable'] === true) { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + } - if (empty($sensor['sensor_current'])) - { - $sensor['sensor_current'] = "NaN"; - } + if (empty($sensor['sensor_current'])) { + $sensor['sensor_current'] = 'NaN'; + } - // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. - // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? - // FIXME - DUPLICATED IN health/sensors + // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. + // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? + // FIXME - DUPLICATED IN health/sensors + $graph_colour = str_replace('#', '', $row_colour); - $graph_colour = str_replace("#", "", $row_colour); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $sensor['sensor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $sensor['sensor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; + foreach (array('day', 'week', 'month', 'year') as $period) { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + } - $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; - foreach (array('day','week','month','year') as $period) - { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); - } - $overlib_content .= "
    "; + $overlib_content .= '
    '; - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $graph_array['from'] = $config['time']['day']; + $sensor_minigraph = generate_graph_tag($graph_array); - $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); + $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo(" - - - - "); - } + echo ' + + + + '; + }//end foreach - echo("
    ".overlib_link($link, $sensor['sensor_descr'], $overlib_content)."".overlib_link($link, $sensor_minigraph, $overlib_content)."".overlib_link($link, " $sensor['sensor_limit'] ? "style='color: red'" : '') . '>' . $sensor['sensor_current'] . $sensor_unit . "", $overlib_content)."
    '.overlib_link($link, $sensor['sensor_descr'], $overlib_content).''.overlib_link($link, $sensor_minigraph, $overlib_content).''.overlib_link($link, ' $sensor['sensor_limit'] ? "style='color: red'" : '').'>'.$sensor['sensor_current'].$sensor_unit.'', $overlib_content).'
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} - -?> + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/mempools.inc.php b/html/pages/device/overview/mempools.inc.php index 3d35a8d55..069987241 100644 --- a/html/pages/device/overview/mempools.inc.php +++ b/html/pages/device/overview/mempools.inc.php @@ -1,76 +1,77 @@ +if (count($mempools)) { + echo '
    -
    -
    -
    -'); - echo(''); - echo(" Memory Pools"); - echo(' -
    - -'); +
    +
    +
    + '; + echo ''; + echo " Memory Pools"; + echo ' +
    +
    + '; - foreach ($mempools as $mempool) - { + foreach ($mempools as $mempool) { + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if ($debug) { + print_r($state); + } - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $mempool = array_merge($mempool, $state); } - unset($state); - } + if (is_array($state)) { + $mempool = array_merge($mempool, $state); + } - $percent= round($mempool['mempool_perc'],0); - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); - $background = get_percentage_colours($percent); + unset($state); + } - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $percent = round($mempool['mempool_perc'], 0); + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); + $background = get_percentage_colours($percent); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - echo(" - - - - "); - } + echo ' + + + + '; + }//end foreach - echo('
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." -
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' +
    + echo '
    -
    '); - -} - -?> + '; +}//end if diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 807f8ee4f..75cf3ca29 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -1,68 +1,64 @@ '); - echo('
    +if ($ports['total']) { + echo '
    '; + echo '
    Overall Traffic
    - '); +
    '; - $graph_array['height'] = "100"; - $graph_array['width'] = "485"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['type'] = "device_bits"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; - $graph = generate_graph_tag($graph_array); + $graph_array['height'] = '100'; + $graph_array['width'] = '485'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['type'] = 'device_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; + $graph = generate_graph_tag($graph_array); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width']); + $link = generate_url($link_array); - $graph_array['width'] = "210"; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - Device Traffic"); + $graph_array['width'] = '210'; + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - Device Traffic'); - echo(' - - '); + echo ' + + '; - echo(' + echo ' - - - - - '); + + + + + '; - echo(' - + "); - echo(""); - echo("
    '); - echo(overlib_link($link, $graph, $overlib_content, NULL)); - echo('
    '; + echo overlib_link($link, $graph, $overlib_content, null); + echo '
    ' . $ports['total'] . ' ' . $ports['up'] . ' ' . $ports['down'] . ' ' . $ports['disabled'] . '
    '.$ports['total'].' '.$ports['up'].' '.$ports['down'].' '.$ports['disabled'].'
    '); + echo '
    '; - $ifsep = ""; + $ifsep = ''; - foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) - { - $data = ifNameDescr($data); - $data = array_merge($data, $device); - echo("$ifsep" . generate_port_link($data, makeshortif(strtolower($data['label'])))); - $ifsep = ", "; - } + foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) { + $data = ifNameDescr($data); + $data = array_merge($data, $device); + echo "$ifsep".generate_port_link($data, makeshortif(strtolower($data['label']))); + $ifsep = ', '; + } - unset($ifsep); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} - -?> + unset($ifsep); + echo ' '; + echo ''; + echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index 3394e263c..8b4d3f291 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -1,66 +1,63 @@ +if (count($processors)) { + echo '
    -'); - echo(''); - echo(" Processors"); - echo('
    - '); +'; + echo ''; + echo " Processors"; + echo ' +
    '; - foreach ($processors as $proc) - { - $text_descr = rewrite_entity_descr($proc['processor_descr']); + foreach ($processors as $proc) { + $text_descr = rewrite_entity_descr($proc['processor_descr']); - # disable short hrDeviceDescr. need to make this prettier. - #$text_descr = short_hrDeviceDescr($proc['processor_descr']); - $percent = $proc['processor_usage']; - $background = get_percentage_colours($percent); - $graph_colour = str_replace("#", "", $row_colour); + // disable short hrDeviceDescr. need to make this prettier. + // $text_descr = short_hrDeviceDescr($proc['processor_descr']); + $percent = $proc['processor_usage']; + $background = get_percentage_colours($percent); + $graph_colour = str_replace('#', '', $row_colour); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); - - echo(" - - - + + + - "); - } + '; + }//end foreach - echo('
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    + echo '
    -
    '); - -} - -?> + '; +}//end if diff --git a/html/pages/device/overview/sensors/charge.inc.php b/html/pages/device/overview/sensors/charge.inc.php index bf4097749..b0df00968 100644 --- a/html/pages/device/overview/sensors/charge.inc.php +++ b/html/pages/device/overview/sensors/charge.inc.php @@ -1,10 +1,8 @@ +require 'pages/device/overview/generic/sensor.inc.php'; diff --git a/html/pages/device/overview/sensors/load.inc.php b/html/pages/device/overview/sensors/load.inc.php index 989a305b9..089f93dff 100644 --- a/html/pages/device/overview/sensors/load.inc.php +++ b/html/pages/device/overview/sensors/load.inc.php @@ -1,8 +1,8 @@ '); - echo('
    +if ($services['total']) { +echo '
    '; + echo '
    -
    '); - echo(" Services"); - echo('
    - '); +
    '; + echo " Services"; + echo '
    +
    '; - echo(" + echo " @@ -19,22 +18,32 @@ echo('
    ');
    -
    $services[total] $services[up] $services[disabled]
    "); +"; - foreach (dbFetchRows("SELECT * FROM services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $data) - { - if ($data['service_status'] == "0" && $data['service_ignore'] == "1") { $status = "grey"; } - if ($data['service_status'] == "1" && $data['service_ignore'] == "1") { $status = "green"; } - if ($data['service_status'] == "0" && $data['service_ignore'] == "0") { $status = "red"; } - if ($data['service_status'] == "1" && $data['service_ignore'] == "0") { $status = "blue"; } - echo("$break" . strtolower($data['service_type']) . ""); - $break = ", "; - } - echo('
    '); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} + foreach (dbFetchRows('SELECT * FROM services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $data) { + if ($data['service_status'] == '0' && $data['service_ignore'] == '1') { + $status = 'grey'; + } -?> + if ($data['service_status'] == '1' && $data['service_ignore'] == '1') { + $status = 'green'; + } + + if ($data['service_status'] == '0' && $data['service_ignore'] == '0') { + $status = 'red'; + } + + if ($data['service_status'] == '1' && $data['service_ignore'] == '0') { + $status = 'blue'; + } + + echo "$break".strtolower($data['service_type']).''; + $break = ', '; + } + + echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/storage.inc.php b/html/pages/device/overview/storage.inc.php index 01c02edb4..e81b1b5b5 100644 --- a/html/pages/device/overview/storage.inc.php +++ b/html/pages/device/overview/storage.inc.php @@ -1,91 +1,86 @@ +if (count($drives)) { + echo '
    -
    '); - echo(''); - echo(" Storage"); - echo('
    - '); +
    '; + echo ''; + echo " Storage"; + echo '
    +
    '; - foreach ($drives as $drive) - { - $skipdrive = 0; + foreach ($drives as $drive) { + $skipdrive = 0; - if ($device["os"] == "junos") - { - foreach ($config['ignore_junos_os_drives'] as $jdrive) - { - if (preg_match($jdrive, $drive["storage_descr"])) - { - $skipdrive = 1; + if ($device['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']); } - } - $drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]); - } - if ($device['os'] == "freebsd") - { - foreach ($config['ignore_bsd_os_drives'] as $jdrive) - { - if (preg_match($jdrive, $drive["storage_descr"])) - { - $skipdrive = 1; + if ($device['os'] == 'freebsd') { + foreach ($config['ignore_bsd_os_drives'] as $jdrive) { + if (preg_match($jdrive, $drive['storage_descr'])) { + $skipdrive = 1; + } + } } - } - } - if ($skipdrive) { continue; } - $percent = round($drive['storage_perc'], 0); - $total = formatStorage($drive['storage_size']); - $free = formatStorage($drive['storage_free']); - $used = formatStorage($drive['storage_used']); - $background = get_percentage_colours($percent); + if ($skipdrive) { + continue; + } - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $percent = round($drive['storage_perc'], 0); + $total = formatStorage($drive['storage_size']); + $free = formatStorage($drive['storage_free']); + $used = formatStorage($drive['storage_used']); + $background = get_percentage_colours($percent); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $drive['storage_descr']); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$drive['storage_descr']); - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - echo(" - - - + + + - "); - } + '; + }//end foreach - echo('
    ".overlib_link($link, $drive['storage_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $drive['storage_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    + echo '
    -
    '); + '; +}//end if -} - -unset ($drive_rows); - -?> +unset($drive_rows); diff --git a/html/pages/device/overview/syslog.inc.php b/html/pages/device/overview/syslog.inc.php index 1d26fbb2a..bcfb6d2c5 100644 --- a/html/pages/device/overview/syslog.inc.php +++ b/html/pages/device/overview/syslog.inc.php @@ -1,25 +1,24 @@ '); - echo('
    +if ($config['enable_syslog']) { + $syslog = dbFetchRows("SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? ORDER BY timestamp DESC LIMIT 20", array($device['device_id'])); + if (count($syslog)) { + echo '
    '; + echo '
    -
    '); - echo(' Recent Syslog'); -echo('
    - '); - foreach ($syslog as $entry) { include("includes/print-syslog.inc.php"); } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - } -} +
    '; + echo ' Recent Syslog'; + echo '
    + '; + foreach ($syslog as $entry) { + include 'includes/print-syslog.inc.php'; + } -?> + echo '
    '; + echo '
    '; + echo ''; + echo ''; + echo ''; + } +} diff --git a/html/pages/device/overview/toner.inc.php b/html/pages/device/overview/toner.inc.php index 347a63619..7c789573c 100644 --- a/html/pages/device/overview/toner.inc.php +++ b/html/pages/device/overview/toner.inc.php @@ -1,64 +1,62 @@ +if (count($toners)) { + echo '
    -
    '); - echo(''); - echo(" Toner"); - echo('
    - '); +
    '; + echo ''; + echo " Toner"; + echo '
    +
    '; - foreach ($toners as $toner) - { - $percent = round($toner['toner_current'], 0); - $total = formatStorage($toner['toner_size']); - $free = formatStorage($toner['toner_free']); - $used = formatStorage($toner['toner_used']); + foreach ($toners as $toner) { + $percent = round($toner['toner_current'], 0); + $total = formatStorage($toner['toner_size']); + $free = formatStorage($toner['toner_free']); + $used = formatStorage($toner['toner_used']); - $background = toner2colour($toner['toner_descr'], $percent); + $background = toner2colour($toner['toner_descr'], $percent); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $toner['toner_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $toner['toner_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $toner['toner_descr']); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$toner['toner_descr']); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); - - echo(" - - - + + + - "); - } + '; + }//end foreach - echo("
    ".overlib_link($link, $toner['toner_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $toner['toner_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); -} + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if -unset ($toner_rows); - -?> +unset($toner_rows); diff --git a/html/pages/device/performance.inc.php b/html/pages/device/performance.inc.php index 8686bf803..da2056c54 100644 --- a/html/pages/device/performance.inc.php +++ b/html/pages/device/performance.inc.php @@ -21,7 +21,9 @@ */ -if(!isset($vars['section'])) { $vars['section'] = "performance"; } +if(!isset($vars['section'])) { + $vars['section'] = "performance"; +} if (empty($vars['dtpickerfrom'])) { $vars['dtpickerfrom'] = date($config['dateformat']['byminute'], time() - 3600 * 24 * 2); @@ -57,7 +59,8 @@ if (empty($vars['dtpickerto'])) { if (is_admin() === true || is_read() === true) { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf` WHERE `device_id` = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); -} else { +} +else { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf`,`devices_perms` WHERE `device_id` = ? AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $_SESSION['user_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); } @@ -81,7 +84,7 @@ foreach(dbFetchRows($query, $param) as $return_value) { $avg = $return_value['avg']; if ($max > $max_val) { - $max_val = $max; + $max_val = $max; } $data[] = array('x' => $date,'y' => $loss,'group' => 0); @@ -186,4 +189,3 @@ echo $milisec_diff; var graph2d = new vis.Graph2d(container, items, groups, options); - diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index ecb25cfd2..a70d40a76 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -1,15 +1,22 @@ get('port-'.$port['port_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $port = array_merge($port, $state); } - unset($state); +if ($config['memcached']['enable'] === true) { + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if ($debug) { + print_r($state); + } + + if (is_array($state)) { + $port = array_merge($port, $state); + } + + unset($state); } $port_details = 1; @@ -17,148 +24,218 @@ $port_details = 1; $hostname = $device['hostname']; $hostid = $device['port_id']; $ifname = $port['ifDescr']; -$ifIndex = $port['ifIndex']; -$speed = humanspeed($port['ifSpeed']); +$ifIndex = $port['ifIndex']; +$speed = humanspeed($port['ifSpeed']); $ifalias = $port['name']; -if ($port['ifPhysAddress']) { $mac = "$port[ifPhysAddress]"; } +if ($port['ifPhysAddress']) { + $mac = "$port[ifPhysAddress]"; +} -$color = "black"; -if ($port['ifAdminStatus'] == "down") { $status = "Disabled"; } -if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } -if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } +$color = 'black'; +if ($port['ifAdminStatus'] == 'down') { + $status = "Disabled"; +} -$i = 1; +if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { + $status = "Enabled / Disconnected"; +} + +if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { + $status = "Enabled / Connected"; +} + +$i = 1; $inf = fixifName($ifname); -$bg="#ffffff"; +$bg = '#ffffff'; $show_all = 1; -echo("
    "); +echo "
    "; -include("includes/print-interface.inc.php"); +require 'includes/print-interface.inc.php'; -echo("
    "); +echo ''; -$pos = strpos(strtolower($ifname), "vlan"); -if ($pos !== false ) -{ - $broke = yes; +$pos = strpos(strtolower($ifname), 'vlan'); +if ($pos !== false) { + $broke = yes; } -$pos = strpos(strtolower($ifname), "loopback"); +$pos = strpos(strtolower($ifname), 'loopback'); -if ($pos !== false ) -{ - $broke = yes; +if ($pos !== false) { + $broke = yes; } -echo("
    "); +echo "
    "; print_optionbar_start(); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'port', - 'port' => $port['port_id']); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'port', + 'port' => $port['port_id'], +); $menu_options['graphs'] = 'Graphs'; -$menu_options['realtime'] = 'Real time'; // FIXME CONDITIONAL -$menu_options['arp'] = 'ARP Table'; -$menu_options['events'] = 'Eventlog'; +$menu_options['realtime'] = 'Real time'; +// FIXME CONDITIONAL +$menu_options['arp'] = 'ARP Table'; +$menu_options['events'] = 'Eventlog'; -if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'") ) -{ $menu_options['adsl'] = 'ADSL'; } - -if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'") ) -{ $menu_options['pagp'] = 'PAgP'; } - -if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'") ) -{ $menu_options['vlans'] = 'VLANs'; } - -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text,$link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - $sep = " | "; +if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'")) { + $menu_options['adsl'] = 'ADSL'; } + +if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'")) { + $menu_options['pagp'] = 'PAgP'; +} + +if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'")) { + $menu_options['vlans'] = 'VLANs'; +} + +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; +} + unset($sep); -if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > "0" ) -{ +if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > '0') { + echo generate_link($descr, $link_array, array('view' => 'macaccounting', 'graph' => $type)); - echo(generate_link($descr,$link_array,array('view'=>'macaccounting','graph'=>$type))); + echo ' | Mac Accounting : '; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { + echo ""; + } - echo(" | Mac Accounting : "); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } - echo(generate_link("Bits",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } + echo generate_link('Bits', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { + echo ''; + } - echo("("); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } - echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } - echo('|'); + echo '('; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { + echo ""; + } - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } - echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } - echo(") | "); + echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { + echo ''; + } - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } - echo(generate_link("Packets",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } - echo("("); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } - echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } - echo('|'); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } - echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } - echo(")"); -} + echo '|'; -if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > "0" ) -{ + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { + echo ""; + } - // FIXME ATM VPs - // FIXME URLs BROKEN + echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { + echo ''; + } - echo(" | ATM VPs : "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo("Bits"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "packets") { echo(""); } - echo("Packets"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "cells") { echo(""); } - echo("Cells"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "errors") { echo(""); } - echo("Errors"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } -} + echo ') | '; -if ($_SESSION['userlevel'] >= '10') -{ - echo(" Create Bill"); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { + echo ""; + } + + echo generate_link('Packets', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { + echo ''; + } + + echo '('; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { + echo ""; + } + + echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { + echo ''; + } + + echo '|'; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { + echo ""; + } + + echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { + echo ''; + } + + echo ')'; +}//end if + +if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > '0') { + // FIXME ATM VPs + // FIXME URLs BROKEN + echo ' | ATM VPs : '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ""; + } + + echo "Bits"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'packets') { + echo ""; + } + + echo "Packets"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'cells') { + echo ""; + } + + echo "Cells"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'errors') { + echo ""; + } + + echo "Errors"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } +}//end if + +if ($_SESSION['userlevel'] >= '10') { + echo " Create Bill"; } print_optionbar_end(); -echo("
    "); +echo "
    "; -include("pages/device/port/".mres($vars['view']).".inc.php"); +require 'pages/device/port/'.mres($vars['view']).'.inc.php'; -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/device/port/events.inc.php b/html/pages/device/port/events.inc.php index 6de49ef26..5a113fafe 100644 --- a/html/pages/device/port/events.inc.php +++ b/html/pages/device/port/events.inc.php @@ -1,15 +1,12 @@ '); +echo ''; -foreach ($entries as $entry) -{ - include("includes/print-event.inc.php"); +foreach ($entries as $entry) { + include 'includes/print-event.inc.php'; } -echo('
    '); +echo ''; -$pagetitle[] = "Events"; - -?> +$pagetitle[] = 'Events'; diff --git a/html/pages/device/port/pagp.inc.php b/html/pages/device/port/pagp.inc.php index e64437e2c..7a8e41ff5 100644 --- a/html/pages/device/port/pagp.inc.php +++ b/html/pages/device/port/pagp.inc.php @@ -3,34 +3,32 @@ global $config; // FIXME functions! - -if (!$graph_type) { $graph_type = "pagp_bits"; } - -$daily_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100"; -$daily_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - -$weekly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=215&height=100"; -$weekly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=500&height=150"; - -$monthly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=215&height=100"; -$monthly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=500&height=150"; - -$yearly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=215&height=100"; -$yearly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=500&height=150"; - -echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "); - -foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) -{ - echo("$br " . generate_port_link($member) . " (PAgP)"); - $br = "
    "; +if (!$graph_type) { + $graph_type = 'pagp_bits'; } -?> +$daily_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=215&height=100'; +$daily_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$weekly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=215&height=100'; +$weekly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$monthly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=215&height=100'; +$monthly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$yearly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=215&height=100'; +$yearly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=500&height=150'; + +echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "; + +foreach (dbFetchRows('SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?', array($port['ifIndex'], $device['device_id'])) as $member) { + echo "$br ".generate_port_link($member).' (PAgP)'; + $br = '
    '; +} diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index b254b376d..dc941e246 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -1,15 +1,23 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'ports'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'ports', +); print_optionbar_start(); @@ -17,110 +25,136 @@ $menu_options['basic'] = 'Basic'; $menu_options['details'] = 'Details'; $menu_options['arp'] = 'ARP Table'; -if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) -{ - $menu_options['neighbours'] = 'Neighbours'; -} -if(dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) -{ - $menu_options['adsl'] = 'ADSL'; +if (dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) { + $menu_options['neighbours'] = 'Neighbours'; } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text,$link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - $sep = " | "; +if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) { + $menu_options['adsl'] = 'ADSL'; +} + +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); -echo(' | Graphs: '); +echo ' | Graphs: '; -$graph_types = array("bits" => "Bits", - "upkts" => "Unicast Packets", - "nupkts" => "Non-Unicast Packets", - "errors" => "Errors", - "etherlike" => "Etherlike"); +$graph_types = array( + 'bits' => 'Bits', + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors', + 'etherlike' => 'Etherlike', +); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } - echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type))); - if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($vars['graph'] == $type && $vars['view'] == 'graphs') { + echo ""; + } - echo(' ('); - if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } - echo(generate_link('Mini',$link_array,array('view'=>'minigraphs','graph'=>$type))); - if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } - echo(')'); - $type_sep = " | "; -} + echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type)); + if ($vars['graph'] == $type && $vars['view'] == 'graphs') { + echo ''; + } + + echo ' ('; + if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { + echo ""; + } + + echo generate_link('Mini', $link_array, array('view' => 'minigraphs', 'graph' => $type)); + if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { + echo ''; + } + + echo ')'; + $type_sep = ' | '; +}//end foreach print_optionbar_end(); -if ($vars['view'] == 'minigraphs') -{ - $timeperiods = array('-1day','-1week','-1month','-1year'); - $from = '-1day'; - echo("
    "); - unset ($seperator); +if ($vars['view'] == 'minigraphs') { + $timeperiods = array( + '-1day', + '-1week', + '-1month', + '-1year', + ); + $from = '-1day'; + echo "
    "; + unset($seperator); - // FIXME - FIX THIS. UGLY. - foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $port) - { - echo("
    -
    ".makeshortif($port['ifDescr'])."
    - ".$device['hostname']." - ".$port['ifDescr']."
    \ - ".$port['ifAlias']." \ - \ - ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " - -
    ".truncate(short_port_descr($port['ifAlias']), 32, '')."
    -
    "); - } - echo("
    "); -} elseif ($vars['view'] == "arp" || $vars['view'] == "adsl" || $vars['view'] == "neighbours") { - include("ports/".$vars['view'].".inc.php"); -} else { - if ($vars['view'] == "details") { $port_details = 1; } - echo("
    "); - $i = "1"; - - global $port_cache, $port_index_cache; - - $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); - // As we've dragged the whole database, lets pre-populate our caches :) - // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. - foreach ($ports as $port) - { - $port_cache[$port['port_id']] = $port; - $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; - } - - foreach ($ports as $port) - { - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('port-'.$port['port_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $port = array_merge($port, $state); } - unset($state); + // FIXME - FIX THIS. UGLY. + foreach (dbFetchRows('select * from ports WHERE device_id = ? ORDER BY ifIndex', array($device['device_id'])) as $port) { + echo "
    +
    ".makeshortif($port['ifDescr']).'
    + ".$device['hostname'].' - '.$port['ifDescr'].'
    \ + '.$port['ifAlias']." \ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"." + +
    ".truncate(short_port_descr($port['ifAlias']), 32, '').'
    + '; } - include("includes/print-interface.inc.php"); - - $i++; - } - echo("
    "); + echo '
    '; } +else if ($vars['view'] == 'arp' || $vars['view'] == 'adsl' || $vars['view'] == 'neighbours') { + include 'ports/'.$vars['view'].'.inc.php'; +} +else { + if ($vars['view'] == 'details') { + $port_details = 1; + } -$pagetitle[] = "Ports"; + echo "
    "; + $i = '1'; -?> + global $port_cache, $port_index_cache; + + $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); + // As we've dragged the whole database, lets pre-populate our caches :) + // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. + foreach ($ports as $port) { + $port_cache[$port['port_id']] = $port; + $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; + } + + foreach ($ports as $port) { + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if ($debug) { + print_r($state); + } + + if (is_array($state)) { + $port = array_merge($port, $state); + } + + unset($state); + } + + include 'includes/print-interface.inc.php'; + + $i++; + } + + echo '
    '; +}//end if + +$pagetitle[] = 'Ports'; diff --git a/html/pages/device/ports/neighbours.inc.php b/html/pages/device/ports/neighbours.inc.php index 5e417eb99..b56136881 100644 --- a/html/pages/device/ports/neighbours.inc.php +++ b/html/pages/device/ports/neighbours.inc.php @@ -10,8 +10,7 @@ echo 'Local Port Protocol '; -foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) -{ +foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) { if ($bg_colour == $list_colour_b) { $bg_colour = $list_colour_a; } diff --git a/html/pages/device/processes.inc.php b/html/pages/device/processes.inc.php index 41fda9288..0ce8e4c70 100644 --- a/html/pages/device/processes.inc.php +++ b/html/pages/device/processes.inc.php @@ -1,19 +1,21 @@ +/* + * Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * Process Listing * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -22,77 +24,89 @@ * @subpackage Pages */ -switch( $vars['order'] ) { - case "vsz": - $order = "`vsz`"; - break; - case "rss": - $order = "`rss`"; - break; - case "cputime": - $order = "`cputime`"; - break; - case "user": - $order = "`user`"; - break; - case "command": - $order = "`command`"; - break; - default: - $order = "`pid`"; - break; +switch ($vars['order']) { + case 'vsz': + $order = '`vsz`'; + break; + + case 'rss': + $order = '`rss`'; + break; + + case 'cputime': + $order = '`cputime`'; + break; + + case 'user': + $order = '`user`'; + break; + + case 'command': + $order = '`command`'; + break; + + default: + $order = '`pid`'; + break; +}//end switch + +if ($vars['by'] == 'desc') { + $by = 'desc'; } -if( $vars['by'] == "desc" ) { - $by = "desc"; -} else { - $by = "asc"; +else { + $by = 'asc'; } $heads = array( - 'PID' => '', - 'VSZ' => 'Virtual Memory', - 'RSS' => 'Resident Memory', - 'cputime' => '', - 'user' => '', - 'command' => '' + 'PID' => '', + 'VSZ' => 'Virtual Memory', + 'RSS' => 'Resident Memory', + 'cputime' => '', + 'user' => '', + 'command' => '', ); echo "
    "; -foreach( $heads as $head=>$extra ) { - unset($lhead, $bhead); - $lhead = strtolower($head); - $bhead = 'asc'; - $icon = ""; - if( '`'.$lhead.'`' == $order ) { - $icon = " class='glyphicon glyphicon-chevron-"; - if( $by == 'asc' ) { - $bhead = 'desc'; - $icon .= 'up'; - } else { - $icon .= 'down'; - } - $icon .= "'"; - } - echo ''; -} -echo ""; +foreach ($heads as $head => $extra) { + unset($lhead, $bhead); + $lhead = strtolower($head); + $bhead = 'asc'; + $icon = ''; + if ('`'.$lhead.'`' == $order) { + $icon = " class='glyphicon glyphicon-chevron-"; + if ($by == 'asc') { + $bhead = 'desc'; + $icon .= 'up'; + } + else { + $icon .= 'down'; + } -foreach (dbFetchRows("SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY ".$order." ".$by, array($device['device_id'])) as $entry) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; -} -echo"
     '; - if( !empty($extra) ) { - echo "$head"; - } else { - echo $head; - } - echo '
    '.$entry['pid'].''.format_si($entry['vsz']*1024).''.format_si($entry['rss']*1024).''.$entry['cputime'].''.$entry['user'].''.$entry['command'].'
    "; + $icon .= "'"; + } -?> + echo ' '; + if (!empty($extra)) { + echo "$head"; + } + else { + echo $head; + } + + echo ''; +}//end foreach + +echo ''; + +foreach (dbFetchRows('SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY '.$order.' '.$by, array($device['device_id'])) as $entry) { + echo ''; + echo ''.$entry['pid'].''; + echo ''.format_si(($entry['vsz'] * 1024)).''; + echo ''.format_si(($entry['rss'] * 1024)).''; + echo ''.$entry['cputime'].''; + echo ''.$entry['user'].''; + echo ''.$entry['command'].''; + echo ''; +} + +echo '
    '; diff --git a/html/pages/device/pseudowires.inc.php b/html/pages/device/pseudowires.inc.php index c134c8b66..c48bca573 100644 --- a/html/pages/device/pseudowires.inc.php +++ b/html/pages/device/pseudowires.inc.php @@ -89,8 +89,7 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I WHERE P.port_id 'upkts', 'errors', ); - foreach ($types as $graph_type) - { + foreach ($types as $graph_type) { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index 5b327aca3..17f0629a0 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -1,203 +1,275 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'routing', - 'proto' => 'bgp'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'routing', + 'proto' => 'bgp', +); -if(!isset($vars['view'])) { $vars['view'] = "basic"; } +if (!isset($vars['view'])) { + $vars['view'] = 'basic'; +} print_optionbar_start(); -echo "Local AS : " .$device['bgpLocalAs']." "; +echo 'Local AS : '.$device['bgpLocalAs'].' '; -echo("BGP » "); +echo "BGP » "; -if ($vars['view'] == "basic") { echo(""); } -echo(generate_link("Basic", $link_array,array('view'=>'basic'))); -if ($vars['view'] == "basic") { echo(""); } +if ($vars['view'] == 'basic') { + echo ""; +} -echo(" | "); +echo generate_link('Basic', $link_array, array('view' => 'basic')); +if ($vars['view'] == 'basic') { + echo ''; +} -if ($vars['view'] == "updates") { echo(""); } -echo(generate_link("Updates", $link_array,array('view'=>'updates'))); -if ($vars['view'] == "updates") { echo(""); } +echo ' | '; -echo(" | Prefixes: "); +if ($vars['view'] == 'updates') { + echo ""; +} -if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } -echo(generate_link("IPv4", $link_array,array('view'=>'prefixes_ipv4unicast'))); -if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } +echo generate_link('Updates', $link_array, array('view' => 'updates')); +if ($vars['view'] == 'updates') { + echo ''; +} -echo(" | "); +echo ' | Prefixes: '; -if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } -echo(generate_link("VPNv4", $link_array,array('view'=>'prefixes_vpnv4unicast'))); -if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } +if ($vars['view'] == 'prefixes_ipv4unicast') { + echo ""; +} -echo(" | "); +echo generate_link('IPv4', $link_array, array('view' => 'prefixes_ipv4unicast')); +if ($vars['view'] == 'prefixes_ipv4unicast') { + echo ''; +} -if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } -echo(generate_link("IPv6", $link_array,array('view'=>'prefixes_ipv6unicast'))); -if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } +echo ' | '; -echo(" | Traffic: "); +if ($vars['view'] == 'prefixes_vpnv4unicast') { + echo ""; +} -if ($vars['view'] == "macaccounting_bits") { echo(""); } -echo(generate_link("Bits", $link_array,array('view'=>'macaccounting_bits'))); -if ($vars['view'] == "macaccounting_bits") { echo(""); } -echo(" | "); -if ($vars['view'] == "macaccounting_pkts") { echo(""); } -echo(generate_link("Packets", $link_array,array('view'=>'macaccounting_pkts'))); -if ($vars['view'] == "macaccounting_pkts") { echo(""); } +echo generate_link('VPNv4', $link_array, array('view' => 'prefixes_vpnv4unicast')); +if ($vars['view'] == 'prefixes_vpnv4unicast') { + echo ''; +} + +echo ' | '; + +if ($vars['view'] == 'prefixes_ipv6unicast') { + echo ""; +} + +echo generate_link('IPv6', $link_array, array('view' => 'prefixes_ipv6unicast')); +if ($vars['view'] == 'prefixes_ipv6unicast') { + echo ''; +} + +echo ' | Traffic: '; + +if ($vars['view'] == 'macaccounting_bits') { + echo ""; +} + +echo generate_link('Bits', $link_array, array('view' => 'macaccounting_bits')); +if ($vars['view'] == 'macaccounting_bits') { + echo ''; +} + +echo ' | '; +if ($vars['view'] == 'macaccounting_pkts') { + echo ""; +} + +echo generate_link('Packets', $link_array, array('view' => 'macaccounting_pkts')); +if ($vars['view'] == 'macaccounting_pkts') { + echo ''; +} print_optionbar_end(); -echo(''); -echo(''); +echo '
    Peer addressTypeRemote ASStateUptime
    '; +echo ''; -$i = "1"; +$i = '1'; -foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`", array($device['device_id'])) as $peer) -{ - $has_macaccounting = dbFetchCell("SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address", array($peer['bgpPeerIdentifier'])); - unset($bg_image); - if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - unset ($alert, $bg_image); - unset ($peerhost, $peername); +foreach (dbFetchRows('SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`', array($device['device_id'])) as $peer) { + $has_macaccounting = dbFetchCell('SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address', array($peer['bgpPeerIdentifier'])); + unset($bg_image); + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } - if (!is_integer($i/2)) { $bg_colour = $list_colour_b; } else { $bg_colour = $list_colour_a; } - if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } - if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } - if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } + unset($alert, $bg_image); + unset($peerhost, $peername); - if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; } + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_b; + } + else { + $bg_colour = $list_colour_a; + } - $query = "SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE "; - $query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; - $query .= " AND D.device_id = I.device_id"; - $ipv4_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); + if ($peer['bgpPeerState'] == 'established') { + $col = 'green'; + } + else { + $col = 'red'; + $peer['alert'] = 1; + } - $query = "SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE "; - $query .= "(A.ipv6_address = ? AND I.port_id = A.port_id)"; - $query .= " AND D.device_id = I.device_id"; - $ipv6_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); + if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { + $admin_col = 'green'; + } + else { + $admin_col = 'gray'; + } - if ($ipv4_host) - { - $peerhost = $ipv4_host; - } elseif ($ipv6_host) { - $peerhost = $ipv6_host; - } else { - unset($peerhost); - } + if ($peer['bgpPeerAdminStatus'] == 'stop') { + $peer['alert'] = 0; + $peer['disabled'] = 1; + } - if (is_array($peerhost)) - { - #$peername = generate_device_link($peerhost); - $peername = generate_device_link($peerhost) ." ". generate_port_link($peerhost); - $peer_url = "device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/view=updates/"; - } - else - { - #$peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? -# if ($peername == $peer['bgpPeerIdentifier']) -# { -# unset($peername); -# } else { -# $peername = "".$peername.""; -# } - } + if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { + $peer_type = "iBGP"; + } + else { + $peer_type = "eBGP"; + } - unset($peer_af); - unset($sep); + $query = 'SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE '; + $query .= '(A.ipv4_address = ? AND I.port_id = A.port_id)'; + $query .= ' AND D.device_id = I.device_id'; + $ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); - foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) - { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep . $afi .".".$safi; - $sep = "
    "; - $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer - } + $query = 'SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE '; + $query .= '(A.ipv6_address = ? AND I.port_id = A.port_id)'; + $query .= ' AND D.device_id = I.device_id'; + $ipv6_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); - unset($sep); + if ($ipv4_host) { + $peerhost = $ipv4_host; + } + else if ($ipv6_host) { + $peerhost = $ipv6_host; + } + else { + unset($peerhost); + } - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } + if (is_array($peerhost)) { + // $peername = generate_device_link($peerhost); + $peername = generate_device_link($peerhost).' '.generate_port_link($peerhost); + $peer_url = 'device/device='.$peer['device_id'].'/tab=routing/proto=bgp/view=updates/'; + } + else { + // FIXME + // $peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? + // if ($peername == $peer['bgpPeerIdentifier']) + // { + // unset($peername); + // } else { + // $peername = "".$peername.""; + // } + } + + unset($peer_af); + unset($sep); + + foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep.$afi.'.'.$safi; + $sep = '
    '; + $peer['afisafi'][$this_afisafi] = 1; + // Build a list of valid AFI/SAFI for this peer + } + + unset($sep); + + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } - $graph_type = "bgp_updates"; - $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpPeerIdentifier'] . ""; + $graph_type = 'bgp_updates'; + $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer['bgpPeerIdentifier'].''; - echo('
    - "); + echo ' + '; - echo(" - - - - - - - - "); + echo ' + + + + + + + + '; - unset($invalid); + unset($invalid); - switch ($vars['view']) - { + switch ($vars['view']) { case 'prefixes_ipv4unicast': case 'prefixes_ipv4multicast': case 'prefixes_ipv4vpn': case 'prefixes_ipv6unicast': case 'prefixes_ipv6multicast': - list(,$afisafi) = explode("_", $vars['view']); - if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } - // FIXME no break?? - case 'updates': - $graph_array['type'] = "bgp_" . $vars['view']; - $graph_array['id'] = $peer['bgpPeer_id']; - } + list(,$afisafi) = explode('_', $vars['view']); + if (isset($peer['afisafi'][$afisafi])) { + $peer['graph'] = 1; + } - switch ($vars['view']) - { + // FIXME no break?? + case 'updates': + $graph_array['type'] = 'bgp_'.$vars['view']; + $graph_array['id'] = $peer['bgpPeer_id']; + } + + switch ($vars['view']) { case 'macaccounting_bits': case 'macaccounting_pkts': - $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - if (is_array($acc) && is_file($database)) - { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['view']; - } - } + $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; + if (is_array($acc) && is_file($database)) { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['view']; + } + } - if ($vars['view'] == 'updates') { $peer['graph'] = 1; } + if ($vars['view'] == 'updates') { + $peer['graph'] = 1; + } - if ($peer['graph']) - { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - echo('"); - } + echo ''; + } - $i++; + $i++; - unset($valid_afi_safi); -} + unset($valid_afi_safi); +}//end foreach ?>
    Peer addressTypeRemote ASStateUptime
    ".$i."" . $peeraddresslink . "
    ".$peername."
    $peer_type" . (isset($peer['afi']) ? $peer['afi'] : '') . "AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    - Updates " . $peer['bgpPeerInUpdates'] . " - " . $peer['bgpPeerOutUpdates'] . "
    '.$i.''.$peeraddresslink.'
    '.$peername."
    $peer_type".(isset($peer['afi']) ? $peer['afi'] : '').'AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']."
    ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    + Updates ".$peer['bgpPeerInUpdates']." + ".$peer['bgpPeerOutUpdates'].'
    '); + if ($peer['graph']) { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + echo '
    '; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    diff --git a/html/pages/device/routing/ospf.inc.php b/html/pages/device/routing/ospf.inc.php index ed126a7fe..7bf6798b7 100644 --- a/html/pages/device/routing/ospf.inc.php +++ b/html/pages/device/routing/ospf.inc.php @@ -88,8 +88,7 @@ foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', arr // # Loop Ports $i_p = ($i_a + 1); $p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id"; - foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) - { + foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) { if (!is_integer($i_a / 2)) { if (!is_integer($i_p / 2)) { $port_bg = $list_colour_b_b; diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index aed9398dd..9efc95d63 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -1,134 +1,135 @@ = '7') { + if (!is_array($config['rancid_configs'])) { + $config['rancid_configs'] = array($config['rancid_configs']); + } -if ($_SESSION['userlevel'] >= "7") -{ + if (isset($config['rancid_configs'][0])) { + foreach ($config['rancid_configs'] as $configs) { + if ($configs[(strlen($configs) - 1)] != '/') { + $configs .= '/'; + } - if (!is_array($config['rancid_configs'])) { $config['rancid_configs'] = array($config['rancid_configs']); } + if (is_file($configs.$device['hostname'])) { + $file = $configs.$device['hostname']; + } + } - if (isset($config['rancid_configs'][0])) { + echo '
    '; - foreach ($config['rancid_configs'] as $configs) { - if ($configs[strlen($configs) - 1] != '/') { - $configs .= '/'; - } - if (is_file($configs . $device['hostname'])) { - $file = $configs . $device['hostname']; - } - } + print_optionbar_start('', ''); - echo('
    '); + echo "Config » "; - print_optionbar_start('', ''); + if (!$vars['rev']) { + echo ''; + echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); + echo ''; + } + else { + echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); + } - echo("Config » "); + if (function_exists('svn_log')) { + $sep = ' | '; + $svnlogs = svn_log($file, SVN_REVISION_HEAD, null, 8); + $revlist = array(); - if (!$vars['rev']) { - echo(''); - echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); - echo(""); - } else { - echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); - } + foreach ($svnlogs as $svnlog) { + echo $sep; + $revlist[] = $svnlog['rev']; - if (function_exists('svn_log')) { + if ($vars['rev'] == $svnlog['rev']) { + echo ''; + } - $sep = " | "; - $svnlogs = svn_log($file, SVN_REVISION_HEAD, NULL, 8); - $revlist = array(); + $linktext = 'r'.$svnlog['rev'].' '.date($config['dateformat']['byminute'], strtotime($svnlog['date'])).''; + echo generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog['rev'])); - foreach ($svnlogs as $svnlog) { + if ($vars['rev'] == $svnlog['rev']) { + echo ''; + } - echo($sep); - $revlist[] = $svnlog["rev"]; + $sep = ' | '; + } + }//end if - if ($vars['rev'] == $svnlog["rev"]) { - echo(''); - } - $linktext = "r" . $svnlog["rev"] . " " . date($config['dateformat']['byminute'], strtotime($svnlog["date"])) . ""; - echo(generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog["rev"]))); + print_optionbar_end(); - if ($vars['rev'] == $svnlog["rev"]) { - echo(""); - } + if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { + list($diff, $errors) = svn_diff($file, ($vars['rev'] - 1), $file, $vars['rev']); + if (!$diff) { + $text = 'No Difference'; + } + else { + $text = ''; + while (!feof($diff)) { + $text .= fread($diff, 8192); + } - $sep = " | "; - } - } + fclose($diff); + fclose($errors); + } + } + else { + $fh = fopen($file, 'r') or die("Can't open file"); + $text = fread($fh, filesize($file)); + fclose($fh); + } - print_optionbar_end(); + if ($config['rancid_ignorecomments']) { + $lines = explode("\n", $text); + for ($i = 0; $i < count($lines); $i++) { + if ($lines[$i][0] == '#') { + unset($lines[$i]); + } + } - if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { - list($diff, $errors) = svn_diff($file, $vars['rev'] - 1, $file, $vars['rev']); - if (!$diff) { - $text = "No Difference"; - } else { - $text = ""; - while (!feof($diff)) { - $text .= fread($diff, 8192); - } - fclose($diff); - fclose($errors); - } + $text = join("\n", $lines); + } + } + else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) { + $node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true); + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['hostname']); + if ($text == 'node not found') { + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['os'].'/'.$device['hostname']); + } - } else { - $fh = fopen($file, 'r') or die("Can't open file"); - $text = fread($fh, filesize($file)); - fclose($fh); - } - - if ($config['rancid_ignorecomments']) { - $lines = explode("\n", $text); - for ($i = 0; $i < count($lines); $i++) { - if ($lines[$i][0] == "#") { - unset($lines[$i]); - } - } - $text = join("\n", $lines); - } - } elseif ($config['oxidized']['enabled'] === TRUE && isset($config['oxidized']['url'])) { - $node_info = json_decode(file_get_contents($config['oxidized']['url']."/node/show/".$device['hostname']."?format=json"),TRUE); - $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['hostname']); - if ($text == "node not found") { - $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['os']."/".$device['hostname']); - } - - if (is_array($node_info)) { - echo('
    -
    + if (is_array($node_info)) { + echo '
    +
    -
    -
    Sync status: '.$node_info['last']['status'].'
    -
      -
    • Node: '. $node_info['name'].'
    • -
    • IP: '. $node_info['ip'].'
    • -
    • Model: '. $node_info['model'].'
    • -
    • Last Sync: '. $node_info['last']['end'].'
    • -
    -
    +
    +
    Sync status: '.$node_info['last']['status'].'
    +
      +
    • Node: '.$node_info['name'].'
    • +
    • IP: '.$node_info['ip'].'
    • +
    • Model: '.$node_info['model'].'
    • +
    • Last Sync: '.$node_info['last']['end'].'
    • +
    -
    '); - } else { - echo "
    "; - print_error("We couldn't retrieve the device information from Oxidized"); - $text = ''; - } +
    +
    '; + } + else { + echo '
    '; + print_error("We couldn't retrieve the device information from Oxidized"); + $text = ''; + } + }//end if - } + if (!empty($text)) { + $language = 'ios'; + $geshi = new GeSHi($text, $language); + $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); + $geshi->set_overall_style('color: black;'); + // $geshi->set_line_style('color: #999999'); + echo $geshi->parse_code(); + } +}//end if - if (!empty($text)) { - $language = "ios"; - $geshi = new GeSHi($text, $language); - $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); - $geshi->set_overall_style('color: black;'); - #$geshi->set_line_style('color: #999999'); - echo($geshi->parse_code()); - } -} - -$pagetitle[] = "Config"; - -?> +$pagetitle[] = 'Config'; diff --git a/html/pages/device/slas.inc.php b/html/pages/device/slas.inc.php index 3cc6cbf11..587c7d743 100644 --- a/html/pages/device/slas.inc.php +++ b/html/pages/device/slas.inc.php @@ -12,7 +12,7 @@ foreach ($slas as $sla) { $sla_type = $sla['rtt_type']; if (!in_array($sla_type, $sla_types)) { - if (isset($config['sla_type_labels'][$sla_type])) { + if (isset($config['sla_type_labels'][$sla_type])) { $text = $config['sla_type_labels'][$sla_type]; } } diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index 67a8c39ed..0367b8a1c 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -2,7 +2,9 @@ // Set Defaults here -if(!isset($vars['format'])) { $vars['format'] = "list_detail"; } +if(!isset($vars['format'])) { + $vars['format'] = "list_detail"; +} $pagetitle[] = "Devices"; @@ -10,23 +12,19 @@ print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', - 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == "list_".$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) { + echo(""); + } + $sep = " | "; } ?> @@ -38,29 +36,26 @@ foreach ($menu_options as $option => $text) 'Bits', - 'processor' => 'CPU', - 'ucd_load' => 'Load', - 'mempool' => 'Memory', - 'uptime' => 'Uptime', - 'storage' => 'Storage', - 'diskio' => 'Disk I/O', - 'poller_perf' => 'Poller', - 'ping_perf' => 'Ping' - ); + 'processor' => 'CPU', + 'ucd_load' => 'Load', + 'mempool' => 'Memory', + 'uptime' => 'Uptime', + 'storage' => 'Storage', + 'diskio' => 'Disk I/O', + 'poller_perf' => 'Poller', + 'ping_perf' => 'Ping' +); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + $sep = " | "; } ?> @@ -69,21 +64,21 @@ foreach ($menu_options as $option => $text) '')).'">Restore Search'); - } else { +} +else { echo('Remove Search'); - } +} - echo(" | "); +echo(" | "); - if (isset($vars['bare']) && $vars['bare'] == "yes") - { +if (isset($vars['bare']) && $vars['bare'] == "yes") { echo('Restore Header'); - } else { +} +else { echo('Remove Header'); - } +} print_optionbar_end(); ?> @@ -94,76 +89,110 @@ print_optionbar_end(); list($format, $subformat) = explode("_", $vars['format'], 2); -if($format == "graph") -{ -$sql_param = array(); +if($format == "graph") { + $sql_param = array(); -if(isset($vars['state'])) -{ - if($vars['state'] == 'up') - { - $state = '1'; - } - elseif($vars['state'] == 'down') - { - $state = '0'; - } -} + if(isset($vars['state'])) { + if($vars['state'] == 'up') { + $state = '1'; + } + elseif($vars['state'] == 'down') { + $state = '0'; + } + } -if (!empty($vars['hostname'])) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; } -if (!empty($vars['os'])) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; } -if (!empty($vars['version'])) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; } -if (!empty($vars['hardware'])) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; } -if (!empty($vars['features'])) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; } -if (!empty($vars['type'])) { - if ($vars['type'] == 'generic') { - $where .= " AND ( type = ? OR type = '')"; $sql_param[] = $vars['type']; - } else { - $where .= " AND type = ?"; $sql_param[] = $vars['type']; - } -} -if (!empty($vars['state'])) { - $where .= " AND status= ?"; $sql_param[] = $state; - $where .= " AND disabled='0' AND `ignore`='0'"; $sql_param[] = ''; -} -if (!empty($vars['disabled'])) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; } -if (!empty($vars['ignore'])) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; } -if (!empty($vars['location']) && $vars['location'] == "Unset") { $location_filter = ''; } -if (!empty($vars['location'])) { $location_filter = $vars['location']; } -if( !empty($vars['group']) ) { - require_once('../includes/device-groups.inc.php'); - $where .= " AND ( "; - foreach( GetDevicesFromGroup($vars['group']) as $dev ) { - $where .= "device_id = ? OR "; - $sql_param[] = $dev['device_id']; - } - $where = substr($where, 0, strlen($where)-3); - $where .= " )"; -} + if (!empty($vars['hostname'])) { + $where .= " AND hostname LIKE ?"; + $sql_param[] = "%".$vars['hostname']."%"; + } + if (!empty($vars['os'])) { + $where .= " AND os = ?"; + $sql_param[] = $vars['os']; + } + if (!empty($vars['version'])) { + $where .= " AND version = ?"; + $sql_param[] = $vars['version']; + } + if (!empty($vars['hardware'])) { + $where .= " AND hardware = ?"; + $sql_param[] = $vars['hardware']; + } + if (!empty($vars['features'])) { + $where .= " AND features = ?"; + $sql_param[] = $vars['features']; + } -$query = "SELECT * FROM `devices` WHERE 1 "; + if (!empty($vars['type'])) { + if ($vars['type'] == 'generic') { + $where .= " AND ( type = ? OR type = '')"; + $sql_param[] = $vars['type']; + } + else { + $where .= " AND type = ?"; + $sql_param[] = $vars['type']; + } + } + if (!empty($vars['state'])) { + $where .= " AND status= ?"; + $sql_param[] = $state; + $where .= " AND disabled='0' AND `ignore`='0'"; + $sql_param[] = ''; + } + if (!empty($vars['disabled'])) { + $where .= " AND disabled= ?"; + $sql_param[] = $vars['disabled']; + } + if (!empty($vars['ignore'])) { + $where .= " AND `ignore`= ?"; + $sql_param[] = $vars['ignore']; + } + if (!empty($vars['location']) && $vars['location'] == "Unset") { + $location_filter = ''; + } + if (!empty($vars['location'])) { + $location_filter = $vars['location']; + } + if( !empty($vars['group']) ) { + require_once('../includes/device-groups.inc.php'); + $where .= " AND ( "; + foreach( GetDevicesFromGroup($vars['group']) as $dev ) { + $where .= "device_id = ? OR "; + $sql_param[] = $dev['device_id']; + } + $where = substr($where, 0, strlen($where)-3); + $where .= " )"; + } -if (isset($where)) { - $query .= $where; -} + $query = "SELECT * FROM `devices` WHERE 1 "; -$query .= " ORDER BY hostname"; + if (isset($where)) { + $query .= $where; + } - $row = 1; - foreach (dbFetchRows($query, $sql_param) as $device) - { - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + $query .= " ORDER BY hostname"; - if (device_permitted($device['device_id'])) - { - if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) - || $device['location'] == $location_filter)) - { - $graph_type = "device_".$subformat; + $row = 1; + foreach (dbFetchRows($query, $sql_param) as $device) { + if (is_integer($row/2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - if ($_SESSION['widescreen']) { $width=270; } else { $width=315; } + if (device_permitted($device['device_id'])) { + if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) + || $device['location'] == $location_filter)) { + $graph_type = "device_".$subformat; - echo("
    + if ($_SESSION['widescreen']) { + $width=270; + } + else { + $width=315; + } + + echo("\ \ @@ -171,11 +200,11 @@ $query .= " ORDER BY hostname"; "
    "); - } + } + } } - } - -} else { +} +else { ?> @@ -209,22 +238,23 @@ $query .= " ORDER BY hostname"; ""+ '.$config['os'][$tmp_os]['text'].'"+'); } - echo('">'.$config['os'][$tmp_os]['text'].'"+'); } -} ?> ""+ "
    "+ @@ -233,22 +263,23 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_version.'"+'); } - echo('">'.$tmp_version.'"+'); - } -} + } ?> ""+ "
    "+ @@ -257,22 +288,23 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_hardware.'"+'); } - echo('">'.$tmp_hardware.'"+'); } -} ?> ""+ @@ -282,24 +314,24 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_features.'"+'); + else { + $sql = "SELECT `features` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `features` ORDER BY `features`"; + $param[] = $_SESSION['user_id']; + } + + foreach (dbFetch($sql,$param) as $data) { + if ($data['features']) { + $tmp_features = clean_bootgrid($data['features']); + echo('""+'); + } } -} ?> ""+ @@ -311,16 +343,16 @@ foreach (dbFetch($sql,$param) as $data) '.$location.'"+'); } - echo('">'.$location.'"+'); } -} ?> ""+ ""+ @@ -329,21 +361,22 @@ foreach (getlocations() as $location) { ""+ '.ucfirst($data['type']).'"+'); } - echo('">'.ucfirst($data['type']).'"+'); } -} ?> ""+ @@ -357,9 +390,9 @@ foreach (dbFetch($sql,$param) as $data) { "

    " var grid = $("#devices").bootgrid({ @@ -400,5 +433,3 @@ var grid = $("#devices").bootgrid({ diff --git a/html/pages/editsrv.inc.php b/html/pages/editsrv.inc.php index 9c56b96d1..1c04e4510 100644 --- a/html/pages/editsrv.inc.php +++ b/html/pages/editsrv.inc.php @@ -1,35 +1,30 @@ "5") - { - include("includes/service-edit.inc.php"); + if ($_POST['confirm-editsrv']) { + if ($_SESSION['userlevel'] > '5') { + include 'includes/service-edit.inc.php'; } } - foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname") as $device) - { - $servicesform .= ""; + foreach (dbFetchRows('SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname') as $device) { + $servicesform .= "'; } - if ($updated) { print_message("Service updated!"); } + if ($updated) { + print_message('Service updated!'); + } if ($_POST['editsrv'] == 'yes') { - - require_once "includes/print-service-edit.inc.php"; - - } else { - - echo(" + include_once 'includes/print-service-edit.inc.php'; + } + else { + echo "

    Delete Service

    @@ -46,7 +41,6 @@ if (is_admin() === FALSE && is_read() === FALSE) { -
    "); - } - -} + "; + }//end if +}//end if diff --git a/html/pages/edituser.inc.php b/html/pages/edituser.inc.php index 6a9a7d283..ec2a3f1c9 100644 --- a/html/pages/edituser.inc.php +++ b/html/pages/edituser.inc.php @@ -1,167 +1,170 @@ "); +echo "
    "; -$pagetitle[] = "Edit user"; +$pagetitle[] = 'Edit user'; -if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else -{ - if ($vars['user_id'] && !$vars['edit']) - { - $user_data = dbFetchRow("SELECT * FROM users WHERE user_id = ?", array($vars['user_id'])); - echo("

    " . $user_data['realname'] . "

    Change...

    "); - // Perform actions if requested +if ($_SESSION['userlevel'] != '10') { + include 'includes/error-no-perm.inc.php'; +} +else { + if ($vars['user_id'] && !$vars['edit']) { + $user_data = dbFetchRow('SELECT * FROM users WHERE user_id = ?', array($vars['user_id'])); + echo '

    '.$user_data['realname']."

    Change...

    "; + // Perform actions if requested + if ($vars['action'] == 'deldevperm') { + if (dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { + dbDelete('devices_perms', '`device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id'])); + } + } - if ($vars['action'] == "deldevperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) - { - dbDelete('devices_perms', "`device_id` = ? AND `user_id` = ?", array($vars['device_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "adddevperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) - { - dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); - } - } - if ($vars['action'] == "delifperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) - { - dbDelete('ports_perms', "`port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "addifperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) - { - dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); - } - } - if ($vars['action'] == "delbillperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) - { - dbDelete('bill_perms', "`bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "addbillperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) - { - dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); - } - } + if ($vars['action'] == 'adddevperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { + dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); + } + } - echo('
    -
    '); + if ($vars['action'] == 'delifperm') { + if (dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { + dbDelete('ports_perms', '`port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id'])); + } + } - // Display devices this users has access to - echo("

    Device Access

    "); + if ($vars['action'] == 'addifperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { + dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); + } + } - echo("
    + if ($vars['action'] == 'delbillperm') { + if (dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { + dbDelete('bill_perms', '`bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id'])); + } + } + + if ($vars['action'] == 'addbillperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { + dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); + } + } + + echo '
    +
    '; + + // Display devices this users has access to + echo '

    Device Access

    '; + + echo "
    - "); + "; - $device_perms = dbFetchRows("SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id", array($vars['user_id'])); - foreach ($device_perms as $device_perm) - { - echo(""); - $access_list[] = $device_perm['device_id']; - $permdone = "yes"; - } + $device_perms = dbFetchRows('SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id', array($vars['user_id'])); + foreach ($device_perms as $device_perm) { + echo '"; + $access_list[] = $device_perm['device_id']; + $permdone = 'yes'; + } - echo("
    Device Action
    " . $device_perm['hostname'] . "
    '.$device_perm['hostname']."
    -
    "); + echo ' +
    '; - if (!$permdone) { echo("None Configured"); } + if (!$permdone) { + echo 'None Configured'; + } - // Display devices this user doesn't have access to - echo("

    Grant access to new device

    "); - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new device

    '; + echo " +
    - "; - $devices = dbFetchRows("SELECT * FROM `devices` ORDER BY hostname"); - foreach ($devices as $device) - { - unset($done); - foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } } - if (!$done) - { - echo(""); - } - } + $devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname'); + foreach ($devices as $device) { + unset($done); + foreach ($access_list as $ac) { + if ($ac == $device['device_id']) { + $done = 1; + } + } - echo(" + if (!$done) { + echo "'; + } + } + + echo "
    -
    "); + "; - echo("
    -
    "); - echo("

    Interface Access

    "); + echo "
    +
    "; + echo '

    Interface Access

    '; - $interface_perms = dbFetchRows("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id", array($vars['user_id'])); + $interface_perms = dbFetchRows('SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id', array($vars['user_id'])); - echo("
    + echo "
    - "); - foreach ($interface_perms as $interface_perm) - { - echo(" + "; + foreach ($interface_perms as $interface_perm) { + echo ' - "); - $ipermdone = "yes"; - } - echo("
    Interface name Action
    - ".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."". - "" . $interface_perm['ifAlias'] . " + '.$interface_perm['hostname'].' - '.$interface_perm['ifDescr'].''.''.$interface_perm['ifAlias']." -    +   
    -
    "); + "; + $ipermdone = 'yes'; + } - if (!$ipermdone) { echo("None Configured"); } + echo ' +
    '; - // Display devices this user doesn't have access to - echo("

    Grant access to new interface

    "); + if (!$ipermdone) { + echo 'None Configured'; + } - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new interface

    '; + + echo " +
    + if (!$done) { + echo "'; + } + } + + echo "
    @@ -176,133 +179,135 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - "); + "; - echo("
    -
    "); - echo("

    Bill Access

    "); + echo "
    +
    "; + echo '

    Bill Access

    '; - $bill_perms = dbFetchRows("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id", array($vars['user_id'])); + $bill_perms = dbFetchRows('SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id', array($vars['user_id'])); - echo("
    + echo "
    - "); + "; - foreach ($bill_perms as $bill_perm) - { - echo(" + foreach ($bill_perms as $bill_perm) { + echo ' - "); - $bill_access_list[] = $bill_perm['bill_id']; + "; + $bill_access_list[] = $bill_perm['bill_id']; - $bpermdone = "yes"; - } + $bpermdone = 'yes'; + } - echo("
    Bill name Action
    - ".$bill_perm['bill_name']."   + '.$bill_perm['bill_name']."  
    -
    "); + echo ' +
    '; - if (!$bpermdone) { echo("None Configured"); } + if (!$bpermdone) { + echo 'None Configured'; + } - // Display devices this user doesn't have access to - echo("

    Grant access to new bill

    "); - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new bill

    '; + echo " +
    - "; - $bills = dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`"); - foreach ($bills as $bill) - { - unset($done); - foreach ($bill_access_list as $ac) { if ($ac == $bill['bill_id']) { $done = 1; } } - if (!$done) - { - echo(""); - } - } + $bills = dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_name`'); + foreach ($bills as $bill) { + unset($done); + foreach ($bill_access_list as $ac) { + if ($ac == $bill['bill_id']) { + $done = 1; + } + } - echo(" + if (!$done) { + echo "'; + } + } + + echo "
    -
    "); - - } elseif ($vars['user_id'] && $vars['edit']) { - - if($_SESSION['userlevel'] == 11) { - demo_account(); - } else { - - if(!empty($vars['new_level'])) - { - if($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - update_user($vars['user_id'],$vars['new_realname'],$vars['new_level'],$vars['can_modify_passwd'],$vars['new_email']); - print_message("User has been updated"); +
    "; } - - if(can_update_users() == '1') { - - $users_details = get_user($vars['user_id']); - if(!empty($users_details)) - { - - if(empty($vars['new_realname'])) - { - $vars['new_realname'] = $users_details['realname']; - } - if(empty($vars['new_level'])) - { - $vars['new_level'] = $users_details['level']; - } - if(empty($vars['can_modify_passwd'])) - { - $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; - } elseif($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - if(empty($vars['new_email'])) - { - $vars['new_email'] = $users_details['email']; + else if ($vars['user_id'] && $vars['edit']) { + if ($_SESSION['userlevel'] == 11) { + demo_account(); } + else { + if (!empty($vars['new_level'])) { + if ($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } - if( $config['twofactor'] ) { - if( $vars['twofactorremove'] ) { - if( dbUpdate(array('twofactor'=>''),users,'user_id = ?',array($vars['user_id'])) ) { - echo "
    TwoFactor credentials removed.
    "; - } else { - echo "
    Couldnt remove user's TwoFactor credentials.
    "; + update_user($vars['user_id'], $vars['new_realname'], $vars['new_level'], $vars['can_modify_passwd'], $vars['new_email']); + print_message('User has been updated'); } - } - if( $vars['twofactorunlock'] ) { - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'],true); - $twofactor['fails'] = 0; - if( dbUpdate(array('twofactor'=>json_encode($twofactor)),users,'user_id = ?',array($vars['user_id'])) ) { - echo "
    User unlocked.
    "; - } else { - echo "
    Couldnt reset user's TwoFactor failures.
    "; - } - } - } - echo("
    - + if (can_update_users() == '1') { + $users_details = get_user($vars['user_id']); + if (!empty($users_details)) { + if (empty($vars['new_realname'])) { + $vars['new_realname'] = $users_details['realname']; + } + + if (empty($vars['new_level'])) { + $vars['new_level'] = $users_details['level']; + } + + if (empty($vars['can_modify_passwd'])) { + $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; + } + else if ($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } + + if (empty($vars['new_email'])) { + $vars['new_email'] = $users_details['email']; + } + + if ($config['twofactor']) { + if ($vars['twofactorremove']) { + if (dbUpdate(array('twofactor' => ''), users, 'user_id = ?', array($vars['user_id']))) { + echo "
    TwoFactor credentials removed.
    "; + } + else { + echo "
    Couldnt remove user's TwoFactor credentials.
    "; + } + } + + if ($vars['twofactorunlock']) { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'], true); + $twofactor['fails'] = 0; + if (dbUpdate(array('twofactor' => json_encode($twofactor)), users, 'user_id = ?', array($vars['user_id']))) { + echo "
    User unlocked.
    "; + } + else { + echo "
    Couldnt reset user's TwoFactor failures.
    "; + } + } + } + + echo " +
    - +
    @@ -310,7 +315,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - +
    @@ -319,10 +324,22 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    @@ -332,7 +349,10 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    @@ -340,14 +360,14 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - "); - if( $config['twofactor'] ) { - echo "

    Two-Factor Authentication

    "; - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'],true); - if( $twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time()-$twofactor['last']) < $config['twofactor_lock']) ) { - echo "
    - +
    "; + if ($config['twofactor']) { + echo "

    Two-Factor Authentication

    "; + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'], true); + if ($twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time() - $twofactor['last']) < $config['twofactor_lock'])) { + echo "
    +
    @@ -355,43 +375,47 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    "; - } - if( $twofactor['key'] ) { - echo "
    - + } + + if ($twofactor['key']) { + echo " +
    "; - } else { - echo "

    No TwoFactor key generated for this user, Nothing to do.

    "; - } - } - } else { - echo print_error("Error getting user details"); - } - } else { - echo print_error("Authentication method doesn't support updating users"); + } + else { + echo '

    No TwoFactor key generated for this user, Nothing to do.

    '; + } + }//end if + } + else { + echo print_error('Error getting user details'); + }//end if + } + else { + echo print_error("Authentication method doesn't support updating users"); + }//end if + }//end if } - } - } else { + else { + $user_list = get_userlist(); - $user_list = get_userlist(); + echo '

    Select a user to edit

    '; - echo("

    Select a user to edit

    "); - - echo("
    + echo "
    - +
    @@ -399,11 +423,8 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); /
    - "); - } + "; + }//end if +}//end if -} - -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/eventlog.inc.php b/html/pages/eventlog.inc.php index 4e1cad13d..2ac41ec91 100644 --- a/html/pages/eventlog.inc.php +++ b/html/pages/eventlog.inc.php @@ -1,16 +1,15 @@ = '10') -{ - dbQuery("TRUNCATE TABLE `eventlog`"); - print_message("Event log truncated"); +if ($vars['action'] == 'expunge' && $_SESSION['userlevel'] >= '10') { + dbQuery('TRUNCATE TABLE `eventlog`'); + print_message('Event log truncated'); } -$pagetitle[] = "Eventlog"; +$pagetitle[] = 'Eventlog'; print_optionbar_start(); @@ -24,15 +23,17 @@ print_optionbar_start();
    @@ -40,9 +41,7 @@ print_optionbar_start(); diff --git a/html/pages/front/default.php b/html/pages/front/default.php index 7b17f08a4..b69f7f97b 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -1,174 +1,180 @@ + +function generate_front_box($frontbox_class, $content) { + echo "
    $content -
    "); + "; + +}//end generate_front_box() + + +echo ' +
    +'; +if ($config['vertical_summary']) { + echo '
    '; +} +else { + echo '
    '; } -echo(' -
    -'); -if ($config['vertical_summary']) { - echo('
    '); -} -else -{ - echo('
    '); -} -echo(' +echo '
    -'); +'; -echo('
    '); +echo '
    '; -echo('
    '); +echo '
    '; $count_boxes = 0; // Device down boxes -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; -} else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; } -foreach (dbFetchRows($sql) as $device) -{ - generate_front_box("device-down", generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 20).""); - ++$count_boxes; +else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; } -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; -} else { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +foreach (dbFetchRows($sql) as $device) { + generate_front_box( + 'device-down', + generate_device_link($device, shorthost($device['hostname'])).'
    + Device Down
    + '.truncate($device['location'], 20).'' + ); + ++$count_boxes; +} + +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +} +else { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; } // These things need to become more generic, and more manageable across different frontpages... rewrite inc :> - // Port down boxes -if ($config['warn']['ifdown']) -{ - foreach (dbFetchRows($sql) as $interface) - { - if (!$interface['deleted']) - { - $interface = ifNameDescr($interface); - generate_front_box("port-down", generate_device_link($interface, shorthost($interface['hostname']))."
    +if ($config['warn']['ifdown']) { + foreach (dbFetchRows($sql) as $interface) { + if (!$interface['deleted']) { + $interface = ifNameDescr($interface); + generate_front_box( + 'port-down', + generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    - - ".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
    - " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '')); - ++$count_boxes; + + ".generate_port_link($interface, truncate(makeshortif($interface['label']), 13, '')).'
    + '.($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') + ); + ++$count_boxes; + } } - } } -/* FIXME service permissions? seem nonexisting now.. */ +/* + FIXME service permissions? seem nonexisting now.. */ // Service down boxes -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = ''; +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = ''; } -else -{ - $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = $_SESSION['user_id']; +else { + $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = $_SESSION['user_id']; } -foreach (dbFetchRows($sql,$param) as $service) -{ - generate_front_box("service-down", generate_device_link($service, shorthost($service['hostname']))."
    + +foreach (dbFetchRows($sql, $param) as $service) { + generate_front_box( + 'service-down', + generate_device_link($service, shorthost($service['hostname'])).'
    Service Down - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 20).""); - ++$count_boxes; + '.$service['service_type'].'
    + '.truncate($interface['ifAlias'], 20).'' + ); + ++$count_boxes; } // BGP neighbour down boxes -if (isset($config['enable_bgp']) && $config['enable_bgp']) -{ - if ($_SESSION['userlevel'] >= '10') - { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } else { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } - foreach (dbFetchRows($sql) as $peer) - { - generate_front_box("bgp-down", generate_device_link($peer, shorthost($peer['hostname']))."
    +if (isset($config['enable_bgp']) && $config['enable_bgp']) { + if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } + else { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } + + foreach (dbFetchRows($sql) as $peer) { + generate_front_box( + 'bgp-down', + generate_device_link($peer, shorthost($peer['hostname']))."
    BGP Down - ".$peer['bgpPeerIdentifier']."
    - AS".truncate($peer['bgpPeerRemoteAs']." ".$peer['astext'], 14, "").""); - ++$count_boxes; - } + ".$peer['bgpPeerIdentifier'].'
    + AS'.truncate($peer['bgpPeerRemoteAs'].' '.$peer['astext'], 14, '').'' + ); + ++$count_boxes; + } } // Device rebooted boxes -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - if ($_SESSION['userlevel'] >= '10') - { - $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" . - $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } + else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } - foreach (dbFetchRows($sql) as $device) - { - generate_front_box("device-rebooted", generate_device_link($device, shorthost($device['hostname']))."
    + foreach (dbFetchRows($sql) as $device) { + generate_front_box( + 'device-rebooted', + generate_device_link($device, shorthost($device['hostname'])).'
    Device Rebooted
    - ".formatUptime($device['uptime'], 'short').""); - ++$count_boxes; - } + '.formatUptime($device['uptime'], 'short').'' + ); + ++$count_boxes; + } } + if ($count_boxes == 0) { - echo("
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none - because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].", you might - want to start by adding one or more devices in the Devices menu.

    "); -} -echo('
    '); -echo('
    '); -echo('
    '); -echo(' -
    -
    -'); - -if ($config['vertical_summary']) -{ - echo('
    '); - include_once("includes/device-summary-vert.inc.php"); -} -else -{ - echo('
    '); - include_once("includes/device-summary-horiz.inc.php"); + echo "
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none + because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].', you might + want to start by adding one or more devices in the Devices menu.

    '; } -echo(' +echo '
    '; +echo '
    '; +echo '
    '; +echo ' +
    +
    +'; + +if ($config['vertical_summary']) { + echo '
    '; + include_once 'includes/device-summary-vert.inc.php'; +} +else { + echo '
    '; + include_once 'includes/device-summary-horiz.inc.php'; +} + +echo '
    -'); +'; -if ($config['enable_syslog']) -{ +if ($config['enable_syslog']) { + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; + $query = mysql_query($sql); - $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; - $query = mysql_query($sql); - - echo('
    + echo '
      @@ -180,35 +186,34 @@ if ($config['enable_syslog'])
    Syslog entries
    -
    '); +
    '; - foreach (dbFetchRows($sql) as $entry) - { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); - } - echo("
    "); - echo(""); - echo(""); - echo(""); - echo(""); + include 'includes/print-syslog.inc.php'; + } -} else { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +} +else { + if ($_SESSION['userlevel'] >= '10') { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15'; + } + else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = ".$_SESSION['user_id'].' ORDER BY `datetime` DESC LIMIT 0,15'; + $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = '.$_SESSION['user_id'].' ORDER BY `time_logged` DESC LIMIT 0,15'; + } - if ($_SESSION['userlevel'] >= '10') - { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15"; - } else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15"; - } + $data = mysql_query($query); + $alertdata = mysql_query($alertquery); - $data = mysql_query($query); - $alertdata = mysql_query($alertquery); - - echo('
    + echo '
      @@ -220,13 +225,13 @@ if ($config['enable_syslog'])
    Alertlog entries
    - '); +
    '; - foreach (dbFetchRows($alertquery) as $alert_entry) - { - include("includes/print-alerts.inc.php"); - } - echo('
    + foreach (dbFetchRows($alertquery) as $alert_entry) { + include 'includes/print-alerts.inc.php'; + } + + echo '
    @@ -234,24 +239,21 @@ if ($config['enable_syslog'])
    Eventlog entries
    - '); +
    '; - foreach (dbFetchRows($query) as $entry) - { - include("includes/print-event.inc.php"); - } + foreach (dbFetchRows($query) as $entry) { + include 'includes/print-event.inc.php'; + } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); -} + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if -echo(""); +echo ''; -echo(' +echo ' -'); - -?> +'; diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 1000fbca2..6478a566b 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -4,56 +4,55 @@ "); +echo ''; -$dev_list = array('6' => 'Central Fileserver', - '7' => 'NE61 Fileserver', - '34' => 'DE56 Fileserver'); +$dev_list = array( + '6' => 'Central Fileserver', + '7' => 'NE61 Fileserver', + '34' => 'DE56 Fileserver', +); -foreach ($dev_list as $device_id => $descr) -{ +foreach ($dev_list as $device_id => $descr) { + echo ''; +}//end foreach - echo(""); - -} - -echo("
    '; + echo "
    ".$descr.'
    '; + $graph_array['height'] = '100'; + $graph_array['width'] = '310'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device_id; + $graph_array['type'] = 'device_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; + $graph_array['popup_title'] = $descr; + // $graph_array['link'] = generate_device_link($device_id); + print_graph_popup($graph_array); - echo("
    "); - echo("
    ".$descr."
    "); - $graph_array['height'] = "100"; - $graph_array['width'] = "310"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device_id; - $graph_array['type'] = "device_bits"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; - $graph_array['popup_title'] = $descr; -# $graph_array['link'] = generate_device_link($device_id); - print_graph_popup($graph_array); + $graph_array['height'] = '50'; + $graph_array['width'] = '180'; - $graph_array['height'] = "50"; - $graph_array['width'] = "180"; + echo "
    "; + $graph_array['type'] = 'device_ucd_memory'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_ucd_memory"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_processor'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_processor"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_storage'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_storage"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_diskio'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_diskio"; - print_graph_popup($graph_array); - echo("
    "); + echo '
    "); +echo ''; ?> @@ -62,115 +61,105 @@ echo(""); '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } -if ($config['warn']['ifdown']) -{ - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; - foreach (dbFetchRows($sql) as $interface) - { - if (port_permitted($interface['port_id'])) - { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); +if ($config['warn']['ifdown']) { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; + foreach (dbFetchRows($sql) as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } - } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - if (device_permitted($service['device_id'])) - { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows($sql) as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - if (device_permitted($peer['device_id'])) - { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } -} - -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE - A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) - { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") - { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); +foreach (dbFetchRows($sql) as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; } - } } -echo(" -
    $errorboxes
    +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE + A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } +} -

    Recent Syslog Messages

    -"); +echo " +
    $errorboxes
    + +

    Recent Syslog Messages

    + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from `syslog` ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); + include 'includes/print-syslog.inc.php'; } -echo("
    "); +echo ''; ?> diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php index 717ee7518..e5898ac07 100644 --- a/html/pages/front/example2.php +++ b/html/pages/front/example2.php @@ -4,173 +4,141 @@
    Devices with Alerts
    Host
    Int
    Srv
    +// ?> '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) - { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) - { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - echo("
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down - ".truncate($device['location'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $device) { + echo "
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down + ".truncate($device['location'], 20).' +
    '; } $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; -foreach (dbFetchRows($sql) as $interface) -{ - echo("
    -
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $interface) { + echo "
    +
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 20).' +
    '; } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - echo("
    -
    ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $service) { + echo "
    +
    ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 20).' +
    '; } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - echo("
    -
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - +foreach (dbFetchRows($sql) as $peer) { + echo "
    +
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'"; - foreach (dbFetchRows($sql) as $device) - { - echo("
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '".$config['uptime_warning']."'"; + foreach (dbFetchRows($sql) as $device) { + echo "
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } } -echo(" +echo " -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; -echo("
    Devices with Alerts
    Host
    Int
    Srv
    "); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['l2tp'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['l2tp'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['voip'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['voip'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + if ($ports['transit']) { + echo "', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    Internet Transit
    "."
    "; + } - if ($ports['transit']) - { - echo("', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    Internet Transit
    ". - "
    "); - } + if ($ports['l2tp']) { + echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    L2TP ADSL
    "."
    "; + } - if ($ports['l2tp']) - { - echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    L2TP ADSL
    ". - "
    "); - } - - if ($ports['voip']) - { - echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    VoIP to PSTN
    ". - "
    "); - } - -} + if ($ports['voip']) { + echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    VoIP to PSTN
    "."
    "; + } +}//end if // END VOSTRON - ?> diff --git a/html/pages/front/globe.php b/html/pages/front/globe.php index 75a5917c7..9884b402f 100644 --- a/html/pages/front/globe.php +++ b/html/pages/front/globe.php @@ -4,16 +4,17 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * Custom Frontpage * @author f0o * @copyright 2014 f0o, LibreNMS @@ -25,107 +26,111 @@ ?> -
    -
    -
    -
    -
    -
    -
    -
    '; - include_once("includes/device-summary-vert.inc.php"); -echo '
    -
    -
    -
    '; - include_once("includes/front/boxes.inc.php"); -echo '
    -
    -
    -
    -
    -
    -
    '; - $device['device_id'] = '-1'; - require_once('includes/print-alerts.php'); - unset($device['device_id']); -echo '
    -
    +
    +
    +
    +
    +
    +
    +
    +
    '; + include_once("includes/device-summary-vert.inc.php"); +echo '
    +
    +
    +
    '; + include_once("includes/front/boxes.inc.php"); +echo '
    +
    +
    +
    +
    +
    +
    '; + $device['device_id'] = '-1'; + require_once('includes/print-alerts.php'); + unset($device['device_id']); +echo '
    +
    '; //From default.php - This code is not part of above license. if ($config['enable_syslog']) { -$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; -$query = mysql_query($sql); -echo('
    + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; + $query = mysql_query($sql); + echo('
      @@ -139,29 +144,28 @@ echo('
    '); - foreach (dbFetchRows($sql) as $entry) - { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); - } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); + include 'includes/print-syslog.inc.php'; + } + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); +} +else { -} else { + if ($_SESSION['userlevel'] == '10') { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + } + else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = + P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + } - if ($_SESSION['userlevel'] == '10') - { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - } else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = - P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - } - - $data = mysql_query($query); + $data = mysql_query($query); echo('
    @@ -177,15 +181,13 @@ echo('
    '); - foreach (dbFetchRows($query) as $entry) - { - include("includes/print-event.inc.php"); - } + foreach (dbFetchRows($query) as $entry) { + include 'includes/print-event.inc.php'; + } - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); - echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); } -?> diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index 2256cf085..cda0b49bb 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -5,238 +5,209 @@ $nodes = array(); -$uptimesql = ""; -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $uptimesql = " AND A.attrib_value < '" . $config['uptime_warning'] . "'"; +$uptimesql = ''; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $uptimesql = " AND A.attrib_value < '".$config['uptime_warning']."'"; } -$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql; +$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } if ($config['warn']['ifdown']) { - -$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; -foreach (dbFetchRows($sql) as $interface) -{ - if (port_permitted($interface['port_id'])) { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } -} - + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; + foreach (dbFetchRows($sql) as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } + } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - if (device_permitted($service['device_id'])) { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows($sql) as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - if (device_permitted($peer['device_id'])) { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } +foreach (dbFetchRows($sql) as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } } -echo(" +echo " -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['peering'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $ports['broadband'] = '3294,3295,688,3534'; + $ports['wave_broadband'] = '827'; - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['peering'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $ports['new_broadband'] = '3659,4149,4121,4108,3676,4135'; - $ports['broadband'] = "3294,3295,688,3534"; - $ports['wave_broadband'] = "827"; + echo "
    "; - $ports['new_broadband'] = "3659,4149,4121,4108,3676,4135"; + if ($ports['peering'] && $ports['transit']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['peering'] && $ports['transit']) { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['transit']) { + echo ""; + } - echo("'; - if ($ports['peering']) { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) { + echo ""; + } - echo("
    "); + echo "
    "; - if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) { - echo(""); - } + if ($ports['broadband']) { + echo ""; + } - echo("
    "); + echo "
    "; - if ($ports['broadband']) { - echo(""); - } + if ($ports['new_broadband']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['new_broadband']) { - echo(""); - } + if ($ports['wave_broadband']) { + echo ""; + } - echo("
    "); - - if ($ports['wave_broadband']) { - echo(""); - } - - echo("
    "); - -} + echo '
    '; +}//end if ?> diff --git a/html/pages/front/traffic.php b/html/pages/front/traffic.php index 5f9a8acce..6b501cf9c 100644 --- a/html/pages/front/traffic.php +++ b/html/pages/front/traffic.php @@ -3,200 +3,172 @@ 0) -{ - $uptimesql = " AND A.attrib_value < ?"; - $param = array($config['uptime_warning']); +$nodes = array(); +$param = array(); +$uptimesql = ''; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $uptimesql = ' AND A.attrib_value < ?'; + $param = array($config['uptime_warning']); } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql, $param) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql, $param) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } -foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } if ($config['warn']['ifdown']) { - -foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) -{ - if (port_permitted($interface['port_id'])) { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } + foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } + } } +foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } -foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) -{ - if (device_permitted($service['device_id'])) { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; + } } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) -{ - if (device_permitted($peer['device_id'])) { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } - } -} +echo " -echo(" +
    $errorboxes
    -
    $errorboxes
    +

    Recent Syslog Messages

    -

    Recent Syslog Messages

    - -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['peering'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['core'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['peering'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + echo "
    "; - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['core'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + if ($ports['peering'] && $ports['transit']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['peering'] && $ports['transit']) - { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['transit']) { + echo ""; + } - echo("
    "); + if ($ports['peering']) { + echo ""; + } - if ($ports['transit']) - { - echo(""); - } + if ($ports['core']) { + echo ""; + } - if ($ports['peering']) - { - echo(""); - } - - if ($ports['core']) - { - echo(""); - } - - echo("
    "); - -} + echo '
    '; +}//end if ?> diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 0cc268fce..78c6a73e0 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -4,17 +4,21 @@ unset($vars['page']); // Setup here -if($_SESSION['widescreen']) -{ - $graph_width=1700; - $thumb_width=180; -} else { - $graph_width=1075; - $thumb_width=113; +if($_SESSION['widescreen']) { + $graph_width=1700; + $thumb_width=180; +} +else { + $graph_width=1075; + $thumb_width=113; } -if (!is_numeric($vars['from'])) { $vars['from'] = $config['time']['day']; } -if (!is_numeric($vars['to'])) { $vars['to'] = $config['time']['now']; } +if (!is_numeric($vars['from'])) { + $vars['from'] = $config['time']['day']; +} +if (!is_numeric($vars['to'])) { + $vars['to'] = $config['time']['now']; +} preg_match('/^(?P[A-Za-z0-9]+)_(?P.+)/', $vars['type'], $graphtype); @@ -22,208 +26,201 @@ $type = $graphtype['type']; $subtype = $graphtype['subtype']; $id = $vars['id']; -if(is_numeric($vars['device'])) -{ - $device = device_by_id_cache($vars['device']); -} elseif(!empty($vars['device'])) { - $device = device_by_name($vars['device']); +if(is_numeric($vars['device'])) { + $device = device_by_id_cache($vars['device']); +} +elseif(!empty($vars['device'])) { + $device = device_by_name($vars['device']); } -if (is_file("includes/graphs/".$type."/auth.inc.php")) -{ - include("includes/graphs/".$type."/auth.inc.php"); +if (is_file("includes/graphs/".$type."/auth.inc.php")) { + require "includes/graphs/".$type."/auth.inc.php"; } -if (!$auth) -{ - include("includes/error-no-perm.inc.php"); -} else { - if (isset($config['graph_types'][$type][$subtype]['descr'])) - { - $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; - } else { - $title .= " :: ".ucfirst($subtype); - } +if (!$auth) { + require 'includes/error-no-perm.inc.php'; +} +else { + if (isset($config['graph_types'][$type][$subtype]['descr'])) { + $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; + } + else { + $title .= " :: ".ucfirst($subtype); + } - $graph_array = $vars; - $graph_array['height'] = "60"; - $graph_array['width'] = $thumb_width; - $graph_array['legend'] = "no"; - $graph_array['to'] = $config['time']['now']; + $graph_array = $vars; + $graph_array['height'] = "60"; + $graph_array['width'] = $thumb_width; + $graph_array['legend'] = "no"; + $graph_array['to'] = $config['time']['now']; - print_optionbar_start(); - echo($title); + print_optionbar_start(); + echo($title); - echo('
    '); - ?> + echo('
    '); +?>
    - '); +'); - print_optionbar_end(); + print_optionbar_end(); - print_optionbar_start(); + print_optionbar_start(); - $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', - 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); + $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', + 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); - echo(''); + echo('
    '); - foreach ($thumb_array as $period => $text) - { - $graph_array['from'] = $config['time'][$period]; + foreach ($thumb_array as $period => $text) { + $graph_array['from'] = $config['time'][$period]; - $link_array = $vars; - $link_array['from'] = $graph_array['from']; - $link_array['to'] = $graph_array['to']; - $link_array['page'] = "graphs"; - $link = generate_url($link_array); + $link_array = $vars; + $link_array['from'] = $graph_array['from']; + $link_array['to'] = $graph_array['to']; + $link_array['page'] = "graphs"; + $link = generate_url($link_array); - echo(''); + echo(''); - } + } - echo('
    '); - echo(''.$text.'
    '); - echo(''); - echo(generate_graph_tag($graph_array)); - echo(''); - echo('
    '); + echo(''.$text.'
    '); + echo(''); + echo(generate_graph_tag($graph_array)); + echo(''); + echo('
    '); + echo(''); - $graph_array = $vars; - $graph_array['height'] = "300"; - $graph_array['width'] = $graph_width; + $graph_array = $vars; + $graph_array['height'] = "300"; + $graph_array['width'] = $graph_width; - echo("
    "); + echo("
    "); - // datetime range picker + // datetime range picker ?> - "); - echo(' + echo(" +
    + "); + echo('
    - - + +
    - - + +
    -
    - '); - echo("
    "); + echo("
    "); - if ($vars['legend'] == "no") - { - echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); - } else { - echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); - } - - // FIXME : do this properly -# if ($type == "port" && $subtype == "bits") -# { - echo(' | '); - if ($vars['previous'] == "yes") - { - echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); - } else { - echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); + if ($vars['legend'] == "no") { + echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); + } + else { + echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); } -# } - echo('
    '); + // FIXME : do this properly + # if ($type == "port" && $subtype == "bits") + # { + echo(' | '); + if ($vars['previous'] == "yes") { + echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); + } + else { + echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); + } + # } - if ($vars['showcommand'] == "yes") - { - echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); - } else { - echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); - } + echo('
    '); - echo('
    '); + if ($vars['showcommand'] == "yes") { + echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); + } + else { + echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); + } - print_optionbar_end(); + echo('
    '); - echo generate_graph_js_state($graph_array); - - echo('
    '); - echo(generate_graph_tag($graph_array)); - echo("
    "); - - if (isset($config['graph_descr'][$vars['type']])) - { - - print_optionbar_start(); - echo('
    -
    - -
    -
    '); - echo($config['graph_descr'][$vars['type']]); print_optionbar_end(); - } - if ($vars['showcommand']) - { - $_GET = $graph_array; - $command_only = 1; + echo generate_graph_js_state($graph_array); - include("includes/graphs/graph.inc.php"); - } + echo('
    '); + echo(generate_graph_tag($graph_array)); + echo("
    "); + + if (isset($config['graph_descr'][$vars['type']])) { + + print_optionbar_start(); + echo('
    +
    + +
    +
    '); + echo($config['graph_descr'][$vars['type']]); + print_optionbar_end(); + } + + if ($vars['showcommand']) { + $_GET = $graph_array; + $command_only = 1; + + require 'includes/graphs/graph.inc.php'; + } } - -?> diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index 3b06d4db6..eb13def9b 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -30,8 +30,12 @@ $type_text['toner'] = "Toner"; $type_text['dbm'] = "dBm"; $type_text['load'] = "Load"; -if (!$vars['metric']) { $vars['metric'] = "processor"; } -if (!$vars['view']) { $vars['view'] = "detail"; } +if (!$vars['metric']) { + $vars['metric'] = "processor"; +} +if (!$vars['view']) { + $vars['view'] = "detail"; +} $link_array = array('page' => 'health'); @@ -42,48 +46,44 @@ print_optionbar_start('', ''); echo('Health » '); $sep = ""; -foreach ($datas as $texttype) -{ - $metric = strtolower($texttype); - echo($sep); - if ($vars['metric'] == $metric) - { - echo(""); - } +foreach ($datas as $texttype) { + $metric = strtolower($texttype); + echo($sep); + if ($vars['metric'] == $metric) { + echo(""); + } - echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); + echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); - if ($vars['metric'] == $metric) { echo(""); } + if ($vars['metric'] == $metric) { + echo(""); + } - $sep = ' | '; + $sep = ' | '; } unset ($sep); echo('
    '); -if ($vars['view'] == "graphs") -{ - echo(''); +if ($vars['view'] == "graphs") { + echo(''); } echo(generate_link("Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "graphs"))); -if ($vars['view'] == "graphs") -{ - echo(''); +if ($vars['view'] == "graphs") { + echo(''); } echo(' | '); -if ($vars['view'] != "graphs") -{ - echo(''); +if ($vars['view'] != "graphs") { + echo(''); } echo(generate_link("No Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "detail"))); -if ($vars['view'] != "graphs") -{ - echo(''); +if ($vars['view'] != "graphs") { + echo(''); } echo('
    '); @@ -91,16 +91,14 @@ echo('
    '); print_optionbar_end(); if (in_array($vars['metric'],array_keys($used_sensors)) - || $vars['metric'] == 'processor' - || $vars['metric'] == 'storage' - || $vars['metric'] == 'toner' - || $vars['metric'] == 'mempool') -{ - include('pages/health/'.$vars['metric'].'.inc.php'); + || $vars['metric'] == 'processor' + || $vars['metric'] == 'storage' + || $vars['metric'] == 'toner' + || $vars['metric'] == 'mempool') { + include('pages/health/'.$vars['metric'].'.inc.php'); } -else -{ - echo("No sensors of type " . $vars['metric'] . " found."); +else { + echo("No sensors of type " . $vars['metric'] . " found."); } ?> diff --git a/html/pages/health/charge.inc.php b/html/pages/health/charge.inc.php index 867b50f9e..3838d0e79 100644 --- a/html/pages/health/charge.inc.php +++ b/html/pages/health/charge.inc.php @@ -4,6 +4,4 @@ $graph_type = "sensor_charge"; $unit = "%"; $class = "charge"; -include("pages/health/sensors.inc.php"); - -?> +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/load.inc.php b/html/pages/health/load.inc.php index d9257519d..f506e3ca1 100644 --- a/html/pages/health/load.inc.php +++ b/html/pages/health/load.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index 02224d485..52828b9c1 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -1,19 +1,18 @@ = '5') -{ - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; - $param = array(); -} else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; - $param = array($_SESSION['user_id']); +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; + $param = array(); +} +else { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; + $param = array($_SESSION['user_id']); } -echo(''); +echo '
    '; -echo(' +echo ' @@ -21,99 +20,102 @@ echo(' - '); + '; -foreach (dbFetchRows($sql, $param) as $sensor) -{ +foreach (dbFetchRows($sql, $param) as $sensor) { + if ($config['memcached']['enable'] === true) { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + if ($debug) { + echo 'Memcached['.'sensor-'.$sensor['sensor_id'].'-value'.'='.$sensor['sensor_current'].']'; + } + } - if ($config['memcached']['enable'] === TRUE) - { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - if($debug) { echo("Memcached[".'sensor-'.$sensor['sensor_id'].'-value'."=".$sensor['sensor_current']."]"); } - } - - if (empty($sensor['sensor_current'])) - { - $sensor['sensor_current'] = "NaN"; - } else { - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - } + if (empty($sensor['sensor_current'])) { + $sensor['sensor_current'] = 'NaN'; + } + else { + if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { + $alert = 'alert'; + } + else { + $alert = ''; + } + } // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? // FIXME - DUPLICATED IN device/overview/sensors - - $graph_colour = str_replace("#", "", $row_colour); + $graph_colour = str_replace('#', '', $row_colour); $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $sensor['sensor_id']; $graph_array['type'] = $graph_type; $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; + $link_array = $graph_array; + $link_array['page'] = 'graphs'; unset($link_array['height'], $link_array['width'], $link_array['legend']); $link_graph = generate_url($link_array); - $link = generate_url(array("page" => "device", "device" => $sensor['device_id'], "tab" => "health", "metric" => $sensor['sensor_class'])); + $link = generate_url(array('page' => 'device', 'device' => $sensor['device_id'], 'tab' => 'health', 'metric' => $sensor['sensor_class'])); - $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; - foreach (array('day','week','month','year') as $period) - { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; + foreach (array('day', 'week', 'month', 'year') as $period) { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); } - $overlib_content .= "
    "; - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content .= '
    '; + + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $sensor_minigraph = generate_graph_tag($graph_array); $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo(' - - + echo ' + + - - - + + + - '); + '; - if ($vars['view'] == "graphs") - { - echo(""); - } # endif graphs -} + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo ''; + } //end if +}//end foreach -echo("
    Device Sensor
    Current Range limit Notes
    ' . generate_device_link($sensor) . ''.overlib_link($link, $sensor['sensor_descr'],$overlib_content).'
    '.generate_device_link($sensor).''.overlib_link($link, $sensor['sensor_descr'], $overlib_content).' '.overlib_link($link_graph, $sensor_minigraph, $overlib_content).' '.$alert.'' . $sensor['sensor_current'] . $unit . '' . round($sensor['sensor_limit_low'],2) . $unit . ' - ' . round($sensor['sensor_limit'],2) . $unit . '' . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . ''.$sensor['sensor_current'].$unit.''.round($sensor['sensor_limit_low'], 2).$unit.' - '.round($sensor['sensor_limit'], 2).$unit.''.(isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '').'
    "); + if ($vars['view'] == 'graphs') { + echo "
    "; - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=211&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150"; + $daily_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=211&height=100'; + $daily_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=400&height=150'; - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=211&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=400&height=150"; + $weekly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=211&height=100'; + $weekly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=400&height=150'; - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=211&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=400&height=150"; + $monthly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=211&height=100'; + $monthly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=400&height=150'; - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=211&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=400&height=150"; + $yearly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['now'].'&width=211&height=100'; + $yearly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['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/iftype.inc.php b/html/pages/iftype.inc.php index f4349111c..8a6d20201 100644 --- a/html/pages/iftype.inc.php +++ b/html/pages/iftype.inc.php @@ -9,92 +9,102 @@ - Total Graph for ports of type : ".$types."
    "); - -if ($if_list) -{ - $graph_type = "multiport_bits_separate"; - $port['port_id'] = $if_list; - - include("includes/print-interface-graphs.inc.php"); - - echo(""); - - foreach ($ports as $port) - { - $done = "yes"; - unset($class); - $port['ifAlias'] = str_ireplace($type . ": ", "", $port['ifAlias']); - $port['ifAlias'] = str_ireplace("[PNI]", "Private", $port['ifAlias']); - $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - if ($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg = "#ffffff"; } - echo(" - " . generate_port_link($port,$port['port_descr_descr']) . "
    - ".generate_device_link($port)." ".generate_port_link($port)." - ".generate_port_link($port, makeshortif($port['ifDescr']))." - ".$port['port_descr_speed']." - ".$port['port_descr_circuit']." - ".$port['port_descr_notes']." - - - MAC Accounting"); - } - - echo('
    '); - - if (file_exists($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . $port['ifIndex'] . ".rrd")) - { - $graph_type = "port_bits"; - - include("includes/print-interface-graphs.inc.php"); - } - - echo(""); - } - +$types_array = explode(',', $vars['type']); +for ($i = 0; $i < count($types_array); +$i++) { + $types_array[$i] = ucfirst($types_array[$i]); } -else -{ - echo("None found."); + +$types = implode(' + ', $types_array); + +echo " + Total Graph for ports of type : ".$types.'
    '; + +if ($if_list) { + $graph_type = 'multiport_bits_separate'; + $port['port_id'] = $if_list; + + include 'includes/print-interface-graphs.inc.php'; + + echo ''; + + foreach ($ports as $port) { + $done = 'yes'; + unset($class); + $port['ifAlias'] = str_ireplace($type.': ', '', $port['ifAlias']); + $port['ifAlias'] = str_ireplace('[PNI]', 'Private', $port['ifAlias']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ($bg == '#ffffff') { + $bg = '#e5e5e5'; + } + else { + $bg = '#ffffff'; + } + + echo " + ".generate_port_link($port, $port['port_descr_descr'])."
    + ".generate_device_link($port).' '.generate_port_link($port).' + '.generate_port_link($port, makeshortif($port['ifDescr'])).' + '.$port['port_descr_speed'].' + '.$port['port_descr_circuit'].' + '.$port['port_descr_notes']." + + + MAC Accounting"; + } + + echo '
    '; + + if (file_exists($config['rrd_dir'].'/'.$port['hostname'].'/port-'.$port['ifIndex'].'.rrd')) { + $graph_type = 'port_bits'; + + include 'includes/print-interface-graphs.inc.php'; + } + + echo ''; + } +} +else { + echo 'None found.'; } ?> diff --git a/html/pages/inventory.inc.php b/html/pages/inventory.inc.php index e53daab96..7fc461e4a 100644 --- a/html/pages/inventory.inc.php +++ b/html/pages/inventory.inc.php @@ -1,6 +1,6 @@ @@ -29,46 +29,53 @@ var grid = $("#inventory").bootgrid({ header: "
    "+ "
    "+ "
    "+ - "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ + "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ "
    "+ "
    "+ " Part No "+ ""+ "
    "+ "
    "+ - "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ + "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ "
    "+ "
    "+ " Device "+ ""+ "
    "+ "
    "+ - "\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ + " +\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/locations.inc.php b/html/pages/locations.inc.php index 93dffa0e3..bbe6adcf9 100644 --- a/html/pages/locations.inc.php +++ b/html/pages/locations.inc.php @@ -1,88 +1,92 @@ Locations » '); +echo 'Locations » '; -$menu_options = array('basic' => 'Basic', - 'traffic' => 'Traffic'); +$menu_options = array( + 'basic' => 'Basic', + 'traffic' => 'Traffic', +); -if (!$vars['view']) { $vars['view'] = "basic"; } +if (!$vars['view']) { + $vars['view'] = 'basic'; +} -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['view'] == $option) - { - echo(""); - } - $sep = " | "; +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo ''.$text.''; + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); print_optionbar_end(); -echo(''); +echo '
    '; -foreach (getlocations() as $location) -{ - if ($_SESSION['userlevel'] >= '10') - { - $num = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ?", array($location)); - $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); - $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); - $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); - } else { - $num = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?", array($_SESSION['user_id'], $location)); - $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); - $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); - $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); - } - - if ($hostalerts) { $alert = 'alert'; } else { $alert = ""; } - - if ($location != "") - { - echo(' - - - - - - - - '); - - if ($vars['view'] == "traffic") - { - echo('"); +foreach (getlocations() as $location) { + if ($_SESSION['userlevel'] >= '10') { + $num = dbFetchCell('SELECT COUNT(device_id) FROM devices WHERE location = ?', array($location)); + $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); + $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); + $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); + } + else { + $num = dbFetchCell('SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?', array($_SESSION['user_id'], $location)); + $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); + $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); + $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); } - $done = "yes"; - } -} -echo("
    ' . $location . '' . $alert . '' . $num . ' devices' . $net . ' network' . $srv . ' servers' . $fwl . ' firewalls
    '); - - $graph_array['type'] = "location_bits"; - $graph_array['height'] = "100"; - $graph_array['width'] = "220"; - $graph_array['to'] = $config['time']['now']; - $graph_array['legend'] = "no"; - $graph_array['id'] = $location; - - include("includes/print-graphrow.inc.php"); - - echo("
    "); + if ($hostalerts) { + $alert = 'alert'; + } + else { + $alert = ''; + } -?> + if ($location != '') { + echo ' + '.$location.' + '.$alert.' + '.$num.' devices + '.$net.' network + '.$srv.' servers + '.$fwl.' firewalls + + '; + + if ($vars['view'] == 'traffic') { + echo ''; + + $graph_array['type'] = 'location_bits'; + $graph_array['height'] = '100'; + $graph_array['width'] = '220'; + $graph_array['to'] = $config['time']['now']; + $graph_array['legend'] = 'no'; + $graph_array['id'] = $location; + + include 'includes/print-graphrow.inc.php'; + + echo ''; + } + + $done = 'yes'; + }//end if +}//end foreach + +echo ''; diff --git a/html/pages/logon.inc.php b/html/pages/logon.inc.php index e9819b1b0..a8a156574 100644 --- a/html/pages/logon.inc.php +++ b/html/pages/logon.inc.php @@ -1,7 +1,8 @@
    @@ -32,14 +33,12 @@ if( $config['twofactor'] && isset($twofactorform) ) {
    'error','message'=>$auth_message,'title'=>'Login error'); } ?>
    diff --git a/html/pages/map.inc.php b/html/pages/map.inc.php index 0fa1cbb5f..115c0600c 100644 --- a/html/pages/map.inc.php +++ b/html/pages/map.inc.php @@ -10,6 +10,5 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -$pagetitle[] = "Map"; -require_once "includes/print-map.inc.php"; -?> +$pagetitle[] = 'Map'; +require_once 'includes/print-map.inc.php'; diff --git a/html/pages/packages.inc.php b/html/pages/packages.inc.php index c3e79c8cf..ab26fd00a 100644 --- a/html/pages/packages.inc.php +++ b/html/pages/packages.inc.php @@ -2,8 +2,7 @@ foreach ($vars as $var => $value) { if ($value != '') { - switch ($var) - { + switch ($var) { case 'name': $where .= " AND `$var` = ?"; $param[] = $value; @@ -26,8 +25,7 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", foreach ($entry['blah'] as $version => $bleu) { $content = '
    '; - foreach ($bleu as $build => $bloo) - { + foreach ($bleu as $build => $bloo) { if ($build) { $dbuild = '-'.$build; } @@ -36,8 +34,7 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", } $content .= '
    '.$version.$dbuild.''; - foreach ($bloo as $device_id => $no) - { + foreach ($bloo as $device_id => $no) { $this_device = device_by_id_cache($device_id); $content .= ''.$this_device['hostname'].' '; } diff --git a/html/pages/plugin.inc.php b/html/pages/plugin.inc.php index daec96f46..1f718acff 100644 --- a/html/pages/plugin.inc.php +++ b/html/pages/plugin.inc.php @@ -1,24 +1,18 @@ 'plugin'); +$link_array = array('page' => 'plugin'); -$pagetitle[] = "Plugin"; +$pagetitle[] = 'Plugin'; -if ($vars['view'] == "admin") -{ - include_once('pages/plugin/admin.inc.php'); +if ($vars['view'] == 'admin') { + include_once 'pages/plugin/admin.inc.php'; } -else -{ - $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); - if(!empty($plugin)) - { - require('plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'); - } - else - { - print_error( "This plugin is either disabled or not available." ); - } +else { + $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); + if (!empty($plugin)) { + include 'plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'; + } + else { + print_error('This plugin is either disabled or not available.'); + } } - -?> diff --git a/html/pages/plugin/admin.inc.php b/html/pages/plugin/admin.inc.php index 1773d641d..e20bec1b6 100644 --- a/html/pages/plugin/admin.inc.php +++ b/html/pages/plugin/admin.inc.php @@ -1,33 +1,26 @@ = '10') -{ - - // Scan for new plugins and add to the database - $new_plugins = scan_new_plugins(); +if ($_SESSION['userlevel'] >= '10') { + // Scan for new plugins and add to the database + $new_plugins = scan_new_plugins(); - // Check if we have to toggle enabled / disable a particular module - $plugin_id = $_POST['plugin_id']; - $plugin_active = $_POST['plugin_active']; - if(is_numeric($plugin_id) && is_numeric($plugin_active)) - { - if( $plugin_active == '0') - { - $plugin_active = 1; - } - elseif( $plugin_active == '1') - { - $plugin_active = 0; - } - else - { - $plugin_active = 0; - } + // Check if we have to toggle enabled / disable a particular module + $plugin_id = $_POST['plugin_id']; + $plugin_active = $_POST['plugin_active']; + if (is_numeric($plugin_id) && is_numeric($plugin_active)) { + if ($plugin_active == '0') { + $plugin_active = 1; + } + else if ($plugin_active == '1') { + $plugin_active = 0; + } + else { + $plugin_active = 0; + } - if(dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) - { - echo(' + if (dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) { + echo ' -'); - } - - } +'; + } + }//end if ?> @@ -49,14 +41,13 @@ $.ajax({ System plugins
    0) - { - echo('
    +if ($new_plugins > 0) { + echo '
    - We have found ' . $new_plugins . ' new plugins that need to be configured and enabled + We have found '.$new_plugins.' new plugins that need to be configured and enabled
    -
    '); - } +
    '; +} ?> @@ -65,24 +56,21 @@ $.ajax({ + echo ' - '); - } - + '; +}//end foreach ?>
    - '. $plugins['plugin_name'] . ' + '.$plugins['plugin_name'].' @@ -91,18 +79,14 @@ $.ajax({
    +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/poll-log.inc.php b/html/pages/poll-log.inc.php index 3abdf05a8..91ef8132e 100644 --- a/html/pages/poll-log.inc.php +++ b/html/pages/poll-log.inc.php @@ -1,5 +1,5 @@ diff --git a/html/pages/pollers.inc.php b/html/pages/pollers.inc.php index de85c2344..3fef3d931 100644 --- a/html/pages/pollers.inc.php +++ b/html/pages/pollers.inc.php @@ -12,25 +12,32 @@ * the source code distribution for details. */ -$no_refresh = TRUE; +$no_refresh = true; -echo(''; if (isset($vars['tab'])) { - require_once "pages/pollers/".mres($vars['tab']).".inc.php"; + include_once 'pages/pollers/'.mres($vars['tab']).'.inc.php'; } diff --git a/html/pages/pollers/groups.inc.php b/html/pages/pollers/groups.inc.php index 50019dfc2..a914650ae 100644 --- a/html/pages/pollers/groups.inc.php +++ b/html/pages/pollers/groups.inc.php @@ -12,7 +12,7 @@ * the source code distribution for details. */ -require_once "includes/modal/poller_groups.inc.php"; +require_once 'includes/modal/poller_groups.inc.php'; ?>
    @@ -28,18 +28,17 @@ require_once "includes/modal/poller_groups.inc.php"; + echo ' + -'); +'; } ?> diff --git a/html/pages/pollers/pollers.inc.php b/html/pages/pollers/pollers.inc.php index c5e0eb279..f948d3a8b 100644 --- a/html/pages/pollers/pollers.inc.php +++ b/html/pages/pollers/pollers.inc.php @@ -24,26 +24,28 @@ = 300) { $row_class = 'danger'; - } elseif ($old >= 280 && $old < 300) { + } + else if ($old >= 280 && $old < 300) { $row_class = 'warning'; - } else { + } + else { $row_class = 'success'; } - echo(' + + echo ' -'); +'; } ?> diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php index 8ff1f7d34..edeea9fbe 100644 --- a/html/pages/ports.inc.php +++ b/html/pages/ports.inc.php @@ -4,29 +4,27 @@ $pagetitle[] = "Ports"; // Set Defaults here -if(!isset($vars['format'])) { $vars['format'] = "list_basic"; } +if(!isset($vars['format'])) { + $vars['format'] = "list_basic"; +} print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', - 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == "list_".$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) { + echo(""); + } + $sep = " | "; } ?> @@ -37,24 +35,21 @@ foreach ($menu_options as $option => $text) 'Bits', - 'upkts' => 'Unicast Packets', - 'nupkts' => 'Non-Unicast Packets', - 'errors' => 'Errors'); + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == 'graph_'.$option) - { - echo(''); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == 'graph_'.$option) { + echo(''); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + $sep = " | "; } echo('
    '); @@ -64,29 +59,28 @@ echo('
    '); Update URL | '')).'">Search'); - } else { +} +else { echo('Search'); - } +} - echo(" | "); +echo(" | "); - if (isset($vars['bare']) && $vars['bare'] == "yes") - { +if (isset($vars['bare']) && $vars['bare'] == "yes") { echo('Header'); - } else { +} +else { echo('Header'); - } +} echo('
    '); print_optionbar_end(); print_optionbar_start(); -if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) -{ +if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) { ?>
    @@ -95,67 +89,66 @@ if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars[' = 5) -{ - $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); -} -else -{ - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); -} -foreach ($results as $data) -{ - echo(' "); -} + if($_SESSION['userlevel'] >= 5) { + $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); + } + else { + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); + } + foreach ($results as $data) { + echo(' "); + } -if($_SESSION['userlevel'] < 5) -{ - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); -} -else -{ - $results = array(); -} -foreach ($results as $data) -{ - echo(' "); -} + if($_SESSION['userlevel'] < 5) { + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); + } + else { + $results = array(); + } + foreach ($results as $data) { + echo(' "); + } ?> - placeholder="Hostname" /> + placeholder="Hostname" />
    @@ -164,97 +157,100 @@ foreach (dbFetchRows($sql,$param) as $data) ".$data['ifType'].""); - } -} + if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`"; + } + else { + $sql = "SELECT `ifType` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `ifType` ORDER BY `ifType`"; + $param[] = array($_SESSION['user_id'],$_SESSION['user_id']); + } + foreach (dbFetchRows($sql,$param) as $data) { + if ($data['ifType']) { + echo(' "); + } + } ?>
    - placeholder="Port Description"/> + placeholder="Port Description"/>
    - > + > - > + > - > + >
    @@ -266,95 +262,98 @@ foreach ($sorts as $sort => $sort_text)
    '.$group['id'].' '.$group['group_name'].' '.$group['descr'].'
    '.$poller['poller_name'].' '.$poller['devices'].' '.$poller['time_taken'].' Seconds '.$poller['last_polled'].'
    - $value) -{ - if ($value != "") - { - switch ($var) - { - case 'hostname': - $where .= " AND D.hostname LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'location': - $where .= " AND D.location LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'device_id': - $where .= " AND D.device_id = ?"; - $param[] = $value; - break; - case 'deleted': - if ($value == 1) { - $where .= " AND `I`.`deleted` = 1"; - $ignore_filter = 1; +foreach ($vars as $var => $value) { + if ($value != "") { + switch ($var) { + case 'hostname': + $where .= " AND D.hostname LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'location': + $where .= " AND D.location LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'device_id': + $where .= " AND D.device_id = ?"; + $param[] = $value; + break; + case 'deleted': + if ($value == 1) { + $where .= " AND `I`.`deleted` = 1"; + $ignore_filter = 1; + } + break; + case 'ignore': + if ($value == 1) { + $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; + $ignore_filter = 1; + } + break; + case 'disabled': + if ($value == 1) { + $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; + $disabled_filter = 1; + } + break; + case 'ifSpeed': + if (is_numeric($value)) { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'errors': + if ($value == 1) { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + case 'state': + if ($value == "down") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; + $param[] = "up"; + $param[] = "down"; + } + elseif($value == "up") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = "up"; + $param[] = "up"; + } + elseif($value == "admindown") { + $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; + $param[] = "down"; + } + break; } - break; - case 'ignore': - if ($value == 1) { - $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; - $ignore_filter = 1; - } - break; - case 'disabled': - if ($value == 1) { - $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; - $disabled_filter = 1; - } - break; - case 'ifSpeed': - if (is_numeric($value)) - { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'errors': - if ($value == 1) - { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - case 'state': - if ($value == "down") - { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; - $param[] = "up"; - $param[] = "down"; - } elseif($value == "up") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = "up"; - $param[] = "up"; - } elseif($value == "admindown") { - $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; - $param[] = "down"; - } - break; } - } } if ($ignore_filter == 0 && $disabled_filter == 0) { @@ -369,49 +368,47 @@ list($format, $subformat) = explode("_", $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) -{ - case 'traffic': - $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); - break; - case 'traffic_in': - $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); - break; - case 'traffic_out': - $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); - break; - case 'packets': - $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); - break; - case 'packets_in': - $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); - break; - case 'packets_out': - $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); - break; - case 'errors': - $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); - break; - case 'speed': - $ports = array_sort($ports, 'ifSpeed', SORT_DESC); - break; - case 'port': - $ports = array_sort($ports, 'ifDescr', SORT_ASC); - break; - case 'media': - $ports = array_sort($ports, 'ifType', SORT_ASC); - break; - case 'descr': - $ports = array_sort($ports, 'ifAlias', SORT_ASC); - break; - case 'device': - default: - $ports = array_sort($ports, 'hostname', SORT_ASC); +switch ($vars['sort']) { + case 'traffic': + $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); + break; + case 'traffic_in': + $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); + break; + case 'traffic_out': + $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); + break; + case 'packets': + $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); + break; + case 'packets_in': + $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); + break; + case 'packets_out': + $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); + break; + case 'errors': + $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); + break; + case 'speed': + $ports = array_sort($ports, 'ifSpeed', SORT_DESC); + break; + case 'port': + $ports = array_sort($ports, 'ifDescr', SORT_ASC); + break; + case 'media': + $ports = array_sort($ports, 'ifType', SORT_ASC); + break; + case 'descr': + $ports = array_sort($ports, 'ifAlias', SORT_ASC); + break; + case 'device': + default: + $ports = array_sort($ports, 'hostname', SORT_ASC); } -if(file_exists('pages/ports/'.$format.'.inc.php')) -{ - include('pages/ports/'.$format.'.inc.php'); +if(file_exists('pages/ports/'.$format.'.inc.php')) { + require 'pages/ports/'.$format.'.inc.php'; } ?> diff --git a/html/pages/ports/list.inc.php b/html/pages/ports/list.inc.php index 8ae9c9df3..71f52e618 100644 --- a/html/pages/ports/list.inc.php +++ b/html/pages/ports/list.inc.php @@ -3,68 +3,75 @@ '); +echo ''; -$cols = array('device' => 'Device', - 'port' => 'Port', - 'speed' => 'Speed', - 'traffic_in' => 'Down', - 'traffic_out' => 'Up', - 'media' => 'Media', - 'descr' => 'Description' ); +$cols = array( + 'device' => 'Device', + 'port' => 'Port', + 'speed' => 'Speed', + 'traffic_in' => 'Down', + 'traffic_out' => 'Up', + 'media' => 'Media', + 'descr' => 'Description', +); -foreach ($cols as $sort => $col) -{ - if (isset($vars['sort']) && $vars['sort'] == $sort) - { - echo(''.$col.' *'); - } else { - echo(''.$col.''); - } +foreach ($cols as $sort => $col) { + if (isset($vars['sort']) && $vars['sort'] == $sort) { + echo ''.$col.' *'; + } + else { + echo ''.$col.''; + } } -echo(" "); +echo ' '; -$ports_disabled = 0; $ports_down = 0; $ports_up = 0; $ports_total = 0; +$ports_disabled = 0; +$ports_down = 0; +$ports_up = 0; +$ports_total = 0; -foreach ($ports as $port) -{ +foreach ($ports as $port) { + if (port_permitted($port['port_id'], $port['device_id'])) { + if ($port['ifAdminStatus'] == 'down') { + $ports_disabled++; + } + else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { + $ports_down++; + } + else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { + $ports_up++; + } - if (port_permitted($port['port_id'], $port['device_id'])) - { + $ports_total++; - if ($port['ifAdminStatus'] == "down") { $ports_disabled++; - } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "down") { $ports_down++; - } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "up") { $ports_up++; } - $ports_total++; + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) { + $error_img = generate_port_link($port, "Interface Errors", errors); + } + else { + $error_img = ''; + } - if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) - { - $error_img = generate_port_link($port,"Interface Errors",errors); - } else { $error_img = ""; } + $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); + $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); - $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); - $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); + $port = ifLabel($port, $device); + echo " + ".generate_device_link($port, shorthost($port['hostname'], '20'))." + ".fixIfName($port['label'])." $error_img + $speed + ".$port['in_rate'].' + '.$port['out_rate']." + $type + ".$port['ifAlias']." + \n"; + }//end if +}//end foreach - $port = ifLabel($port, $device); - echo(" - ".generate_device_link($port, shorthost($port['hostname'], "20"))." - ".fixIfName($port['label'])." $error_img - $speed - ".$port['in_rate']." - ".$port['out_rate']." - $type - " . $port['ifAlias'] . " - \n"); - } -} - -echo(''); -echo("Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"); -echo(''); - -?> +echo ''; +echo "Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"; +echo ''; diff --git a/html/pages/preferences.inc.php b/html/pages/preferences.inc.php index f4815df24..ca2f79835 100644 --- a/html/pages/preferences.inc.php +++ b/html/pages/preferences.inc.php @@ -1,48 +1,41 @@ User Preferences"); +echo '

    User Preferences

    '; if ($_SESSION['userlevel'] == 11) { - demo_account(); - -} else { - -if ($_POST['action'] == "changepass") -{ - if (authenticate($_SESSION['username'],$_POST['old_pass'])) - { - if ($_POST['new_pass'] == "" || $_POST['new_pass2'] == "") - { - $changepass_message = "Password must not be blank."; - } - elseif ($_POST['new_pass'] == $_POST['new_pass2']) - { - changepassword($_SESSION['username'],$_POST['new_pass']); - $changepass_message = "Password Changed."; - } - else - { - $changepass_message = "Passwords don't match."; - } - } else { - $changepass_message = "Incorrect password"; - } } +else { + if ($_POST['action'] == 'changepass') { + if (authenticate($_SESSION['username'], $_POST['old_pass'])) { + if ($_POST['new_pass'] == '' || $_POST['new_pass2'] == '') { + $changepass_message = 'Password must not be blank.'; + } + else if ($_POST['new_pass'] == $_POST['new_pass2']) { + changepassword($_SESSION['username'], $_POST['new_pass']); + $changepass_message = 'Password Changed.'; + } + else { + $changepass_message = "Passwords don't match."; + } + } + else { + $changepass_message = 'Incorrect password'; + } + } -include("includes/update-preferences-password.inc.php"); + include 'includes/update-preferences-password.inc.php'; -echo("
    "); + echo "
    "; -if (passwordscanchange($_SESSION['username'])) -{ - echo("

    Change Password

    "); - echo($changepass_message); - echo(" + if (passwordscanchange($_SESSION['username'])) { + echo '

    Change Password

    '; + echo $changepass_message; + echo "
    @@ -69,93 +62,107 @@ if (passwordscanchange($_SESSION['username']))
    -"); - echo("
    "); -} +"; + echo '
    '; + }//end if -if( $config['twofactor'] === true ) { - if( $_POST['twofactorremove'] == 1 ) { - require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); - if( !isset($_POST['twofactor']) ) { - echo '
    '; - echo ''; - echo twofactor_form(false); - echo '
    '; - } else{ - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - if( empty($twofactor['twofactor']) ) { - echo '
    Error: How did you even get here?!
    '; - } else { - $twofactor = json_decode($twofactor['twofactor'],true); - } - if( verify_hotp($twofactor['key'],$_POST['twofactor'],$twofactor['counter']) ) { - if( !dbUpdate(array('twofactor' => ''),'users','username = ?',array($_SESSION['username'])) ) { - echo '
    Error while disabling TwoFactor.
    '; - } else { - echo '
    TwoFactor Disabled.
    '; + if ($config['twofactor'] === true) { + if ($_POST['twofactorremove'] == 1) { + include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; + if (!isset($_POST['twofactor'])) { + echo '
    '; + echo ''; + echo twofactor_form(false); + echo '
    '; + } + else { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + if (empty($twofactor['twofactor'])) { + echo '
    Error: How did you even get here?!
    '; + } + else { + $twofactor = json_decode($twofactor['twofactor'], true); + } + + if (verify_hotp($twofactor['key'], $_POST['twofactor'], $twofactor['counter'])) { + if (!dbUpdate(array('twofactor' => ''), 'users', 'username = ?', array($_SESSION['username']))) { + echo '
    Error while disabling TwoFactor.
    '; + } + else { + echo '
    TwoFactor Disabled.
    '; + } + } + else { + session_destroy(); + echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; + } + }//end if } - } else { - session_destroy(); - echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; - } - } - } else { - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); - echo ''; - echo '

    Two-Factor Authentication

    '; - if( !empty($twofactor['twofactor']) ) { - $twofactor = json_decode($twofactor['twofactor'],true); - $twofactor['text'] = "
    + else { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + echo ''; + echo '

    Two-Factor Authentication

    '; + if (!empty($twofactor['twofactor'])) { + $twofactor = json_decode($twofactor['twofactor'], true); + $twofactor['text'] = "
    "; - if( $twofactor['counter'] !== false ) { - $twofactor['uri'] = "otpauth://hotp/".$_SESSION['username']."?issuer=LibreNMS&counter=".$twofactor['counter']."&secret=".$twofactor['key']; - $twofactor['text'] .= "
    + if ($twofactor['counter'] !== false) { + $twofactor['uri'] = 'otpauth://hotp/'.$_SESSION['username'].'?issuer=LibreNMS&counter='.$twofactor['counter'].'&secret='.$twofactor['key']; + $twofactor['text'] .= "
    "; - } else { - $twofactor['uri'] = "otpauth://totp/".$_SESSION['username']."?issuer=LibreNMS&secret=".$twofactor['key']; - } - echo '
    + } + else { + $twofactor['uri'] = 'otpauth://totp/'.$_SESSION['username'].'?issuer=LibreNMS&secret='.$twofactor['key']; + } + + echo '
    '; - echo '
    + echo '
    '.$twofactor['text'].'
    '; - echo ''; - echo '
    + echo ''; + echo '
    '; - } else { - if( isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype']) ) { - require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); - $chk = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); - if( empty($chk['twofactor']) ) { - $twofactor = array('key' => twofactor_genkey()); - if( $_POST['twofactortype'] == "counter" ) { - $twofactor['counter'] = 1; - } else { - $twofactor['counter'] = false; - } - if( !dbUpdate(array('twofactor' => json_encode($twofactor)),'users','username = ?',array($_SESSION['username'])) ) { - echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; - } else { - echo '
    Added TwoFactor credentials. Please reload page.
    '; - } - } else { - echo '
    TwoFactor credentials already exists.
    '; - } - } else { - echo '
    + } + else { + if (isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype'])) { + include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; + $chk = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + if (empty($chk['twofactor'])) { + $twofactor = array('key' => twofactor_genkey()); + if ($_POST['twofactortype'] == 'counter') { + $twofactor['counter'] = 1; + } + else { + $twofactor['counter'] = false; + } + + if (!dbUpdate(array('twofactor' => json_encode($twofactor)), 'users', 'username = ?', array($_SESSION['username']))) { + echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; + } + else { + echo '
    Added TwoFactor credentials. Please reload page.
    '; + } + } + else { + echo '
    TwoFactor credentials already exists.
    '; + } + } + else { + echo '
    @@ -169,32 +176,34 @@ if( $config['twofactor'] === true ) {
    '; - } + }//end if + }//end if + echo '
    '; + }//end if + }//end if +}//end if + +echo "
    '; - } } -} - -echo("
    "); -echo("
    Device Permissions
    "); - -if ($_SESSION['userlevel'] == '10') { echo("Global Administrative Access"); } -if ($_SESSION['userlevel'] == '5') { echo("Global Viewing Access"); } -if ($_SESSION['userlevel'] == '1') -{ - - foreach (dbFetchRows("SELECT * FROM `devices_perms` AS P, `devices` AS D WHERE `user_id` = ? AND P.device_id = D.device_id", array($_SESSION['user_id'])) as $perm) - { - #FIXME generatedevicelink? - echo("" . $perm['hostname'] . "
    "); - $dev_access = 1; - } - - if (!$dev_access) { echo("No access!"); } -} - -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index 5dd77f468..3408973fd 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -90,8 +90,7 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I, devices AS D W $pw_a['to'] = $config['time']['now']; $pw_a['bg'] = $bg; $types = array('bits', 'upkts', 'errors'); - foreach ($types as $graph_type) - { + foreach ($types as $graph_type) { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php index ad89593bc..bb2583884 100644 --- a/html/pages/public.inc.php +++ b/html/pages/public.inc.php @@ -1,14 +1,14 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * This file is part of LibreNMS + * + * Copyright (c) 2014 Bohdan Sanders + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ ?> @@ -28,14 +28,11 @@ $(document).ready(function() {

    System Status

    @@ -50,9 +47,8 @@ $query = "SELECT * FROM `devices` WHERE 1 AND disabled='0' AND `ignore`='0' ORDE Uptime/Location diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index 5e0494562..3268715ec 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -1,260 +1,355 @@ 'routing', 'protocol' => 'bgp'); +else { + $link_array = array( + 'page' => 'routing', + 'protocol' => 'bgp', + ); - print_optionbar_start('', ''); + print_optionbar_start('', ''); - echo('BGP » '); + echo 'BGP » '; - if (!$vars['type']) { $vars['type'] = "all"; } - - if ($vars['type'] == "all") { echo(""); } - echo(generate_link("All",$vars, array('type' => 'all'))); - if ($vars['type'] == "all") { echo(""); } - - echo(" | "); - - if ($vars['type'] == "internal") { echo(""); } - echo(generate_link("iBGP",$vars, array('type' => 'internal'))); - if ($vars['type'] == "internal") { echo(""); } - - echo(" | "); - - if ($vars['type'] == "external") { echo(""); } - echo(generate_link("eBGP",$vars, array('type' => 'external'))); - if ($vars['type'] == "external") { echo(""); } - - echo(" | "); - - if ($vars['adminstatus'] == "stop") - { - echo(""); - echo(generate_link("Shutdown",$vars, array('adminstatus' => NULL))); - echo(""); - } else { - echo(generate_link("Shutdown",$vars, array('adminstatus' => 'stop'))); - } - - echo(" | "); - - if ($vars['adminstatus'] == "start") - { - echo(""); - echo(generate_link("Enabled",$vars, array('adminstatus' => NULL))); - echo(""); - } else { - echo(generate_link("Enabled",$vars, array('adminstatus' => 'start'))); - } - - echo(" | "); - - if ($vars['state'] == "down") - { - echo(""); - echo(generate_link("Down",$vars, array('state' => NULL))); - echo(""); - } else { - echo(generate_link("Down",$vars, array('state' => 'down'))); - } - - // End BGP Menu - - if (!isset($vars['view'])) { $vars['view'] = 'details'; } - - echo('
    '); - - if ($vars['view'] == "details") { echo(""); } - echo(generate_link("No Graphs",$vars, array('view' => 'details', 'graph' => 'NULL'))); - if ($vars['view'] == "details") { echo(""); } - - echo(" | "); - - if ($vars['graph'] == "updates") { echo(""); } - echo(generate_link("Updates",$vars, array('view' => 'graphs', 'graph' => 'updates'))); - if ($vars['graph'] == "updates") { echo(""); } - - echo(" | Prefixes: Unicast ("); - if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } - echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast'))); - if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } - echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast'))); - if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } - echo(generate_link("VPNv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn'))); - if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } - echo(")"); - - echo(" | Multicast ("); - if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } - echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast'))); - if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } - echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast'))); - if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } - echo(")"); - - echo(" | MAC ("); - if ($vars['graph'] == "macaccounting_bits") { echo(""); } - echo(generate_link("Bits",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits'))); - if ($vars['graph'] == "macaccounting_bits") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "macaccounting_pkts") { echo(""); } - echo(generate_link("Packets",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts'))); - if ($vars['graph'] == "macaccounting_pkts") { echo(""); } - echo(")"); - - echo('
    '); - - print_optionbar_end(); - - echo(""); - echo(''); - - if ($vars['type'] == "external") - { - $where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs"; - } elseif ($vars['type'] == "internal") { - $where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs"; - } - - if ($vars['adminstatus'] == "stop") - { - $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; - } elseif ($vars['adminstatus'] == "start") - { - $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; - } - - if ($vars['state'] == "down") - { - $where .= " AND (B.bgpPeerState != 'established')"; - } - - $peer_query = "select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id ".$where." ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"; - foreach (dbFetchRows($peer_query) as $peer) - { - unset ($alert, $bg_image); - - if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } - if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } - if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } - if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; - if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } + if (!$vars['type']) { + $vars['type'] = 'all'; } - $peerhost = dbFetchRow("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($peer['bgpPeerIdentifier'])); - - if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } - - // display overlib graphs - - $graph_type = "bgp_updates"; - $local_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150&&afi=ipv4&safi=unicast"; - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); - } else { - $peer_ip = $peer['bgpLocalAddr']; - } - $localaddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ip . ""; - - $graph_type = "bgp_updates"; - $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } else { - $peer_ident = $peer['bgpPeerIdentifier']; + if ($vars['type'] == 'all') { + echo ""; } - $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ident . ""; - - echo('"); - - unset($sep); - foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) - { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep . $afi .".".$safi; - $sep = "
    "; - $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer - } - unset($sep); - - echo(" - - - - - - - - "); - - unset($invalid); - switch ($vars['graph']) - { - case 'prefixes_ipv4unicast': - case 'prefixes_ipv4multicast': - case 'prefixes_ipv4vpn': - case 'prefixes_ipv6unicast': - case 'prefixes_ipv6multicast': - list(,$afisafi) = explode("_", $vars['graph']); - if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } - case 'updates': - $graph_array['type'] = "bgp_" . $vars['graph']; - $graph_array['id'] = $peer['bgpPeer_id']; + echo generate_link('All', $vars, array('type' => 'all')); + if ($vars['type'] == 'all') { + echo ''; } - switch ($vars['graph']) - { - case 'macaccounting_bits': - case 'macaccounting_pkts': - $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - if (is_array($acc) && is_file($database)) - { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['graph']; + echo ' | '; + + if ($vars['type'] == 'internal') { + echo ""; + } + + echo generate_link('iBGP', $vars, array('type' => 'internal')); + if ($vars['type'] == 'internal') { + echo ''; + } + + echo ' | '; + + if ($vars['type'] == 'external') { + echo ""; + } + + echo generate_link('eBGP', $vars, array('type' => 'external')); + if ($vars['type'] == 'external') { + echo ''; + } + + echo ' | '; + + if ($vars['adminstatus'] == 'stop') { + echo ""; + echo generate_link('Shutdown', $vars, array('adminstatus' => null)); + echo ''; + } + else { + echo generate_link('Shutdown', $vars, array('adminstatus' => 'stop')); + } + + echo ' | '; + + if ($vars['adminstatus'] == 'start') { + echo ""; + echo generate_link('Enabled', $vars, array('adminstatus' => null)); + echo ''; + } + else { + echo generate_link('Enabled', $vars, array('adminstatus' => 'start')); + } + + echo ' | '; + + if ($vars['state'] == 'down') { + echo ""; + echo generate_link('Down', $vars, array('state' => null)); + echo ''; + } + else { + echo generate_link('Down', $vars, array('state' => 'down')); + } + + // End BGP Menu + if (!isset($vars['view'])) { + $vars['view'] = 'details'; + } + + echo '
    '; + + if ($vars['view'] == 'details') { + echo ""; + } + + echo generate_link('No Graphs', $vars, array('view' => 'details', 'graph' => 'NULL')); + if ($vars['view'] == 'details') { + echo ''; + } + + echo ' | '; + + if ($vars['graph'] == 'updates') { + echo ""; + } + + echo generate_link('Updates', $vars, array('view' => 'graphs', 'graph' => 'updates')); + if ($vars['graph'] == 'updates') { + echo ''; + } + + echo ' | Prefixes: Unicast ('; + if ($vars['graph'] == 'prefixes_ipv4unicast') { + echo ""; + } + + echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast')); + if ($vars['graph'] == 'prefixes_ipv4unicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv6unicast') { + echo ""; + } + + echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast')); + if ($vars['graph'] == 'prefixes_ipv6unicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv4vpn') { + echo ""; + } + + echo generate_link('VPNv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn')); + if ($vars['graph'] == 'prefixes_ipv4vpn') { + echo ''; + } + + echo ')'; + + echo ' | Multicast ('; + if ($vars['graph'] == 'prefixes_ipv4multicast') { + echo ""; + } + + echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast')); + if ($vars['graph'] == 'prefixes_ipv4multicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv6multicast') { + echo ""; + } + + echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast')); + if ($vars['graph'] == 'prefixes_ipv6multicast') { + echo ''; + } + + echo ')'; + + echo ' | MAC ('; + if ($vars['graph'] == 'macaccounting_bits') { + echo ""; + } + + echo generate_link('Bits', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits')); + if ($vars['graph'] == 'macaccounting_bits') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'macaccounting_pkts') { + echo ""; + } + + echo generate_link('Packets', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts')); + if ($vars['graph'] == 'macaccounting_pkts') { + echo ''; + } + + echo ')'; + + echo '
    '; + + print_optionbar_end(); + + echo "
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    " . $localaddresslink . "
    ".generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp'))."
    »" . $peeraddresslink . "$peer_type".$peer['afi']."AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    - Updates " . format_si($peer['bgpPeerInUpdates']) . " - " . format_si($peer['bgpPeerOutUpdates']) . "
    "; + echo ''; + + if ($vars['type'] == 'external') { + $where = 'AND D.bgpLocalAs != B.bgpPeerRemoteAs'; + } + else if ($vars['type'] == 'internal') { + $where = 'AND D.bgpLocalAs = B.bgpPeerRemoteAs'; + } + + if ($vars['adminstatus'] == 'stop') { + $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; + } + else if ($vars['adminstatus'] == 'start') { + $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; + } + + if ($vars['state'] == 'down') { + $where .= " AND (B.bgpPeerState != 'established')"; + } + + $peer_query = 'select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id '.$where.' ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier'; + foreach (dbFetchRows($peer_query) as $peer) { + unset($alert, $bg_image); + + if ($peer['bgpPeerState'] == 'established') { + $col = 'green'; + } + else { + $col = 'red'; + $peer['alert'] = 1; } - } - if ($vars['graph'] == 'updates') { $peer['graph'] = 1; } + if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { + $admin_col = 'green'; + } + else { + $admin_col = 'gray'; + } - if ($peer['graph']) - { - $graph_array['height'] = "100"; - $graph_array['width'] = "218"; - $graph_array['to'] = $config['time']['now']; - echo('"); - } - } + $peerhost = dbFetchRow('SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($peer['bgpPeerIdentifier'])); - echo("
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    '); + if ($peer['bgpPeerAdminStatus'] == 'stop') { + $peer['alert'] = 0; + $peer['disabled'] = 1; + } - include("includes/print-graphrow.inc.php"); + if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { + $peer_type = "iBGP"; + } + else { + $peer_type = "eBGP"; + if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { + $peer_type = "Priv eBGP"; + } + } - echo("
    "); -} + if ($peerhost) { + $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); + } + else { + unset($peername); + } + // display overlib graphs + $graph_type = 'bgp_updates'; + $local_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150&&afi=ipv4&safi=unicast'; + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); + } + else { + $peer_ip = $peer['bgpLocalAddr']; + } + + $localaddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ip.''; + + $graph_type = 'bgp_updates'; + $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } + else { + $peer_ident = $peer['bgpPeerIdentifier']; + } + + $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ident.''; + + echo ''; + + unset($sep); + foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep.$afi.'.'.$safi; + $sep = '
    '; + $peer['afisafi'][$this_afisafi] = 1; + // Build a list of valid AFI/SAFI for this peer + } + + unset($sep); + + echo ' + '.$localaddresslink.'
    '.generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')).' + » + '.$peeraddresslink." + $peer_type + ".$peer['afi'].' + AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']." + ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    + '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    + Updates ".format_si($peer['bgpPeerInUpdates'])." + ".format_si($peer['bgpPeerOutUpdates']).''; + + unset($invalid); + switch ($vars['graph']) { + case 'prefixes_ipv4unicast': + case 'prefixes_ipv4multicast': + case 'prefixes_ipv4vpn': + case 'prefixes_ipv6unicast': + case 'prefixes_ipv6multicast': + list(,$afisafi) = explode('_', $vars['graph']); + if (isset($peer['afisafi'][$afisafi])) { + $peer['graph'] = 1; + } + + case 'updates': + $graph_array['type'] = 'bgp_'.$vars['graph']; + $graph_array['id'] = $peer['bgpPeer_id']; + } + + switch ($vars['graph']) { + case 'macaccounting_bits': + case 'macaccounting_pkts': + $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; + if (is_array($acc) && is_file($database)) { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['graph']; + } + } + + if ($vars['graph'] == 'updates') { + $peer['graph'] = 1; + } + + if ($peer['graph']) { + $graph_array['height'] = '100'; + $graph_array['width'] = '218'; + $graph_array['to'] = $config['time']['now']; + echo ''; + + include 'includes/print-graphrow.inc.php'; + + echo ''; + } + }//end foreach + + echo ''; +}//end if diff --git a/html/pages/routing/overview.inc.php b/html/pages/routing/overview.inc.php index bd9a9e63e..c16262143 100644 --- a/html/pages/routing/overview.inc.php +++ b/html/pages/routing/overview.inc.php @@ -1,7 +1,7 @@ 'IPv4 Address', 'ipv6' => 'IPv6 Address', 'mac' => 'MAC Address', 'arp' => 'ARP Table'); +$sections = array( + 'ipv4' => 'IPv4 Address', + 'ipv6' => 'IPv6 Address', + 'mac' => 'MAC Address', + 'arp' => 'ARP Table', +); -if( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { - $sections['packages'] = 'Packages'; +if (dbFetchCell('SELECT 1 from `packages` LIMIT 1')) { + $sections['packages'] = 'Packages'; } -if (!isset($vars['search'])) { $vars['search'] = "ipv4"; } +if (!isset($vars['search'])) { + $vars['search'] = 'ipv4'; +} print_optionbar_start('', ''); - echo('Search » '); +echo 'Search » '; unset($sep); -foreach ($sections as $type => $texttype) -{ - echo($sep); - if ($vars['search'] == $type) - { - echo(""); - } +foreach ($sections as $type => $texttype) { + echo $sep; + if ($vars['search'] == $type) { + echo ""; + } -# echo('' . $texttype .''); - echo(generate_link($texttype, array('page'=>'search','search'=>$type))); + // echo('' . $texttype .''); + echo generate_link($texttype, array('page' => 'search', 'search' => $type)); - if ($vars['search'] == $type) { echo(""); } + if ($vars['search'] == $type) { + echo ''; + } - $sep = ' | '; + $sep = ' | '; } -unset ($sep); + +unset($sep); print_optionbar_end('', ''); -if( file_exists('pages/search/'.$vars['search'].'.inc.php') ) { - include('pages/search/'.$vars['search'].'.inc.php'); -} else { - echo(report_this('Unknown search type '.$vars['search'])); +if (file_exists('pages/search/'.$vars['search'].'.inc.php')) { + include 'pages/search/'.$vars['search'].'.inc.php'; +} +else { + echo report_this('Unknown search type '.$vars['search']); } - -?> diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index a4dcbd113..45cd6888a 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -30,21 +30,22 @@ var grid = $("#arp-search").bootgrid({ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -53,18 +54,16 @@ foreach (dbFetchRows($sql,$param) as $data) { " "\" class=\"form-control input-sm\" placeholder=\"Address\" />"+ diff --git a/html/pages/search/ipv4.inc.php b/html/pages/search/ipv4.inc.php index e2ea785c0..843acbd1b 100644 --- a/html/pages/search/ipv4.inc.php +++ b/html/pages/search/ipv4.inc.php @@ -27,22 +27,23 @@ var grid = $("#ipv4-search").bootgrid({ ""+ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -52,18 +53,16 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
     "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ "
     "+ ""+ "
    "+ diff --git a/html/pages/search/ipv6.inc.php b/html/pages/search/ipv6.inc.php index 8ab58d9ff..2b9115013 100644 --- a/html/pages/search/ipv6.inc.php +++ b/html/pages/search/ipv6.inc.php @@ -26,22 +26,23 @@ var grid = $("#ipv6-search").bootgrid({ ""+ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -51,9 +52,8 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
    "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index c040a1e16..f606e4436 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -26,21 +26,22 @@ var grid = $("#mac-search").bootgrid({ ""+ @@ -50,17 +51,15 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
    '-1', - 'rule' => '%macros.device_down = "1"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"-1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Devices up/down', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%devices.uptime < "300" && %macros.device = "1"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Device rebooted', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%bgpPeers.bgpPeerState != "established" && %macros.device_up = "1"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"1","delay":"300"}', - 'disabled' => 0, - 'name' => 'BGP Session down', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"1","delay":"300"}', - 'disabled' => 0, - 'name' => 'BGP Session establised', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%macros.port_down = "1"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Port status up/down', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%macros.port_usage_perc >= "80"', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"-1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Port utilisation over threshold', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"-1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Sensor over limit', - ); - $default_rules[] = array( - 'device_id' => '-1', - 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', - 'severity' => 'critical', - 'extra' => '{"mute":false,"count":"-1","delay":"300"}', - 'disabled' => 0, - 'name' => 'Sensor under limit', - ); - foreach ($default_rules as $add_rule) { - dbInsert($add_rule, 'alert_rules'); - } -}//end if -require_once 'includes/modal/new_alert_rule.inc.php'; -require_once 'includes/modal/delete_alert_rule.inc.php'; +if(isset($_POST['create-default'])) { + $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.device_down = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Devices up/down'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%devices.uptime < "300" && %macros.device = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Device rebooted'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerState != "established" && %macros.device_up = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session down'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session establised'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.port_down = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Port status up/down'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.port_usage_perc >= "80"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Port utilisation over threshold'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor over limit'); + $default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor under limit'); + foreach( $default_rules as $add_rule ) { + dbInsert($add_rule,'alert_rules'); + } +} + +require_once('includes/modal/new_alert_rule.inc.php'); +require_once('includes/modal/delete_alert_rule.inc.php'); + ?>
    0) { + +if(isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} -else { +} else { $results = 50; } echo '
    - - +
    + @@ -103,150 +49,126 @@ echo '
    - '; + '; -echo ' - +'); -echo ''; - -$rulei = 1; -$count_query = 'SELECT COUNT(id)'; -$full_query = 'SELECT *'; -$sql = ''; -$param = array(); -if (isset($device['device_id']) && $device['device_id'] > 0) { - $sql = 'WHERE (device_id=? OR device_id="-1")'; +$rulei=1; +$count_query = "SELECT COUNT(id)"; +$full_query = "SELECT *"; +$sql = ''; +$param = array(); +if(isset($device['device_id']) && $device['device_id'] > 0) { + $sql = 'WHERE (device_id=? OR device_id="-1")'; $param = array($device['device_id']); } - -$query = " FROM alert_rules $sql ORDER BY device_id,id"; -$count_query = $count_query.$query; -$count = dbFetchCell($count_query, $param); -if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { +$query = " FROM alert_rules $sql ORDER BY device_id,id"; +$count_query = $count_query . $query; +$count = dbFetchCell($count_query,$param); +if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} -else { +} else { $page_number = $_POST['page_number']; } +$start = ($page_number - 1) * $results; +$full_query = $full_query . $query . " LIMIT $start,$results"; -$start = (($page_number - 1) * $results); -$full_query = $full_query.$query." LIMIT $start,$results"; - -foreach (dbFetchRows($full_query, $param) as $rule) { - $sub = dbFetchRows('SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1', array($rule['id'])); - $ico = 'ok'; - $col = 'success'; - $extra = ''; - if (sizeof($sub) == 1) { - $sub = $sub[0]; - if ((int) $sub['state'] === 0) { - $ico = 'ok'; - $col = 'success'; +foreach( dbFetchRows($full_query, $param) as $rule ) { + $sub = dbFetchRows("SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1", array($rule['id'])); + $ico = "ok"; + $col = "success"; + $extra = ""; + if( sizeof($sub) == 1 ) { + $sub = $sub[0]; + if( (int) $sub['state'] === 0 ) { + $ico = "ok"; + $col = "success"; + } elseif( (int) $sub['state'] === 1 ) { + $ico = "remove"; + $col = "danger"; + $extra = "danger"; + } elseif( (int) $sub['state'] === 2 ) { + $ico = "time"; + $col = "default"; + $extra = "warning"; + } + } + $alert_checked = ''; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; + if( $rule['disabled'] ) { + $ico = "pause"; + $col = ""; + $extra = "active"; + } else { + $alert_checked = 'checked'; } - else if ((int) $sub['state'] === 1) { - $ico = 'remove'; - $col = 'danger'; - $extra = 'danger'; + $rule_extra = json_decode($rule['extra'],TRUE); + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; } - } - - $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; - if ($rule['disabled']) { - $ico = 'pause'; - $col = ''; - $extra = 'active'; - } - else { - $alert_checked = 'checked'; - } - - $rule_extra = json_decode($rule['extra'], true); - echo ""; - echo ''; - echo ''; - echo "'; - echo ''; - echo ""; - } - - echo ''; - echo ''; - echo ''; - echo "\r\n"; -}//end foreach - -if (($count % $results) > 0) { - echo ' - - '; + echo ""; + echo ""; + echo ""; + echo "\r\n"; } +if($count % $results > 0) { + echo(' + + '); +} echo '
    # Name RuleExtra Enabled Action
    '; +echo (''); if ($_SESSION['userlevel'] >= '10') { - echo ''; + echo(''); } - -echo '
    #".((int) $rulei++)."".$rule['name'].""; + if($rule_extra['invert'] === true) { + echo "Inverted "; } - else if ((int) $sub['state'] === 2) { - $ico = 'time'; - $col = 'default'; - $extra = 'warning'; + echo "".htmlentities($rule['rule'])."".$rule['severity']." "; + if($rule_extra['mute'] === true) { + echo "
    #'.((int) $rulei++).''.$rule['name'].'"; - if ($rule_extra['invert'] === true) { - echo 'Inverted '; - } - - echo ''.htmlentities($rule['rule']).''.$rule['severity'].' "; - if ($rule_extra['mute'] === true) { - echo "Max: '.$rule_extra['count'].'
    Delay: '.$rule_extra['delay'].'
    Interval: '.$rule_extra['interval'].'
    '; - if ($_SESSION['userlevel'] >= '10') { - echo ""; - } - - echo ''; - if ($_SESSION['userlevel'] >= '10') { - echo " "; - echo ""; - } - - echo '
    '.generate_pagination($count, $results, $page_number).'
    Max: ".$rule_extra['count']."
    Delay: ".$rule_extra['delay']."
    Interval: ".$rule_extra['interval']."
    "; + if ($_SESSION['userlevel'] >= '10') { + echo ""; + } + echo ""; + if ($_SESSION['userlevel'] >= '10') { + echo " "; + echo ""; + } + echo "
    '. generate_pagination($count,$results,$page_number) .'
    - - - -
    '; + + + +
    '; -if ($count < 1) { +if($count < 1) { if ($_SESSION['userlevel'] >= '10') { echo '
    -
    -
    -

    - -

    -
    -
    -
    '; +
    +
    +

    + +

    +
    +
    +
    '; } } @@ -258,19 +180,19 @@ $('#ack-alert').click('', function(e) { var alert_id = $(this).data("alert_id"); $.ajax({ type: "POST", - url: "/ajax_form.php", - data: { type: "ack-alert", alert_id: alert_id }, - success: function(msg){ - $("#message").html('
    '+msg+'
    '); - if(msg.indexOf("ERROR:") <= -1) { - setTimeout(function() { - location.reload(1); - }, 1000); - } - }, - error: function(){ - $("#message").html('
    An error occurred acking this alert.
    '); - } + url: "/ajax_form.php", + data: { type: "ack-alert", alert_id: alert_id }, + success: function(msg){ + $("#message").html('
    '+msg+'
    '); + if(msg.indexOf("ERROR:") <= -1) { + setTimeout(function() { + location.reload(1); + }, 1000); + } + }, + error: function(){ + $("#message").html('
    An error occurred acking this alert.
    '); + } }); }); @@ -284,42 +206,42 @@ $('input[name="alert-rule"]').on('switchChange.bootstrapSwitch', function(event var orig_class = $(this).data("orig_class"); $.ajax({ type: 'POST', - url: '/ajax_form.php', - data: { type: "update-alert-rule", alert_id: alert_id, state: state }, - dataType: "html", - success: function(msg) { - if(msg.indexOf("ERROR:") <= -1) { - if(state) { - $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).removeClass('text-default'); - $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); - $('#row_'+alert_id).removeClass('active'); - $('#row_'+alert_id).addClass(orig_class); - } else { - $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); - $('#alert-rule-'+alert_id).addClass('text-default'); - $('#row_'+alert_id).removeClass('warning'); - $('#row_'+alert_id).addClass('active'); - } + url: '/ajax_form.php', + data: { type: "update-alert-rule", alert_id: alert_id, state: state }, + dataType: "html", + success: function(msg) { + if(msg.indexOf("ERROR:") <= -1) { + if(state) { + $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).removeClass('text-default'); + $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); + $('#row_'+alert_id).removeClass('active'); + $('#row_'+alert_id).addClass(orig_class); } else { - $("#message").html('
    '+msg+'
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); - } - }, - error: function() { - $("#message").html('
    This alert could not be updated.
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); + $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); + $('#alert-rule-'+alert_id).addClass('text-default'); + $('#row_'+alert_id).removeClass('warning'); + $('#row_'+alert_id).addClass('active'); } + } else { + $("#message").html('
    '+msg+'
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); + } + }, + error: function() { + $("#message").html('
    This alert could not be updated.
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); + } }); }); function updateResults(results) { - $('#results_amount').val(results.value); - $('#page_number').val(1); - $('#result_form').submit(); + $('#results_amount').val(results.value); + $('#page_number').val(1); + $('#result_form').submit(); } function changePage(page,e) { diff --git a/html/includes/print-alert-templates.php b/html/includes/print-alert-templates.php index 8ad6e8265..16a3afdd0 100644 --- a/html/includes/print-alert-templates.php +++ b/html/includes/print-alert-templates.php @@ -1,6 +1,6 @@ @@ -10,17 +10,17 @@ $no_refresh = true;
    0) { +if (isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} else { +} +else { $results = 50; } @@ -34,37 +34,49 @@ echo '
    '; if ($_SESSION['userlevel'] >= '10') { - echo(''); + echo ''; } echo ' '); -$count_query = "SELECT COUNT(id)"; -$full_query = "SELECT *"; +echo ''; -$query = " FROM `alert_templates`"; +$count_query = 'SELECT COUNT(id)'; +$full_query = 'SELECT *'; -$count_query = $count_query . $query; -$count = dbFetchCell($count_query,$param); -if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { +$query = ' FROM `alert_templates`'; + +$count_query = $count_query.$query; +$count = dbFetchCell($count_query, $param); +if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} else { +} +else { $page_number = $_POST['page_number']; } -$start = ($page_number - 1) * $results; -$full_query = $full_query . $query . " LIMIT $start,$results"; -foreach( dbFetchRows($full_query, $param) as $template ) { +$start = (($page_number - 1) * $results); +$full_query = $full_query.$query." LIMIT $start,$results"; + +foreach (dbFetchRows($full_query, $param) as $template) { echo ' '.$template['name'].' '; @@ -73,14 +85,15 @@ foreach( dbFetchRows($full_query, $param) as $template ) { echo " "; echo ""; } + echo ' '; } -if($count % $results > 0) { - echo(' - '. generate_pagination($count,$results,$page_number) .' - '); +if (($count % $results) > 0) { + echo ' + '.generate_pagination($count, $results, $page_number).' + '; } echo ' diff --git a/html/includes/print-alerts.inc.php b/html/includes/print-alerts.inc.php index dcbab4b3d..d9758a0f3 100644 --- a/html/includes/print-alerts.inc.php +++ b/html/includes/print-alerts.inc.php @@ -1,49 +1,49 @@ - - ' . $alert_entry['time_logged'] . ' - '); +echo ' + + '.$alert_entry['time_logged'].' + '; if (!isset($alert_entry['device'])) { - $dev = device_by_id_cache($alert_entry['device_id']); - echo(" - " . generate_device_link($dev, shorthost($dev['hostname'])) . " - "); + $dev = device_by_id_cache($alert_entry['device_id']); + echo ' + '.generate_device_link($dev, shorthost($dev['hostname'])).' + '; } -echo("".htmlspecialchars($alert_entry['name']) . ""); +echo ''.htmlspecialchars($alert_entry['name']).''; -if ($alert_state!='') { - if ($alert_state=='0') { - $glyph_icon = 'ok'; +if ($alert_state != '') { + if ($alert_state == '0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - elseif ($alert_state=='1') { - $glyph_icon = 'remove'; + else if ($alert_state == '1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - elseif ($alert_state=='2') { - $glyph_icon = 'info-sign'; + else if ($alert_state == '2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - elseif ($alert_state=='3') { - $glyph_icon = 'arrow-down'; + else if ($alert_state == '3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - elseif ($alert_state=='4') { - $glyph_icon = 'arrow-up'; + else if ($alert_state == '4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - } - echo(" $text"); -} + $text = 'Better'; + }//end if + echo " $text"; +}//end if -echo(""); +echo ''; diff --git a/html/includes/print-debug.php b/html/includes/print-debug.php index f35cd05bf..7fdbbcc6d 100644 --- a/html/includes/print-debug.php +++ b/html/includes/print-debug.php @@ -1,6 +1,6 @@ @@ -14,25 +14,23 @@ @@ -52,26 +50,25 @@ foreach ($sql_debug as $sql_error) { @@ -97,10 +95,12 @@ if ($_SESSION['userlevel'] >= '10') { if (is_admin() === TRUE || is_read() === TRUE) { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; -} else { +} +else { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`"; $param[] = $_SESSION['user_id']; } + foreach (dbFetchRows($sql,$param) as $devtype) { if (empty($devtype['type'])) { $devtype['type'] = 'generic'; @@ -108,9 +108,10 @@ foreach (dbFetchRows($sql,$param) as $devtype) { echo('
  • ' . ucfirst($devtype['type']) . '
  • '); } -require_once('../includes/device-groups.inc.php'); +require_once '../includes/device-groups.inc.php'; + foreach( GetDeviceGroups() as $group ) { - echo '
  • '.ucfirst($group['name']).'
  • '; + echo '
  • '.ucfirst($group['name']).'
  • '; } unset($group); @@ -118,29 +119,24 @@ unset($group); '); if ($_SESSION['userlevel'] >= '10') { -if ($config['show_locations']) -{ - - echo(' + if ($config['show_locations']) { + echo(' - '); -} - echo(' + '); + } + echo('
  • Manage Groups
  • Add Device
  • @@ -155,8 +151,7 @@ if ($config['show_locations'])
  • Alerts ('.$service_alerts.')
  • '); } -if ($_SESSION['userlevel'] >= '10') -{ - echo(' +if ($_SESSION['userlevel'] >= '10') { + echo('
  • Add Service
  • Edit Service
  • @@ -197,36 +190,53 @@ if ($_SESSION['userlevel'] >= '10') 0) -{ - echo('
  • Errored ('.$ports['errored'].')
  • '); +if ($ports['errored'] > 0) { + echo('
  • Errored ('.$ports['errored'].')
  • '); } -if ($ports['ignored'] > 0) -{ - echo('
  • Ignored ('.$ports['ignored'].')
  • '); +if ($ports['ignored'] > 0) { + echo('
  • Ignored ('.$ports['ignored'].')
  • '); } if ($config['enable_billing']) { - echo('
  • Traffic Bills
  • '); $ifbreak = 1; + echo('
  • Traffic Bills
  • '); + $ifbreak = 1; } if ($config['enable_pseudowires']) { - echo('
  • Pseudowires
  • '); $ifbreak = 1; + echo('
  • Pseudowires
  • '); + $ifbreak = 1; } ?> = '5') -{ - echo(' '); - if ($config['int_customers']) { echo('
  • Customers
  • '); $ifbreak = 1; } - if ($config['int_l2tp']) { echo('
  • L2TP
  • '); $ifbreak = 1; } - if ($config['int_transit']) { echo('
  • Transit
  • '); $ifbreak = 1; } - if ($config['int_peering']) { echo('
  • Peering
  • '); $ifbreak = 1; } - if ($config['int_peering'] && $config['int_transit']) { echo('
  • Peering + Transit
  • '); $ifbreak = 1; } - if ($config['int_core']) { echo('
  • Core
  • '); $ifbreak = 1; } +if ($_SESSION['userlevel'] >= '5') { + echo(' '); + if ($config['int_customers']) { + echo('
  • Customers
  • '); + $ifbreak = 1; + } + if ($config['int_l2tp']) { + echo('
  • L2TP
  • '); + $ifbreak = 1; + } + if ($config['int_transit']) { + echo('
  • Transit
  • '); + $ifbreak = 1; + } + if ($config['int_peering']) { + echo('
  • Peering
  • '); + $ifbreak = 1; + } + if ($config['int_peering'] && $config['int_transit']) { + echo('
  • Peering + Transit
  • '); + $ifbreak = 1; + } + if ($config['int_core']) { + echo('
  • Core
  • '); + $ifbreak = 1; + } if (is_array($config['custom_descr']) === FALSE) { $config['custom_descr'] = array($config['custom_descr']); } @@ -239,21 +249,18 @@ if ($_SESSION['userlevel'] >= '5') } if ($ifbreak) { - echo(' '); + echo(' '); } -if (isset($interface_alerts)) -{ - echo('
  • Alerts ('.$interface_alerts.')
  • '); +if (isset($interface_alerts)) { + echo('
  • Alerts ('.$interface_alerts.')
  • '); } $deleted_ports = 0; -foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) -{ - if (port_permitted($interface['port_id'], $interface['device_id'])) - { - $deleted_ports++; - } +foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { + if (port_permitted($interface['port_id'], $interface['device_id'])) { + $deleted_ports++; + } } ?> @@ -261,7 +268,9 @@ foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`delete
  • Disabled
  • Deleted ('.$deleted_ports.')'); } +if ($deleted_ports) { + echo('
  • Deleted ('.$deleted_ports.')
  • '); +} ?> @@ -270,9 +279,8 @@ if ($deleted_ports) { echo('
  • Processor
  • Storage
  • '); +if ($menu_sensors) { + $sep = 0; + echo(' '); } $icons = array('fanspeed'=>'tachometer','humidity'=>'tint','temperature'=>'fire','current'=>'bolt','frequency'=>'line-chart','power'=>'power-off','voltage'=>'bolt','charge'=>'plus-square','dbm'=>'sun-o', 'load'=>'spinner','state'=>'bullseye'); -foreach (array('fanspeed','humidity','temperature') as $item) -{ - if (isset($menu_sensors[$item])) - { +foreach (array('fanspeed','humidity','temperature') as $item) { + if (isset($menu_sensors[$item])) { + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) { + echo(' '); + $sep = 0; +} + +foreach (array('current','frequency','power','voltage') as $item) { + if (isset($menu_sensors[$item])) { + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) { + echo(' '); + $sep = 0; +} + +foreach (array_keys($menu_sensors) as $item) { echo('
  • '.nicecase($item).'
  • '); unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) -{ - echo(' '); - $sep = 0; -} - -foreach (array('current','frequency','power','voltage') as $item) -{ - if (isset($menu_sensors[$item])) - { - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) -{ - echo(' '); - $sep = 0; -} - -foreach (array_keys($menu_sensors) as $item) -{ - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; } ?> @@ -337,27 +337,24 @@ foreach (array_keys($menu_sensors) as $item) $app_count = dbFetchCell("SELECT COUNT(`app_id`) FROM `applications`"); -if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") -{ +if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") { ?> + = '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") -{ +if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") { ?> @@ -440,16 +427,11 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { = '10') -{ - if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { - echo(' - - '); - } - echo(' -
  • Plugin Admin
  • - '); +if ($_SESSION['userlevel'] >= '10') { + if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { + echo(''); + } + echo('
  • Plugin Admin
  • '); } ?> @@ -457,9 +439,8 @@ if ($_SESSION['userlevel'] >= '10') @@ -476,50 +457,42 @@ if(is_file("includes/print-menubar-custom.inc.php"))
    -"); \ No newline at end of file +"; diff --git a/html/includes/print-service-edit.inc.php b/html/includes/print-service-edit.inc.php index 0954649d6..d0ad23a56 100644 --- a/html/includes/print-service-edit.inc.php +++ b/html/includes/print-service-edit.inc.php @@ -1,35 +1,33 @@ Edit Service
    - - + +
    - +
    - +
    - +
    -
    "); - -} \ No newline at end of file +"; +}//end if diff --git a/html/includes/print-syslog.inc.php b/html/includes/print-syslog.inc.php index 09467dd7c..1a7564920 100644 --- a/html/includes/print-syslog.inc.php +++ b/html/includes/print-syslog.inc.php @@ -1,23 +1,18 @@ "); +if (device_permitted($entry['device_id'])) { + echo ''; - // Stop shortening hostname. Issue #61 - //$entry['hostname'] = shorthost($entry['hostname'], 20); - - if ($vars['page'] != "device") - { - echo("" . $entry['date'] . ""); - echo("".generate_device_link($entry).""); - echo("" . $entry['program'] . " : " . htmlspecialchars($entry['msg']) . ""); - } else { - echo("" . $entry['date'] . "   " . $entry['program'] . "   " . htmlspecialchars($entry['msg']) . ""); - } - - echo(""); + // Stop shortening hostname. Issue #61 + // $entry['hostname'] = shorthost($entry['hostname'], 20); + if ($vars['page'] != 'device') { + echo ''.$entry['date'].''; + echo ''.generate_device_link($entry).''; + echo ''.$entry['program'].' : '.htmlspecialchars($entry['msg']).''; + } + else { + echo ''.$entry['date'].'   '.$entry['program'].'   '.htmlspecialchars($entry['msg']).''; + } + echo ''; } - -?> diff --git a/html/includes/reports/alert-log.pdf.inc.php b/html/includes/reports/alert-log.pdf.inc.php index 5ee0e91ea..d293b474b 100644 --- a/html/includes/reports/alert-log.pdf.inc.php +++ b/html/includes/reports/alert-log.pdf.inc.php @@ -1,65 +1,83 @@ AddPage('L'); +$where = '1'; +if (is_numeric($_GET['device_id'])) { + $where .= ' AND E.device_id = ?'; + $param[] = $_GET['device_id']; +} - $where = "1"; - if (is_numeric($_GET['device_id'])) { - $where .= ' AND E.device_id = ?'; - $param[] = $_GET['device_id']; - } - if ($_GET['string']) { - $where .= " AND R.rule LIKE ?"; - $param[] = "%".$_GET['string']."%"; - } +if ($_GET['string']) { + $where .= ' AND R.rule LIKE ?'; + $param[] = '%'.$_GET['string'].'%'; +} - if ($_SESSION['userlevel'] >= '5') { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; - } else { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; - $param[] = $_SESSION['user_id']; - } +if ($_SESSION['userlevel'] >= '5') { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; +} +else { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; + $param[] = $_SESSION['user_id']; +} - if (isset($_GET['start']) && is_numeric($_GET['start'])) { - $start = mres($_GET['start']); - } else { - $start = 0; - } +if (isset($_GET['start']) && is_numeric($_GET['start'])) { + $start = mres($_GET['start']); +} +else { + $start = 0; +} - if (isset($_GET['results']) && is_numeric($_GET['results'])) { - $numresults = mres($_GET['results']); - } else { - $numresults = 250; - } +if (isset($_GET['results']) && is_numeric($_GET['results'])) { + $numresults = mres($_GET['results']); +} +else { + $numresults = 250; +} - $full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; +$full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; - foreach (dbFetchRows($full_query, $param) as $alert_entry) { - $hostname = gethostbyid(mres($alert_entry['device_id'])); - $alert_state = $alert_entry['state']; +foreach (dbFetchRows($full_query, $param) as $alert_entry) { + $hostname = gethostbyid(mres($alert_entry['device_id'])); + $alert_state = $alert_entry['state']; - if ($alert_state!='') { - if ($alert_state=='0') { - $glyph_color = 'green'; - $text = 'Ok'; - } elseif ($alert_state=='1') { - $glyph_color = 'red'; - $text = 'Alert'; - } elseif ($alert_state=='2') { - $glyph_color = 'lightgrey'; - $text = 'Ack'; - } elseif ($alert_state=='3') { - $glyph_color = 'orange'; - $text = 'Worse'; - } elseif ($alert_state=='4') { - $glyph_color = 'khaki'; - $text = 'Better'; - } - $data[] = array($alert_entry['time_logged'],$hostname,htmlspecialchars($alert_entry['name']),$text); + if ($alert_state != '') { + if ($alert_state == '0') { + $glyph_color = 'green'; + $text = 'Ok'; + } + else if ($alert_state == '1') { + $glyph_color = 'red'; + $text = 'Alert'; + } + else if ($alert_state == '2') { + $glyph_color = 'lightgrey'; + $text = 'Ack'; + } + else if ($alert_state == '3') { + $glyph_color = 'orange'; + $text = 'Worse'; + } + else if ($alert_state == '4') { + $glyph_color = 'khaki'; + $text = 'Better'; } - } -$header = array('Datetime', 'Device', 'Log', 'Status'); + $data[] = array( + $alert_entry['time_logged'], + $hostname, + htmlspecialchars($alert_entry['name']), + $text, + ); + }//end if +}//end foreach + +$header = array( + 'Datetime', + 'Device', + 'Log', + 'Status', +); $table = << @@ -74,17 +92,19 @@ EOD; foreach ($data as $log) { if ($log[3] == 'Alert') { $tr_col = '#d39392'; - } else { + } + else { $tr_col = '#bbd392'; } + $table .= ' - + '.$log[0].' '.$log[1].' '.$log[2].' '.$log[3].' - - '; + + '; } $table .= << $value) -{ - if ($value != "") - { - switch ($var) - { - case 'hostname': - $where .= " AND D.hostname LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'location': - $where .= " AND D.location LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'device_id': - $where .= " AND D.device_id = ?"; - $param[] = $value; - break; - case 'deleted': - case 'ignore': - if ($value == 1) - { - $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; - } - break; - case 'disable': - case 'ifSpeed': - if (is_numeric($value)) - { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'errors': - if ($value == 1) - { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - case 'state': - if ($value == "down") - { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; - $param[] = "up"; - $param[] = "down"; - } elseif($value == "up") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = "up"; - $param[] = "up"; - } elseif($value == "admindown") { - $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; - $param[] = "down"; - } - break; - } - } -} +foreach ($vars as $var => $value) { + if ($value != '') { + switch ($var) { + case 'hostname': + $where .= ' AND D.hostname LIKE ?'; + $param[] = '%'.$value.'%'; + break; -$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ".$query_sort; + case 'location': + $where .= ' AND D.location LIKE ?'; + $param[] = '%'.$value.'%'; + break; + + case 'device_id': + $where .= ' AND D.device_id = ?'; + $param[] = $value; + break; + + case 'deleted': + case 'ignore': + if ($value == 1) { + $where .= ' AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0'; + } + break; + + case 'disable': + case 'ifSpeed': + if (is_numeric($value)) { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = '%'.$value.'%'; + break; + + case 'errors': + if ($value == 1) { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + + case 'state': + if ($value == 'down') { + $where .= 'AND I.ifAdminStatus = ? AND I.ifOperStatus = ?'; + $param[] = 'up'; + $param[] = 'down'; + } + else if ($value == 'up') { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = 'up'; + $param[] = 'up'; + } + else if ($value == 'admindown') { + $where .= 'AND I.ifAdminStatus = ? AND D.ignore = 0'; + $param[] = 'down'; + } + break; + }//end switch + }//end if +}//end foreach + +$query = 'SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id '.$where.' '.$query_sort; $row = 1; -list($format, $subformat) = explode("_", $vars['format']); +list($format, $subformat) = explode('_', $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) -{ - case 'traffic': +switch ($vars['sort']) { +case 'traffic': $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); break; - case 'traffic_in': + +case 'traffic_in': $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); break; - case 'traffic_out': + +case 'traffic_out': $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); break; - case 'packets': + +case 'packets': $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); break; - case 'packets_in': + +case 'packets_in': $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); break; - case 'packets_out': + +case 'packets_out': $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); break; - case 'errors': + +case 'errors': $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); break; - case 'speed': + +case 'speed': $ports = array_sort($ports, 'ifSpeed', SORT_DESC); break; - case 'port': + +case 'port': $ports = array_sort($ports, 'ifDescr', SORT_ASC); break; - case 'media': + +case 'media': $ports = array_sort($ports, 'ifType', SORT_ASC); break; - case 'descr': + +case 'descr': $ports = array_sort($ports, 'ifAlias', SORT_ASC); break; - case 'device': - default: - $ports = array_sort($ports, 'hostname', SORT_ASC); -} -$csv[] = array('Device','Port','Speed','Down','Up','Media','Description'); -foreach( $ports as $port ) { - if( port_permitted($port['port_id'], $port['device_id']) ) { - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); - $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); - $port = ifLabel($port, $device); - $csv[] = array($port['hostname'],fixIfName($port['label']),$speed,$port['in_rate'],$port['out_rate'],$type,$port['ifAlias']); - } +case 'device': +default: + $ports = array_sort($ports, 'hostname', SORT_ASC); +}//end switch + +$csv[] = array( + 'Device', + 'Port', + 'Speed', + 'Down', + 'Up', + 'Media', + 'Description', +); +foreach ($ports as $port) { + if (port_permitted($port['port_id'], $port['device_id'])) { + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); + $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); + $port = ifLabel($port, $device); + $csv[] = array( + $port['hostname'], + fixIfName($port['label']), + $speed, + $port['in_rate'], + $port['out_rate'], + $type, + $port['ifAlias'], + ); + } } -?> diff --git a/html/includes/service-add.inc.php b/html/includes/service-add.inc.php index 3bc9eca63..cf1433b27 100644 --- a/html/includes/service-add.inc.php +++ b/html/includes/service-add.inc.php @@ -5,6 +5,6 @@ $updated = '1'; $service_id = add_service(mres($_POST['device']), mres($_POST['type']), mres($_POST['descr']), mres($_POST['ip']), mres($_POST['params'])); if ($service_id) { - $message .= $message_break . "Service added (".$service_id.")!"; - $message_break .= "
    "; -} \ No newline at end of file + $message .= $message_break.'Service added ('.$service_id.')!'; + $message_break .= '
    '; +} diff --git a/html/includes/table/address-search.inc.php b/html/includes/table/address-search.inc.php index a50d06afc..25eb75360 100644 --- a/html/includes/table/address-search.inc.php +++ b/html/includes/table/address-search.inc.php @@ -2,56 +2,64 @@ $param = array(); -if (is_admin() === FALSE && is_read() === FALSE) { - $perms_sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; - $param[] = array($_SESSION['user_id']); +if (is_admin() === false && is_read() === false) { + $perms_sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; + $param[] = array($_SESSION['user_id']); } -list($address,$prefix) = explode("/", $_POST['address']); +list($address,$prefix) = explode('/', $_POST['address']); if ($_POST['search_type'] == 'ipv4') { - $sql = " FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D"; + $sql = ' FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D'; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id $where "; if (!empty($address)) { $sql .= " AND ipv4_address LIKE '%".$address."%'"; } + if (!empty($prefix)) { - $sql .= " AND ipv4_prefixlen='?'"; + $sql .= " AND ipv4_prefixlen='?'"; $param[] = array($prefix); } -} elseif ($_POST['search_type'] == 'ipv6') { - $sql = " FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D"; +} +else if ($_POST['search_type'] == 'ipv6') { + $sql = ' FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D'; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id $where "; if (!empty($address)) { $sql .= " AND (ipv6_address LIKE '%".$address."%' OR ipv6_compressed LIKE '%".$address."%')"; } + if (!empty($prefix)) { $sql .= " AND ipv6_prefixlen = '$prefix'"; } -} elseif ($_POST['search_type'] == 'mac') { - $sql = " FROM `ports` AS I, `devices` AS D"; - $sql .= $perms_sql; - $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%' $where "; } +else if ($_POST['search_type'] == 'mac') { + $sql = ' FROM `ports` AS I, `devices` AS D'; + $sql .= $perms_sql; + $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address']))."%' $where "; +}//end if if (is_numeric($_POST['device_id'])) { - $sql .= " AND I.device_id = ?"; + $sql .= ' AND I.device_id = ?'; $param[] = array($_POST['device_id']); } + if ($_POST['interface']) { - $sql .= " AND I.ifDescr LIKE '?'"; + $sql .= " AND I.ifDescr LIKE '?'"; $param[] = array($_POST['interface']); } if ($_POST['search_type'] == 'ipv4') { $count_sql = "SELECT COUNT(`ipv4_address_id`) $sql"; -} elseif ($_POST['search_type'] == 'ipv6') { - $count_sql = "SELECT COUNT(`ipv6_address_id`) $sql"; -} elseif ($_POST['search_type'] == 'mac') { - $count_sql = "SELECT COUNT(`port_id`) $sql"; } -$total = dbFetchCell($count_sql,$param); +else if ($_POST['search_type'] == 'ipv6') { + $count_sql = "SELECT COUNT(`ipv6_address_id`) $sql"; +} +else if ($_POST['search_type'] == 'mac') { + $count_sql = "SELECT COUNT(`port_id`) $sql"; +} + +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -63,7 +71,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -75,31 +83,42 @@ $sql = "SELECT *,`I`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $interface) { $speed = humanspeed($interface['ifSpeed']); - $type = humanmedia($interface['ifType']); + $type = humanmedia($interface['ifType']); if ($_POST['search_type'] == 'ipv6') { - list($prefix, $length) = explode("/", $interface['ipv6_network']); - $address = Net_IPv6::compress($interface['ipv6_address']) . '/'.$length; - } elseif ($_POST['search_type'] == 'mac') { + list($prefix, $length) = explode('/', $interface['ipv6_network']); + $address = Net_IPv6::compress($interface['ipv6_address']).'/'.$length; + } + else if ($_POST['search_type'] == 'mac') { $address = formatMac($interface['ifPhysAddress']); - } else { - list($prefix, $length) = explode("/", $interface['ipv4_network']); - $address = $interface['ipv4_address'] . '/' .$length; + } + else { + list($prefix, $length) = explode('/', $interface['ipv4_network']); + $address = $interface['ipv4_address'].'/'.$length; } if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) { - $error_img = generate_port_link($interface,"Interface Errors",errors); - } else { - $error_img = ""; + $error_img = generate_port_link($interface, "Interface Errors", errors); } - if (port_permitted($interface['port_id'])) { - $interface = ifLabel ($interface, $interface); - $response[] = array('hostname'=>generate_device_link($interface), - 'interface'=>generate_port_link($interface) . ' ' . $error_img, - 'address'=>$address, - 'description'=>$interface['ifAlias']); + else { + $error_img = ''; } -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + if (port_permitted($interface['port_id'])) { + $interface = ifLabel($interface, $interface); + $response[] = array( + 'hostname' => generate_device_link($interface), + 'interface' => generate_port_link($interface).' '.$error_img, + 'address' => $address, + 'description' => $interface['ifAlias'], + ); + } +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/alert-schedule.inc.php b/html/includes/table/alert-schedule.inc.php index 635e67be9..5d2bfa9b8 100644 --- a/html/includes/table/alert-schedule.inc.php +++ b/html/includes/table/alert-schedule.inc.php @@ -16,8 +16,9 @@ $where = 1; if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_schedule` AS S WHERE $where"; -} else { - $sql = " FROM `alert_schedule` AS S WHERE $where"; +} +else { + $sql = " FROM `alert_schedule` AS S WHERE $where"; $param[] = $_SESSION['user_id']; } @@ -26,7 +27,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -38,7 +39,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -48,20 +49,29 @@ if ($rowCount != -1) { $sql = "SELECT `S`.`schedule_id`, DATE_FORMAT(`S`.`start`, '".$config['dateformat']['mysql']['compact']."') AS `start`, DATE_FORMAT(`S`.`end`, '".$config['dateformat']['mysql']['compact']."') AS `end`, `S`.`title` $sql"; -foreach (dbFetchRows($sql,$param) as $schedule) { +foreach (dbFetchRows($sql, $param) as $schedule) { $status = 0; if ($schedule['end'] < date('dS M Y H:i::s')) { $status = 1; } + if (date('dS M Y H:i::s') >= $schedule['start'] && date('dS M Y H:i::s') < $schedule['end']) { $status = 2; } - $response[] = array('title'=>$schedule['title'], - 'start'=>$schedule['start'], - 'end'=>$schedule['end'], - 'id'=>$schedule['schedule_id'], - 'status'=>$status); + + $response[] = array( + 'title' => $schedule['title'], + 'start' => $schedule['start'], + 'end' => $schedule['end'], + 'id' => $schedule['schedule_id'], + 'status' => $status, + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/alertlog.inc.php b/html/includes/table/alertlog.inc.php index 0c8e515e6..8b4d94d3e 100644 --- a/html/includes/table/alertlog.inc.php +++ b/html/includes/table/alertlog.inc.php @@ -3,14 +3,15 @@ $where = 1; if (is_numeric($_POST['device_id'])) { - $where .= ' AND E.device_id = ?'; + $where .= ' AND E.device_id = ?'; $param[] = $_POST['device_id']; } if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where"; -} else { - $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; +} +else { + $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; $param[] = array($_SESSION['user_id']); } @@ -19,7 +20,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`E`.`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -31,7 +32,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -42,42 +43,49 @@ if ($rowCount != -1) { $sql = "SELECT D.device_id,name AS alert,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate,details $sql"; $rulei = 0; -foreach (dbFetchRows($sql,$param) as $alertlog) { - $dev = device_by_id_cache($alertlog['device_id']); +foreach (dbFetchRows($sql, $param) as $alertlog) { + $dev = device_by_id_cache($alertlog['device_id']); $fault_detail = alert_details($alertlog['details']); - $alert_state = $alertlog['state']; - if ($alert_state=='0') { - $glyph_icon = 'ok'; + $alert_state = $alertlog['state']; + if ($alert_state == '0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - elseif ($alert_state=='1') { - $glyph_icon = 'remove'; + else if ($alert_state == '1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - elseif ($alert_state=='2') { - $glyph_icon = 'info-sign'; + else if ($alert_state == '2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - elseif ($alert_state=='3') { - $glyph_icon = 'arrow-down'; + else if ($alert_state == '3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - elseif ($alert_state=='4') { - $glyph_icon = 'arrow-up'; + else if ($alert_state == '4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - } - $response[] = array('id'=>$rulei++, - 'time_logged'=>$alertlog['humandate'], - 'details'=>'', - 'hostname'=>'
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', - 'alert'=>htmlspecialchars($alertlog['alert']), - 'status'=>" $text"); -} + $text = 'Better'; + }//end if + $response[] = array( + 'id' => $rulei++, + 'time_logged' => $alertlog['humandate'], + 'details' => '', + 'hostname' => '
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', + 'alert' => htmlspecialchars($alertlog['alert']), + 'status' => " $text", + ); +}//end foreach -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); -echo _json_encode($output); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); +echo _json_encode($output); diff --git a/html/includes/table/alerts.inc.php b/html/includes/table/alerts.inc.php index 799404b1a..2efab5d1f 100644 --- a/html/includes/table/alerts.inc.php +++ b/html/includes/table/alerts.inc.php @@ -10,18 +10,18 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { $sql_search .= " AND (`timestamp` LIKE '%$searchPhrase%' OR `rule` LIKE '%$searchPhrase%' OR `name` LIKE '%$searchPhrase%' OR `hostname` LIKE '%$searchPhrase%')"; } -$sql = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`"; +$sql = ' FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`'; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } $sql .= " RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE $where AND `state` IN (1,2,3,4) $sql_search"; $count_sql = "SELECT COUNT(`alerts`.`id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -33,7 +33,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -43,76 +43,86 @@ if ($rowCount != -1) { $sql = "SELECT `alerts`.*, `devices`.`hostname` AS `hostname`,`alert_rules`.`rule` AS `rule`, `alert_rules`.`name` AS `name`, `alert_rules`.`severity` AS `severity` $sql"; -$rulei = 0; +$rulei = 0; $format = $_POST['format']; -foreach (dbFetchRows($sql,$param) as $alert) { - $log = dbFetchCell("SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1", array($alert['rule_id'],$alert['device_id'])); +foreach (dbFetchRows($sql, $param) as $alert) { + $log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', array($alert['rule_id'], $alert['device_id'])); $fault_detail = alert_details($log); - $ico = "ok"; - $col = "green"; - $extra = ""; - $msg = ""; - if ( (int) $alert['state'] === 0 ) { - $ico = "ok"; - $col = "green"; - $extra = "success"; - $msg = "ok"; - } elseif ( (int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { - $ico = "volume-up"; - $col = "red"; - $extra = "danger"; - $msg = "alert"; - if ( (int) $alert['state'] === 3) { - $msg = "worse"; - } elseif ( (int) $alert['state'] === 4) { - $msg = "better"; - } - } elseif ( (int) $alert['state'] === 2) { - $ico = "volume-off"; - $col = "#800080"; - $extra = "warning"; - $msg = "muted"; + $ico = 'ok'; + $col = 'green'; + $extra = ''; + $msg = ''; + if ((int) $alert['state'] === 0) { + $ico = 'ok'; + $col = 'green'; + $extra = 'success'; + $msg = 'ok'; } + else if ((int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { + $ico = 'volume-up'; + $col = 'red'; + $extra = 'danger'; + $msg = 'alert'; + if ((int) $alert['state'] === 3) { + $msg = 'worse'; + } + else if ((int) $alert['state'] === 4) { + $msg = 'better'; + } + } + else if ((int) $alert['state'] === 2) { + $ico = 'volume-off'; + $col = '#800080'; + $extra = 'warning'; + $msg = 'muted'; + }//end if $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; $severity = $alert['severity']; if ($alert['state'] == 3) { - $severity .= " +"; - } elseif ($alert['state'] == 4) { - $severity .= " -"; + $severity .= ' +'; + } + else if ($alert['state'] == 4) { + $severity .= ' -'; } $ack_ico = 'volume-up'; $ack_col = 'success'; - if($alert['state'] == 2) { + if ($alert['state'] == 2) { $ack_ico = 'volume-off'; $ack_col = 'danger'; - } + } $hostname = ' -
    - '.generate_device_link($alert).' -
    '.$fault_detail.'
    -
    '; +
    + '.generate_device_link($alert).' +
    '.$fault_detail.'
    +
    '; - $response[] = array('id'=>$rulei++, - 'rule'=>"".htmlentities($alert['name'])."", - 'details'=>'', - 'hostname'=>$hostname, - 'timestamp'=>($alert['timestamp'] ? $alert['timestamp'] : "N/A"), - 'severity'=>$severity, - 'ack_col'=>$ack_col, - 'state'=>$alert['state'], - 'alert_id'=>$alert['id'], - 'ack_ico'=>$ack_ico, - 'extra'=>$extra, - 'msg'=>$msg); + $response[] = array( + 'id' => $rulei++, + 'rule' => ''.htmlentities($alert['name']).'', + 'details' => '', + 'hostname' => $hostname, + 'timestamp' => ($alert['timestamp'] ? $alert['timestamp'] : 'N/A'), + 'severity' => $severity, + 'ack_col' => $ack_col, + 'state' => $alert['state'], + 'alert_id' => $alert['id'], + 'ack_ico' => $ack_ico, + 'extra' => $extra, + 'msg' => $msg, + ); +}//end foreach -} - -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index dd5c6225e..090476048 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -2,32 +2,33 @@ $param = array(); -$sql .= " FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D "; +$sql .= ' FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D '; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } $sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where "; -if (isset($_POST['searchby']) && $_POST['searchby'] == "ip") { - $sql .= " AND `ipv4_address` LIKE ?"; - $param[] = "%".trim($_POST['address'])."%"; -} elseif (isset($_POST['searchby']) && $_POST['searchby'] == "mac") { - $sql .= " AND `mac_address` LIKE ?"; - $param[] = "%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"; +if (isset($_POST['searchby']) && $_POST['searchby'] == 'ip') { + $sql .= ' AND `ipv4_address` LIKE ?'; + $param[] = '%'.trim($_POST['address']).'%'; +} +else if (isset($_POST['searchby']) && $_POST['searchby'] == 'mac') { + $sql .= ' AND `mac_address` LIKE ?'; + $param[] = '%'.str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address'])).'%'; } if (is_numeric($_POST['device_id'])) { - $sql .= " AND P.device_id = ?"; + $sql .= ' AND P.device_id = ?'; $param[] = $_POST['device_id']; } $count_sql = "SELECT COUNT(`M`.`port_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -39,7 +40,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -51,39 +52,53 @@ $sql = "SELECT *,`P`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $entry) { if (!$ignore) { - if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) { - $error_img = generate_port_link($entry,"Interface Errors",port_errors); - } else { - $error_img = ""; + $error_img = generate_port_link($entry, "Interface Errors", port_errors); + } + else { + $error_img = ''; } - $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($entry['ipv4_address'])); - if ($arp_host) { - $arp_name = generate_device_link($arp_host); - } else { - unset($arp_name); - } - if ($arp_host) { - $arp_if = generate_port_link($arp_host); - } else { - unset($arp_if); - } - if ($arp_host['device_id'] == $entry['device_id']) { - $arp_name = "Localhost"; - } - if ($arp_host['port_id'] == $entry['port_id']) { - $arp_if = "Local port"; - } - $response[] = array('mac_address'=>formatMac($entry['mac_address']), - 'ipv4_address'=>$entry['ipv4_address'], - 'hostname'=>generate_device_link($entry), - 'interface'=>generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, - 'remote_device'=>$arp_name, - 'remote_interface'=>$arp_if); - } - unset($ignore); -} + $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($entry['ipv4_address'])); + if ($arp_host) { + $arp_name = generate_device_link($arp_host); + } + else { + unset($arp_name); + } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + if ($arp_host) { + $arp_if = generate_port_link($arp_host); + } + else { + unset($arp_if); + } + + if ($arp_host['device_id'] == $entry['device_id']) { + $arp_name = 'Localhost'; + } + + if ($arp_host['port_id'] == $entry['port_id']) { + $arp_if = 'Local port'; + } + + $response[] = array( + 'mac_address' => formatMac($entry['mac_address']), + 'ipv4_address' => $entry['ipv4_address'], + 'hostname' => generate_device_link($entry), + 'interface' => generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))).' '.$error_img, + 'remote_device' => $arp_name, + 'remote_interface' => $arp_if, + ); + }//end if + + unset($ignore); +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/devices.inc.php b/html/includes/table/devices.inc.php index 25cf21bd5..129e198f2 100644 --- a/html/includes/table/devices.inc.php +++ b/html/includes/table/devices.inc.php @@ -3,11 +3,11 @@ $where = 1; $param = array(); -$sql = " FROM `devices`"; +$sql = ' FROM `devices`'; -if (is_admin() === FALSE && is_read() === FALSE) { - $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; - $where .= " AND `DP`.`user_id`=?"; +if (is_admin() === false && is_read() === false) { + $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; + $where .= ' AND `DP`.`user_id`=?'; $param[] = $_SESSION['user_id']; } @@ -17,48 +17,87 @@ if (!empty($_POST['location'])) { $sql .= " WHERE $where "; -if (!empty($_POST['hostname'])) { $sql .= " AND hostname LIKE ?"; $param[] = "%".$_POST['hostname']."%"; } -if (!empty($_POST['os'])) { $sql .= " AND os = ?"; $param[] = $_POST['os']; } -if (!empty($_POST['version'])) { $sql .= " AND version = ?"; $param[] = $_POST['version']; } -if (!empty($_POST['hardware'])) { $sql .= " AND hardware = ?"; $param[] = $_POST['hardware']; } -if (!empty($_POST['features'])) { $sql .= " AND features = ?"; $param[] = $_POST['features']; } -if (!empty($_POST['type'])) { - if ($_POST['type'] == 'generic') { - $sql .= " AND ( type = ? OR type = '')"; $param[] = $_POST['type']; - } else { - $sql .= " AND type = ?"; $param[] = $_POST['type']; - } +if (!empty($_POST['hostname'])) { + $sql .= ' AND hostname LIKE ?'; + $param[] = '%'.$_POST['hostname'].'%'; } -if (!empty($_POST['state'])) { - $sql .= " AND status= ?"; - if( is_numeric($_POST['state']) ) { - $param[] = $_POST['state']; - } else { - $param[] = str_replace(array('up','down'),array(1,0),$_POST['state']); + +if (!empty($_POST['os'])) { + $sql .= ' AND os = ?'; + $param[] = $_POST['os']; +} + +if (!empty($_POST['version'])) { + $sql .= ' AND version = ?'; + $param[] = $_POST['version']; +} + +if (!empty($_POST['hardware'])) { + $sql .= ' AND hardware = ?'; + $param[] = $_POST['hardware']; +} + +if (!empty($_POST['features'])) { + $sql .= ' AND features = ?'; + $param[] = $_POST['features']; +} + +if (!empty($_POST['type'])) { + if ($_POST['type'] == 'generic') { + $sql .= " AND ( type = ? OR type = '')"; + $param[] = $_POST['type']; + } + else { + $sql .= ' AND type = ?'; + $param[] = $_POST['type']; } } -if (!empty($_POST['disabled'])) { $sql .= " AND disabled= ?"; $param[] = $_POST['disabled']; } -if (!empty($_POST['ignore'])) { $sql .= " AND `ignore`= ?"; $param[] = $_POST['ignore']; } -if (!empty($_POST['location']) && $_POST['location'] == "Unset") { $location_filter = ''; } + +if (!empty($_POST['state'])) { + $sql .= ' AND status= ?'; + if (is_numeric($_POST['state'])) { + $param[] = $_POST['state']; + } + else { + $param[] = str_replace(array('up', 'down'), array(1, 0), $_POST['state']); + } +} + +if (!empty($_POST['disabled'])) { + $sql .= ' AND disabled= ?'; + $param[] = $_POST['disabled']; +} + +if (!empty($_POST['ignore'])) { + $sql .= ' AND `ignore`= ?'; + $param[] = $_POST['ignore']; +} + +if (!empty($_POST['location']) && $_POST['location'] == 'Unset') { + $location_filter = ''; +} + if (!empty($_POST['location'])) { - $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; + $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; $param[] = mres($_POST['location']); $param[] = mres($_POST['location']); } -if( !empty($_POST['group']) ) { - require_once('../includes/device-groups.inc.php'); - $sql .= " AND ( "; - foreach( GetDevicesFromGroup($_POST['group']) as $dev ) { - $sql .= "`devices`.`device_id` = ? OR "; + +if (!empty($_POST['group'])) { + include_once '../includes/device-groups.inc.php'; + $sql .= ' AND ( '; + foreach (GetDevicesFromGroup($_POST['group']) as $dev) { + $sql .= '`devices`.`device_id` = ? OR '; $param[] = $dev['device_id']; } - $sql = substr($sql, 0, strlen($sql)-3); - $sql .= " )"; + + $sql = substr($sql, 0, (strlen($sql) - 3)); + $sql .= ' )'; } $count_sql = "SELECT COUNT(`devices`.`device_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -70,7 +109,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -81,99 +120,124 @@ if ($rowCount != -1) { $sql = "SELECT DISTINCT(`devices`.`device_id`),`devices`.* $sql"; if (!isset($_POST['format'])) { - $_POST['format'] = "list_detail"; + $_POST['format'] = 'list_detail'; } -list($format, $subformat) = explode("_", $_POST['format']); + +list($format, $subformat) = explode('_', $_POST['format']); foreach (dbFetchRows($sql, $param) as $device) { - if (isset($bg) && $bg == $list_colour_b) { - $bg = $list_colour_a; - } else { - $bg = $list_colour_b; - } + if (isset($bg) && $bg == $list_colour_b) { + $bg = $list_colour_a; + } + else { + $bg = $list_colour_b; + } - if ($device['status'] == '0') { - $extra = "danger"; - $msg = $device['status_reason']; - } else { - $extra = "success"; - $msg = "up"; - } - if ($device['ignore'] == '1') { - $extra = "default"; - $msg = "ignored"; - if ($device['status'] == '1') { - $extra = "warning"; - $msg = "ignored"; - } - } - if ($device['disabled'] == '1') { - $extra = "default"; - $msg = "disabled"; - } + if ($device['status'] == '0') { + $extra = 'danger'; + $msg = $device['status_reason']; + } + else { + $extra = 'success'; + $msg = 'up'; + } - $type = strtolower($device['os']); - $image = getImage($device); - - if ($device['os'] == "ios") { - formatCiscoHardware($device, true); - } + if ($device['ignore'] == '1') { + $extra = 'default'; + $msg = 'ignored'; + if ($device['status'] == '1') { + $extra = 'warning'; + $msg = 'ignored'; + } + } - $device['os_text'] = $config['os'][$device['os']]['text']; - $port_count = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?", array($device['device_id'])); - $sensor_count = dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?", array($device['device_id'])); + if ($device['disabled'] == '1') { + $extra = 'default'; + $msg = 'disabled'; + } - if (get_dev_attrib($device,'override_sysLocation_bool')) { - $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); - } + $type = strtolower($device['os']); + $image = getImage($device); - $actions = ('
    -
    '); - $actions .= ' View device '; - $actions .= ('
    -
    '); - $actions .= ' View alerts '; - $actions .= '
    '; - if ($_SESSION['userlevel'] >= "7") { - $actions .= ('
    - Edit device -
    '); - } - $actions .= ('
    -
    -
    - telnet -
    -
    - ssh -
    -
    - https -
    -
    '); + if ($device['os'] == 'ios') { + formatCiscoHardware($device, true); + } - $hostname = generate_device_link($device); - $platform = $device['hardware'] . '
    ' . $device['features']; - $os = $device['os_text'] . '
    ' . $device['version']; - if (extension_loaded('mbstring')) { - $location = mb_substr($device['location'], 0, 32, 'utf8'); - } else { - $location = truncate($device['location'], 32, ''); - } - $uptime = formatUptime($device['uptime'], 'short') . '
    ' . $location; - if ($subformat == "detail") { - $hostname .= '
    ' . $device['sysName']; - if ($port_count) { - $col_port = ' '.$port_count . '
    '; - } - if ($sensor_count) { - $col_port .= ' '.$sensor_count; - } - } else { + $device['os_text'] = $config['os'][$device['os']]['text']; + $port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id'])); + $sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id'])); - } - $response[] = array('extra'=>$extra,'msg'=>$msg,'icon'=>$image,'hostname'=>$hostname,'ports'=>$col_port,'hardware'=>$platform,'os'=>$os,'uptime'=>$uptime,'actions'=>$actions); -} + if (get_dev_attrib($device, 'override_sysLocation_bool')) { + $device['location'] = get_dev_attrib($device, 'override_sysLocation_string'); + } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); + $actions = ('
    +
    '); + $actions .= ' View device '; + $actions .= ('
    +
    '); + $actions .= ' View alerts '; + $actions .= '
    '; + if ($_SESSION['userlevel'] >= '7') { + $actions .= ('
    + Edit device +
    '); + } + + $actions .= ('
    +
    +
    + telnet +
    +
    + ssh +
    +
    + https +
    +
    '); + + $hostname = generate_device_link($device); + $platform = $device['hardware'].'
    '.$device['features']; + $os = $device['os_text'].'
    '.$device['version']; + if (extension_loaded('mbstring')) { + $location = mb_substr($device['location'], 0, 32, 'utf8'); + } + else { + $location = truncate($device['location'], 32, ''); + } + + $uptime = formatUptime($device['uptime'], 'short').'
    '.$location; + if ($subformat == 'detail') { + $hostname .= '
    '.$device['sysName']; + if ($port_count) { + $col_port = ' '.$port_count.'
    '; + } + + if ($sensor_count) { + $col_port .= ' '.$sensor_count; + } + } + else { + } + + $response[] = array( + 'extra' => $extra, + 'msg' => $msg, + 'icon' => $image, + 'hostname' => $hostname, + 'ports' => $col_port, + 'hardware' => $platform, + 'os' => $os, + 'uptime' => $uptime, + 'actions' => $actions, + ); +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/eventlog.inc.php b/html/includes/table/eventlog.inc.php index d5e5e7d60..9cae42296 100644 --- a/html/includes/table/eventlog.inc.php +++ b/html/includes/table/eventlog.inc.php @@ -1,23 +1,22 @@ = '5') { $sql = " FROM `eventlog` AS E LEFT JOIN `devices` AS `D` ON `E`.`host`=`D`.`device_id` WHERE $where"; -} else { - $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; +} +else { + $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -26,7 +25,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(datetime) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -38,7 +37,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -48,22 +47,28 @@ if ($rowCount != -1) { $sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate $sql"; -foreach (dbFetchRows($sql,$param) as $eventlog) { +foreach (dbFetchRows($sql, $param) as $eventlog) { $dev = device_by_id_cache($eventlog['host']); - if ($eventlog['type'] == "interface") { + if ($eventlog['type'] == 'interface') { $this_if = ifLabel(getifbyid($eventlog['reference'])); - $type = "".generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).""; - } else { - $type = "System"; + $type = ''.generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).''; } - - $response[] = array('datetime'=>$eventlog['humandate'], - 'hostname'=>generate_device_link($dev, shorthost($dev['hostname'])), - 'type'=>$type, - 'message'=>htmlspecialchars($eventlog['message'])); + else { + $type = 'System'; + } + + $response[] = array( + 'datetime' => $eventlog['humandate'], + 'hostname' => generate_device_link($dev, shorthost($dev['hostname'])), + 'type' => $type, + 'message' => htmlspecialchars($eventlog['message']), + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); - -?> diff --git a/html/includes/table/inventory.inc.php b/html/includes/table/inventory.inc.php index 6c5b92823..2e4c0b928 100644 --- a/html/includes/table/inventory.inc.php +++ b/html/includes/table/inventory.inc.php @@ -1,14 +1,15 @@ = '5') { $sql = " FROM entPhysical AS E, devices AS D WHERE $where AND D.device_id = E.device_id"; -} else { - $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; +} +else { + $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -17,32 +18,32 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } if (isset($_POST['string']) && strlen($_POST['string'])) { - $sql .= " AND E.entPhysicalDescr LIKE ?"; - $param[] = "%".$_POST['string']."%"; + $sql .= ' AND E.entPhysicalDescr LIKE ?'; + $param[] = '%'.$_POST['string'].'%'; } if (isset($_POST['device_string']) && strlen($_POST['device_string'])) { - $sql .= " AND D.hostname LIKE ?"; - $param[] = "%".$_POST['device_string']."%"; + $sql .= ' AND D.hostname LIKE ?'; + $param[] = '%'.$_POST['device_string'].'%'; } if (isset($_POST['part']) && strlen($_POST['part'])) { - $sql .= " AND E.entPhysicalModelName = ?"; - $param[] = $_POST['part']; + $sql .= ' AND E.entPhysicalModelName = ?'; + $param[] = $_POST['part']; } if (isset($_POST['serial']) && strlen($_POST['serial'])) { - $sql .= " AND E.entPhysicalSerialNum LIKE ?"; - $param[] = "%".$_POST['serial']."%"; + $sql .= ' AND E.entPhysicalSerialNum LIKE ?'; + $param[] = '%'.$_POST['serial'].'%'; } if (isset($_POST['device']) && is_numeric($_POST['device'])) { - $sql .= " AND D.device_id = ?"; - $param[] = $_POST['device']; + $sql .= ' AND D.device_id = ?'; + $param[] = $_POST['device']; } $count_sql = "SELECT COUNT(`entPhysical_id`) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -54,7 +55,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -65,12 +66,19 @@ if ($rowCount != -1) { $sql = "SELECT `D`.`device_id` AS `device_id`, `D`.`hostname` AS `hostname`,`entPhysicalDescr` AS `description`, `entPhysicalName` AS `name`, `entPhysicalModelName` AS `model`, `entPhysicalSerialNum` AS `serial` $sql"; foreach (dbFetchRows($sql, $param) as $invent) { - $response[] = array('hostname'=>generate_device_link($invent, shortHost($invent['hostname'])), - 'description'=>$invent['description'], - 'name'=>$invent['name'], - 'model'=>$invent['model'], - 'serial'=>$invent['serial']); + $response[] = array( + 'hostname' => generate_device_link($invent, shortHost($invent['hostname'])), + 'description' => $invent['description'], + 'name' => $invent['name'], + 'model' => $invent['model'], + 'serial' => $invent['serial'], + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, + ); echo _json_encode($output); diff --git a/html/includes/table/mempool.inc.php b/html/includes/table/mempool.inc.php index d3968a531..2afb80edc 100644 --- a/html/includes/table/mempool.inc.php +++ b/html/includes/table/mempool.inc.php @@ -1,72 +1,88 @@ generate_device_link($mempool), - 'mempool_descr' => $mempool['mempool_descr'], - 'graph' => $mini_graph, - 'mempool_used' => $bar_link, - 'mempool_perc' => $perc . "%"); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'mempool_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'mempool_used' => $graph_data[3], - 'mempool_perc' => ''); - } # endif graphs -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); +$sql = "SELECT * $sql"; +foreach (dbFetchRows($sql, $param) as $mempool) { + $perc = round($mempool['mempool_perc'], 0); + $total = formatStorage($mempool['mempool_total']); + $free = formatStorage($mempool['mempool_free']); + $used = formatStorage($mempool['mempool_used']); + $graph_array['type'] = $graph_type; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = '20'; + $graph_array['width'] = '80'; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; + $link = 'graphs/id='.$graph_array['id'].'/type='.$graph_array['type'].'/from='.$graph_array['from'].'/to='.$graph_array['to'].'/'; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + $background = get_percentage_colours($perc); + $bar_link = overlib_link($link, print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $free, 'ffffff', $background['right']), generate_graph_tag($graph_array_zoom), null); + + $response[] = array( + 'hostname' => generate_device_link($mempool), + 'mempool_descr' => $mempool['mempool_descr'], + 'graph' => $mini_graph, + 'mempool_used' => $bar_link, + 'mempool_perc' => $perc.'%', + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'mempool_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'mempool_used' => $graph_data[3], + 'mempool_perc' => '', + ); + } //end if +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $count, +); echo _json_encode($output); diff --git a/html/includes/table/poll-log.inc.php b/html/includes/table/poll-log.inc.php index 3a0ca3213..3579759b6 100644 --- a/html/includes/table/poll-log.inc.php +++ b/html/includes/table/poll-log.inc.php @@ -1,11 +1,12 @@ " 'graphs', 'group' => 'poller')). "'>" .$device['hostname']. "", - 'last_polled' => $device['last_polled'], - 'last_polled_timetaken' => $device['last_polled_timetaken']); + $response[] = array( + 'hostname' => " 'graphs', 'group' => 'poller'))."'>".$device['hostname'].'', + 'last_polled' => $device['last_polled'], + 'last_polled_timetaken' => $device['last_polled_timetaken'], + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); - -?> diff --git a/html/includes/table/processor.inc.php b/html/includes/table/processor.inc.php index a7b3d9745..bcedd6196 100644 --- a/html/includes/table/processor.inc.php +++ b/html/includes/table/processor.inc.php @@ -1,67 +1,83 @@ generate_device_link($processor), - 'processor_descr' => $processor['processor_descr'], - 'graph' => $mini_graph, - 'processor_usage' => $bar_link); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $processor['processor_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'processor_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'processor_usage' => $graph_data[3]); - } # endif graphs -} -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$sql = "SELECT * $sql"; +foreach (dbFetchRows($sql, $param) as $processor) { + $perc = round($processor['processor_usage'], 0); + $graph_array['type'] = $graph_type; + $graph_array['id'] = $processor['processor_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = '20'; + $graph_array['width'] = '80'; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; + $link = 'graphs/id='.$graph_array['id'].'/type='.$graph_array['type'].'/from='.$graph_array['from'].'/to='.$graph_array['to'].'/'; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + $background = get_percentage_colours($perc); + $bar_link = overlib_link($link, print_percentage_bar(400, 20, $perc, $perc.'%', 'ffffff', $background['left'], (100 - $perc).'%', 'ffffff', $background['right']), generate_graph_tag($graph_array_zoom), null); + + $response[] = array( + 'hostname' => generate_device_link($processor), + 'processor_descr' => $processor['processor_descr'], + 'graph' => $mini_graph, + 'processor_usage' => $bar_link, + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $processor['processor_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'processor_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'processor_usage' => $graph_data[3], + ); + } //end if +}//end foreach + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); diff --git a/html/includes/table/storage.inc.php b/html/includes/table/storage.inc.php index a912ba1d2..3d301456f 100644 --- a/html/includes/table/storage.inc.php +++ b/html/includes/table/storage.inc.php @@ -1,14 +1,14 @@ generate_device_link($drive), + 'storage_descr' => $drive['storage_descr'], + 'graph' => $mini_graph, + 'storage_used' => $bar_link, + 'storage_perc' => $perc.'%', + ); + if ($_POST['view'] == 'graphs') { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; - $response[] = array('hostname' => generate_device_link($drive), - 'storage_descr' => $drive['storage_descr'], - 'graph' => $mini_graph, - 'storage_used' => $bar_link, - 'storage_perc' => $perc . "%"); - if ($_POST['view'] == "graphs") { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $return_data = true; + include 'includes/print-graphrow.inc.php'; + unset($return_data); + $response[] = array( + 'hostname' => $graph_data[0], + 'storage_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'storage_used' => $graph_data[3], + 'storage_perc' => '', + ); + } //end if +}//end foreach - $return_data = true; - include("includes/print-graphrow.inc.php"); - unset($return_data); - $response[] = array('hostname' => $graph_data[0], - 'storage_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'storage_used' => $graph_data[3], - 'storage_perc' => ''); - - } # endif graphs -} - -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $count, +); echo _json_encode($output); diff --git a/html/includes/table/syslog.inc.php b/html/includes/table/syslog.inc.php index 81df05d28..987aac65a 100644 --- a/html/includes/table/syslog.inc.php +++ b/html/includes/table/syslog.inc.php @@ -1,46 +1,44 @@ = ?"; - $param[] = $_POST['from']; -} -if( !empty($_POST['to']) ) { - $where .= " AND timestamp <= ?"; - $param[] = $_POST['to']; +if (!empty($_POST['from'])) { + $where .= ' AND timestamp >= ?'; + $param[] = $_POST['from']; } -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "FROM syslog AS S"; - $sql .= " WHERE ".$where; -} else { - $sql = "FROM syslog AS S, devices_perms AS P"; - $sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?"; - $sql .= $where; - $param = array_merge(array($_SESSION['user_id']), $param); +if (!empty($_POST['to'])) { + $where .= ' AND timestamp <= ?'; + $param[] = $_POST['to']; +} + +if ($_SESSION['userlevel'] >= '5') { + $sql = 'FROM syslog AS S'; + $sql .= ' WHERE '.$where; +} +else { + $sql = 'FROM syslog AS S, devices_perms AS P'; + $sql .= 'WHERE S.device_id = P.device_id AND P.user_id = ?'; + $sql .= $where; + $param = array_merge(array($_SESSION['user_id']), $param); } $count_sql = "SELECT COUNT(timestamp) $sql"; -$total = dbFetchCell($count_sql,$param); +$total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } @@ -52,7 +50,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = ($current * $rowCount) - ($rowCount); + $limit_low = (($current * $rowCount) - ($rowCount)); $limit_high = $rowCount; } @@ -62,14 +60,20 @@ if ($rowCount != -1) { $sql = "SELECT S.*, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date $sql"; -foreach (dbFetchRows($sql,$param) as $syslog) { - $dev = device_by_id_cache($syslog['device_id']); - $response[] = array('timestamp'=>$syslog['date'], - 'device_id'=>generate_device_link($dev, shorthost($dev['hostname'])), - 'program'=>$syslog['program'], - 'msg'=>htmlspecialchars($syslog['msg'])); +foreach (dbFetchRows($sql, $param) as $syslog) { + $dev = device_by_id_cache($syslog['device_id']); + $response[] = array( + 'timestamp' => $syslog['date'], + 'device_id' => generate_device_link($dev, shorthost($dev['hostname'])), + 'program' => $syslog['program'], + 'msg' => htmlspecialchars($syslog['msg']), + ); } -$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); echo _json_encode($output); -?> diff --git a/html/includes/vars.inc.php b/html/includes/vars.inc.php index 788915f69..477f056b4 100644 --- a/html/includes/vars.inc.php +++ b/html/includes/vars.inc.php @@ -1,40 +1,38 @@ $get_var) -{ - if (strstr($key, "opt")) - { - list($name, $value) = explode("|", $get_var); - if (!isset($value)) { $value = "yes"; } - $vars[$name] = $value; - } +foreach ($_GET as $key => $get_var) { + if (strstr($key, 'opt')) { + list($name, $value) = explode('|', $get_var); + if (!isset($value)) { + $value = 'yes'; + } + + $vars[$name] = $value; + } } $segments = explode('/', trim($_SERVER['REQUEST_URI'], '/')); -foreach ($segments as $pos => $segment) -{ - $segment = urldecode($segment); - if ($pos == "0") - { - $vars['page'] = $segment; - } else { - list($name, $value) = explode("=", $segment); - if ($value == "" || !isset($value)) - { - $vars[$name] = yes; - } else { - $vars[$name] = $value; +foreach ($segments as $pos => $segment) { + $segment = urldecode($segment); + if ($pos == '0') { + $vars['page'] = $segment; + } + else { + list($name, $value) = explode('=', $segment); + if ($value == '' || !isset($value)) { + $vars[$name] = yes; + } + else { + $vars[$name] = $value; + } } - } } -foreach ($_GET as $name => $value) -{ - $vars[$name] = $value; +foreach ($_GET as $name => $value) { + $vars[$name] = $value; } -foreach ($_POST as $name => $value) -{ - $vars[$name] = $value; +foreach ($_POST as $name => $value) { + $vars[$name] = $value; } diff --git a/html/index.php b/html/index.php index 57fff1b57..a3de9ba0c 100644 --- a/html/index.php +++ b/html/index.php @@ -14,7 +14,8 @@ if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) { $_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']); -} else { +} +else { $_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''); } @@ -31,40 +32,40 @@ function catchFatal() { } } -if (strpos($_SERVER['PATH_INFO'], "debug")) -{ - $debug = "1"; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 1); - ini_set('log_errors', 1); - ini_set('error_reporting', E_ALL); - set_error_handler('logErrors'); - register_shutdown_function('catchFatal'); -} else { - $debug = FALSE; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 0); - ini_set('log_errors', 0); - ini_set('error_reporting', 0); +if (strpos($_SERVER['PATH_INFO'], "debug")) { + $debug = "1"; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 1); + ini_set('log_errors', 1); + ini_set('error_reporting', E_ALL); + set_error_handler('logErrors'); + register_shutdown_function('catchFatal'); +} +else { + $debug = FALSE; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 0); + ini_set('log_errors', 0); + ini_set('error_reporting', 0); } // Set variables $msg_box = array(); // Check for install.inc.php -if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') -{ - // no config.php does so let's redirect to the install - header('Location: /install.php'); - exit; +if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') { + // no config.php does so let's redirect to the install + header('Location: /install.php'); + exit; } -include("../includes/defaults.inc.php"); -include("../config.php"); -include_once("../includes/definitions.inc.php"); -include("../includes/functions.php"); -include("includes/functions.inc.php"); -include("includes/vars.inc.php"); -include('includes/plugins.inc.php'); +require '../includes/defaults.inc.php'; +require '../config.php'; +require_once '../includes/definitions.inc.php'; +require '../includes/functions.php'; +require 'includes/functions.inc.php'; +require 'includes/vars.inc.php'; +require 'includes/plugins.inc.php'; + Plugins::start(); $runtime_start = utime(); @@ -74,30 +75,33 @@ ob_start(); ini_set('allow_url_fopen', 0); ini_set('display_errors', 0); -include("includes/authenticate.inc.php"); +require 'includes/authenticate.inc.php'; -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { $_SESSION['widescreen'] = 1; } -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { unset($_SESSION['widescreen']); } +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { + $_SESSION['widescreen'] = 1; +} +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { + unset($_SESSION['widescreen']); +} # Load the settings for Multi-Tenancy. -if (isset($config['branding']) && is_array($config['branding'])) -{ - if ($config['branding'][$_SERVER['SERVER_NAME']]) - { - foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) - { - eval("\$config['" . $confitem . "'] = \$confval;"); +if (isset($config['branding']) && is_array($config['branding'])) { + if ($config['branding'][$_SERVER['SERVER_NAME']]) { + foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } } - } else { - foreach ($config['branding']['default'] as $confitem => $confval) - { - eval("\$config['" . $confitem . "'] = \$confval;"); + else { + foreach ($config['branding']['default'] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } } - } } # page_title_prefix is displayed, unless page_title is set -if (isset($config['page_title'])) { $config['page_title_prefix'] = $config['page_title']; } +if (isset($config['page_title'])) { + $config['page_title_prefix'] = $config['page_title']; +} ?> @@ -119,7 +123,8 @@ if (empty($config['favicon'])) { ' . "\n"); } ?> @@ -169,14 +174,13 @@ if (empty($config['favicon'])) { body { padding-top: 0px !important; - padding-bottom: 0px !important; }"; + padding-bottom: 0px !important; }"; } @@ -188,50 +192,47 @@ if ((isset($vars['bare']) && $vars['bare'] != "yes") || !isset($vars['bare'])) { "); - print_r($_GET); - print_r($vars); - echo(""); +if (isset($devel) || isset($vars['devel'])) { + echo("
    ");
    +    print_r($_GET);
    +    print_r($vars);
    +    echo("
    "); } -if ($_SESSION['authenticated']) -{ - // Authenticated. Print a page. - if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) - { - include("pages/" . $vars['page'] . ".inc.php"); - } else { - if (isset($config['front_page']) && is_file($config['front_page'])) - { - include($config['front_page']); - } else { - include("pages/front/default.php"); +if ($_SESSION['authenticated']) { + // Authenticated. Print a page. + if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) { + require "pages/" . $vars['page'] . ".inc.php"; + } + else { + if (isset($config['front_page']) && is_file($config['front_page'])) { + require $config['front_page']; + } + else { + require 'pages/front/default.php'; + } } - } -} else { - // Not Authenticated. Show status page if enabled - if ( $config['public_status'] === true ) - { - if (isset($vars['page']) && strstr("login", $vars['page'])) - { - include("pages/logon.inc.php"); - } else { - echo '
    '; - include("pages/public.inc.php"); - echo '
    '; - echo ''; +} +else { + // Not Authenticated. Show status page if enabled + if ( $config['public_status'] === true ) { + if (isset($vars['page']) && strstr("login", $vars['page'])) { + require 'pages/logon.inc.php'; + } + else { + echo '
    '; + require 'pages/public.inc.php'; + echo '
    '; + echo ''; + } + } + else { + require 'pages/logon.inc.php'; } - } - else - { - include("pages/logon.inc.php"); - } } ?> @@ -239,37 +240,42 @@ if ($_SESSION['authenticated']) MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. - ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. - ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. - ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); +if ($config['page_gen']) { + echo('
    MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. + ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. + ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. + ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); - $fullsize = memory_get_usage(); - unset($cache); - $cachesize = $fullsize - memory_get_usage(); - if ($cachesize < 0) { $cachesize = 0; } // Silly PHP! + $fullsize = memory_get_usage(); + unset($cache); + $cachesize = $fullsize - memory_get_usage(); + if ($cachesize < 0) { + $cachesize = 0; + } // Silly PHP! - echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); - echo('
    Generated in ' . $gentime . ' seconds.'); + echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); + echo('
    Generated in ' . $gentime . ' seconds.'); } -if (isset($pagetitle) && is_array($pagetitle)) -{ - # if prefix is set, put it in front - if ($config['page_title_prefix']) { array_unshift($pagetitle,$config['page_title_prefix']); } +if (isset($pagetitle) && is_array($pagetitle)) { + # if prefix is set, put it in front + if ($config['page_title_prefix']) { + array_unshift($pagetitle,$config['page_title_prefix']); + } - # if suffix is set, put it in the back - if ($config['page_title_suffix']) { $pagetitle[] = $config['page_title_suffix']; } + # if suffix is set, put it in the back + if ($config['page_title_suffix']) { + $pagetitle[] = $config['page_title_suffix']; + } - # create and set the title - $title = join(" - ",$pagetitle); - echo(""); + # create and set the title + $title = join(" - ",$pagetitle); + echo(""); } ?> @@ -295,23 +301,21 @@ if(dbFetchCell("SELECT COUNT(`device_id`) FROM `devices` WHERE `last_polled` <= } if(is_array($msg_box)) { - echo(""); + echo(""); } if (is_array($sql_debug) && is_array($php_debug) && $_SESSION['authenticated'] === TRUE) { - - include_once "includes/print-debug.php"; - + require_once "includes/print-debug.php"; } if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { @@ -367,7 +371,8 @@ if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { }); '); -} else { +} +else { echo(' +}//end if diff --git a/html/pages/alert-stats.inc.php b/html/pages/alert-stats.inc.php index d392f1dd2..ab9a0c57f 100644 --- a/html/pages/alert-stats.inc.php +++ b/html/pages/alert-stats.inc.php @@ -1,12 +1,13 @@ -* This program is free software: you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation, either version 3 of the License, or (at your -* option) any later version. Please see LICENSE.txt at the top level of -* the source code distribution for details. -*/ -require_once('includes/print-graph-alerts.inc.php'); + * LibreNMS + * + * Copyright (c) 2015 Søren Friis Rosiak + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +require_once 'includes/print-graph-alerts.inc.php'; diff --git a/html/pages/alerts.inc.php b/html/pages/alerts.inc.php index bcc97a32a..fae3fba5e 100644 --- a/html/pages/alerts.inc.php +++ b/html/pages/alerts.inc.php @@ -13,7 +13,5 @@ */ $device['device_id'] = '-1'; -require_once('includes/print-alerts.php'); +require_once 'includes/print-alerts.php'; unset($device['device_id']); - -?> diff --git a/html/pages/api-access.inc.php b/html/pages/api-access.inc.php index a1b6e5a52..6b8a885a7 100644 --- a/html/pages/api-access.inc.php +++ b/html/pages/api-access.inc.php @@ -12,22 +12,22 @@ * the source code distribution for details. */ -if ($_SESSION['userlevel'] >= '10') -{ -if(empty($_POST['token'])) { +if ($_SESSION['userlevel'] >= '10') { +if (empty($_POST['token'])) { $_POST['token'] = bin2hex(openssl_random_pseudo_bytes(16)); } + ?> -'); - if($_SESSION['api_token'] === TRUE) - { - echo(" - "); + "; unset($_SESSION['api_token']); - } -echo(' +} + +echo '
    @@ -127,19 +125,17 @@ echo(' Disabled Remove -'); +'; - foreach (dbFetchRows("SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id") as $api) - { - if($api['disabled'] == '1') - { - $api_disabled = 'checked'; +foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id') as $api) { + if ($api['disabled'] == '1') { + $api_disabled = 'checked'; } - else - { - $api_disabled = ''; + else { + $api_disabled = ''; } - echo(' + + echo ' '.$api['username'].' '.$api['token_hash'].' @@ -147,14 +143,14 @@ echo(' -'); - } +'; +} - echo(' + echo '
    -'); +'; ?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/api-docs.inc.php b/html/pages/api-docs.inc.php index c260b73ce..d3bd68b84 100644 --- a/html/pages/api-docs.inc.php +++ b/html/pages/api-docs.inc.php @@ -17,8 +17,7 @@
    here.'); +print_error('Documentation for the API has now been moved to GitHub, you can go straight to the API Wiki from here.'); ?>
    - diff --git a/html/pages/apps.inc.php b/html/pages/apps.inc.php index 1a20acc41..cfd2378dd 100644 --- a/html/pages/apps.inc.php +++ b/html/pages/apps.inc.php @@ -1,54 +1,91 @@ Apps » "); +echo "Apps » "; unset($sep); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'apps'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'apps', +); -foreach ($app_list as $app) -{ - echo($sep); +foreach ($app_list as $app) { + echo $sep; -# if (!$vars['app']) { $vars['app'] = $app['app_type']; } + // if (!$vars['app']) { $vars['app'] = $app['app_type']; } + if ($vars['app'] == $app['app_type']) { + echo ""; + // echo(''); + } + else { + // echo(''); + } - if ($vars['app'] == $app['app_type']) - { - echo(""); - #echo(''); - } else { - #echo(''); - } - echo(generate_link(nicecase($app['app_type']),array('page'=>'apps','app'=>$app['app_type']))); - if ($vars['app'] == $app['app_type']) { echo(""); } - $sep = " | "; + echo generate_link(nicecase($app['app_type']), array('page' => 'apps', 'app' => $app['app_type'])); + if ($vars['app'] == $app['app_type']) { + echo ''; + } + + $sep = ' | '; } print_optionbar_end(); -if($vars['app']) -{ - if (is_file("pages/apps/".mres($vars['app']).".inc.php")) - { - include("pages/apps/".mres($vars['app']).".inc.php"); - } else { - include("pages/apps/default.inc.php"); - } -} else { - include("pages/apps/overview.inc.php"); +if ($vars['app']) { + if (is_file('pages/apps/'.mres($vars['app']).'.inc.php')) { + include 'pages/apps/'.mres($vars['app']).'.inc.php'; + } + else { + include 'pages/apps/default.inc.php'; + } +} +else { + include 'pages/apps/overview.inc.php'; } -$pagetitle[] = "Apps"; -?> +$pagetitle[] = 'Apps'; diff --git a/html/pages/apps/default.inc.php b/html/pages/apps/default.inc.php index e33367405..bf752de29 100644 --- a/html/pages/apps/default.inc.php +++ b/html/pages/apps/default.inc.php @@ -1,45 +1,41 @@ '.nicecase($vars['app']).''); -echo(''); -$app_devices = dbFetchRows("SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?", array($vars['app'])); +echo '

    '.nicecase($vars['app']).'

    '; +echo '
    '; +$app_devices = dbFetchRows('SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?', array($vars['app'])); -foreach ($app_devices as $app_device) -{ - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''); - echo(''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''); - echo(''); -} + echo ''; + echo ''; +}//end foreach -echo('
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab'=>'apps','app'=>$vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '); +foreach ($app_devices as $app_device) { + echo '
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab' => 'apps', 'app' => $vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '; - foreach ($graphs[$vars['app']] as $graph_type) - { - $graph_array['type'] = "application_".$vars['app']."_".$graph_type; - $graph_array['id'] = $app_device['app_id']; - $graph_array_zoom['type'] = "application_".$vars['app']."_".$graph_type; - $graph_array_zoom['id'] = $app_device['app_id']; + foreach ($graphs[$vars['app']] as $graph_type) { + $graph_array['type'] = 'application_'.$vars['app'].'_'.$graph_type; + $graph_array['id'] = $app_device['app_id']; + $graph_array_zoom['type'] = 'application_'.$vars['app'].'_'.$graph_type; + $graph_array_zoom['id'] = $app_device['app_id']; - $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'],'tab'=>'apps','app'=>$vars['app'])); + $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'], 'tab' => 'apps', 'app' => $vars['app'])); - echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); - } + echo overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + } - echo('
    '); - -?> +echo ''; diff --git a/html/pages/authlog.inc.php b/html/pages/authlog.inc.php index 64b4080ad..3cffbbea9 100644 --- a/html/pages/authlog.inc.php +++ b/html/pages/authlog.inc.php @@ -1,37 +1,37 @@ = '10') -{ - echo(""); +if ($_SESSION['userlevel'] >= '10') { + echo '
    '; - foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) - { - if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } + foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) { + if ($bg == $list_colour_a) { + $bg = $list_colour_b; + } + else { + $bg = $list_colour_a; + } - echo(" - - - - - - "); - } + echo " + + + + + + '; + }//end foreach - $pagetitle[] = "Authlog"; + $pagetitle[] = 'Authlog'; - echo("
    - " . $entry['datetime'] . " - - ".$entry['user']." - - ".$entry['address']." - - ".$entry['result']." -
    + ".$entry['datetime'].' + + '.$entry['user'].' + + '.$entry['address'].' + + '.$entry['result'].' +
    "); + echo ''; } -else -{ - include("includes/error-no-perm.inc.php"); -} - -?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index 13b640057..03faf35c1 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -2,255 +2,274 @@ $bill_id = mres($vars['bill_id']); -if ($_SESSION['userlevel'] >= "10") -{ - include("pages/bill/actions.inc.php"); +if ($_SESSION['userlevel'] >= '10') { + include 'pages/bill/actions.inc.php'; } -if (bill_permitted($bill_id)) -{ - $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); +if (bill_permitted($bill_id)) { + $bill_data = dbFetchRow('SELECT * FROM bills WHERE bill_id = ?', array($bill_id)); - $bill_name = $bill_data['bill_name']; + $bill_name = $bill_data['bill_name']; - $today = str_replace("-", "", dbFetchCell("SELECT CURDATE()")); - $yesterday = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)")); - $tomorrow = str_replace("-", "", dbFetchCell("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)")); - $last_month = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)")); + $today = str_replace('-', '', dbFetchCell('SELECT CURDATE()')); + $yesterday = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)')); + $tomorrow = str_replace('-', '', dbFetchCell('SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)')); + $last_month = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)')); - $rightnow = $today . date(His); - $before = $yesterday . date(His); - $lastmonth = $last_month . date(His); + $rightnow = $today.date(His); + $before = $yesterday.date(His); + $lastmonth = $last_month.date(His); - $bill_name = $bill_data['bill_name']; - $dayofmonth = $bill_data['bill_day']; + $bill_name = $bill_data['bill_name']; + $dayofmonth = $bill_data['bill_day']; - $day_data = getDates($dayofmonth); + $day_data = getDates($dayofmonth); - $datefrom = $day_data['0']; - $dateto = $day_data['1']; - $lastfrom = $day_data['2']; - $lastto = $day_data['3']; + $datefrom = $day_data['0']; + $dateto = $day_data['1']; + $lastfrom = $day_data['2']; + $lastto = $day_data['3']; - $rate_95th = $bill_data['rate_95th']; - $dir_95th = $bill_data['dir_95th']; - $total_data = $bill_data['total_data']; - $rate_average = $bill_data['rate_average']; + $rate_95th = $bill_data['rate_95th']; + $dir_95th = $bill_data['dir_95th']; + $total_data = $bill_data['total_data']; + $rate_average = $bill_data['rate_average']; - if ($rate_95th > $paid_kb) - { - $over = $rate_95th - $paid_kb; - $bill_text = $over . "Kbit excess."; - $bill_color = "#cc0000"; - } - else - { - $under = $paid_kb - $rate_95th; - $bill_text = $under . "Kbit headroom."; - $bill_color = "#0000cc"; - } - - $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); - $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); - $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); - $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); - - $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); - $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); - # Speeds up loading for other included pages by setting it before progessing of mysql data! - - $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D - WHERE B.bill_id = ? AND P.port_id = B.port_id - AND D.device_id = P.device_id", array($bill_id)); - - echo("

    - Bill : " . $bill_data['bill_name'] . "

    "); - - print_optionbar_start(); - - echo("Bill » "); - - if (!$vars['view']) { $vars['view'] = "quick"; } - - if ($vars['view'] == "quick") { echo(""); } - echo('Quick Graphs'); - if ($vars['view'] == "quick") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "accurate") { echo(""); } - echo('Accurate Graphs'); - if ($vars['view'] == "accurate") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "transfer") { echo(""); } - echo('Transfer Graphs'); - if ($vars['view'] == "transfer") { echo(""); } - - echo(" | "); - - if ($vars['view'] == "history") { echo(""); } - echo('Historical Usage'); - if ($vars['view'] == "history") { echo(""); } - - if ($_SESSION['userlevel'] >= "10") - { - echo(" | "); - if ($vars['view'] == "edit") { echo(""); } - echo('Edit'); - if ($vars['view'] == "edit") { echo(""); } - - echo(" | "); - if ($vars['view'] == "delete") { echo(""); } - echo('Delete'); - if ($vars['view'] == "delete") { echo(""); } - - echo(" | "); - if ($vars['view'] == "reset") { echo(""); } - echo('Reset'); - if ($vars['view'] == "reset") { echo(""); } - } - - echo(''); - - print_optionbar_end(); - - if ($vars['view'] == "edit" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/edit.inc.php"); - } - elseif ($vars['view'] == "delete" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/delete.inc.php"); - } - elseif ($vars['view'] == "reset" && $_SESSION['userlevel'] >= "10") - { - include("pages/bill/reset.inc.php"); - } - elseif ($vars['view'] == "history") - { - include("pages/bill/history.inc.php"); - } - elseif ($vars['view'] == "transfer") - { - include("pages/bill/transfer.inc.php"); - } - elseif ($vars['view'] == "quick" || $vars['view'] == "accurate") { - - echo("

    Billed Ports

    "); - - // Collected Earlier - foreach ($ports as $port) - { - echo(generate_port_link($port) . " on " . generate_device_link($port) . "
    "); + if ($rate_95th > $paid_kb) { + $over = ($rate_95th - $paid_kb); + $bill_text = $over.'Kbit excess.'; + $bill_color = '#cc0000'; + } + else { + $under = ($paid_kb - $rate_95th); + $bill_text = $under.'Kbit headroom.'; + $bill_color = '#0000cc'; } - echo("

    Bill Summary

    "); + $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); + $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); + $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); + $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); - if ($bill_data['bill_type'] == "quota") - { - // The Customer is billed based on a pre-paid quota with overage in xB + $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); + $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); + // Speeds up loading for other included pages by setting it before progessing of mysql data! + $ports = dbFetchRows( + 'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D + WHERE B.bill_id = ? AND P.port_id = B.port_id + AND D.device_id = P.device_id', + array($bill_id) + ); - echo("

    Quota Bill

    "); + echo '

    + Bill : '.$bill_data['bill_name'].'

    '; - $percent = round(($total_data) / $bill_data['bill_quota'] * 100, 2); - $unit = "MB"; - $total_data = round($total_data, 2); - echo("Billing Period from " . $fromtext . " to " . $totext); - echo("
    Transferred ".format_bytes_billing($total_data)." of ".format_bytes_billing($bill_data['bill_quota'])." (".$percent."%)"); - echo("
    Average rate " . formatRates($rate_average)); + print_optionbar_start(); - $background = get_percentage_colours($percent); + echo "Bill » "; - echo("

    ".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); - - $type="&ave=yes"; - } - elseif ($bill_data['bill_type'] == "cdr") - { - // The customer is billed based on a CDR with 95th%ile overage - - echo("

    CDR / 95th Bill

    "); - - $unit = "kbps"; - $cdr = $bill_data['bill_cdr']; - $rate_95th = round($rate_95th, 2); - - $percent = round(($rate_95th) / $cdr * 100, 2); - - $type="&95th=yes"; - - echo("" . $fromtext . " to " . $totext . " -
    Measured ".format_si($rate_95th)."bps of ".format_si($cdr)."bps (".$percent."%) @ 95th %ile"); - - $background = get_percentage_colours($percent); - - echo("

    ".print_percentage_bar (350, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); - - # echo("

    Billing Period : " . $fromtext . " to " . $totext . "
    - # " . $paidrate_text . "
    - # " . $total_data . "MB transfered in the current billing cycle.
    - # " . $rate_average . "Kbps Average during the current billing cycle.

    - # " . $rate_95th . "Kbps @ 95th Percentile. (" . $dir_95th . ") (" . $bill_text . ") - # - #
    "); + if (!$vars['view']) { + $vars['view'] = 'quick'; } - $lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"); - $yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"); - $rightnow = date(U); - - if ($vars['view'] == "accurate") { - - $bi = ""; - - $li = ""; - - $di = ""; - - $mi = ""; - + if ($vars['view'] == 'quick') { + echo ""; } - if ($null) - { - echo(" - @@ -268,39 +287,32 @@ if (bill_permitted($bill_id)) - "); + "; + }//end if - } - - if ($_GET['all']) - { - $ai = ""; - echo("

    Entire Data View

    $ai"); - } - elseif ($_GET['custom']) - { - $cg = ""; - echo("

    Custom Graph

    $cg"); - } - else - { - echo("

    Billing View

    $bi"); -# echo("

    Previous Bill View

    $li"); - echo("

    24 Hour View

    $di"); - echo("

    Monthly View

    $mi"); -# echo("
    Graph All Data (SLOW)"); - } - } # End if details + if ($_GET['all']) { + $ai = ''; + echo "

    Entire Data View

    $ai"; + } + else if ($_GET['custom']) { + $cg = ''; + echo "

    Custom Graph

    $cg"; + } + else { + echo "

    Billing View

    $bi"; + // echo("

    Previous Bill View

    $li"); + echo "

    24 Hour View

    $di"; + echo "

    Monthly View

    $mi"; + // echo("
    Graph All Data (SLOW)"); + }//end if + } //end if } -else -{ - include("includes/error-no-perm.inc.php"); -} - -?> +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/bill/actions.inc.php b/html/pages/bill/actions.inc.php index d55c2944c..29afb6d3b 100644 --- a/html/pages/bill/actions.inc.php +++ b/html/pages/bill/actions.inc.php @@ -1,8 +1,7 @@ = 1) { + $quota = array( + 'type' => 'tb', + 'select_tb' => ' selected', + 'data' => $tmp['tb'], + ); + } + else if (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) { + $quota = array( + 'type' => 'gb', + 'select_gb' => ' selected', + 'data' => $tmp['gb'], + ); + } + else if (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) { + $quota = array( + 'type' => 'mb', + 'select_mb' => ' selected', + 'data' => $tmp['mb'], + ); + } +}//end if -if ($bill_data['bill_type'] == "quota") { - $data = $bill_data['bill_quota']; - $tmp['mb'] = $data / $base / $base; - $tmp['gb'] = $data / $base / $base / $base; - $tmp['tb'] = $data / $base / $base / $base / $base; - if ($tmp['tb']>=1) { $quota = array("type" => "tb", "select_tb" => " selected", "data" => $tmp['tb']); } - elseif (($tmp['gb']>=1) and ($tmp['gb']<$base)) { $quota = array("type" => "gb", "select_gb" => " selected", "data" => $tmp['gb']); } - elseif (($tmp['mb']>=1) and ($tmp['mb']<$base)) { $quota = array("type" => "mb", "select_mb" => " selected", "data" => $tmp['mb']); } -} -if ($bill_data['bill_type'] == "cdr") { - $data = $bill_data['bill_cdr']; - $tmp['kbps'] = $data / $base; - $tmp['mbps'] = $data / $base / $base; - $tmp['gbps'] = $data / $base / $base / $base; - if ($tmp['gbps']>=1) { $cdr = array("type" => "gbps", "select_gbps" => " selected", "data" => $tmp['gbps']); } - elseif (($tmp['mbps']>=1) and ($tmp['mbps']<$base)) { $cdr = array("type" => "mbps", "select_mbps" => " selected", "data" => $tmp['mbps']); } - elseif (($tmp['kbps']>=1) and ($tmp['kbps']<$base)) { $cdr = array("type" => "kbps", "select_kbps" => " selected", "data" => $tmp['kbps']); } -} +if ($bill_data['bill_type'] == 'cdr') { + $data = $bill_data['bill_cdr']; + $tmp['kbps'] = ($data / $base); + $tmp['mbps'] = ($data / $base / $base); + $tmp['gbps'] = ($data / $base / $base / $base); + if ($tmp['gbps'] >= 1) { + $cdr = array( + 'type' => 'gbps', + 'select_gbps' => ' selected', + 'data' => $tmp['gbps'], + ); + } + else if (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) { + $cdr = array( + 'type' => 'mbps', + 'select_mbps' => ' selected', + 'data' => $tmp['mbps'], + ); + } + else if (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) { + $cdr = array( + 'type' => 'kbps', + 'select_kbps' => ' selected', + 'data' => $tmp['kbps'], + ); + } +}//end if ?>
    - +

    Bill Properties

    - " /> +
    @@ -51,17 +86,35 @@ if ($bill_data['bill_type'] == "cdr") {
    - -
    @@ -121,19 +124,19 @@ foreach ($config['device_types'] as $type)
    - value="" /> + value="" />
    - /> + />
    - /> + />
    diff --git a/html/pages/device/edit/health.inc.php b/html/pages/device/edit/health.inc.php index 3d7d21352..922bb36c7 100644 --- a/html/pages/device/edit/health.inc.php +++ b/html/pages/device/edit/health.inc.php @@ -30,156 +30,158 @@ $sensor['sensor_id'], 'sensor_limit' => $sensor['sensor_limit'], 'sensor_limit_low' => $sensor['sensor_limit_low'], 'sensor_alert' => $sensor['sensor_alert']); - if($sensor['sensor_alert'] == 1) - { - $alert_status = 'checked'; - } - else - { - $alert_status = ''; - } - if ($sensor['sensor_custom'] == 'No') { - $custom = 'disabled'; - } else { - $custom = ''; - } - echo(' - - '.$sensor['sensor_class'].' - '.$sensor['sensor_type'].' - '.$sensor['sensor_descr'].' - '.$sensor['sensor_current'].' - -
    +foreach (dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND sensor_deleted='0'", array($device['device_id'])) as $sensor) { + $rollback[] = array( + 'sensor_id' => $sensor['sensor_id'], + 'sensor_limit' => $sensor['sensor_limit'], + 'sensor_limit_low' => $sensor['sensor_limit_low'], + 'sensor_alert' => $sensor['sensor_alert'], + ); + if ($sensor['sensor_alert'] == 1) { + $alert_status = 'checked'; + } + else { + $alert_status = ''; + } + + if ($sensor['sensor_custom'] == 'No') { + $custom = 'disabled'; + } + else { + $custom = ''; + } + + echo ' + + '.$sensor['sensor_class'].' + '.$sensor['sensor_type'].' + '.$sensor['sensor_descr'].' + '.$sensor['sensor_current'].' + +
    -
    - - -
    +
    + + +
    -
    - - - - - +
    + + + + + Clear custom - - -'); + + + '; } - ?>
    - - - - '); +foreach ($rollback as $reset_data) { + echo ' + + + + + '; } ?>
    - diff --git a/html/pages/device/edit/ipmi.inc.php b/html/pages/device/edit/ipmi.inc.php index f3971ca41..0aff50bdd 100644 --- a/html/pages/device/edit/ipmi.inc.php +++ b/html/pages/device/edit/ipmi.inc.php @@ -1,31 +1,45 @@ "7") - { - $ipmi_hostname = mres($_POST['ipmi_hostname']); - $ipmi_username = mres($_POST['ipmi_username']); - $ipmi_password = mres($_POST['ipmi_password']); +if ($_POST['editing']) { + if ($_SESSION['userlevel'] > '7') { + $ipmi_hostname = mres($_POST['ipmi_hostname']); + $ipmi_username = mres($_POST['ipmi_username']); + $ipmi_password = mres($_POST['ipmi_password']); - if ($ipmi_hostname != '') { set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); } else { del_dev_attrib($device, 'ipmi_hostname'); } - if ($ipmi_username != '') { set_dev_attrib($device, 'ipmi_username', $ipmi_username); } else { del_dev_attrib($device, 'ipmi_username'); } - if ($ipmi_password != '') { set_dev_attrib($device, 'ipmi_password', $ipmi_password); } else { del_dev_attrib($device, 'ipmi_password'); } + if ($ipmi_hostname != '') { + set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); + } + else { + del_dev_attrib($device, 'ipmi_hostname'); + } - $update_message = "Device IPMI data updated."; - $updated = 1; - } - else - { - include("includes/error-no-perm.inc.php"); - } + if ($ipmi_username != '') { + set_dev_attrib($device, 'ipmi_username', $ipmi_username); + } + else { + del_dev_attrib($device, 'ipmi_username'); + } + + if ($ipmi_password != '') { + set_dev_attrib($device, 'ipmi_password', $ipmi_password); + } + else { + del_dev_attrib($device, 'ipmi_password'); + } + + $update_message = 'Device IPMI data updated.'; + $updated = 1; + } + else { + include 'includes/error-no-perm.inc.php'; + }//end if +}//end if + +if ($updated && $update_message) { + print_message($update_message); } - -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +else if ($update_message) { + print_error($update_message); } ?> @@ -37,19 +51,19 @@ if ($updated && $update_message)
    - +
    - +
    - +
    diff --git a/html/pages/device/edit/modules.inc.php b/html/pages/device/edit/modules.inc.php index 36a53b3f1..319617162 100644 --- a/html/pages/device/edit/modules.inc.php +++ b/html/pages/device/edit/modules.inc.php @@ -17,68 +17,57 @@ $module_status) -{ - echo(' +foreach ($config['poller_modules'] as $module => $module_status) { + echo(' '.$module.' -'); + '); - if($module_status == 1) - { - echo('Enabled'); - } - else - { - echo('Disabled'); - } + if($module_status == 1) { + echo('Enabled'); + } + else { + echo('Disabled'); + } - echo(' + echo(' -'); + '); - if (isset($attribs['poll_'.$module])) - { - if ($attribs['poll_'.$module]) - { - echo('Enabled'); - $module_checked = 'checked'; + if (isset($attribs['poll_'.$module])) { + if ($attribs['poll_'.$module]) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - else - { - echo('Disabled'); - $module_checked = ''; + else { + if($module_status == 1) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - } - else - { - if($module_status == 1) - { - echo('Enabled'); - $module_checked = 'checked'; - } - else - { - echo('Disabled'); - $module_checked = ''; - } - } - echo(' + echo(' -'); + '); - echo(' - -'); + echo(''); - echo(' + echo(' -'); + '); } ?> @@ -96,71 +85,56 @@ foreach ($config['poller_modules'] as $module => $module_status) $module_status) -{ - - echo(' +foreach ($config['discovery_modules'] as $module => $module_status) { + echo(' '.$module.' -'); + '); - if($module_status == 1) - { - echo('Enabled'); - } - else - { - echo('Disabled'); - } + if($module_status == 1) { + echo('Enabled'); + } + else { + echo('Disabled'); + } - echo(' + echo(' - -'); + '); - if (isset($attribs['discover_'.$module])) - { - if($attribs['discover_'.$module]) - { - echo('Enabled'); - $module_checked = 'checked'; + if (isset($attribs['discover_'.$module])) { + if($attribs['discover_'.$module]) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - else - { - echo('Disabled'); - $module_checked = ''; + else { + if($module_status == 1) { + echo('Enabled'); + $module_checked = 'checked'; + } + else { + echo('Disabled'); + $module_checked = ''; + } } - } - else - { - if($module_status == 1) - { - echo('Enabled'); - $module_checked = 'checked'; - } - else - { - echo('Disabled'); - $module_checked = ''; - } - } - echo(' + echo(' - -'); + '); - echo(' - -'); + echo(''); - echo(' + echo(' - -'); + '); } echo(' diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index b382cf05a..d8dc562e4 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -1,28 +1,26 @@ '); +echo '
    '; -if ($_POST['ignoreport']) -{ - if ($_SESSION['userlevel'] == '10') - { - include("includes/port-edit.inc.php"); - } +if ($_POST['ignoreport']) { + if ($_SESSION['userlevel'] == '10') { + include 'includes/port-edit.inc.php'; + } } -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +if ($updated && $update_message) { + print_message($update_message); +} +else if ($update_message) { + print_error($update_message); } -echo("
    +echo "
    - "); + "; -echo(" +echo "
    @@ -41,14 +39,14 @@ echo("
    Index Name
    -"); +"; ?> '; + echo ''; + echo ''; + echo ''; - echo(""); - echo(""); - echo(""); - echo(""); + // Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled + // - as to draw the attention to a possible problem. + $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; + $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; + $outofsync = $dowecare ? " class='red'" : ''; - # Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled - # - as to draw the attention to a possible problem. - $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; - $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; - $outofsync = $dowecare ? " class='red'" : ""; + echo "'; - echo(""); + echo '"); + echo '"); - echo(""); + echo "\n"; - echo("\n"); + $row++; +}//end foreach - $row++; -} - -echo('
    '.$port['ifIndex'].''.$port['label'].''.$port['ifAdminStatus'].'
    ". $port['ifIndex']."".$port['label'] . "". $port['ifAdminStatus']."'.$port['ifOperStatus'].'". $port['ifOperStatus']."'; + echo "'; + echo ""); - echo(""); - echo(""); - echo("'; + echo "'; + echo ""); - echo(""); - echo(""); - echo("".$port['ifAlias'] . "
    '); -echo('
    '); -echo('
    '); - -?> +echo ''; +echo ''; +echo '
    '; diff --git a/html/pages/device/edit/services.inc.php b/html/pages/device/edit/services.inc.php index e6969a9fe..1f2bc1d30 100644 --- a/html/pages/device/edit/services.inc.php +++ b/html/pages/device/edit/services.inc.php @@ -1,29 +1,28 @@ = '10') { - include("includes/service-add.inc.php"); + include 'includes/service-add.inc.php'; } } if ($_POST['delsrv']) { if ($_SESSION['userlevel'] >= '10') { - include("includes/service-delete.inc.php"); + include 'includes/service-delete.inc.php'; } } if ($_POST['confirm-editsrv']) { - echo "yeah"; + echo 'yeah'; if ($_SESSION['userlevel'] >= '10') { - include("includes/service-edit.inc.php"); + include 'includes/service-edit.inc.php'; } } - if ($handle = opendir($config['install_dir'] . "/includes/services/")) { + if ($handle = opendir($config['install_dir'].'/includes/services/')) { while (false !== ($file = readdir($handle))) { - if ($file != "." && $file != ".." && !strstr($file, ".")) { + if ($file != '.' && $file != '..' && !strstr($file, '.')) { $servicesform .= ""; } } @@ -31,17 +30,17 @@ if (is_admin() === TRUE || is_read() === TRUE) { closedir($handle); } - $dev = device_by_id_cache($device['device_id']); - $devicesform = ""; + $dev = device_by_id_cache($device['device_id']); + $devicesform = "'; if ($updated) { - print_message("Device Settings Saved"); + print_message('Device Settings Saved'); } - if (dbFetchCell("SELECT COUNT(*) from `services` WHERE `device_id` = ?", array($device['device_id'])) > '0') { - $i = "1"; - foreach (dbFetchRows("select * from services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $service) { - $existform .= ""; + if (dbFetchCell('SELECT COUNT(*) from `services` WHERE `device_id` = ?', array($device['device_id'])) > '0') { + $i = '1'; + foreach (dbFetchRows('select * from services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $service) { + $existform .= "'; } } @@ -49,28 +48,29 @@ if (is_admin() === TRUE || is_read() === TRUE) { if ($existform) { echo '
    '; - if ($_POST['editsrv'] == "yes") { - include_once "includes/print-service-edit.inc.php"; - } else { + if ($_POST['editsrv'] == 'yes') { + include_once 'includes/print-service-edit.inc.php'; + } + else { echo " -

    Edit / Delete Service

    -
    +

    Edit / Delete Service

    +
    -
    - -
    - -
    -
    -
    -
    - -
    -
    +
    + +
    +
    - "; +
    +
    +
    + +
    +
    +
    + "; } echo '
    '; @@ -78,8 +78,8 @@ if (is_admin() === TRUE || is_read() === TRUE) { echo '
    '; - require_once "includes/print-service-add.inc.php"; - -} else { - include("includes/error-no-perm.inc.php"); -} \ No newline at end of file + include_once 'includes/print-service-add.inc.php'; +} +else { + include 'includes/error-no-perm.inc.php'; +} diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php index 9e8a5b7b0..59c6bf4cd 100644 --- a/html/pages/device/edit/snmp.inc.php +++ b/html/pages/device/edit/snmp.inc.php @@ -1,225 +1,240 @@ "7") - { - $community = mres($_POST['community']); - $snmpver = mres($_POST['snmpver']); - $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = "udp"; - $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; - $timeout = mres($_POST['timeout']); - $retries = mres($_POST['retries']); - $poller_group = mres($_POST['poller_group']); - $v3 = array ( - 'authlevel' => mres($_POST['authlevel']), - 'authname' => mres($_POST['authname']), - 'authpass' => mres($_POST['authpass']), - 'authalgo' => mres($_POST['authalgo']), - 'cryptopass' => mres($_POST['cryptopass']), - 'cryptoalgo' => mres($_POST['cryptoalgo']) - ); +if ($_POST['editing']) { + if ($_SESSION['userlevel'] > '7') { + $community = mres($_POST['community']); + $snmpver = mres($_POST['snmpver']); + $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = 'udp'; + $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; + $timeout = mres($_POST['timeout']); + $retries = mres($_POST['retries']); + $poller_group = mres($_POST['poller_group']); + $v3 = array( + 'authlevel' => mres($_POST['authlevel']), + 'authname' => mres($_POST['authname']), + 'authpass' => mres($_POST['authpass']), + 'authalgo' => mres($_POST['authalgo']), + 'cryptopass' => mres($_POST['cryptopass']), + 'cryptoalgo' => mres($_POST['cryptoalgo']), + ); - #FIXME needs better feedback - $update = array( - 'community' => $community, - 'snmpver' => $snmpver, - 'port' => $port, - 'transport' => $transport, - 'poller_group' => $poller_group - ); + // FIXME needs better feedback + $update = array( + 'community' => $community, + 'snmpver' => $snmpver, + 'port' => $port, + 'transport' => $transport, + 'poller_group' => $poller_group, + ); - if ($_POST['timeout']) { $update['timeout'] = $timeout; } - else { $update['timeout'] = array('NULL'); } - if ($_POST['retries']) { $update['retries'] = $retries; } - else { $update['retries'] = array('NULL'); } - - $update = array_merge($update, $v3); - - $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); - if (isSNMPable($device_tmp)) { - $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id'])); - - if ($rows_updated > 0) { - $update_message = $rows_updated . " 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; + if ($_POST['timeout']) { + $update['timeout'] = $timeout; + } + else { + $update['timeout'] = array('NULL'); } - } else { - $update_message = "Could not connect to device with new SNMP details"; - $updated = 0; - } - } -} -$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id'])); + if ($_POST['retries']) { + $update['retries'] = $retries; + } + else { + $update['retries'] = array('NULL'); + } + + $update = array_merge($update, $v3); + + $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); + if (isSNMPable($device_tmp)) { + $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id'])); + + if ($rows_updated > 0) { + $update_message = $rows_updated.' Device record updated.'; + $updated = 1; + } + else if ($rows_updated = '-1') { + $update_message = 'Device record unchanged. No update necessary.'; + $updated = -1; + } + else { + $update_message = 'Device record update error.'; + $updated = 0; + } + } + else { + $update_message = 'Could not connect to device with new SNMP details'; + $updated = 0; + } + }//end if +}//end if + +$device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id'])); $descr = $device['purpose']; -echo('
    -
    '); -if ($updated && $update_message) -{ - print_message($update_message); -} elseif ($update_message) { - print_error($update_message); +echo '
    +
    '; +if ($updated && $update_message) { + print_message($update_message); +} +else if ($update_message) { + print_error($update_message); } -echo('
    -
    '); -echo(" -
    - -
    +echo '
    +
    '; + +echo " + + +
    - +
    - +
    - "; foreach ($config['snmp']['transports'] as $transport) { - echo(""); + + echo '>'.$transport.''; } -echo(" + +echo "
    -
    -
    +
    +
    - +
    - +
    -
    -
    +
    +
    - +
    - -
    - -
    + +
    +
    -
    -
    +
    +
    +
    - +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    +
    -
    "); +
    +
    '; -if ($config['distributed_poller'] === TRUE) { - echo(' -
    - -
    - + + '; - foreach (dbFetchRows("SELECT `id`,`group_name` FROM `poller_groups`") as $group) { - echo ''; + + echo '>'.$group['group_name'].''; } - echo(' - -
    -
    - '); -} + echo ' + +
    +
    + '; +}//end if -echo(' - - -'); +echo ' + + + '; ?> diff --git a/html/pages/device/entphysical.inc.php b/html/pages/device/entphysical.inc.php index af167b4dd..7b5d956fa 100644 --- a/html/pages/device/entphysical.inc.php +++ b/html/pages/device/entphysical.inc.php @@ -1,13 +1,11 @@ "; @@ -33,7 +31,8 @@ function printEntPhysical($ent, $level, $class) if (count($sensor)) { $link = " href='device/device=".$device['device_id'].'/tab=health/metric='.$sensor['sensor_class']."/' onmouseover=\"return overlib('', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\""; } - } else { + } + else { unset($link); } diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index a275e71e3..e4bd13d84 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -1,70 +1,68 @@ 'device', + 'device' => $device['device_id'], + 'tab' => 'graphs', +); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'graphs'); +$bg = '#ffffff'; -$bg="#ffffff"; - -echo('
    '); +echo '
    '; print_optionbar_start(); -echo("Graphs » "); +echo "Graphs » "; -foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph", array($device['device_id'])) as $graph) -{ - $section = $config['graph_types']['device'][$graph['graph']]['section']; - if ($section != "") { - $graph_enable[$section][$graph['graph']] = $graph['graph']; - } +foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph', array($device['device_id'])) as $graph) { + $section = $config['graph_types']['device'][$graph['graph']]['section']; + if ($section != '') { + $graph_enable[$section][$graph['graph']] = $graph['graph']; + } } // These are standard graphs we should have for all systems $graph_enable['poller']['poller_perf'] = 'device_poller_perf'; -$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; +$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; -$sep = ""; -foreach ($graph_enable as $section => $nothing) -{ - if (isset($graph_enable) && is_array($graph_enable[$section])) - { - $type = strtolower($section); - if (!$vars['group']) { $vars['group'] = $type; } - echo($sep); - if ($vars['group'] == $type) - { - echo(''); +$sep = ''; +foreach ($graph_enable as $section => $nothing) { + if (isset($graph_enable) && is_array($graph_enable[$section])) { + $type = strtolower($section); + if (!$vars['group']) { + $vars['group'] = $type; + } + + echo $sep; + if ($vars['group'] == $type) { + echo ''; + } + + echo generate_link(ucwords($type), $link_array, array('group' => $type)); + if ($vars['group'] == $type) { + echo ''; + } + + $sep = ' | '; } - echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); - if ($vars['group'] == $type) - { - echo(""); - } - $sep = " | "; - } } -unset ($sep); + +unset($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -#foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) -{ - $graph_array = array(); - if ($graph_enable[$graph]) - { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = "device_" . $graph; +// foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) { + $graph_array = array(); + if ($graph_enable[$graph]) { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = 'device_'.$graph; - include("includes/print-device-graph.php"); - } + include 'includes/print-device-graph.php'; + } } -$pagetitle[] = "Graphs"; - -?> +$pagetitle[] = 'Graphs'; diff --git a/html/pages/device/graphs/netstats_ip_forward.inc.php b/html/pages/device/graphs/netstats_ip_forward.inc.php index cc728ac77..eda137a78 100644 --- a/html/pages/device/graphs/netstats_ip_forward.inc.php +++ b/html/pages/device/graphs/netstats_ip_forward.inc.php @@ -1,11 +1,8 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'health'); +if ($storage) { + $datas[] = 'storage'; +} + +if ($diskio) { + $datas[] = 'diskio'; +} + +if ($charge) { + $datas[] = 'charge'; +} + +if ($temperatures) { + $datas[] = 'temperature'; +} + +if ($humidity) { + $datas[] = 'humidity'; +} + +if ($fans) { + $datas[] = 'fanspeed'; +} + +if ($volts) { + $datas[] = 'voltage'; +} + +if ($freqs) { + $datas[] = 'frequency'; +} + +if ($current) { + $datas[] = 'current'; +} + +if ($power) { + $datas[] = 'power'; +} + +if ($dBm) { + $datas[] = 'dbm'; +} + +if ($states) { + $datas[] = 'state'; +} + +if ($load) { + $datas[] = 'load'; +} + +$type_text['overview'] = 'Overview'; +$type_text['charge'] = 'Battery Charge'; +$type_text['temperature'] = 'Temperature'; +$type_text['humidity'] = 'Humidity'; +$type_text['mempool'] = 'Memory'; +$type_text['storage'] = 'Disk Usage'; +$type_text['diskio'] = 'Disk I/O'; +$type_text['processor'] = 'Processor'; +$type_text['voltage'] = 'Voltage'; +$type_text['fanspeed'] = 'Fanspeed'; +$type_text['frequency'] = 'Frequency'; +$type_text['current'] = 'Current'; +$type_text['power'] = 'Power'; +$type_text['dbm'] = 'dBm'; +$type_text['state'] = 'State'; +$type_text['load'] = 'Load'; + +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'health', +); print_optionbar_start(); -echo("Health » "); +echo "Health » "; -if (!$vars['metric']) { $vars['metric'] = "overview"; } +if (!$vars['metric']) { + $vars['metric'] = 'overview'; +} unset($sep); -foreach ($datas as $type) -{ - echo($sep); +foreach ($datas as $type) { + echo $sep; - if ($vars['metric'] == $type) - { echo(''); } - echo(generate_link($type_text[$type],$link_array,array('metric'=>$type))); - if ($vars['metric'] == $type) { echo(""); } - $sep = " | "; + if ($vars['metric'] == $type) { + echo ''; + } + + echo generate_link($type_text[$type], $link_array, array('metric' => $type)); + if ($vars['metric'] == $type) { + echo ''; + } + + $sep = ' | '; } print_optionbar_end(); -if (is_file("pages/device/health/".mres($vars['metric']).".inc.php")) -{ - include("pages/device/health/".mres($vars['metric']).".inc.php"); -} else { +if (is_file('pages/device/health/'.mres($vars['metric']).'.inc.php')) { + include 'pages/device/health/'.mres($vars['metric']).'.inc.php'; +} +else { + foreach ($datas as $type) { + if ($type != 'overview') { + $graph_title = $type_text[$type]; + $graph_array['type'] = 'device_'.$type; - foreach ($datas as $type) - { - if ($type != "overview") - { - - $graph_title = $type_text[$type]; - $graph_array['type'] = "device_".$type; - - include("includes/print-device-graph.php"); + include 'includes/print-device-graph.php'; + } } - } } -$pagetitle[] = "Health"; - -?> +$pagetitle[] = 'Health'; diff --git a/html/pages/device/health/charge.inc.php b/html/pages/device/health/charge.inc.php index 7282247bf..0750ae593 100644 --- a/html/pages/device/health/charge.inc.php +++ b/html/pages/device/health/charge.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/current.inc.php b/html/pages/device/health/current.inc.php index 0fa318a9b..70bd4dc42 100644 --- a/html/pages/device/health/current.inc.php +++ b/html/pages/device/health/current.inc.php @@ -4,6 +4,4 @@ $class = "current"; $unit = "A"; $graph_type = "sensor_current"; -include("sensors.inc.php"); - -?> +require 'sensors.inc.php'; diff --git a/html/pages/device/health/humidity.inc.php b/html/pages/device/health/humidity.inc.php index 93b4772a3..ffef7afa6 100644 --- a/html/pages/device/health/humidity.inc.php +++ b/html/pages/device/health/humidity.inc.php @@ -4,6 +4,4 @@ $class = "humidity"; $unit = "%"; $graph_type = "sensor_humidity"; -include("sensors.inc.php"); - -?> +require 'sensors.inc.php'; diff --git a/html/pages/device/health/load.inc.php b/html/pages/device/health/load.inc.php index 399237aae..18f5b5f5c 100644 --- a/html/pages/device/health/load.inc.php +++ b/html/pages/device/health/load.inc.php @@ -1,9 +1,7 @@ +require 'sensors.inc.php'; diff --git a/html/pages/device/health/mempool.inc.php b/html/pages/device/health/mempool.inc.php index 6630c3147..613aa1250 100644 --- a/html/pages/device/health/mempool.inc.php +++ b/html/pages/device/health/mempool.inc.php @@ -1,66 +1,72 @@ "); -echo(""); +echo "
    "; +echo '
    '; $i = '1'; -#FIXME css alternating colours +// FIXME css alternating colours +foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($device['device_id'])) as $mempool) { + if (!is_integer($i / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } -foreach (dbFetchRows("SELECT * FROM `mempools` WHERE device_id = ?", array($device['device_id'])) as $mempool) -{ - if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if ($debug) { + print_r($state); + } - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $mempool = array_merge($mempool, $state); } - unset($state); - } + if (is_array($state)) { + $mempool = array_merge($mempool, $state); + } - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + unset($state); + } - $mempool_url = "graphs/id=".$mempool['mempool_id']."/type=mempool_usage/"; - $mini_url = "graph.php?id=".$mempool['mempool_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; - $mempool_popup .= "
    "; - $mempool_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + $mempool_url = 'graphs/id='.$mempool['mempool_id'].'/type=mempool_usage/'; + $mini_url = 'graph.php?id='.$mempool['mempool_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); + $mempool_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; + $mempool_popup .= "
    "; + $mempool_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; - $perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100); + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); - $background = get_percentage_colours($percent); - $right_background = $background['right']; - $left_background = $background['left']; + $perc = round(($mempool['mempool_used'] / $mempool['mempool_total'] * 100)); - echo(" - - - - "); + $background = get_percentage_colours($percent); + $right_background = $background['right']; + $left_background = $background['left']; - echo(" + + + + '; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; + echo ""); + include 'includes/print-graphrow.inc.php'; - $i++; -} + echo ''; -echo("
    " . $text_descr . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free , "ffffff", $right_background)." - ".$perc."%
    "); + echo "
    ".$text_descr." + ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $left_background, $free, 'ffffff', $right_background).' + '.$perc.'%
    "; - include("includes/print-graphrow.inc.php"); + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; - echo("
    "); -echo("
    "); + $i++; +}//end foreach -?> +echo ''; +echo '
    '; diff --git a/html/pages/device/health/processor.inc.php b/html/pages/device/health/processor.inc.php index bde4a3b3f..725e37c21 100644 --- a/html/pages/device/health/processor.inc.php +++ b/html/pages/device/health/processor.inc.php @@ -1,46 +1,43 @@ "); -echo(""); +echo "
    "; +echo '
    '; $i = '1'; -foreach (dbFetchRows("SELECT * FROM `processors` WHERE device_id = ?", array($device['device_id'])) as $proc) -{ - $proc_url = "graphs/id=".$proc['processor_id']."/type=processor_usage/"; +foreach (dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', array($device['device_id'])) as $proc) { + $proc_url = 'graphs/id='.$proc['processor_id'].'/type=processor_usage/'; - $mini_url = "graph.php?id=".$proc['processor_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; + $mini_url = 'graph.php?id='.$proc['processor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; - $text_descr = $proc['processor_descr']; + $text_descr = $proc['processor_descr']; - $text_descr = rewrite_entity_descr($text_descr); + $text_descr = rewrite_entity_descr($text_descr); - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; - $percent = round($proc['processor_usage']); + $percent = round($proc['processor_usage']); - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo(" - + echo (" + - "); + '); - echo("
    " . $text_descr . "
    ".$text_descr." - ".print_percentage_bar (400, 20, $percent, $percent."%", "ffffff", $background['left'], (100 - $percent)."%" , "ffffff", $background['right'])." + ".print_percentage_bar(400, 20, $percent, $percent.'%', 'ffffff', $background['left'], (100 - $percent).'%', 'ffffff', $background['right']).'
    "); + echo "
    "; - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; - include("includes/print-graphrow.inc.php"); -} + include 'includes/print-graphrow.inc.php'; +}//end foreach -echo("
    "); -echo(""); - -?> +echo ''; +echo ''; diff --git a/html/pages/device/health/state.inc.php b/html/pages/device/health/state.inc.php index 546396219..9781248be 100644 --- a/html/pages/device/health/state.inc.php +++ b/html/pages/device/health/state.inc.php @@ -1,7 +1,7 @@ "); +echo ''; -echo(" +echo ' - "); + '; $row = 1; -foreach (dbFetchRows("SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr", array($device['device_id'])) as $drive) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } +foreach (dbFetchRows('SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr', array($device['device_id'])) as $drive) { + if (is_integer($row / 2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - $total = $drive['storage_size']; - $used = $drive['storage_used']; - $free = $drive['storage_free']; - $perc = round($drive['storage_perc'], 0); - $used = formatStorage($used); - $total = formatStorage($total); - $free = formatStorage($free); + $total = $drive['storage_size']; + $used = $drive['storage_used']; + $free = $drive['storage_free']; + $perc = round($drive['storage_perc'], 0); + $used = formatStorage($used); + $total = formatStorage($total); + $free = formatStorage($free); - $fs_url = "graphs/id=".$drive['storage_id']."/type=storage_usage/"; + $fs_url = 'graphs/id='.$drive['storage_id'].'/type=storage_usage/'; - $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$drive['storage_descr']; - $fs_popup .= "
    "; - $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; + $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$drive['storage_descr']; + $fs_popup .= "
    "; + $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo(""); + echo "'; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; - echo(""); + echo ''; - $row++; -} + $row++; +}//end foreach -echo("
    Drive Usage Free
    " . $drive['storage_descr'] . " - ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $perc . "%", "ffffff", $background['right'])." - " . $free . "
    ".$drive['storage_descr']." + ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $perc.'%', 'ffffff', $background['right']).' + '.$free.'
    "); + echo "
    "; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    "); - -?> +echo ''; diff --git a/html/pages/device/hrdevice.inc.php b/html/pages/device/hrdevice.inc.php index 68928187b..d16a0ba83 100644 --- a/html/pages/device/hrdevice.inc.php +++ b/html/pages/device/hrdevice.inc.php @@ -1,70 +1,69 @@ '); +echo ''; // FIXME missing heading +foreach (dbFetchRows('SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`', array($device['device_id'])) as $hrdevice) { + echo "'; -foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`", array($device['device_id'])) as $hrdevice) -{ - echo(""); + if ($hrdevice['hrDeviceType'] == 'hrDeviceProcessor') { + $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); + $proc_url = 'device/device='.$device['device_id'].'/tab=health/metric=processor/'; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$hrdevice['hrDeviceDescr']; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; + echo "'; - if ($hrdevice['hrDeviceType'] == "hrDeviceProcessor") - { - $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); - $proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/"; - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$hrdevice['hrDeviceDescr']; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - echo(""); + $graph_array['height'] = '20'; + $graph_array['width'] = '100'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc_id; + $graph_array['type'] = 'processor_usage'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; - $graph_array['height'] = "20"; - $graph_array['width'] = "100"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc_id; - $graph_array['type'] = 'processor_usage'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; + $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); - $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); - - echo(''); - } - elseif ($hrdevice['hrDeviceType'] == "hrDeviceNetwork") - { - $int = str_replace("network interface ", "", $hrdevice['hrDeviceDescr']); - $interface = dbFetchRow("SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?", array($device['device_id'], $int)); - if ($interface['ifIndex']) - { - echo(""); - - $graph_array['height'] = "20"; - $graph_array['width'] = "100"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $interface['port_id']; - $graph_array['type'] = 'port_bits'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; - - // FIXME click on graph should also link to port, but can't use generate_port_link here... - $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); - - echo(""); - } else { - echo(""); - echo(""); + echo ''; } - } else { - echo(""); - echo(""); - } + else if ($hrdevice['hrDeviceType'] == 'hrDeviceNetwork') { + $int = str_replace('network interface ', '', $hrdevice['hrDeviceDescr']); + $interface = dbFetchRow('SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?', array($device['device_id'], $int)); + if ($interface['ifIndex']) { + echo ''; - echo(""); - echo(""); - echo(""); -} + $graph_array['height'] = '20'; + $graph_array['width'] = '100'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $interface['port_id']; + $graph_array['type'] = 'port_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '400'; -echo('
    ".$hrdevice['hrDeviceIndex'].'
    ".$hrdevice['hrDeviceIndex']."".$hrdevice['hrDeviceDescr'].'".$hrdevice['hrDeviceDescr']."'.$mini_graph.'".generate_port_link($interface)."$mini_graph".stripslashes($hrdevice['hrDeviceDescr'])."'.$mini_graph.'".stripslashes($hrdevice['hrDeviceDescr'])."'.generate_port_link($interface).'".$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus']."".$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad']."
    '); + // FIXME click on graph should also link to port, but can't use generate_port_link here... + $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); -$pagetitle[] = "Inventory"; + echo "$mini_graph"; + } + else { + echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; + echo ''; + } + } + else { + echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; + echo ''; + }//end if -?> + echo ''.$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus'].''; + echo ''.$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad'].''; + echo ''; +}//end foreach + +echo ''; + +$pagetitle[] = 'Inventory'; diff --git a/html/pages/device/loadbalancer/ace_rservers.inc.php b/html/pages/device/loadbalancer/ace_rservers.inc.php index 52f1773c7..c8b4b2acd 100644 --- a/html/pages/device/loadbalancer/ace_rservers.inc.php +++ b/html/pages/device/loadbalancer/ace_rservers.inc.php @@ -33,10 +33,10 @@ echo ' Graphs: '; // "pkts" => "Packets", // "errors" => "Errors"); $graph_types = array( - 'curr' => 'CurrentConns', - 'failed' => 'FailedConns', - 'total' => 'TotalConns', - ); + 'curr' => 'CurrentConns', + 'failed' => 'FailedConns', + 'total' => 'TotalConns', +); foreach ($graph_types as $type => $descr) { echo "$type_sep"; @@ -66,7 +66,8 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = if ($rserver['StateDescr'] == 'Server is now operational') { $rserver_class = 'green'; - } else { + } + else { $rserver_class = 'red'; } @@ -87,7 +88,7 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = $graph_array['id'] = $rserver['rserver_id']; $graph_array['type'] = $graph_type; - include 'includes/print-graphrow.inc.php'; + require 'includes/print-graphrow.inc.php'; // include("includes/print-interface-graphs.inc.php"); echo ' diff --git a/html/pages/device/loadbalancer/ace_vservers.inc.php b/html/pages/device/loadbalancer/ace_vservers.inc.php index 65032709c..68ebd1d3f 100644 --- a/html/pages/device/loadbalancer/ace_vservers.inc.php +++ b/html/pages/device/loadbalancer/ace_vservers.inc.php @@ -2,84 +2,101 @@ print_optionbar_start(); -echo("Serverfarms » "); +echo "Serverfarms » "; -#$auth = TRUE; +// $auth = TRUE; +$menu_options = array('basic' => 'Basic'); -$menu_options = array('basic' => 'Basic', - ); +if (!$_GET['opta']) { + $_GET['opta'] = 'basic'; +} -if (!$_GET['opta']) { $_GET['opta'] = "basic"; } +$sep = ''; +foreach ($menu_options as $option => $text) { + if ($_GET['type'] == $option) { + echo ""; + } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - if ($_GET['type'] == $option) { echo(""); } - echo(''.$text.''); - if ($_GET['type'] == $option) { echo(""); } - echo(" | "); + echo ''.$text.''; + if ($_GET['type'] == $option) { + echo ''; + } + + echo ' | '; } unset($sep); -echo(' Graphs: '); +echo ' Graphs: '; -$graph_types = array("bits" => "Bits", - "pkts" => "Packets", - "conns" => "Connections"); +$graph_types = array( + 'bits' => 'Bits', + 'pkts' => 'Packets', + 'conns' => 'Connections', +); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($_GET['opte'] == $type) { echo(""); } - echo(''.$descr.''); - echo(''.$text.''); - if ($_GET['opte'] == $type) { echo(""); } +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($_GET['opte'] == $type) { + echo ""; + } - $type_sep = " | "; + echo ''.$descr.''; + echo ''.$text.''; + if ($_GET['opte'] == $type) { + echo ''; + } + + $type_sep = ' | '; } print_optionbar_end(); -echo("
    "); -$i = "0"; -foreach (dbFetchRows("SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`", array($device['device_id'])) as $vserver) -{ -if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } +echo "
    "; +$i = '0'; +foreach (dbFetchRows('SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`', array($device['device_id'])) as $vserver) { + if (is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } -if($vserver['serverstate'] == "inService") { $vserver_class="green"; } else { $vserver_class="red"; } + if ($vserver['serverstate'] == 'inService') { + $vserver_class = 'green'; + } + else { + $vserver_class = 'red'; + } -echo(""); -#echo(""); -echo(""); -#echo(""); -echo(""); -echo(""); - if ($_GET['type'] == "graphs") - { - echo(''); - echo(""; + // echo(""); + echo ''; + // echo(""); + echo "'; + echo ''; + if ($_GET['type'] == 'graphs') { + echo ''; + echo ' - "); - } + echo ' + + '; + } -echo(""); -echo(""); + echo ''; + echo ''; - $i++; -} + $i++; +}//end foreach -echo("
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "" . $vserver['classmap'] . "" . $rserver['farm_id'] . "" . $vserver['serverstate'] . "
    "); - $graph_type = "vserver_" . $_GET['opte']; + echo "
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "'.$vserver['classmap'].'" . $rserver['farm_id'] . "".$vserver['serverstate'].'
    '; + $graph_type = 'vserver_'.$_GET['opte']; -$graph_array['height'] = "100"; -$graph_array['width'] = "215"; -$graph_array['to'] = $config['time']['now']; -$graph_array['id'] = $vserver['classmap_id']; -$graph_array['type'] = $graph_type; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $vserver['classmap_id']; + $graph_array['type'] = $graph_type; -include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo(" -
    "); - -?> +echo ''; diff --git a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php index a67d755b9..91abc8204 100644 --- a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php +++ b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php @@ -1,6 +1,6 @@ VServer
    » "); // echo('All'); diff --git a/html/pages/device/logs.inc.php b/html/pages/device/logs.inc.php index 0b8481a68..11fd6914b 100644 --- a/html/pages/device/logs.inc.php +++ b/html/pages/device/logs.inc.php @@ -1,41 +1,43 @@ Logging » "); +echo 'Logging » '; -if ($vars['section'] == "eventlog") { - echo(''); +if ($vars['section'] == 'eventlog') { + echo ''; } -echo(generate_link("Event Log" , $vars, array('section'=>'eventlog'))); -if ($vars['section'] == "eventlog") { - echo(""); + +echo generate_link('Event Log', $vars, array('section' => 'eventlog')); +if ($vars['section'] == 'eventlog') { + echo ''; } if (isset($config['enable_syslog']) && $config['enable_syslog'] == 1) { - echo(" | "); + echo ' | '; - if ($vars['section'] == "syslog") { - echo(''); + if ($vars['section'] == 'syslog') { + echo ''; } - echo(generate_link("Syslog" , $vars, array('section'=>'syslog'))); - if ($vars['section'] == "syslog") { - echo(""); + + echo generate_link('Syslog', $vars, array('section' => 'syslog')); + if ($vars['section'] == 'syslog') { + echo ''; } } -switch ($vars['section']) -{ - case 'syslog': - case 'eventlog': - include('pages/device/logs/'.$vars['section'].'.inc.php'); - break; - default: - print_optionbar_end(); - echo(report_this('Unknown section '.$vars['section'])); - break; -} +switch ($vars['section']) { + case 'syslog': + case 'eventlog': + include 'pages/device/logs/'.$vars['section'].'.inc.php'; + break; -?> + default: + print_optionbar_end(); + echo report_this('Unknown section '.$vars['section']); + break; +} diff --git a/html/pages/device/logs/eventlog.inc.php b/html/pages/device/logs/eventlog.inc.php index aec8bdd98..7d5204f1c 100644 --- a/html/pages/device/logs/eventlog.inc.php +++ b/html/pages/device/logs/eventlog.inc.php @@ -2,51 +2,49 @@
    +echo '
    Eventlog entries
    - '); +
    '; -foreach ($entries as $entry) -{ - include("includes/print-event.inc.php"); +foreach ($entries as $entry) { + include 'includes/print-event.inc.php'; } -echo('
    -
    '); +echo ' + '; -$pagetitle[] = "Events"; - -?> +$pagetitle[] = 'Events'; diff --git a/html/pages/device/logs/syslog.inc.php b/html/pages/device/logs/syslog.inc.php index 7aae3b8e0..1284ad157 100644 --- a/html/pages/device/logs/syslog.inc.php +++ b/html/pages/device/logs/syslog.inc.php @@ -3,53 +3,54 @@
    +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? $where"; +$sql .= ' ORDER BY timestamp DESC LIMIT 1000'; +echo '
    Syslog entries
    - '); -foreach (dbFetchRows($sql, $param) as $entry) { include("includes/print-syslog.inc.php"); } -echo('
    -
    '); -$pagetitle[] = "Syslog"; + '; +foreach (dbFetchRows($sql, $param) as $entry) { + include 'includes/print-syslog.inc.php'; +} -?> +echo '
    + '; +$pagetitle[] = 'Syslog'; diff --git a/html/pages/device/map.inc.php b/html/pages/device/map.inc.php index 522de36a5..918f62e7f 100644 --- a/html/pages/device/map.inc.php +++ b/html/pages/device/map.inc.php @@ -12,8 +12,6 @@ * the source code distribution for details. */ -$pagetitle[] = "Map"; +$pagetitle[] = 'Map'; -require_once "includes/print-map.inc.php"; - -?> +require_once 'includes/print-map.inc.php'; diff --git a/html/pages/device/munin.inc.php b/html/pages/device/munin.inc.php index 67fd22d6e..e12279687 100644 --- a/html/pages/device/munin.inc.php +++ b/html/pages/device/munin.inc.php @@ -1,75 +1,72 @@ 'device', + 'device' => $device['device_id'], + 'tab' => 'munin', +); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'munin'); +$bg = '#ffffff'; -$bg="#ffffff"; - -echo('
    '); +echo '
    '; print_optionbar_start(); -echo("Munin » "); +echo "Munin » "; -$sep = ""; +$sep = ''; -foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", array($device['device_id'])) as $mplug) -{ -# if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; +foreach (dbFetchRows('SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type', array($device['device_id'])) as $mplug) { + // if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; } -foreach ($graph_enable as $section => $nothing) -{ - if (isset($graph_enable) && is_array($graph_enable[$section])) - { - $type = strtolower($section); - if (!$vars['group']) { $vars['group'] = $type; } - echo($sep); - if ($vars['group'] == $type) - { - echo(''); +foreach ($graph_enable as $section => $nothing) { + if (isset($graph_enable) && is_array($graph_enable[$section])) { + $type = strtolower($section); + if (!$vars['group']) { + $vars['group'] = $type; + } + + echo $sep; + if ($vars['group'] == $type) { + echo ''; + } + + echo generate_link(ucwords($type), $link_array, array('group' => $type)); + if ($vars['group'] == $type) { + echo ''; + } + + $sep = ' | '; } - echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); - if ($vars['group'] == $type) - { - echo(""); - } - $sep = " | "; - } } -unset ($sep); +unset($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -#foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) -{ - $graph_array = array(); - if ($graph_enable[$graph]) - { - if (!empty($entry['plugin'])) - { - $graph_title = $entry['title']; - $graph_array['type'] = "munin_graph"; - $graph_array['device'] = $device['device_id']; - $graph_array['plugin'] = $entry['plugin']; - } else { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = "device_" . $graph; - } +// foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) { + $graph_array = array(); + if ($graph_enable[$graph]) { + if (!empty($entry['plugin'])) { + $graph_title = $entry['title']; + $graph_array['type'] = 'munin_graph'; + $graph_array['device'] = $device['device_id']; + $graph_array['plugin'] = $entry['plugin']; + } + else { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = 'device_'.$graph; + } - include("includes/print-device-graph.php"); - } + include 'includes/print-device-graph.php'; + } } -$pagetitle[] = "Graphs"; - -?> +$pagetitle[] = 'Graphs'; diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index aac3b2ca2..13227e013 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -12,8 +12,18 @@ $services['up'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WH $services['down'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_status` = '0' AND `service_ignore` = '0'", array($device['device_id'])); $services['disabled'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_ignore` = '1'", array($device['device_id'])); -if ($services['down']) { $services_colour = $warn_colour_a; } else { $services_colour = $list_colour_a; } -if ($ports['down']) { $ports_colour = $warn_colour_a; } else { $ports_colour = $list_colour_a; } +if ($services['down']) { + $services_colour = $warn_colour_a; +} +else { + $services_colour = $list_colour_a; +} +if ($ports['down']) { + $ports_colour = $warn_colour_a; +} +else { + $ports_colour = $list_colour_a; +} echo('
    @@ -25,39 +35,41 @@ echo('
    '); -include("includes/dev-overview-data.inc.php"); +require 'includes/dev-overview-data.inc.php'; Plugins::call('device_overview_container',array($device)); -include("overview/ports.inc.php"); +require 'overview/ports.inc.php'; echo('
    '); // Right Pane -include("overview/processors.inc.php"); -include("overview/mempools.inc.php"); -include("overview/storage.inc.php"); +require 'overview/processors.inc.php'; +require 'overview/mempools.inc.php'; +require 'overview/storage.inc.php'; -if(is_array($entity_state['group']['c6kxbar'])) { include("overview/c6kxbar.inc.php"); } +if(is_array($entity_state['group']['c6kxbar'])) { + require 'overview/c6kxbar.inc.php'; +} -include("overview/toner.inc.php"); -include("overview/sensors/charge.inc.php"); -include("overview/sensors/temperatures.inc.php"); -include("overview/sensors/humidity.inc.php"); -include("overview/sensors/fanspeeds.inc.php"); -include("overview/sensors/dbm.inc.php"); -include("overview/sensors/voltages.inc.php"); -include("overview/sensors/current.inc.php"); -include("overview/sensors/power.inc.php"); -include("overview/sensors/frequencies.inc.php"); -include("overview/sensors/load.inc.php"); -include("overview/sensors/state.inc.php"); -include("overview/eventlog.inc.php"); -include("overview/services.inc.php"); -include("overview/syslog.inc.php"); +require 'overview/toner.inc.php'; +require 'overview/sensors/charge.inc.php'; +require 'overview/sensors/temperatures.inc.php'; +require 'overview/sensors/humidity.inc.php'; +require 'overview/sensors/fanspeeds.inc.php'; +require 'overview/sensors/dbm.inc.php'; +require 'overview/sensors/voltages.inc.php'; +require 'overview/sensors/current.inc.php'; +require 'overview/sensors/power.inc.php'; +require 'overview/sensors/frequencies.inc.php'; +require 'overview/sensors/load.inc.php'; +require 'overview/sensors/state.inc.php'; +require 'overview/eventlog.inc.php'; +require 'overview/services.inc.php'; +require 'overview/syslog.inc.php'; echo('
    '); -#include("overview/current.inc.php"); +#require 'overview/current.inc.php"); ?> diff --git a/html/pages/device/overview/c6kxbar.inc.php b/html/pages/device/overview/c6kxbar.inc.php index 14f5d54e4..eb04e0a7d 100644 --- a/html/pages/device/overview/c6kxbar.inc.php +++ b/html/pages/device/overview/c6kxbar.inc.php @@ -1,102 +1,99 @@ -
    -
    -
    -
    '); -echo(''); -echo(" Catalyst 6k Crossbar"); -echo('
    - '); +echo '
    +
    +
    +
    +
    '; +echo ''; +echo " Catalyst 6k Crossbar"; +echo '
    +
    '; -foreach ($entity_state['group']['c6kxbar'] as $index => $entry) -{ - // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> - $entity = dbFetchRow("SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?", array($device['device_id'], $index+1)); +foreach ($entity_state['group']['c6kxbar'] as $index => $entry) { + // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> + $entity = dbFetchRow('SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?', array($device['device_id'], $index + 1)); - echo(" + echo " - - "); + echo ' + '; - foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) - { - if (is_numeric($subindex)) - { - if ($fabric['cc6kxbarModuleChannelFabStatus'] == "ok") - { - $fabric['mode_class'] = "green"; - } else { - $fabric['mode_class'] = "red"; - } + foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) { + if (is_numeric($subindex)) { + if ($fabric['cc6kxbarModuleChannelFabStatus'] == 'ok') { + $fabric['mode_class'] = 'green'; + } + else { + $fabric['mode_class'] = 'red'; + } - $percent_in = $fabric['cc6kxbarStatisticsInUtil']; - $background_in = get_percentage_colours($percent_in); + $percent_in = $fabric['cc6kxbarStatisticsInUtil']; + $background_in = get_percentage_colours($percent_in); - $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; - $background_out = get_percentage_colours($percent_out); + $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; + $background_out = get_percentage_colours($percent_out); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['mod'] = $index; - $graph_array['chan'] = $subindex; - $graph_array['type'] = "c6kxbar_util"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['mod'] = $index; + $graph_array['chan'] = $subindex; + $graph_array['type'] = 'c6kxbar_util'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $text_descr = $entity['entPhysicalName'] . " - Fabric " . $subindex; + $text_descr = $entity['entPhysicalName'].' - Fabric '.$subindex; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); + echo (' + + + - - - - - - - "); - } - } -} - -echo("
    ".$entity['entPhysicalName'].""); + "; - switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) - { - case "busmode": - # echo 'Bus'; + switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) { + case 'busmode': + // echo 'Bus'; break; - case "crossbarmode": + + case 'crossbarmode': echo 'Crossbar'; break; - case "dcefmode": + + case 'dcefmode': echo 'DCEF'; break; - default: + + default: echo $entry['']['cc6kxbarModuleModeSwitchingMode']; } - echo("
    Fabric '.$subindex." - Fabric ".$subindex."". - - $fabric['cc6kxbarModuleChannelFabStatus']."".formatRates($fabric['cc6kxbarModuleChannelSpeed']*1000000)."".overlib_link($link, $minigraph, $overlib_content)."".print_percentage_bar (125, 20, $percent_in, "Ingress", "ffffff", $background['left'], $percent_in . "%", "ffffff", $background['right'])."".print_percentage_bar (125, 20, $percent_out, "Egress", "ffffff", $background['left'], $percent_out . "%", "ffffff", $background['right'])."
    "); -echo("
    "); -echo("
    "); -echo("
    "); -echo("
    "); - -?> +echo ' '; +echo '
    '; +echo ' '; +echo ' '; +echo ''; diff --git a/html/pages/device/overview/eventlog.inc.php b/html/pages/device/overview/eventlog.inc.php index ff235aa4a..d55511813 100644 --- a/html/pages/device/overview/eventlog.inc.php +++ b/html/pages/device/overview/eventlog.inc.php @@ -1,25 +1,22 @@ '); - echo('
    +echo '
    '; +echo '
    -
    '); -echo(''); -echo(" Recent Events"); -echo('
    - '); +
    '; +echo ''; +echo " Recent Events"; +echo '
    +
    '; $eventlog = dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` WHERE `host` = ? ORDER BY `datetime` DESC LIMIT 0,10", array($device['device_id'])); -foreach ($eventlog as $entry) -{ - include("includes/print-event-short.inc.php"); +foreach ($eventlog as $entry) { + include 'includes/print-event-short.inc.php'; } -echo("
    "); -echo('
    '); -echo('
    '); -echo('
    '); -echo('
    '); - -?> +echo ''; +echo '
    '; +echo ''; +echo ''; +echo ''; diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index 6194c37c0..36bc05cd5 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -1,75 +1,71 @@ +if (count($sensors)) { + echo '
    -
    -
    -
    '); - echo(' ' . $sensor_type . ''); - echo('
    - '); - foreach ($sensors as $sensor) - { - if ($config['memcached']['enable'] === TRUE) - { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - } +
    +
    +
    '; + echo ' '.$sensor_type.''; + echo '
    +
    '; + foreach ($sensors as $sensor) { + if ($config['memcached']['enable'] === true) { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + } - if (empty($sensor['sensor_current'])) - { - $sensor['sensor_current'] = "NaN"; - } + if (empty($sensor['sensor_current'])) { + $sensor['sensor_current'] = 'NaN'; + } - // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. - // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? - // FIXME - DUPLICATED IN health/sensors + // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. + // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? + // FIXME - DUPLICATED IN health/sensors + $graph_colour = str_replace('#', '', $row_colour); - $graph_colour = str_replace("#", "", $row_colour); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $sensor['sensor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $sensor['sensor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; + foreach (array('day', 'week', 'month', 'year') as $period) { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + } - $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; - foreach (array('day','week','month','year') as $period) - { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); - } - $overlib_content .= "
    "; + $overlib_content .= '
    '; - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $graph_array['from'] = $config['time']['day']; + $sensor_minigraph = generate_graph_tag($graph_array); - $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); + $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo(" - - - - "); - } + echo ' + + + + '; + }//end foreach - echo("
    ".overlib_link($link, $sensor['sensor_descr'], $overlib_content)."".overlib_link($link, $sensor_minigraph, $overlib_content)."".overlib_link($link, " $sensor['sensor_limit'] ? "style='color: red'" : '') . '>' . $sensor['sensor_current'] . $sensor_unit . "", $overlib_content)."
    '.overlib_link($link, $sensor['sensor_descr'], $overlib_content).''.overlib_link($link, $sensor_minigraph, $overlib_content).''.overlib_link($link, ' $sensor['sensor_limit'] ? "style='color: red'" : '').'>'.$sensor['sensor_current'].$sensor_unit.'', $overlib_content).'
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} - -?> + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/mempools.inc.php b/html/pages/device/overview/mempools.inc.php index 3d35a8d55..069987241 100644 --- a/html/pages/device/overview/mempools.inc.php +++ b/html/pages/device/overview/mempools.inc.php @@ -1,76 +1,77 @@ +if (count($mempools)) { + echo '
    -
    -
    -
    -'); - echo(''); - echo(" Memory Pools"); - echo(' -
    - -'); +
    +
    +
    + '; + echo ''; + echo " Memory Pools"; + echo ' +
    +
    + '; - foreach ($mempools as $mempool) - { + foreach ($mempools as $mempool) { + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if ($debug) { + print_r($state); + } - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $mempool = array_merge($mempool, $state); } - unset($state); - } + if (is_array($state)) { + $mempool = array_merge($mempool, $state); + } - $percent= round($mempool['mempool_perc'],0); - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); - $background = get_percentage_colours($percent); + unset($state); + } - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $percent = round($mempool['mempool_perc'], 0); + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); + $background = get_percentage_colours($percent); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - echo(" - - - - "); - } + echo ' + + + + '; + }//end foreach - echo('
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." -
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' +
    + echo '
    -
    '); - -} - -?> + '; +}//end if diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 807f8ee4f..75cf3ca29 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -1,68 +1,64 @@ '); - echo('
    +if ($ports['total']) { + echo '
    '; + echo '
    Overall Traffic
    - '); +
    '; - $graph_array['height'] = "100"; - $graph_array['width'] = "485"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['type'] = "device_bits"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; - $graph = generate_graph_tag($graph_array); + $graph_array['height'] = '100'; + $graph_array['width'] = '485'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['type'] = 'device_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; + $graph = generate_graph_tag($graph_array); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width']); + $link = generate_url($link_array); - $graph_array['width'] = "210"; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - Device Traffic"); + $graph_array['width'] = '210'; + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - Device Traffic'); - echo(' - - '); + echo ' + + '; - echo(' + echo ' - - - - - '); + + + + + '; - echo(' - + "); - echo(""); - echo("
    '); - echo(overlib_link($link, $graph, $overlib_content, NULL)); - echo('
    '; + echo overlib_link($link, $graph, $overlib_content, null); + echo '
    ' . $ports['total'] . ' ' . $ports['up'] . ' ' . $ports['down'] . ' ' . $ports['disabled'] . '
    '.$ports['total'].' '.$ports['up'].' '.$ports['down'].' '.$ports['disabled'].'
    '); + echo '
    '; - $ifsep = ""; + $ifsep = ''; - foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) - { - $data = ifNameDescr($data); - $data = array_merge($data, $device); - echo("$ifsep" . generate_port_link($data, makeshortif(strtolower($data['label'])))); - $ifsep = ", "; - } + foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) { + $data = ifNameDescr($data); + $data = array_merge($data, $device); + echo "$ifsep".generate_port_link($data, makeshortif(strtolower($data['label']))); + $ifsep = ', '; + } - unset($ifsep); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} - -?> + unset($ifsep); + echo ' '; + echo ''; + echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index 3394e263c..8b4d3f291 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -1,66 +1,63 @@ +if (count($processors)) { + echo '
    -'); - echo(''); - echo(" Processors"); - echo('
    - '); +'; + echo ''; + echo " Processors"; + echo ' +
    '; - foreach ($processors as $proc) - { - $text_descr = rewrite_entity_descr($proc['processor_descr']); + foreach ($processors as $proc) { + $text_descr = rewrite_entity_descr($proc['processor_descr']); - # disable short hrDeviceDescr. need to make this prettier. - #$text_descr = short_hrDeviceDescr($proc['processor_descr']); - $percent = $proc['processor_usage']; - $background = get_percentage_colours($percent); - $graph_colour = str_replace("#", "", $row_colour); + // disable short hrDeviceDescr. need to make this prettier. + // $text_descr = short_hrDeviceDescr($proc['processor_descr']); + $percent = $proc['processor_usage']; + $background = get_percentage_colours($percent); + $graph_colour = str_replace('#', '', $row_colour); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); - - echo(" - - - + + + - "); - } + '; + }//end foreach - echo('
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    + echo '
    -
    '); - -} - -?> + '; +}//end if diff --git a/html/pages/device/overview/sensors/charge.inc.php b/html/pages/device/overview/sensors/charge.inc.php index bf4097749..b0df00968 100644 --- a/html/pages/device/overview/sensors/charge.inc.php +++ b/html/pages/device/overview/sensors/charge.inc.php @@ -1,10 +1,8 @@ +require 'pages/device/overview/generic/sensor.inc.php'; diff --git a/html/pages/device/overview/sensors/load.inc.php b/html/pages/device/overview/sensors/load.inc.php index 989a305b9..089f93dff 100644 --- a/html/pages/device/overview/sensors/load.inc.php +++ b/html/pages/device/overview/sensors/load.inc.php @@ -1,8 +1,8 @@ '); - echo('
    +if ($services['total']) { +echo '
    '; + echo '
    -
    '); - echo(" Services"); - echo('
    - '); +
    '; + echo " Services"; + echo '
    +
    '; - echo(" + echo " @@ -19,22 +18,32 @@ echo('
    ');
    -
    $services[total] $services[up] $services[disabled]
    "); +"; - foreach (dbFetchRows("SELECT * FROM services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $data) - { - if ($data['service_status'] == "0" && $data['service_ignore'] == "1") { $status = "grey"; } - if ($data['service_status'] == "1" && $data['service_ignore'] == "1") { $status = "green"; } - if ($data['service_status'] == "0" && $data['service_ignore'] == "0") { $status = "red"; } - if ($data['service_status'] == "1" && $data['service_ignore'] == "0") { $status = "blue"; } - echo("$break" . strtolower($data['service_type']) . ""); - $break = ", "; - } - echo('
    '); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); -} + foreach (dbFetchRows('SELECT * FROM services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $data) { + if ($data['service_status'] == '0' && $data['service_ignore'] == '1') { + $status = 'grey'; + } -?> + if ($data['service_status'] == '1' && $data['service_ignore'] == '1') { + $status = 'green'; + } + + if ($data['service_status'] == '0' && $data['service_ignore'] == '0') { + $status = 'red'; + } + + if ($data['service_status'] == '1' && $data['service_ignore'] == '0') { + $status = 'blue'; + } + + echo "$break".strtolower($data['service_type']).''; + $break = ', '; + } + + echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; +}//end if diff --git a/html/pages/device/overview/storage.inc.php b/html/pages/device/overview/storage.inc.php index 01c02edb4..e81b1b5b5 100644 --- a/html/pages/device/overview/storage.inc.php +++ b/html/pages/device/overview/storage.inc.php @@ -1,91 +1,86 @@ +if (count($drives)) { + echo '
    -
    '); - echo(''); - echo(" Storage"); - echo('
    - '); +
    '; + echo ''; + echo " Storage"; + echo '
    +
    '; - foreach ($drives as $drive) - { - $skipdrive = 0; + foreach ($drives as $drive) { + $skipdrive = 0; - if ($device["os"] == "junos") - { - foreach ($config['ignore_junos_os_drives'] as $jdrive) - { - if (preg_match($jdrive, $drive["storage_descr"])) - { - $skipdrive = 1; + if ($device['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']); } - } - $drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]); - } - if ($device['os'] == "freebsd") - { - foreach ($config['ignore_bsd_os_drives'] as $jdrive) - { - if (preg_match($jdrive, $drive["storage_descr"])) - { - $skipdrive = 1; + if ($device['os'] == 'freebsd') { + foreach ($config['ignore_bsd_os_drives'] as $jdrive) { + if (preg_match($jdrive, $drive['storage_descr'])) { + $skipdrive = 1; + } + } } - } - } - if ($skipdrive) { continue; } - $percent = round($drive['storage_perc'], 0); - $total = formatStorage($drive['storage_size']); - $free = formatStorage($drive['storage_free']); - $used = formatStorage($drive['storage_used']); - $background = get_percentage_colours($percent); + if ($skipdrive) { + continue; + } - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $percent = round($drive['storage_perc'], 0); + $total = formatStorage($drive['storage_size']); + $free = formatStorage($drive['storage_free']); + $used = formatStorage($drive['storage_used']); + $background = get_percentage_colours($percent); - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $drive['storage_descr']); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$drive['storage_descr']); - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - echo(" - - - + + + - "); - } + '; + }//end foreach - echo('
    ".overlib_link($link, $drive['storage_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $drive['storage_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    + echo '
    -
    '); + '; +}//end if -} - -unset ($drive_rows); - -?> +unset($drive_rows); diff --git a/html/pages/device/overview/syslog.inc.php b/html/pages/device/overview/syslog.inc.php index 1d26fbb2a..bcfb6d2c5 100644 --- a/html/pages/device/overview/syslog.inc.php +++ b/html/pages/device/overview/syslog.inc.php @@ -1,25 +1,24 @@ '); - echo('
    +if ($config['enable_syslog']) { + $syslog = dbFetchRows("SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? ORDER BY timestamp DESC LIMIT 20", array($device['device_id'])); + if (count($syslog)) { + echo '
    '; + echo '
    -
    '); - echo(' Recent Syslog'); -echo('
    - '); - foreach ($syslog as $entry) { include("includes/print-syslog.inc.php"); } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - } -} +
    '; + echo ' Recent Syslog'; + echo '
    + '; + foreach ($syslog as $entry) { + include 'includes/print-syslog.inc.php'; + } -?> + echo '
    '; + echo '
    '; + echo ''; + echo ''; + echo ''; + } +} diff --git a/html/pages/device/overview/toner.inc.php b/html/pages/device/overview/toner.inc.php index 347a63619..7c789573c 100644 --- a/html/pages/device/overview/toner.inc.php +++ b/html/pages/device/overview/toner.inc.php @@ -1,64 +1,62 @@ +if (count($toners)) { + echo '
    -
    '); - echo(''); - echo(" Toner"); - echo('
    - '); +
    '; + echo ''; + echo " Toner"; + echo '
    +
    '; - foreach ($toners as $toner) - { - $percent = round($toner['toner_current'], 0); - $total = formatStorage($toner['toner_size']); - $free = formatStorage($toner['toner_free']); - $used = formatStorage($toner['toner_used']); + foreach ($toners as $toner) { + $percent = round($toner['toner_current'], 0); + $total = formatStorage($toner['toner_size']); + $free = formatStorage($toner['toner_free']); + $used = formatStorage($toner['toner_used']); - $background = toner2colour($toner['toner_descr'], $percent); + $background = toner2colour($toner['toner_descr'], $percent); - $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $toner['toner_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array = array(); + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $toner['toner_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = 'graphs'; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $toner['toner_descr']); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$toner['toner_descr']); - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. + $minigraph = generate_graph_tag($graph_array); - $minigraph = generate_graph_tag($graph_array); - - echo(" - - - + + + - "); - } + '; + }//end foreach - echo("
    ".overlib_link($link, $toner['toner_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." + echo '
    '.overlib_link($link, $toner['toner_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); -} + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if -unset ($toner_rows); - -?> +unset($toner_rows); diff --git a/html/pages/device/performance.inc.php b/html/pages/device/performance.inc.php index 8686bf803..da2056c54 100644 --- a/html/pages/device/performance.inc.php +++ b/html/pages/device/performance.inc.php @@ -21,7 +21,9 @@ */ -if(!isset($vars['section'])) { $vars['section'] = "performance"; } +if(!isset($vars['section'])) { + $vars['section'] = "performance"; +} if (empty($vars['dtpickerfrom'])) { $vars['dtpickerfrom'] = date($config['dateformat']['byminute'], time() - 3600 * 24 * 2); @@ -57,7 +59,8 @@ if (empty($vars['dtpickerto'])) { if (is_admin() === true || is_read() === true) { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf` WHERE `device_id` = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); -} else { +} +else { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf`,`devices_perms` WHERE `device_id` = ? AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $_SESSION['user_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); } @@ -81,7 +84,7 @@ foreach(dbFetchRows($query, $param) as $return_value) { $avg = $return_value['avg']; if ($max > $max_val) { - $max_val = $max; + $max_val = $max; } $data[] = array('x' => $date,'y' => $loss,'group' => 0); @@ -186,4 +189,3 @@ echo $milisec_diff; var graph2d = new vis.Graph2d(container, items, groups, options); - diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index ecb25cfd2..a70d40a76 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -1,15 +1,22 @@ get('port-'.$port['port_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $port = array_merge($port, $state); } - unset($state); +if ($config['memcached']['enable'] === true) { + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if ($debug) { + print_r($state); + } + + if (is_array($state)) { + $port = array_merge($port, $state); + } + + unset($state); } $port_details = 1; @@ -17,148 +24,218 @@ $port_details = 1; $hostname = $device['hostname']; $hostid = $device['port_id']; $ifname = $port['ifDescr']; -$ifIndex = $port['ifIndex']; -$speed = humanspeed($port['ifSpeed']); +$ifIndex = $port['ifIndex']; +$speed = humanspeed($port['ifSpeed']); $ifalias = $port['name']; -if ($port['ifPhysAddress']) { $mac = "$port[ifPhysAddress]"; } +if ($port['ifPhysAddress']) { + $mac = "$port[ifPhysAddress]"; +} -$color = "black"; -if ($port['ifAdminStatus'] == "down") { $status = "Disabled"; } -if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } -if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } +$color = 'black'; +if ($port['ifAdminStatus'] == 'down') { + $status = "Disabled"; +} -$i = 1; +if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { + $status = "Enabled / Disconnected"; +} + +if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { + $status = "Enabled / Connected"; +} + +$i = 1; $inf = fixifName($ifname); -$bg="#ffffff"; +$bg = '#ffffff'; $show_all = 1; -echo("
    "); +echo "
    "; -include("includes/print-interface.inc.php"); +require 'includes/print-interface.inc.php'; -echo("
    "); +echo ''; -$pos = strpos(strtolower($ifname), "vlan"); -if ($pos !== false ) -{ - $broke = yes; +$pos = strpos(strtolower($ifname), 'vlan'); +if ($pos !== false) { + $broke = yes; } -$pos = strpos(strtolower($ifname), "loopback"); +$pos = strpos(strtolower($ifname), 'loopback'); -if ($pos !== false ) -{ - $broke = yes; +if ($pos !== false) { + $broke = yes; } -echo("
    "); +echo "
    "; print_optionbar_start(); -$link_array = array('page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'port', - 'port' => $port['port_id']); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'port', + 'port' => $port['port_id'], +); $menu_options['graphs'] = 'Graphs'; -$menu_options['realtime'] = 'Real time'; // FIXME CONDITIONAL -$menu_options['arp'] = 'ARP Table'; -$menu_options['events'] = 'Eventlog'; +$menu_options['realtime'] = 'Real time'; +// FIXME CONDITIONAL +$menu_options['arp'] = 'ARP Table'; +$menu_options['events'] = 'Eventlog'; -if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'") ) -{ $menu_options['adsl'] = 'ADSL'; } - -if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'") ) -{ $menu_options['pagp'] = 'PAgP'; } - -if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'") ) -{ $menu_options['vlans'] = 'VLANs'; } - -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text,$link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - $sep = " | "; +if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'")) { + $menu_options['adsl'] = 'ADSL'; } + +if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'")) { + $menu_options['pagp'] = 'PAgP'; +} + +if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'")) { + $menu_options['vlans'] = 'VLANs'; +} + +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; +} + unset($sep); -if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > "0" ) -{ +if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > '0') { + echo generate_link($descr, $link_array, array('view' => 'macaccounting', 'graph' => $type)); - echo(generate_link($descr,$link_array,array('view'=>'macaccounting','graph'=>$type))); + echo ' | Mac Accounting : '; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { + echo ""; + } - echo(" | Mac Accounting : "); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } - echo(generate_link("Bits",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } + echo generate_link('Bits', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { + echo ''; + } - echo("("); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } - echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } - echo('|'); + echo '('; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { + echo ""; + } - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } - echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'bits'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } - echo(") | "); + echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { + echo ''; + } - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } - echo(generate_link("Packets",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } - echo("("); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } - echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } - echo('|'); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } - echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'pkts'))); - if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } - echo(")"); -} + echo '|'; -if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > "0" ) -{ + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { + echo ""; + } - // FIXME ATM VPs - // FIXME URLs BROKEN + echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'bits')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { + echo ''; + } - echo(" | ATM VPs : "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo("Bits"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "packets") { echo(""); } - echo("Packets"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "cells") { echo(""); } - echo("Cells"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } - echo(" | "); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "errors") { echo(""); } - echo("Errors"); - if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } -} + echo ') | '; -if ($_SESSION['userlevel'] >= '10') -{ - echo(" Create Bill"); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { + echo ""; + } + + echo generate_link('Packets', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { + echo ''; + } + + echo '('; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { + echo ""; + } + + echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { + echo ''; + } + + echo '|'; + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { + echo ""; + } + + echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'pkts')); + if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { + echo ''; + } + + echo ')'; +}//end if + +if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > '0') { + // FIXME ATM VPs + // FIXME URLs BROKEN + echo ' | ATM VPs : '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ""; + } + + echo "Bits"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'packets') { + echo ""; + } + + echo "Packets"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'cells') { + echo ""; + } + + echo "Cells"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } + + echo ' | '; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'errors') { + echo ""; + } + + echo "Errors"; + if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { + echo ''; + } +}//end if + +if ($_SESSION['userlevel'] >= '10') { + echo " Create Bill"; } print_optionbar_end(); -echo("
    "); +echo "
    "; -include("pages/device/port/".mres($vars['view']).".inc.php"); +require 'pages/device/port/'.mres($vars['view']).'.inc.php'; -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/device/port/events.inc.php b/html/pages/device/port/events.inc.php index 6de49ef26..5a113fafe 100644 --- a/html/pages/device/port/events.inc.php +++ b/html/pages/device/port/events.inc.php @@ -1,15 +1,12 @@ '); +echo ''; -foreach ($entries as $entry) -{ - include("includes/print-event.inc.php"); +foreach ($entries as $entry) { + include 'includes/print-event.inc.php'; } -echo('
    '); +echo ''; -$pagetitle[] = "Events"; - -?> +$pagetitle[] = 'Events'; diff --git a/html/pages/device/port/pagp.inc.php b/html/pages/device/port/pagp.inc.php index e64437e2c..7a8e41ff5 100644 --- a/html/pages/device/port/pagp.inc.php +++ b/html/pages/device/port/pagp.inc.php @@ -3,34 +3,32 @@ global $config; // FIXME functions! - -if (!$graph_type) { $graph_type = "pagp_bits"; } - -$daily_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100"; -$daily_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - -$weekly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=215&height=100"; -$weekly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=500&height=150"; - -$monthly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=215&height=100"; -$monthly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=500&height=150"; - -$yearly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=215&height=100"; -$yearly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=500&height=150"; - -echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "); -echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "); - -foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) -{ - echo("$br " . generate_port_link($member) . " (PAgP)"); - $br = "
    "; +if (!$graph_type) { + $graph_type = 'pagp_bits'; } -?> +$daily_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=215&height=100'; +$daily_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$weekly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=215&height=100'; +$weekly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$monthly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=215&height=100'; +$monthly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=500&height=150'; + +$yearly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=215&height=100'; +$yearly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=500&height=150'; + +echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "; +echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "; + +foreach (dbFetchRows('SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?', array($port['ifIndex'], $device['device_id'])) as $member) { + echo "$br ".generate_port_link($member).' (PAgP)'; + $br = '
    '; +} diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index b254b376d..dc941e246 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -1,15 +1,23 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'ports'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'ports', +); print_optionbar_start(); @@ -17,110 +25,136 @@ $menu_options['basic'] = 'Basic'; $menu_options['details'] = 'Details'; $menu_options['arp'] = 'ARP Table'; -if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) -{ - $menu_options['neighbours'] = 'Neighbours'; -} -if(dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) -{ - $menu_options['adsl'] = 'ADSL'; +if (dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) { + $menu_options['neighbours'] = 'Neighbours'; } -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) { echo(""); } - echo(generate_link($text,$link_array,array('view'=>$option))); - if ($vars['view'] == $option) { echo(""); } - $sep = " | "; +if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) { + $menu_options['adsl'] = 'ADSL'; +} + +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo generate_link($text, $link_array, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); -echo(' | Graphs: '); +echo ' | Graphs: '; -$graph_types = array("bits" => "Bits", - "upkts" => "Unicast Packets", - "nupkts" => "Non-Unicast Packets", - "errors" => "Errors", - "etherlike" => "Etherlike"); +$graph_types = array( + 'bits' => 'Bits', + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors', + 'etherlike' => 'Etherlike', +); -foreach ($graph_types as $type => $descr) -{ - echo("$type_sep"); - if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } - echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type))); - if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } +foreach ($graph_types as $type => $descr) { + echo "$type_sep"; + if ($vars['graph'] == $type && $vars['view'] == 'graphs') { + echo ""; + } - echo(' ('); - if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } - echo(generate_link('Mini',$link_array,array('view'=>'minigraphs','graph'=>$type))); - if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } - echo(')'); - $type_sep = " | "; -} + echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type)); + if ($vars['graph'] == $type && $vars['view'] == 'graphs') { + echo ''; + } + + echo ' ('; + if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { + echo ""; + } + + echo generate_link('Mini', $link_array, array('view' => 'minigraphs', 'graph' => $type)); + if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { + echo ''; + } + + echo ')'; + $type_sep = ' | '; +}//end foreach print_optionbar_end(); -if ($vars['view'] == 'minigraphs') -{ - $timeperiods = array('-1day','-1week','-1month','-1year'); - $from = '-1day'; - echo("
    "); - unset ($seperator); +if ($vars['view'] == 'minigraphs') { + $timeperiods = array( + '-1day', + '-1week', + '-1month', + '-1year', + ); + $from = '-1day'; + echo "
    "; + unset($seperator); - // FIXME - FIX THIS. UGLY. - foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $port) - { - echo("
    -
    ".makeshortif($port['ifDescr'])."
    - ".$device['hostname']." - ".$port['ifDescr']."
    \ - ".$port['ifAlias']." \ - \ - ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". - " - -
    ".truncate(short_port_descr($port['ifAlias']), 32, '')."
    -
    "); - } - echo("
    "); -} elseif ($vars['view'] == "arp" || $vars['view'] == "adsl" || $vars['view'] == "neighbours") { - include("ports/".$vars['view'].".inc.php"); -} else { - if ($vars['view'] == "details") { $port_details = 1; } - echo("
    "); - $i = "1"; - - global $port_cache, $port_index_cache; - - $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); - // As we've dragged the whole database, lets pre-populate our caches :) - // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. - foreach ($ports as $port) - { - $port_cache[$port['port_id']] = $port; - $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; - } - - foreach ($ports as $port) - { - if ($config['memcached']['enable'] === TRUE) - { - $state = $memcache->get('port-'.$port['port_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $port = array_merge($port, $state); } - unset($state); + // FIXME - FIX THIS. UGLY. + foreach (dbFetchRows('select * from ports WHERE device_id = ? ORDER BY ifIndex', array($device['device_id'])) as $port) { + echo "
    +
    ".makeshortif($port['ifDescr']).'
    + ".$device['hostname'].' - '.$port['ifDescr'].'
    \ + '.$port['ifAlias']." \ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"." + +
    ".truncate(short_port_descr($port['ifAlias']), 32, '').'
    + '; } - include("includes/print-interface.inc.php"); - - $i++; - } - echo("
    "); + echo '
    '; } +else if ($vars['view'] == 'arp' || $vars['view'] == 'adsl' || $vars['view'] == 'neighbours') { + include 'ports/'.$vars['view'].'.inc.php'; +} +else { + if ($vars['view'] == 'details') { + $port_details = 1; + } -$pagetitle[] = "Ports"; + echo "
    "; + $i = '1'; -?> + global $port_cache, $port_index_cache; + + $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); + // As we've dragged the whole database, lets pre-populate our caches :) + // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. + foreach ($ports as $port) { + $port_cache[$port['port_id']] = $port; + $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; + } + + foreach ($ports as $port) { + if ($config['memcached']['enable'] === true) { + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if ($debug) { + print_r($state); + } + + if (is_array($state)) { + $port = array_merge($port, $state); + } + + unset($state); + } + + include 'includes/print-interface.inc.php'; + + $i++; + } + + echo '
    '; +}//end if + +$pagetitle[] = 'Ports'; diff --git a/html/pages/device/ports/neighbours.inc.php b/html/pages/device/ports/neighbours.inc.php index 5e417eb99..b56136881 100644 --- a/html/pages/device/ports/neighbours.inc.php +++ b/html/pages/device/ports/neighbours.inc.php @@ -10,8 +10,7 @@ echo 'Local Port Protocol '; -foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) -{ +foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) { if ($bg_colour == $list_colour_b) { $bg_colour = $list_colour_a; } diff --git a/html/pages/device/processes.inc.php b/html/pages/device/processes.inc.php index 41fda9288..0ce8e4c70 100644 --- a/html/pages/device/processes.inc.php +++ b/html/pages/device/processes.inc.php @@ -1,19 +1,21 @@ +/* + * Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * Process Listing * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -22,77 +24,89 @@ * @subpackage Pages */ -switch( $vars['order'] ) { - case "vsz": - $order = "`vsz`"; - break; - case "rss": - $order = "`rss`"; - break; - case "cputime": - $order = "`cputime`"; - break; - case "user": - $order = "`user`"; - break; - case "command": - $order = "`command`"; - break; - default: - $order = "`pid`"; - break; +switch ($vars['order']) { + case 'vsz': + $order = '`vsz`'; + break; + + case 'rss': + $order = '`rss`'; + break; + + case 'cputime': + $order = '`cputime`'; + break; + + case 'user': + $order = '`user`'; + break; + + case 'command': + $order = '`command`'; + break; + + default: + $order = '`pid`'; + break; +}//end switch + +if ($vars['by'] == 'desc') { + $by = 'desc'; } -if( $vars['by'] == "desc" ) { - $by = "desc"; -} else { - $by = "asc"; +else { + $by = 'asc'; } $heads = array( - 'PID' => '', - 'VSZ' => 'Virtual Memory', - 'RSS' => 'Resident Memory', - 'cputime' => '', - 'user' => '', - 'command' => '' + 'PID' => '', + 'VSZ' => 'Virtual Memory', + 'RSS' => 'Resident Memory', + 'cputime' => '', + 'user' => '', + 'command' => '', ); echo "
    "; -foreach( $heads as $head=>$extra ) { - unset($lhead, $bhead); - $lhead = strtolower($head); - $bhead = 'asc'; - $icon = ""; - if( '`'.$lhead.'`' == $order ) { - $icon = " class='glyphicon glyphicon-chevron-"; - if( $by == 'asc' ) { - $bhead = 'desc'; - $icon .= 'up'; - } else { - $icon .= 'down'; - } - $icon .= "'"; - } - echo ''; -} -echo ""; +foreach ($heads as $head => $extra) { + unset($lhead, $bhead); + $lhead = strtolower($head); + $bhead = 'asc'; + $icon = ''; + if ('`'.$lhead.'`' == $order) { + $icon = " class='glyphicon glyphicon-chevron-"; + if ($by == 'asc') { + $bhead = 'desc'; + $icon .= 'up'; + } + else { + $icon .= 'down'; + } -foreach (dbFetchRows("SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY ".$order." ".$by, array($device['device_id'])) as $entry) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; -} -echo"
     '; - if( !empty($extra) ) { - echo "$head"; - } else { - echo $head; - } - echo '
    '.$entry['pid'].''.format_si($entry['vsz']*1024).''.format_si($entry['rss']*1024).''.$entry['cputime'].''.$entry['user'].''.$entry['command'].'
    "; + $icon .= "'"; + } -?> + echo ' '; + if (!empty($extra)) { + echo "$head"; + } + else { + echo $head; + } + + echo ''; +}//end foreach + +echo ''; + +foreach (dbFetchRows('SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY '.$order.' '.$by, array($device['device_id'])) as $entry) { + echo ''; + echo ''.$entry['pid'].''; + echo ''.format_si(($entry['vsz'] * 1024)).''; + echo ''.format_si(($entry['rss'] * 1024)).''; + echo ''.$entry['cputime'].''; + echo ''.$entry['user'].''; + echo ''.$entry['command'].''; + echo ''; +} + +echo '
    '; diff --git a/html/pages/device/pseudowires.inc.php b/html/pages/device/pseudowires.inc.php index c134c8b66..c48bca573 100644 --- a/html/pages/device/pseudowires.inc.php +++ b/html/pages/device/pseudowires.inc.php @@ -89,8 +89,7 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I WHERE P.port_id 'upkts', 'errors', ); - foreach ($types as $graph_type) - { + foreach ($types as $graph_type) { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index 5b327aca3..17f0629a0 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -1,203 +1,275 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'routing', - 'proto' => 'bgp'); +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'routing', + 'proto' => 'bgp', +); -if(!isset($vars['view'])) { $vars['view'] = "basic"; } +if (!isset($vars['view'])) { + $vars['view'] = 'basic'; +} print_optionbar_start(); -echo "Local AS : " .$device['bgpLocalAs']." "; +echo 'Local AS : '.$device['bgpLocalAs'].' '; -echo("BGP » "); +echo "BGP » "; -if ($vars['view'] == "basic") { echo(""); } -echo(generate_link("Basic", $link_array,array('view'=>'basic'))); -if ($vars['view'] == "basic") { echo(""); } +if ($vars['view'] == 'basic') { + echo ""; +} -echo(" | "); +echo generate_link('Basic', $link_array, array('view' => 'basic')); +if ($vars['view'] == 'basic') { + echo ''; +} -if ($vars['view'] == "updates") { echo(""); } -echo(generate_link("Updates", $link_array,array('view'=>'updates'))); -if ($vars['view'] == "updates") { echo(""); } +echo ' | '; -echo(" | Prefixes: "); +if ($vars['view'] == 'updates') { + echo ""; +} -if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } -echo(generate_link("IPv4", $link_array,array('view'=>'prefixes_ipv4unicast'))); -if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } +echo generate_link('Updates', $link_array, array('view' => 'updates')); +if ($vars['view'] == 'updates') { + echo ''; +} -echo(" | "); +echo ' | Prefixes: '; -if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } -echo(generate_link("VPNv4", $link_array,array('view'=>'prefixes_vpnv4unicast'))); -if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } +if ($vars['view'] == 'prefixes_ipv4unicast') { + echo ""; +} -echo(" | "); +echo generate_link('IPv4', $link_array, array('view' => 'prefixes_ipv4unicast')); +if ($vars['view'] == 'prefixes_ipv4unicast') { + echo ''; +} -if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } -echo(generate_link("IPv6", $link_array,array('view'=>'prefixes_ipv6unicast'))); -if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } +echo ' | '; -echo(" | Traffic: "); +if ($vars['view'] == 'prefixes_vpnv4unicast') { + echo ""; +} -if ($vars['view'] == "macaccounting_bits") { echo(""); } -echo(generate_link("Bits", $link_array,array('view'=>'macaccounting_bits'))); -if ($vars['view'] == "macaccounting_bits") { echo(""); } -echo(" | "); -if ($vars['view'] == "macaccounting_pkts") { echo(""); } -echo(generate_link("Packets", $link_array,array('view'=>'macaccounting_pkts'))); -if ($vars['view'] == "macaccounting_pkts") { echo(""); } +echo generate_link('VPNv4', $link_array, array('view' => 'prefixes_vpnv4unicast')); +if ($vars['view'] == 'prefixes_vpnv4unicast') { + echo ''; +} + +echo ' | '; + +if ($vars['view'] == 'prefixes_ipv6unicast') { + echo ""; +} + +echo generate_link('IPv6', $link_array, array('view' => 'prefixes_ipv6unicast')); +if ($vars['view'] == 'prefixes_ipv6unicast') { + echo ''; +} + +echo ' | Traffic: '; + +if ($vars['view'] == 'macaccounting_bits') { + echo ""; +} + +echo generate_link('Bits', $link_array, array('view' => 'macaccounting_bits')); +if ($vars['view'] == 'macaccounting_bits') { + echo ''; +} + +echo ' | '; +if ($vars['view'] == 'macaccounting_pkts') { + echo ""; +} + +echo generate_link('Packets', $link_array, array('view' => 'macaccounting_pkts')); +if ($vars['view'] == 'macaccounting_pkts') { + echo ''; +} print_optionbar_end(); -echo(''); -echo(''); +echo '
    Peer addressTypeRemote ASStateUptime
    '; +echo ''; -$i = "1"; +$i = '1'; -foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`", array($device['device_id'])) as $peer) -{ - $has_macaccounting = dbFetchCell("SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address", array($peer['bgpPeerIdentifier'])); - unset($bg_image); - if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - unset ($alert, $bg_image); - unset ($peerhost, $peername); +foreach (dbFetchRows('SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`', array($device['device_id'])) as $peer) { + $has_macaccounting = dbFetchCell('SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address', array($peer['bgpPeerIdentifier'])); + unset($bg_image); + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_a; + } + else { + $bg_colour = $list_colour_b; + } - if (!is_integer($i/2)) { $bg_colour = $list_colour_b; } else { $bg_colour = $list_colour_a; } - if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } - if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } - if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } + unset($alert, $bg_image); + unset($peerhost, $peername); - if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; } + if (!is_integer($i / 2)) { + $bg_colour = $list_colour_b; + } + else { + $bg_colour = $list_colour_a; + } - $query = "SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE "; - $query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; - $query .= " AND D.device_id = I.device_id"; - $ipv4_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); + if ($peer['bgpPeerState'] == 'established') { + $col = 'green'; + } + else { + $col = 'red'; + $peer['alert'] = 1; + } - $query = "SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE "; - $query .= "(A.ipv6_address = ? AND I.port_id = A.port_id)"; - $query .= " AND D.device_id = I.device_id"; - $ipv6_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); + if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { + $admin_col = 'green'; + } + else { + $admin_col = 'gray'; + } - if ($ipv4_host) - { - $peerhost = $ipv4_host; - } elseif ($ipv6_host) { - $peerhost = $ipv6_host; - } else { - unset($peerhost); - } + if ($peer['bgpPeerAdminStatus'] == 'stop') { + $peer['alert'] = 0; + $peer['disabled'] = 1; + } - if (is_array($peerhost)) - { - #$peername = generate_device_link($peerhost); - $peername = generate_device_link($peerhost) ." ". generate_port_link($peerhost); - $peer_url = "device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/view=updates/"; - } - else - { - #$peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? -# if ($peername == $peer['bgpPeerIdentifier']) -# { -# unset($peername); -# } else { -# $peername = "".$peername.""; -# } - } + if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { + $peer_type = "iBGP"; + } + else { + $peer_type = "eBGP"; + } - unset($peer_af); - unset($sep); + $query = 'SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE '; + $query .= '(A.ipv4_address = ? AND I.port_id = A.port_id)'; + $query .= ' AND D.device_id = I.device_id'; + $ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); - foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) - { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep . $afi .".".$safi; - $sep = "
    "; - $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer - } + $query = 'SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE '; + $query .= '(A.ipv6_address = ? AND I.port_id = A.port_id)'; + $query .= ' AND D.device_id = I.device_id'; + $ipv6_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); - unset($sep); + if ($ipv4_host) { + $peerhost = $ipv4_host; + } + else if ($ipv6_host) { + $peerhost = $ipv6_host; + } + else { + unset($peerhost); + } - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } + if (is_array($peerhost)) { + // $peername = generate_device_link($peerhost); + $peername = generate_device_link($peerhost).' '.generate_port_link($peerhost); + $peer_url = 'device/device='.$peer['device_id'].'/tab=routing/proto=bgp/view=updates/'; + } + else { + // FIXME + // $peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? + // if ($peername == $peer['bgpPeerIdentifier']) + // { + // unset($peername); + // } else { + // $peername = "".$peername.""; + // } + } + + unset($peer_af); + unset($sep); + + foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep.$afi.'.'.$safi; + $sep = '
    '; + $peer['afisafi'][$this_afisafi] = 1; + // Build a list of valid AFI/SAFI for this peer + } + + unset($sep); + + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } - $graph_type = "bgp_updates"; - $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpPeerIdentifier'] . ""; + $graph_type = 'bgp_updates'; + $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer['bgpPeerIdentifier'].''; - echo('
    - "); + echo ' + '; - echo(" - - - - - - - - "); + echo ' + + + + + + + + '; - unset($invalid); + unset($invalid); - switch ($vars['view']) - { + switch ($vars['view']) { case 'prefixes_ipv4unicast': case 'prefixes_ipv4multicast': case 'prefixes_ipv4vpn': case 'prefixes_ipv6unicast': case 'prefixes_ipv6multicast': - list(,$afisafi) = explode("_", $vars['view']); - if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } - // FIXME no break?? - case 'updates': - $graph_array['type'] = "bgp_" . $vars['view']; - $graph_array['id'] = $peer['bgpPeer_id']; - } + list(,$afisafi) = explode('_', $vars['view']); + if (isset($peer['afisafi'][$afisafi])) { + $peer['graph'] = 1; + } - switch ($vars['view']) - { + // FIXME no break?? + case 'updates': + $graph_array['type'] = 'bgp_'.$vars['view']; + $graph_array['id'] = $peer['bgpPeer_id']; + } + + switch ($vars['view']) { case 'macaccounting_bits': case 'macaccounting_pkts': - $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - if (is_array($acc) && is_file($database)) - { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['view']; - } - } + $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; + if (is_array($acc) && is_file($database)) { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['view']; + } + } - if ($vars['view'] == 'updates') { $peer['graph'] = 1; } + if ($vars['view'] == 'updates') { + $peer['graph'] = 1; + } - if ($peer['graph']) - { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $config['time']['now']; - echo('"); - } + echo ''; + } - $i++; + $i++; - unset($valid_afi_safi); -} + unset($valid_afi_safi); +}//end foreach ?>
    Peer addressTypeRemote ASStateUptime
    ".$i."" . $peeraddresslink . "
    ".$peername."
    $peer_type" . (isset($peer['afi']) ? $peer['afi'] : '') . "AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    - Updates " . $peer['bgpPeerInUpdates'] . " - " . $peer['bgpPeerOutUpdates'] . "
    '.$i.''.$peeraddresslink.'
    '.$peername."
    $peer_type".(isset($peer['afi']) ? $peer['afi'] : '').'AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']."
    ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    + Updates ".$peer['bgpPeerInUpdates']." + ".$peer['bgpPeerOutUpdates'].'
    '); + if ($peer['graph']) { + $graph_array['height'] = '100'; + $graph_array['width'] = '216'; + $graph_array['to'] = $config['time']['now']; + echo '
    '; - include("includes/print-graphrow.inc.php"); + include 'includes/print-graphrow.inc.php'; - echo("
    diff --git a/html/pages/device/routing/ospf.inc.php b/html/pages/device/routing/ospf.inc.php index ed126a7fe..7bf6798b7 100644 --- a/html/pages/device/routing/ospf.inc.php +++ b/html/pages/device/routing/ospf.inc.php @@ -88,8 +88,7 @@ foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', arr // # Loop Ports $i_p = ($i_a + 1); $p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id"; - foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) - { + foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) { if (!is_integer($i_a / 2)) { if (!is_integer($i_p / 2)) { $port_bg = $list_colour_b_b; diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index aed9398dd..9efc95d63 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -1,134 +1,135 @@ = '7') { + if (!is_array($config['rancid_configs'])) { + $config['rancid_configs'] = array($config['rancid_configs']); + } -if ($_SESSION['userlevel'] >= "7") -{ + if (isset($config['rancid_configs'][0])) { + foreach ($config['rancid_configs'] as $configs) { + if ($configs[(strlen($configs) - 1)] != '/') { + $configs .= '/'; + } - if (!is_array($config['rancid_configs'])) { $config['rancid_configs'] = array($config['rancid_configs']); } + if (is_file($configs.$device['hostname'])) { + $file = $configs.$device['hostname']; + } + } - if (isset($config['rancid_configs'][0])) { + echo '
    '; - foreach ($config['rancid_configs'] as $configs) { - if ($configs[strlen($configs) - 1] != '/') { - $configs .= '/'; - } - if (is_file($configs . $device['hostname'])) { - $file = $configs . $device['hostname']; - } - } + print_optionbar_start('', ''); - echo('
    '); + echo "Config » "; - print_optionbar_start('', ''); + if (!$vars['rev']) { + echo ''; + echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); + echo ''; + } + else { + echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); + } - echo("Config » "); + if (function_exists('svn_log')) { + $sep = ' | '; + $svnlogs = svn_log($file, SVN_REVISION_HEAD, null, 8); + $revlist = array(); - if (!$vars['rev']) { - echo(''); - echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); - echo(""); - } else { - echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); - } + foreach ($svnlogs as $svnlog) { + echo $sep; + $revlist[] = $svnlog['rev']; - if (function_exists('svn_log')) { + if ($vars['rev'] == $svnlog['rev']) { + echo ''; + } - $sep = " | "; - $svnlogs = svn_log($file, SVN_REVISION_HEAD, NULL, 8); - $revlist = array(); + $linktext = 'r'.$svnlog['rev'].' '.date($config['dateformat']['byminute'], strtotime($svnlog['date'])).''; + echo generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog['rev'])); - foreach ($svnlogs as $svnlog) { + if ($vars['rev'] == $svnlog['rev']) { + echo ''; + } - echo($sep); - $revlist[] = $svnlog["rev"]; + $sep = ' | '; + } + }//end if - if ($vars['rev'] == $svnlog["rev"]) { - echo(''); - } - $linktext = "r" . $svnlog["rev"] . " " . date($config['dateformat']['byminute'], strtotime($svnlog["date"])) . ""; - echo(generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog["rev"]))); + print_optionbar_end(); - if ($vars['rev'] == $svnlog["rev"]) { - echo(""); - } + if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { + list($diff, $errors) = svn_diff($file, ($vars['rev'] - 1), $file, $vars['rev']); + if (!$diff) { + $text = 'No Difference'; + } + else { + $text = ''; + while (!feof($diff)) { + $text .= fread($diff, 8192); + } - $sep = " | "; - } - } + fclose($diff); + fclose($errors); + } + } + else { + $fh = fopen($file, 'r') or die("Can't open file"); + $text = fread($fh, filesize($file)); + fclose($fh); + } - print_optionbar_end(); + if ($config['rancid_ignorecomments']) { + $lines = explode("\n", $text); + for ($i = 0; $i < count($lines); $i++) { + if ($lines[$i][0] == '#') { + unset($lines[$i]); + } + } - if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { - list($diff, $errors) = svn_diff($file, $vars['rev'] - 1, $file, $vars['rev']); - if (!$diff) { - $text = "No Difference"; - } else { - $text = ""; - while (!feof($diff)) { - $text .= fread($diff, 8192); - } - fclose($diff); - fclose($errors); - } + $text = join("\n", $lines); + } + } + else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) { + $node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true); + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['hostname']); + if ($text == 'node not found') { + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['os'].'/'.$device['hostname']); + } - } else { - $fh = fopen($file, 'r') or die("Can't open file"); - $text = fread($fh, filesize($file)); - fclose($fh); - } - - if ($config['rancid_ignorecomments']) { - $lines = explode("\n", $text); - for ($i = 0; $i < count($lines); $i++) { - if ($lines[$i][0] == "#") { - unset($lines[$i]); - } - } - $text = join("\n", $lines); - } - } elseif ($config['oxidized']['enabled'] === TRUE && isset($config['oxidized']['url'])) { - $node_info = json_decode(file_get_contents($config['oxidized']['url']."/node/show/".$device['hostname']."?format=json"),TRUE); - $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['hostname']); - if ($text == "node not found") { - $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['os']."/".$device['hostname']); - } - - if (is_array($node_info)) { - echo('
    -
    + if (is_array($node_info)) { + echo '
    +
    -
    -
    Sync status: '.$node_info['last']['status'].'
    -
      -
    • Node: '. $node_info['name'].'
    • -
    • IP: '. $node_info['ip'].'
    • -
    • Model: '. $node_info['model'].'
    • -
    • Last Sync: '. $node_info['last']['end'].'
    • -
    -
    +
    +
    Sync status: '.$node_info['last']['status'].'
    +
      +
    • Node: '.$node_info['name'].'
    • +
    • IP: '.$node_info['ip'].'
    • +
    • Model: '.$node_info['model'].'
    • +
    • Last Sync: '.$node_info['last']['end'].'
    • +
    -
    '); - } else { - echo "
    "; - print_error("We couldn't retrieve the device information from Oxidized"); - $text = ''; - } +
    +
    '; + } + else { + echo '
    '; + print_error("We couldn't retrieve the device information from Oxidized"); + $text = ''; + } + }//end if - } + if (!empty($text)) { + $language = 'ios'; + $geshi = new GeSHi($text, $language); + $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); + $geshi->set_overall_style('color: black;'); + // $geshi->set_line_style('color: #999999'); + echo $geshi->parse_code(); + } +}//end if - if (!empty($text)) { - $language = "ios"; - $geshi = new GeSHi($text, $language); - $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); - $geshi->set_overall_style('color: black;'); - #$geshi->set_line_style('color: #999999'); - echo($geshi->parse_code()); - } -} - -$pagetitle[] = "Config"; - -?> +$pagetitle[] = 'Config'; diff --git a/html/pages/device/slas.inc.php b/html/pages/device/slas.inc.php index 3cc6cbf11..587c7d743 100644 --- a/html/pages/device/slas.inc.php +++ b/html/pages/device/slas.inc.php @@ -12,7 +12,7 @@ foreach ($slas as $sla) { $sla_type = $sla['rtt_type']; if (!in_array($sla_type, $sla_types)) { - if (isset($config['sla_type_labels'][$sla_type])) { + if (isset($config['sla_type_labels'][$sla_type])) { $text = $config['sla_type_labels'][$sla_type]; } } diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index 67a8c39ed..0367b8a1c 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -2,7 +2,9 @@ // Set Defaults here -if(!isset($vars['format'])) { $vars['format'] = "list_detail"; } +if(!isset($vars['format'])) { + $vars['format'] = "list_detail"; +} $pagetitle[] = "Devices"; @@ -10,23 +12,19 @@ print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', - 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == "list_".$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) { + echo(""); + } + $sep = " | "; } ?> @@ -38,29 +36,26 @@ foreach ($menu_options as $option => $text) 'Bits', - 'processor' => 'CPU', - 'ucd_load' => 'Load', - 'mempool' => 'Memory', - 'uptime' => 'Uptime', - 'storage' => 'Storage', - 'diskio' => 'Disk I/O', - 'poller_perf' => 'Poller', - 'ping_perf' => 'Ping' - ); + 'processor' => 'CPU', + 'ucd_load' => 'Load', + 'mempool' => 'Memory', + 'uptime' => 'Uptime', + 'storage' => 'Storage', + 'diskio' => 'Disk I/O', + 'poller_perf' => 'Poller', + 'ping_perf' => 'Ping' +); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + $sep = " | "; } ?> @@ -69,21 +64,21 @@ foreach ($menu_options as $option => $text) '')).'">Restore Search'); - } else { +} +else { echo('Remove Search'); - } +} - echo(" | "); +echo(" | "); - if (isset($vars['bare']) && $vars['bare'] == "yes") - { +if (isset($vars['bare']) && $vars['bare'] == "yes") { echo('Restore Header'); - } else { +} +else { echo('Remove Header'); - } +} print_optionbar_end(); ?> @@ -94,76 +89,110 @@ print_optionbar_end(); list($format, $subformat) = explode("_", $vars['format'], 2); -if($format == "graph") -{ -$sql_param = array(); +if($format == "graph") { + $sql_param = array(); -if(isset($vars['state'])) -{ - if($vars['state'] == 'up') - { - $state = '1'; - } - elseif($vars['state'] == 'down') - { - $state = '0'; - } -} + if(isset($vars['state'])) { + if($vars['state'] == 'up') { + $state = '1'; + } + elseif($vars['state'] == 'down') { + $state = '0'; + } + } -if (!empty($vars['hostname'])) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; } -if (!empty($vars['os'])) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; } -if (!empty($vars['version'])) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; } -if (!empty($vars['hardware'])) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; } -if (!empty($vars['features'])) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; } -if (!empty($vars['type'])) { - if ($vars['type'] == 'generic') { - $where .= " AND ( type = ? OR type = '')"; $sql_param[] = $vars['type']; - } else { - $where .= " AND type = ?"; $sql_param[] = $vars['type']; - } -} -if (!empty($vars['state'])) { - $where .= " AND status= ?"; $sql_param[] = $state; - $where .= " AND disabled='0' AND `ignore`='0'"; $sql_param[] = ''; -} -if (!empty($vars['disabled'])) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; } -if (!empty($vars['ignore'])) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; } -if (!empty($vars['location']) && $vars['location'] == "Unset") { $location_filter = ''; } -if (!empty($vars['location'])) { $location_filter = $vars['location']; } -if( !empty($vars['group']) ) { - require_once('../includes/device-groups.inc.php'); - $where .= " AND ( "; - foreach( GetDevicesFromGroup($vars['group']) as $dev ) { - $where .= "device_id = ? OR "; - $sql_param[] = $dev['device_id']; - } - $where = substr($where, 0, strlen($where)-3); - $where .= " )"; -} + if (!empty($vars['hostname'])) { + $where .= " AND hostname LIKE ?"; + $sql_param[] = "%".$vars['hostname']."%"; + } + if (!empty($vars['os'])) { + $where .= " AND os = ?"; + $sql_param[] = $vars['os']; + } + if (!empty($vars['version'])) { + $where .= " AND version = ?"; + $sql_param[] = $vars['version']; + } + if (!empty($vars['hardware'])) { + $where .= " AND hardware = ?"; + $sql_param[] = $vars['hardware']; + } + if (!empty($vars['features'])) { + $where .= " AND features = ?"; + $sql_param[] = $vars['features']; + } -$query = "SELECT * FROM `devices` WHERE 1 "; + if (!empty($vars['type'])) { + if ($vars['type'] == 'generic') { + $where .= " AND ( type = ? OR type = '')"; + $sql_param[] = $vars['type']; + } + else { + $where .= " AND type = ?"; + $sql_param[] = $vars['type']; + } + } + if (!empty($vars['state'])) { + $where .= " AND status= ?"; + $sql_param[] = $state; + $where .= " AND disabled='0' AND `ignore`='0'"; + $sql_param[] = ''; + } + if (!empty($vars['disabled'])) { + $where .= " AND disabled= ?"; + $sql_param[] = $vars['disabled']; + } + if (!empty($vars['ignore'])) { + $where .= " AND `ignore`= ?"; + $sql_param[] = $vars['ignore']; + } + if (!empty($vars['location']) && $vars['location'] == "Unset") { + $location_filter = ''; + } + if (!empty($vars['location'])) { + $location_filter = $vars['location']; + } + if( !empty($vars['group']) ) { + require_once('../includes/device-groups.inc.php'); + $where .= " AND ( "; + foreach( GetDevicesFromGroup($vars['group']) as $dev ) { + $where .= "device_id = ? OR "; + $sql_param[] = $dev['device_id']; + } + $where = substr($where, 0, strlen($where)-3); + $where .= " )"; + } -if (isset($where)) { - $query .= $where; -} + $query = "SELECT * FROM `devices` WHERE 1 "; -$query .= " ORDER BY hostname"; + if (isset($where)) { + $query .= $where; + } - $row = 1; - foreach (dbFetchRows($query, $sql_param) as $device) - { - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + $query .= " ORDER BY hostname"; - if (device_permitted($device['device_id'])) - { - if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) - || $device['location'] == $location_filter)) - { - $graph_type = "device_".$subformat; + $row = 1; + foreach (dbFetchRows($query, $sql_param) as $device) { + if (is_integer($row/2)) { + $row_colour = $list_colour_a; + } + else { + $row_colour = $list_colour_b; + } - if ($_SESSION['widescreen']) { $width=270; } else { $width=315; } + if (device_permitted($device['device_id'])) { + if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) + || $device['location'] == $location_filter)) { + $graph_type = "device_".$subformat; - echo("
    + if ($_SESSION['widescreen']) { + $width=270; + } + else { + $width=315; + } + + echo("\ \ @@ -171,11 +200,11 @@ $query .= " ORDER BY hostname"; "
    "); - } + } + } } - } - -} else { +} +else { ?> @@ -209,22 +238,23 @@ $query .= " ORDER BY hostname"; ""+ '.$config['os'][$tmp_os]['text'].'"+'); } - echo('">'.$config['os'][$tmp_os]['text'].'"+'); } -} ?> ""+ "
    "+ @@ -233,22 +263,23 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_version.'"+'); } - echo('">'.$tmp_version.'"+'); - } -} + } ?> ""+ "
    "+ @@ -257,22 +288,23 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_hardware.'"+'); } - echo('">'.$tmp_hardware.'"+'); } -} ?> ""+ @@ -282,24 +314,24 @@ foreach (dbFetch($sql,$param) as $data) { ""+ '.$tmp_features.'"+'); + else { + $sql = "SELECT `features` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `features` ORDER BY `features`"; + $param[] = $_SESSION['user_id']; + } + + foreach (dbFetch($sql,$param) as $data) { + if ($data['features']) { + $tmp_features = clean_bootgrid($data['features']); + echo('""+'); + } } -} ?> ""+ @@ -311,16 +343,16 @@ foreach (dbFetch($sql,$param) as $data) '.$location.'"+'); } - echo('">'.$location.'"+'); } -} ?> ""+ ""+ @@ -329,21 +361,22 @@ foreach (getlocations() as $location) { ""+ '.ucfirst($data['type']).'"+'); } - echo('">'.ucfirst($data['type']).'"+'); } -} ?> ""+ @@ -357,9 +390,9 @@ foreach (dbFetch($sql,$param) as $data) { "

    " var grid = $("#devices").bootgrid({ @@ -400,5 +433,3 @@ var grid = $("#devices").bootgrid({ diff --git a/html/pages/editsrv.inc.php b/html/pages/editsrv.inc.php index 9c56b96d1..1c04e4510 100644 --- a/html/pages/editsrv.inc.php +++ b/html/pages/editsrv.inc.php @@ -1,35 +1,30 @@ "5") - { - include("includes/service-edit.inc.php"); + if ($_POST['confirm-editsrv']) { + if ($_SESSION['userlevel'] > '5') { + include 'includes/service-edit.inc.php'; } } - foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname") as $device) - { - $servicesform .= ""; + foreach (dbFetchRows('SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname') as $device) { + $servicesform .= "'; } - if ($updated) { print_message("Service updated!"); } + if ($updated) { + print_message('Service updated!'); + } if ($_POST['editsrv'] == 'yes') { - - require_once "includes/print-service-edit.inc.php"; - - } else { - - echo(" + include_once 'includes/print-service-edit.inc.php'; + } + else { + echo "

    Delete Service

    @@ -46,7 +41,6 @@ if (is_admin() === FALSE && is_read() === FALSE) { -
    "); - } - -} + "; + }//end if +}//end if diff --git a/html/pages/edituser.inc.php b/html/pages/edituser.inc.php index 6a9a7d283..ec2a3f1c9 100644 --- a/html/pages/edituser.inc.php +++ b/html/pages/edituser.inc.php @@ -1,167 +1,170 @@ "); +echo "
    "; -$pagetitle[] = "Edit user"; +$pagetitle[] = 'Edit user'; -if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else -{ - if ($vars['user_id'] && !$vars['edit']) - { - $user_data = dbFetchRow("SELECT * FROM users WHERE user_id = ?", array($vars['user_id'])); - echo("

    " . $user_data['realname'] . "

    Change...

    "); - // Perform actions if requested +if ($_SESSION['userlevel'] != '10') { + include 'includes/error-no-perm.inc.php'; +} +else { + if ($vars['user_id'] && !$vars['edit']) { + $user_data = dbFetchRow('SELECT * FROM users WHERE user_id = ?', array($vars['user_id'])); + echo '

    '.$user_data['realname']."

    Change...

    "; + // Perform actions if requested + if ($vars['action'] == 'deldevperm') { + if (dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { + dbDelete('devices_perms', '`device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id'])); + } + } - if ($vars['action'] == "deldevperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) - { - dbDelete('devices_perms', "`device_id` = ? AND `user_id` = ?", array($vars['device_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "adddevperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) - { - dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); - } - } - if ($vars['action'] == "delifperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) - { - dbDelete('ports_perms', "`port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "addifperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) - { - dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); - } - } - if ($vars['action'] == "delbillperm") - { - if (dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) - { - dbDelete('bill_perms', "`bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id'])); - } - } - if ($vars['action'] == "addbillperm") - { - if (!dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) - { - dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); - } - } + if ($vars['action'] == 'adddevperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { + dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); + } + } - echo('
    -
    '); + if ($vars['action'] == 'delifperm') { + if (dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { + dbDelete('ports_perms', '`port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id'])); + } + } - // Display devices this users has access to - echo("

    Device Access

    "); + if ($vars['action'] == 'addifperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { + dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); + } + } - echo("
    + if ($vars['action'] == 'delbillperm') { + if (dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { + dbDelete('bill_perms', '`bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id'])); + } + } + + if ($vars['action'] == 'addbillperm') { + if (!dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { + dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); + } + } + + echo '
    +
    '; + + // Display devices this users has access to + echo '

    Device Access

    '; + + echo "
    - "); + "; - $device_perms = dbFetchRows("SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id", array($vars['user_id'])); - foreach ($device_perms as $device_perm) - { - echo(""); - $access_list[] = $device_perm['device_id']; - $permdone = "yes"; - } + $device_perms = dbFetchRows('SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id', array($vars['user_id'])); + foreach ($device_perms as $device_perm) { + echo '"; + $access_list[] = $device_perm['device_id']; + $permdone = 'yes'; + } - echo("
    Device Action
    " . $device_perm['hostname'] . "
    '.$device_perm['hostname']."
    -
    "); + echo ' +
    '; - if (!$permdone) { echo("None Configured"); } + if (!$permdone) { + echo 'None Configured'; + } - // Display devices this user doesn't have access to - echo("

    Grant access to new device

    "); - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new device

    '; + echo " +
    - "; - $devices = dbFetchRows("SELECT * FROM `devices` ORDER BY hostname"); - foreach ($devices as $device) - { - unset($done); - foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } } - if (!$done) - { - echo(""); - } - } + $devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname'); + foreach ($devices as $device) { + unset($done); + foreach ($access_list as $ac) { + if ($ac == $device['device_id']) { + $done = 1; + } + } - echo(" + if (!$done) { + echo "'; + } + } + + echo "
    -
    "); + "; - echo("
    -
    "); - echo("

    Interface Access

    "); + echo "
    +
    "; + echo '

    Interface Access

    '; - $interface_perms = dbFetchRows("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id", array($vars['user_id'])); + $interface_perms = dbFetchRows('SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id', array($vars['user_id'])); - echo("
    + echo "
    - "); - foreach ($interface_perms as $interface_perm) - { - echo(" + "; + foreach ($interface_perms as $interface_perm) { + echo ' - "); - $ipermdone = "yes"; - } - echo("
    Interface name Action
    - ".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."". - "" . $interface_perm['ifAlias'] . " + '.$interface_perm['hostname'].' - '.$interface_perm['ifDescr'].''.''.$interface_perm['ifAlias']." -    +   
    -
    "); + "; + $ipermdone = 'yes'; + } - if (!$ipermdone) { echo("None Configured"); } + echo ' +
    '; - // Display devices this user doesn't have access to - echo("

    Grant access to new interface

    "); + if (!$ipermdone) { + echo 'None Configured'; + } - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new interface

    '; + + echo " +
    + if (!$done) { + echo "'; + } + } + + echo "
    @@ -176,133 +179,135 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - "); + "; - echo("
    -
    "); - echo("

    Bill Access

    "); + echo "
    +
    "; + echo '

    Bill Access

    '; - $bill_perms = dbFetchRows("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id", array($vars['user_id'])); + $bill_perms = dbFetchRows('SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id', array($vars['user_id'])); - echo("
    + echo "
    - "); + "; - foreach ($bill_perms as $bill_perm) - { - echo(" + foreach ($bill_perms as $bill_perm) { + echo ' - "); - $bill_access_list[] = $bill_perm['bill_id']; + "; + $bill_access_list[] = $bill_perm['bill_id']; - $bpermdone = "yes"; - } + $bpermdone = 'yes'; + } - echo("
    Bill name Action
    - ".$bill_perm['bill_name']."   + '.$bill_perm['bill_name']."  
    -
    "); + echo ' +
    '; - if (!$bpermdone) { echo("None Configured"); } + if (!$bpermdone) { + echo 'None Configured'; + } - // Display devices this user doesn't have access to - echo("

    Grant access to new bill

    "); - echo("
    - + // Display devices this user doesn't have access to + echo '

    Grant access to new bill

    '; + echo " +
    - "; - $bills = dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`"); - foreach ($bills as $bill) - { - unset($done); - foreach ($bill_access_list as $ac) { if ($ac == $bill['bill_id']) { $done = 1; } } - if (!$done) - { - echo(""); - } - } + $bills = dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_name`'); + foreach ($bills as $bill) { + unset($done); + foreach ($bill_access_list as $ac) { + if ($ac == $bill['bill_id']) { + $done = 1; + } + } - echo(" + if (!$done) { + echo "'; + } + } + + echo "
    -
    "); - - } elseif ($vars['user_id'] && $vars['edit']) { - - if($_SESSION['userlevel'] == 11) { - demo_account(); - } else { - - if(!empty($vars['new_level'])) - { - if($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - update_user($vars['user_id'],$vars['new_realname'],$vars['new_level'],$vars['can_modify_passwd'],$vars['new_email']); - print_message("User has been updated"); +
    "; } - - if(can_update_users() == '1') { - - $users_details = get_user($vars['user_id']); - if(!empty($users_details)) - { - - if(empty($vars['new_realname'])) - { - $vars['new_realname'] = $users_details['realname']; - } - if(empty($vars['new_level'])) - { - $vars['new_level'] = $users_details['level']; - } - if(empty($vars['can_modify_passwd'])) - { - $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; - } elseif($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - if(empty($vars['new_email'])) - { - $vars['new_email'] = $users_details['email']; + else if ($vars['user_id'] && $vars['edit']) { + if ($_SESSION['userlevel'] == 11) { + demo_account(); } + else { + if (!empty($vars['new_level'])) { + if ($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } - if( $config['twofactor'] ) { - if( $vars['twofactorremove'] ) { - if( dbUpdate(array('twofactor'=>''),users,'user_id = ?',array($vars['user_id'])) ) { - echo "
    TwoFactor credentials removed.
    "; - } else { - echo "
    Couldnt remove user's TwoFactor credentials.
    "; + update_user($vars['user_id'], $vars['new_realname'], $vars['new_level'], $vars['can_modify_passwd'], $vars['new_email']); + print_message('User has been updated'); } - } - if( $vars['twofactorunlock'] ) { - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'],true); - $twofactor['fails'] = 0; - if( dbUpdate(array('twofactor'=>json_encode($twofactor)),users,'user_id = ?',array($vars['user_id'])) ) { - echo "
    User unlocked.
    "; - } else { - echo "
    Couldnt reset user's TwoFactor failures.
    "; - } - } - } - echo("
    - + if (can_update_users() == '1') { + $users_details = get_user($vars['user_id']); + if (!empty($users_details)) { + if (empty($vars['new_realname'])) { + $vars['new_realname'] = $users_details['realname']; + } + + if (empty($vars['new_level'])) { + $vars['new_level'] = $users_details['level']; + } + + if (empty($vars['can_modify_passwd'])) { + $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; + } + else if ($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } + + if (empty($vars['new_email'])) { + $vars['new_email'] = $users_details['email']; + } + + if ($config['twofactor']) { + if ($vars['twofactorremove']) { + if (dbUpdate(array('twofactor' => ''), users, 'user_id = ?', array($vars['user_id']))) { + echo "
    TwoFactor credentials removed.
    "; + } + else { + echo "
    Couldnt remove user's TwoFactor credentials.
    "; + } + } + + if ($vars['twofactorunlock']) { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'], true); + $twofactor['fails'] = 0; + if (dbUpdate(array('twofactor' => json_encode($twofactor)), users, 'user_id = ?', array($vars['user_id']))) { + echo "
    User unlocked.
    "; + } + else { + echo "
    Couldnt reset user's TwoFactor failures.
    "; + } + } + } + + echo " +
    - +
    @@ -310,7 +315,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - +
    @@ -319,10 +324,22 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    @@ -332,7 +349,10 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    @@ -340,14 +360,14 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    - "); - if( $config['twofactor'] ) { - echo "

    Two-Factor Authentication

    "; - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'],true); - if( $twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time()-$twofactor['last']) < $config['twofactor_lock']) ) { - echo "
    - +
    "; + if ($config['twofactor']) { + echo "

    Two-Factor Authentication

    "; + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'], true); + if ($twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time() - $twofactor['last']) < $config['twofactor_lock'])) { + echo "
    +
    @@ -355,43 +375,47 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    "; - } - if( $twofactor['key'] ) { - echo "
    - + } + + if ($twofactor['key']) { + echo " +
    "; - } else { - echo "

    No TwoFactor key generated for this user, Nothing to do.

    "; - } - } - } else { - echo print_error("Error getting user details"); - } - } else { - echo print_error("Authentication method doesn't support updating users"); + } + else { + echo '

    No TwoFactor key generated for this user, Nothing to do.

    '; + } + }//end if + } + else { + echo print_error('Error getting user details'); + }//end if + } + else { + echo print_error("Authentication method doesn't support updating users"); + }//end if + }//end if } - } - } else { + else { + $user_list = get_userlist(); - $user_list = get_userlist(); + echo '

    Select a user to edit

    '; - echo("

    Select a user to edit

    "); - - echo("
    + echo "
    - +
    @@ -399,11 +423,8 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); /
    - "); - } + "; + }//end if +}//end if -} - -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/eventlog.inc.php b/html/pages/eventlog.inc.php index 4e1cad13d..2ac41ec91 100644 --- a/html/pages/eventlog.inc.php +++ b/html/pages/eventlog.inc.php @@ -1,16 +1,15 @@ = '10') -{ - dbQuery("TRUNCATE TABLE `eventlog`"); - print_message("Event log truncated"); +if ($vars['action'] == 'expunge' && $_SESSION['userlevel'] >= '10') { + dbQuery('TRUNCATE TABLE `eventlog`'); + print_message('Event log truncated'); } -$pagetitle[] = "Eventlog"; +$pagetitle[] = 'Eventlog'; print_optionbar_start(); @@ -24,15 +23,17 @@ print_optionbar_start();
    @@ -40,9 +41,7 @@ print_optionbar_start(); diff --git a/html/pages/front/default.php b/html/pages/front/default.php index 7b17f08a4..b69f7f97b 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -1,174 +1,180 @@ + +function generate_front_box($frontbox_class, $content) { + echo "
    $content -
    "); + "; + +}//end generate_front_box() + + +echo ' +
    +'; +if ($config['vertical_summary']) { + echo '
    '; +} +else { + echo '
    '; } -echo(' -
    -'); -if ($config['vertical_summary']) { - echo('
    '); -} -else -{ - echo('
    '); -} -echo(' +echo '
    -'); +'; -echo('
    '); +echo '
    '; -echo('
    '); +echo '
    '; $count_boxes = 0; // Device down boxes -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; -} else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; } -foreach (dbFetchRows($sql) as $device) -{ - generate_front_box("device-down", generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 20).""); - ++$count_boxes; +else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; } -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; -} else { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +foreach (dbFetchRows($sql) as $device) { + generate_front_box( + 'device-down', + generate_device_link($device, shorthost($device['hostname'])).'
    + Device Down
    + '.truncate($device['location'], 20).'' + ); + ++$count_boxes; +} + +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +} +else { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; } // These things need to become more generic, and more manageable across different frontpages... rewrite inc :> - // Port down boxes -if ($config['warn']['ifdown']) -{ - foreach (dbFetchRows($sql) as $interface) - { - if (!$interface['deleted']) - { - $interface = ifNameDescr($interface); - generate_front_box("port-down", generate_device_link($interface, shorthost($interface['hostname']))."
    +if ($config['warn']['ifdown']) { + foreach (dbFetchRows($sql) as $interface) { + if (!$interface['deleted']) { + $interface = ifNameDescr($interface); + generate_front_box( + 'port-down', + generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    - - ".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
    - " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '')); - ++$count_boxes; + + ".generate_port_link($interface, truncate(makeshortif($interface['label']), 13, '')).'
    + '.($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') + ); + ++$count_boxes; + } } - } } -/* FIXME service permissions? seem nonexisting now.. */ +/* + FIXME service permissions? seem nonexisting now.. */ // Service down boxes -if ($_SESSION['userlevel'] >= '10') -{ - $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = ''; +if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = ''; } -else -{ - $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = $_SESSION['user_id']; +else { + $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = $_SESSION['user_id']; } -foreach (dbFetchRows($sql,$param) as $service) -{ - generate_front_box("service-down", generate_device_link($service, shorthost($service['hostname']))."
    + +foreach (dbFetchRows($sql, $param) as $service) { + generate_front_box( + 'service-down', + generate_device_link($service, shorthost($service['hostname'])).'
    Service Down - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 20).""); - ++$count_boxes; + '.$service['service_type'].'
    + '.truncate($interface['ifAlias'], 20).'' + ); + ++$count_boxes; } // BGP neighbour down boxes -if (isset($config['enable_bgp']) && $config['enable_bgp']) -{ - if ($_SESSION['userlevel'] >= '10') - { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } else { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } - foreach (dbFetchRows($sql) as $peer) - { - generate_front_box("bgp-down", generate_device_link($peer, shorthost($peer['hostname']))."
    +if (isset($config['enable_bgp']) && $config['enable_bgp']) { + if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } + else { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } + + foreach (dbFetchRows($sql) as $peer) { + generate_front_box( + 'bgp-down', + generate_device_link($peer, shorthost($peer['hostname']))."
    BGP Down - ".$peer['bgpPeerIdentifier']."
    - AS".truncate($peer['bgpPeerRemoteAs']." ".$peer['astext'], 14, "").""); - ++$count_boxes; - } + ".$peer['bgpPeerIdentifier'].'
    + AS'.truncate($peer['bgpPeerRemoteAs'].' '.$peer['astext'], 14, '').'' + ); + ++$count_boxes; + } } // Device rebooted boxes -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - if ($_SESSION['userlevel'] >= '10') - { - $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" . - $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + if ($_SESSION['userlevel'] >= '10') { + $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } + else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } - foreach (dbFetchRows($sql) as $device) - { - generate_front_box("device-rebooted", generate_device_link($device, shorthost($device['hostname']))."
    + foreach (dbFetchRows($sql) as $device) { + generate_front_box( + 'device-rebooted', + generate_device_link($device, shorthost($device['hostname'])).'
    Device Rebooted
    - ".formatUptime($device['uptime'], 'short').""); - ++$count_boxes; - } + '.formatUptime($device['uptime'], 'short').'' + ); + ++$count_boxes; + } } + if ($count_boxes == 0) { - echo("
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none - because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].", you might - want to start by adding one or more devices in the Devices menu.

    "); -} -echo('
    '); -echo('
    '); -echo('
    '); -echo(' -
    -
    -'); - -if ($config['vertical_summary']) -{ - echo('
    '); - include_once("includes/device-summary-vert.inc.php"); -} -else -{ - echo('
    '); - include_once("includes/device-summary-horiz.inc.php"); + echo "
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none + because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].', you might + want to start by adding one or more devices in the Devices menu.

    '; } -echo(' +echo '
    '; +echo '
    '; +echo '
    '; +echo ' +
    +
    +'; + +if ($config['vertical_summary']) { + echo '
    '; + include_once 'includes/device-summary-vert.inc.php'; +} +else { + echo '
    '; + include_once 'includes/device-summary-horiz.inc.php'; +} + +echo '
    -'); +'; -if ($config['enable_syslog']) -{ +if ($config['enable_syslog']) { + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; + $query = mysql_query($sql); - $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; - $query = mysql_query($sql); - - echo('
    + echo '
      @@ -180,35 +186,34 @@ if ($config['enable_syslog'])
    Syslog entries
    -
    '); +
    '; - foreach (dbFetchRows($sql) as $entry) - { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); - } - echo("
    "); - echo(""); - echo(""); - echo(""); - echo(""); + include 'includes/print-syslog.inc.php'; + } -} else { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +} +else { + if ($_SESSION['userlevel'] >= '10') { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15'; + } + else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = ".$_SESSION['user_id'].' ORDER BY `datetime` DESC LIMIT 0,15'; + $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = '.$_SESSION['user_id'].' ORDER BY `time_logged` DESC LIMIT 0,15'; + } - if ($_SESSION['userlevel'] >= '10') - { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15"; - } else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15"; - } + $data = mysql_query($query); + $alertdata = mysql_query($alertquery); - $data = mysql_query($query); - $alertdata = mysql_query($alertquery); - - echo('
    + echo '
      @@ -220,13 +225,13 @@ if ($config['enable_syslog'])
    Alertlog entries
    - '); +
    '; - foreach (dbFetchRows($alertquery) as $alert_entry) - { - include("includes/print-alerts.inc.php"); - } - echo('
    + foreach (dbFetchRows($alertquery) as $alert_entry) { + include 'includes/print-alerts.inc.php'; + } + + echo '
    @@ -234,24 +239,21 @@ if ($config['enable_syslog'])
    Eventlog entries
    - '); +
    '; - foreach (dbFetchRows($query) as $entry) - { - include("includes/print-event.inc.php"); - } + foreach (dbFetchRows($query) as $entry) { + include 'includes/print-event.inc.php'; + } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); -} + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +}//end if -echo(""); +echo ''; -echo(' +echo ' -'); - -?> +'; diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 1000fbca2..6478a566b 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -4,56 +4,55 @@ "); +echo ''; -$dev_list = array('6' => 'Central Fileserver', - '7' => 'NE61 Fileserver', - '34' => 'DE56 Fileserver'); +$dev_list = array( + '6' => 'Central Fileserver', + '7' => 'NE61 Fileserver', + '34' => 'DE56 Fileserver', +); -foreach ($dev_list as $device_id => $descr) -{ +foreach ($dev_list as $device_id => $descr) { + echo ''; +}//end foreach - echo(""); - -} - -echo("
    '; + echo "
    ".$descr.'
    '; + $graph_array['height'] = '100'; + $graph_array['width'] = '310'; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device_id; + $graph_array['type'] = 'device_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = 'no'; + $graph_array['popup_title'] = $descr; + // $graph_array['link'] = generate_device_link($device_id); + print_graph_popup($graph_array); - echo("
    "); - echo("
    ".$descr."
    "); - $graph_array['height'] = "100"; - $graph_array['width'] = "310"; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device_id; - $graph_array['type'] = "device_bits"; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; - $graph_array['popup_title'] = $descr; -# $graph_array['link'] = generate_device_link($device_id); - print_graph_popup($graph_array); + $graph_array['height'] = '50'; + $graph_array['width'] = '180'; - $graph_array['height'] = "50"; - $graph_array['width'] = "180"; + echo "
    "; + $graph_array['type'] = 'device_ucd_memory'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_ucd_memory"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_processor'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_processor"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_storage'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_storage"; - print_graph_popup($graph_array); - echo("
    "); + echo "
    "; + $graph_array['type'] = 'device_diskio'; + print_graph_popup($graph_array); + echo '
    '; - echo("
    "); - $graph_array['type'] = "device_diskio"; - print_graph_popup($graph_array); - echo("
    "); + echo '
    "); +echo ''; ?> @@ -62,115 +61,105 @@ echo(""); '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } -if ($config['warn']['ifdown']) -{ - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; - foreach (dbFetchRows($sql) as $interface) - { - if (port_permitted($interface['port_id'])) - { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); +if ($config['warn']['ifdown']) { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; + foreach (dbFetchRows($sql) as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } - } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - if (device_permitted($service['device_id'])) - { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows($sql) as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - if (device_permitted($peer['device_id'])) - { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } -} - -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE - A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) - { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") - { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); +foreach (dbFetchRows($sql) as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; } - } } -echo(" -
    $errorboxes
    +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE + A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } +} -

    Recent Syslog Messages

    -"); +echo " +
    $errorboxes
    + +

    Recent Syslog Messages

    + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from `syslog` ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); + include 'includes/print-syslog.inc.php'; } -echo("
    "); +echo ''; ?> diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php index 717ee7518..e5898ac07 100644 --- a/html/pages/front/example2.php +++ b/html/pages/front/example2.php @@ -4,173 +4,141 @@
    Devices with Alerts
    Host
    Int
    Srv
    +// ?> '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) - { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) - { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - echo("
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down - ".truncate($device['location'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $device) { + echo "
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down + ".truncate($device['location'], 20).' +
    '; } $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; -foreach (dbFetchRows($sql) as $interface) -{ - echo("
    -
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $interface) { + echo "
    +
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 20).' +
    '; } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - echo("
    -
    ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 20)." -
    "); - +foreach (dbFetchRows($sql) as $service) { + echo "
    +
    ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 20).' +
    '; } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - echo("
    -
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - +foreach (dbFetchRows($sql) as $peer) { + echo "
    +
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'"; - foreach (dbFetchRows($sql) as $device) - { - echo("
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '".$config['uptime_warning']."'"; + foreach (dbFetchRows($sql) as $device) { + echo "
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } } -echo(" +echo " -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; -echo("
    Devices with Alerts
    Host
    Int
    Srv
    "); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['l2tp'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['l2tp'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['voip'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['voip'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + if ($ports['transit']) { + echo "', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    Internet Transit
    "."
    "; + } - if ($ports['transit']) - { - echo("', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    Internet Transit
    ". - "
    "); - } + if ($ports['l2tp']) { + echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    L2TP ADSL
    "."
    "; + } - if ($ports['l2tp']) - { - echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    L2TP ADSL
    ". - "
    "); - } - - if ($ports['voip']) - { - echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    VoIP to PSTN
    ". - "
    "); - } - -} + if ($ports['voip']) { + echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    VoIP to PSTN
    "."
    "; + } +}//end if // END VOSTRON - ?> diff --git a/html/pages/front/globe.php b/html/pages/front/globe.php index 75a5917c7..9884b402f 100644 --- a/html/pages/front/globe.php +++ b/html/pages/front/globe.php @@ -4,16 +4,17 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ + * along with this program. If not, see . + */ -/** +/* * Custom Frontpage * @author f0o * @copyright 2014 f0o, LibreNMS @@ -25,107 +26,111 @@ ?> -
    -
    -
    -
    -
    -
    -
    -
    '; - include_once("includes/device-summary-vert.inc.php"); -echo '
    -
    -
    -
    '; - include_once("includes/front/boxes.inc.php"); -echo '
    -
    -
    -
    -
    -
    -
    '; - $device['device_id'] = '-1'; - require_once('includes/print-alerts.php'); - unset($device['device_id']); -echo '
    -
    +
    +
    +
    +
    +
    +
    +
    +
    '; + include_once("includes/device-summary-vert.inc.php"); +echo '
    +
    +
    +
    '; + include_once("includes/front/boxes.inc.php"); +echo '
    +
    +
    +
    +
    +
    +
    '; + $device['device_id'] = '-1'; + require_once('includes/print-alerts.php'); + unset($device['device_id']); +echo '
    +
    '; //From default.php - This code is not part of above license. if ($config['enable_syslog']) { -$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; -$query = mysql_query($sql); -echo('
    + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; + $query = mysql_query($sql); + echo('
      @@ -139,29 +144,28 @@ echo('
    '); - foreach (dbFetchRows($sql) as $entry) - { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include("includes/print-syslog.inc.php"); - } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); + include 'includes/print-syslog.inc.php'; + } + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); +} +else { -} else { + if ($_SESSION['userlevel'] == '10') { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + } + else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = + P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + } - if ($_SESSION['userlevel'] == '10') - { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - } else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = - P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - } - - $data = mysql_query($query); + $data = mysql_query($query); echo('
    @@ -177,15 +181,13 @@ echo('
    '); - foreach (dbFetchRows($query) as $entry) - { - include("includes/print-event.inc.php"); - } + foreach (dbFetchRows($query) as $entry) { + include 'includes/print-event.inc.php'; + } - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); - echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); } -?> diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index 2256cf085..cda0b49bb 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -5,238 +5,209 @@ $nodes = array(); -$uptimesql = ""; -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $uptimesql = " AND A.attrib_value < '" . $config['uptime_warning'] . "'"; +$uptimesql = ''; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $uptimesql = " AND A.attrib_value < '".$config['uptime_warning']."'"; } -$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql; +$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql; -foreach (dbFetchRows($sql) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows($sql) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } if ($config['warn']['ifdown']) { - -$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; -foreach (dbFetchRows($sql) as $interface) -{ - if (port_permitted($interface['port_id'])) { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } -} - + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; + foreach (dbFetchRows($sql) as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } + } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) -{ - if (device_permitted($service['device_id'])) { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows($sql) as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) -{ - if (device_permitted($peer['device_id'])) { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } +foreach (dbFetchRows($sql) as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } } -echo(" +echo " -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['peering'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $ports['broadband'] = '3294,3295,688,3534'; + $ports['wave_broadband'] = '827'; - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['peering'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $ports['new_broadband'] = '3659,4149,4121,4108,3676,4135'; - $ports['broadband'] = "3294,3295,688,3534"; - $ports['wave_broadband'] = "827"; + echo "
    "; - $ports['new_broadband'] = "3659,4149,4121,4108,3676,4135"; + if ($ports['peering'] && $ports['transit']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['peering'] && $ports['transit']) { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['transit']) { + echo ""; + } - echo("'; - if ($ports['peering']) { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) { + echo ""; + } - echo("
    "); + echo "
    "; - if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) { - echo(""); - } + if ($ports['broadband']) { + echo ""; + } - echo("
    "); + echo "
    "; - if ($ports['broadband']) { - echo(""); - } + if ($ports['new_broadband']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['new_broadband']) { - echo(""); - } + if ($ports['wave_broadband']) { + echo ""; + } - echo("
    "); - - if ($ports['wave_broadband']) { - echo(""); - } - - echo("
    "); - -} + echo '
    '; +}//end if ?> diff --git a/html/pages/front/traffic.php b/html/pages/front/traffic.php index 5f9a8acce..6b501cf9c 100644 --- a/html/pages/front/traffic.php +++ b/html/pages/front/traffic.php @@ -3,200 +3,172 @@ 0) -{ - $uptimesql = " AND A.attrib_value < ?"; - $param = array($config['uptime_warning']); +$nodes = array(); +$param = array(); +$uptimesql = ''; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + $uptimesql = ' AND A.attrib_value < ?'; + $param = array($config['uptime_warning']); } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql, $param) as $device) -{ - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = "yes"; +foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql, $param) as $device) { + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = 'yes'; + } + + $i++; + } + + if (!$already) { + $nodes[] = $device['device_id']; } - $i++; - } - if (!$already) { $nodes[] = $device['device_id']; } } -foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) -{ - if (device_permitted($device['device_id'])) { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35)." -
    "); - } +foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) { + if (device_permitted($device['device_id'])) { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35).' +
    '; + } } if ($config['warn']['ifdown']) { - -foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) -{ - if (port_permitted($interface['port_id'])) { - echo("
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } + foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) { + if (port_permitted($interface['port_id'])) { + echo "
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } + } } +foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) { + if (device_permitted($service['device_id'])) { + echo "
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type'].'
    + '.truncate($interface['ifAlias'], 15).' +
    '; + } } -foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) -{ - if (device_permitted($service['device_id'])) { - echo("
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 15)." -
    "); - } +foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) { + if (device_permitted($peer['device_id'])) { + echo "
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier'].'
    + AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' +
    '; + } } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) -{ - if (device_permitted($peer['device_id'])) { - echo("
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier']."
    - AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { + foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { + echo "
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value']).' +
    '; + } + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) -{ - foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { - echo("
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value'])." -
    "); - } - } -} +echo " -echo(" +
    $errorboxes
    -
    $errorboxes
    +

    Recent Syslog Messages

    -

    Recent Syslog Messages

    - -"); + "; $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo(""); -foreach (dbFetchRows($sql) as $entry) -{ - include("includes/print-syslog.inc.php"); +echo '
    '; +foreach (dbFetchRows($sql) as $entry) { + include 'includes/print-syslog.inc.php'; } -echo("
    "); -echo("
    +echo ''; - - "); +echo '
    + + + '; // this stuff can be customised to show whatever you want.... +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['transit'] .= $seperator.$interface['port_id']; + $seperator = ','; + } -if ($_SESSION['userlevel'] >= '5') -{ + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['peering'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['transit'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset($seperator); + foreach (dbFetchRows($sql) as $interface) { + $ports['core'] .= $seperator.$interface['port_id']; + $seperator = ','; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['peering'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + echo "
    "; - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset ($seperator); - foreach (dbFetchRows($sql) as $interface) - { - $ports['core'] .= $seperator . $interface['port_id']; - $seperator = ","; - } + if ($ports['peering'] && $ports['transit']) { + echo ""; + } - echo("
    "); + echo '
    '; - if ($ports['peering'] && $ports['transit']) - { - echo(""); - } + echo "
    "; - echo("
    "); + if ($ports['transit']) { + echo ""; + } - echo("
    "); + if ($ports['peering']) { + echo ""; + } - if ($ports['transit']) - { - echo(""); - } + if ($ports['core']) { + echo ""; + } - if ($ports['peering']) - { - echo(""); - } - - if ($ports['core']) - { - echo(""); - } - - echo("
    "); - -} + echo '
    '; +}//end if ?> diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 0cc268fce..78c6a73e0 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -4,17 +4,21 @@ unset($vars['page']); // Setup here -if($_SESSION['widescreen']) -{ - $graph_width=1700; - $thumb_width=180; -} else { - $graph_width=1075; - $thumb_width=113; +if($_SESSION['widescreen']) { + $graph_width=1700; + $thumb_width=180; +} +else { + $graph_width=1075; + $thumb_width=113; } -if (!is_numeric($vars['from'])) { $vars['from'] = $config['time']['day']; } -if (!is_numeric($vars['to'])) { $vars['to'] = $config['time']['now']; } +if (!is_numeric($vars['from'])) { + $vars['from'] = $config['time']['day']; +} +if (!is_numeric($vars['to'])) { + $vars['to'] = $config['time']['now']; +} preg_match('/^(?P[A-Za-z0-9]+)_(?P.+)/', $vars['type'], $graphtype); @@ -22,208 +26,201 @@ $type = $graphtype['type']; $subtype = $graphtype['subtype']; $id = $vars['id']; -if(is_numeric($vars['device'])) -{ - $device = device_by_id_cache($vars['device']); -} elseif(!empty($vars['device'])) { - $device = device_by_name($vars['device']); +if(is_numeric($vars['device'])) { + $device = device_by_id_cache($vars['device']); +} +elseif(!empty($vars['device'])) { + $device = device_by_name($vars['device']); } -if (is_file("includes/graphs/".$type."/auth.inc.php")) -{ - include("includes/graphs/".$type."/auth.inc.php"); +if (is_file("includes/graphs/".$type."/auth.inc.php")) { + require "includes/graphs/".$type."/auth.inc.php"; } -if (!$auth) -{ - include("includes/error-no-perm.inc.php"); -} else { - if (isset($config['graph_types'][$type][$subtype]['descr'])) - { - $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; - } else { - $title .= " :: ".ucfirst($subtype); - } +if (!$auth) { + require 'includes/error-no-perm.inc.php'; +} +else { + if (isset($config['graph_types'][$type][$subtype]['descr'])) { + $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; + } + else { + $title .= " :: ".ucfirst($subtype); + } - $graph_array = $vars; - $graph_array['height'] = "60"; - $graph_array['width'] = $thumb_width; - $graph_array['legend'] = "no"; - $graph_array['to'] = $config['time']['now']; + $graph_array = $vars; + $graph_array['height'] = "60"; + $graph_array['width'] = $thumb_width; + $graph_array['legend'] = "no"; + $graph_array['to'] = $config['time']['now']; - print_optionbar_start(); - echo($title); + print_optionbar_start(); + echo($title); - echo('
    '); - ?> + echo('
    '); +?>
    - '); +'); - print_optionbar_end(); + print_optionbar_end(); - print_optionbar_start(); + print_optionbar_start(); - $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', - 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); + $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', + 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); - echo(''); + echo('
    '); - foreach ($thumb_array as $period => $text) - { - $graph_array['from'] = $config['time'][$period]; + foreach ($thumb_array as $period => $text) { + $graph_array['from'] = $config['time'][$period]; - $link_array = $vars; - $link_array['from'] = $graph_array['from']; - $link_array['to'] = $graph_array['to']; - $link_array['page'] = "graphs"; - $link = generate_url($link_array); + $link_array = $vars; + $link_array['from'] = $graph_array['from']; + $link_array['to'] = $graph_array['to']; + $link_array['page'] = "graphs"; + $link = generate_url($link_array); - echo(''); + echo(''); - } + } - echo('
    '); - echo(''.$text.'
    '); - echo(''); - echo(generate_graph_tag($graph_array)); - echo(''); - echo('
    '); + echo(''.$text.'
    '); + echo(''); + echo(generate_graph_tag($graph_array)); + echo(''); + echo('
    '); + echo(''); - $graph_array = $vars; - $graph_array['height'] = "300"; - $graph_array['width'] = $graph_width; + $graph_array = $vars; + $graph_array['height'] = "300"; + $graph_array['width'] = $graph_width; - echo("
    "); + echo("
    "); - // datetime range picker + // datetime range picker ?> - "); - echo(' + echo(" +
    + "); + echo('
    - - + +
    - - + +
    -
    - '); - echo("
    "); + echo("
    "); - if ($vars['legend'] == "no") - { - echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); - } else { - echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); - } - - // FIXME : do this properly -# if ($type == "port" && $subtype == "bits") -# { - echo(' | '); - if ($vars['previous'] == "yes") - { - echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); - } else { - echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); + if ($vars['legend'] == "no") { + echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); + } + else { + echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); } -# } - echo('
    '); + // FIXME : do this properly + # if ($type == "port" && $subtype == "bits") + # { + echo(' | '); + if ($vars['previous'] == "yes") { + echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); + } + else { + echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); + } + # } - if ($vars['showcommand'] == "yes") - { - echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); - } else { - echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); - } + echo('
    '); - echo('
    '); + if ($vars['showcommand'] == "yes") { + echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); + } + else { + echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); + } - print_optionbar_end(); + echo('
    '); - echo generate_graph_js_state($graph_array); - - echo('
    '); - echo(generate_graph_tag($graph_array)); - echo("
    "); - - if (isset($config['graph_descr'][$vars['type']])) - { - - print_optionbar_start(); - echo('
    -
    - -
    -
    '); - echo($config['graph_descr'][$vars['type']]); print_optionbar_end(); - } - if ($vars['showcommand']) - { - $_GET = $graph_array; - $command_only = 1; + echo generate_graph_js_state($graph_array); - include("includes/graphs/graph.inc.php"); - } + echo('
    '); + echo(generate_graph_tag($graph_array)); + echo("
    "); + + if (isset($config['graph_descr'][$vars['type']])) { + + print_optionbar_start(); + echo('
    +
    + +
    +
    '); + echo($config['graph_descr'][$vars['type']]); + print_optionbar_end(); + } + + if ($vars['showcommand']) { + $_GET = $graph_array; + $command_only = 1; + + require 'includes/graphs/graph.inc.php'; + } } - -?> diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index 3b06d4db6..eb13def9b 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -30,8 +30,12 @@ $type_text['toner'] = "Toner"; $type_text['dbm'] = "dBm"; $type_text['load'] = "Load"; -if (!$vars['metric']) { $vars['metric'] = "processor"; } -if (!$vars['view']) { $vars['view'] = "detail"; } +if (!$vars['metric']) { + $vars['metric'] = "processor"; +} +if (!$vars['view']) { + $vars['view'] = "detail"; +} $link_array = array('page' => 'health'); @@ -42,48 +46,44 @@ print_optionbar_start('', ''); echo('Health » '); $sep = ""; -foreach ($datas as $texttype) -{ - $metric = strtolower($texttype); - echo($sep); - if ($vars['metric'] == $metric) - { - echo(""); - } +foreach ($datas as $texttype) { + $metric = strtolower($texttype); + echo($sep); + if ($vars['metric'] == $metric) { + echo(""); + } - echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); + echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); - if ($vars['metric'] == $metric) { echo(""); } + if ($vars['metric'] == $metric) { + echo(""); + } - $sep = ' | '; + $sep = ' | '; } unset ($sep); echo('
    '); -if ($vars['view'] == "graphs") -{ - echo(''); +if ($vars['view'] == "graphs") { + echo(''); } echo(generate_link("Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "graphs"))); -if ($vars['view'] == "graphs") -{ - echo(''); +if ($vars['view'] == "graphs") { + echo(''); } echo(' | '); -if ($vars['view'] != "graphs") -{ - echo(''); +if ($vars['view'] != "graphs") { + echo(''); } echo(generate_link("No Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "detail"))); -if ($vars['view'] != "graphs") -{ - echo(''); +if ($vars['view'] != "graphs") { + echo(''); } echo('
    '); @@ -91,16 +91,14 @@ echo('
    '); print_optionbar_end(); if (in_array($vars['metric'],array_keys($used_sensors)) - || $vars['metric'] == 'processor' - || $vars['metric'] == 'storage' - || $vars['metric'] == 'toner' - || $vars['metric'] == 'mempool') -{ - include('pages/health/'.$vars['metric'].'.inc.php'); + || $vars['metric'] == 'processor' + || $vars['metric'] == 'storage' + || $vars['metric'] == 'toner' + || $vars['metric'] == 'mempool') { + include('pages/health/'.$vars['metric'].'.inc.php'); } -else -{ - echo("No sensors of type " . $vars['metric'] . " found."); +else { + echo("No sensors of type " . $vars['metric'] . " found."); } ?> diff --git a/html/pages/health/charge.inc.php b/html/pages/health/charge.inc.php index 867b50f9e..3838d0e79 100644 --- a/html/pages/health/charge.inc.php +++ b/html/pages/health/charge.inc.php @@ -4,6 +4,4 @@ $graph_type = "sensor_charge"; $unit = "%"; $class = "charge"; -include("pages/health/sensors.inc.php"); - -?> +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/load.inc.php b/html/pages/health/load.inc.php index d9257519d..f506e3ca1 100644 --- a/html/pages/health/load.inc.php +++ b/html/pages/health/load.inc.php @@ -1,9 +1,7 @@ +require 'pages/health/sensors.inc.php'; diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index 02224d485..52828b9c1 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -1,19 +1,18 @@ = '5') -{ - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; - $param = array(); -} else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; - $param = array($_SESSION['user_id']); +if ($_SESSION['userlevel'] >= '5') { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; + $param = array(); +} +else { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; + $param = array($_SESSION['user_id']); } -echo(''); +echo '
    '; -echo(' +echo ' @@ -21,99 +20,102 @@ echo(' - '); + '; -foreach (dbFetchRows($sql, $param) as $sensor) -{ +foreach (dbFetchRows($sql, $param) as $sensor) { + if ($config['memcached']['enable'] === true) { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + if ($debug) { + echo 'Memcached['.'sensor-'.$sensor['sensor_id'].'-value'.'='.$sensor['sensor_current'].']'; + } + } - if ($config['memcached']['enable'] === TRUE) - { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - if($debug) { echo("Memcached[".'sensor-'.$sensor['sensor_id'].'-value'."=".$sensor['sensor_current']."]"); } - } - - if (empty($sensor['sensor_current'])) - { - $sensor['sensor_current'] = "NaN"; - } else { - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - } + if (empty($sensor['sensor_current'])) { + $sensor['sensor_current'] = 'NaN'; + } + else { + if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { + $alert = 'alert'; + } + else { + $alert = ''; + } + } // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? // FIXME - DUPLICATED IN device/overview/sensors - - $graph_colour = str_replace("#", "", $row_colour); + $graph_colour = str_replace('#', '', $row_colour); $graph_array = array(); - $graph_array['height'] = "100"; - $graph_array['width'] = "210"; + $graph_array['height'] = '100'; + $graph_array['width'] = '210'; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $sensor['sensor_id']; $graph_array['type'] = $graph_type; $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = "no"; + $graph_array['legend'] = 'no'; - $link_array = $graph_array; - $link_array['page'] = "graphs"; + $link_array = $graph_array; + $link_array['page'] = 'graphs'; unset($link_array['height'], $link_array['width'], $link_array['legend']); $link_graph = generate_url($link_array); - $link = generate_url(array("page" => "device", "device" => $sensor['device_id'], "tab" => "health", "metric" => $sensor['sensor_class'])); + $link = generate_url(array('page' => 'device', 'device' => $sensor['device_id'], 'tab' => 'health', 'metric' => $sensor['sensor_class'])); - $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; - foreach (array('day','week','month','year') as $period) - { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; + foreach (array('day', 'week', 'month', 'year') as $period) { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); } - $overlib_content .= "
    "; - $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $overlib_content .= '
    '; + + $graph_array['width'] = 80; + $graph_array['height'] = 20; + $graph_array['bg'] = 'ffffff00'; + // the 00 at the end makes the area transparent. $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $sensor_minigraph = generate_graph_tag($graph_array); $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo(' - - + echo ' + + - - - + + + - '); + '; - if ($vars['view'] == "graphs") - { - echo(""); - } # endif graphs -} + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo "', LEFT);\" onmouseout=\"return nd();\"> + "; + echo ''; + } //end if +}//end foreach -echo("
    Device Sensor
    Current Range limit Notes
    ' . generate_device_link($sensor) . ''.overlib_link($link, $sensor['sensor_descr'],$overlib_content).'
    '.generate_device_link($sensor).''.overlib_link($link, $sensor['sensor_descr'], $overlib_content).' '.overlib_link($link_graph, $sensor_minigraph, $overlib_content).' '.$alert.'' . $sensor['sensor_current'] . $unit . '' . round($sensor['sensor_limit_low'],2) . $unit . ' - ' . round($sensor['sensor_limit'],2) . $unit . '' . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . ''.$sensor['sensor_current'].$unit.''.round($sensor['sensor_limit_low'], 2).$unit.' - '.round($sensor['sensor_limit'], 2).$unit.''.(isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '').'
    "); + if ($vars['view'] == 'graphs') { + echo "
    "; - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=211&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150"; + $daily_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=211&height=100'; + $daily_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=400&height=150'; - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=211&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=400&height=150"; + $weekly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=211&height=100'; + $weekly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=400&height=150'; - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=211&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=400&height=150"; + $monthly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=211&height=100'; + $monthly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=400&height=150'; - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=211&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=400&height=150"; + $yearly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['now'].'&width=211&height=100'; + $yearly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['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/iftype.inc.php b/html/pages/iftype.inc.php index f4349111c..8a6d20201 100644 --- a/html/pages/iftype.inc.php +++ b/html/pages/iftype.inc.php @@ -9,92 +9,102 @@ - Total Graph for ports of type : ".$types."
    "); - -if ($if_list) -{ - $graph_type = "multiport_bits_separate"; - $port['port_id'] = $if_list; - - include("includes/print-interface-graphs.inc.php"); - - echo(""); - - foreach ($ports as $port) - { - $done = "yes"; - unset($class); - $port['ifAlias'] = str_ireplace($type . ": ", "", $port['ifAlias']); - $port['ifAlias'] = str_ireplace("[PNI]", "Private", $port['ifAlias']); - $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - if ($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg = "#ffffff"; } - echo(" - " . generate_port_link($port,$port['port_descr_descr']) . "
    - ".generate_device_link($port)." ".generate_port_link($port)." - ".generate_port_link($port, makeshortif($port['ifDescr']))." - ".$port['port_descr_speed']." - ".$port['port_descr_circuit']." - ".$port['port_descr_notes']." - - - MAC Accounting"); - } - - echo('
    '); - - if (file_exists($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . $port['ifIndex'] . ".rrd")) - { - $graph_type = "port_bits"; - - include("includes/print-interface-graphs.inc.php"); - } - - echo(""); - } - +$types_array = explode(',', $vars['type']); +for ($i = 0; $i < count($types_array); +$i++) { + $types_array[$i] = ucfirst($types_array[$i]); } -else -{ - echo("None found."); + +$types = implode(' + ', $types_array); + +echo " + Total Graph for ports of type : ".$types.'
    '; + +if ($if_list) { + $graph_type = 'multiport_bits_separate'; + $port['port_id'] = $if_list; + + include 'includes/print-interface-graphs.inc.php'; + + echo ''; + + foreach ($ports as $port) { + $done = 'yes'; + unset($class); + $port['ifAlias'] = str_ireplace($type.': ', '', $port['ifAlias']); + $port['ifAlias'] = str_ireplace('[PNI]', 'Private', $port['ifAlias']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ($bg == '#ffffff') { + $bg = '#e5e5e5'; + } + else { + $bg = '#ffffff'; + } + + echo " + ".generate_port_link($port, $port['port_descr_descr'])."
    + ".generate_device_link($port).' '.generate_port_link($port).' + '.generate_port_link($port, makeshortif($port['ifDescr'])).' + '.$port['port_descr_speed'].' + '.$port['port_descr_circuit'].' + '.$port['port_descr_notes']." + + + MAC Accounting"; + } + + echo '
    '; + + if (file_exists($config['rrd_dir'].'/'.$port['hostname'].'/port-'.$port['ifIndex'].'.rrd')) { + $graph_type = 'port_bits'; + + include 'includes/print-interface-graphs.inc.php'; + } + + echo ''; + } +} +else { + echo 'None found.'; } ?> diff --git a/html/pages/inventory.inc.php b/html/pages/inventory.inc.php index e53daab96..7fc461e4a 100644 --- a/html/pages/inventory.inc.php +++ b/html/pages/inventory.inc.php @@ -1,6 +1,6 @@ @@ -29,46 +29,53 @@ var grid = $("#inventory").bootgrid({ header: "
    "+ "
    "+ "
    "+ - "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ + "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ "
    "+ "
    "+ " Part No "+ ""+ "
    "+ "
    "+ - "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ + "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ "
    "+ "
    "+ " Device "+ ""+ "
    "+ "
    "+ - "\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ + " +\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/locations.inc.php b/html/pages/locations.inc.php index 93dffa0e3..bbe6adcf9 100644 --- a/html/pages/locations.inc.php +++ b/html/pages/locations.inc.php @@ -1,88 +1,92 @@ Locations » '); +echo 'Locations » '; -$menu_options = array('basic' => 'Basic', - 'traffic' => 'Traffic'); +$menu_options = array( + 'basic' => 'Basic', + 'traffic' => 'Traffic', +); -if (!$vars['view']) { $vars['view'] = "basic"; } +if (!$vars['view']) { + $vars['view'] = 'basic'; +} -$sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['view'] == $option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['view'] == $option) - { - echo(""); - } - $sep = " | "; +$sep = ''; +foreach ($menu_options as $option => $text) { + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + + echo ''.$text.''; + if ($vars['view'] == $option) { + echo ''; + } + + $sep = ' | '; } unset($sep); print_optionbar_end(); -echo(''); +echo '
    '; -foreach (getlocations() as $location) -{ - if ($_SESSION['userlevel'] >= '10') - { - $num = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ?", array($location)); - $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); - $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); - $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); - } else { - $num = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?", array($_SESSION['user_id'], $location)); - $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); - $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); - $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); - } - - if ($hostalerts) { $alert = 'alert'; } else { $alert = ""; } - - if ($location != "") - { - echo(' - - - - - - - - '); - - if ($vars['view'] == "traffic") - { - echo('"); +foreach (getlocations() as $location) { + if ($_SESSION['userlevel'] >= '10') { + $num = dbFetchCell('SELECT COUNT(device_id) FROM devices WHERE location = ?', array($location)); + $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); + $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); + $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); + } + else { + $num = dbFetchCell('SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?', array($_SESSION['user_id'], $location)); + $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); + $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); + $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); } - $done = "yes"; - } -} -echo("
    ' . $location . '' . $alert . '' . $num . ' devices' . $net . ' network' . $srv . ' servers' . $fwl . ' firewalls
    '); - - $graph_array['type'] = "location_bits"; - $graph_array['height'] = "100"; - $graph_array['width'] = "220"; - $graph_array['to'] = $config['time']['now']; - $graph_array['legend'] = "no"; - $graph_array['id'] = $location; - - include("includes/print-graphrow.inc.php"); - - echo("
    "); + if ($hostalerts) { + $alert = 'alert'; + } + else { + $alert = ''; + } -?> + if ($location != '') { + echo ' + '.$location.' + '.$alert.' + '.$num.' devices + '.$net.' network + '.$srv.' servers + '.$fwl.' firewalls + + '; + + if ($vars['view'] == 'traffic') { + echo ''; + + $graph_array['type'] = 'location_bits'; + $graph_array['height'] = '100'; + $graph_array['width'] = '220'; + $graph_array['to'] = $config['time']['now']; + $graph_array['legend'] = 'no'; + $graph_array['id'] = $location; + + include 'includes/print-graphrow.inc.php'; + + echo ''; + } + + $done = 'yes'; + }//end if +}//end foreach + +echo ''; diff --git a/html/pages/logon.inc.php b/html/pages/logon.inc.php index e9819b1b0..a8a156574 100644 --- a/html/pages/logon.inc.php +++ b/html/pages/logon.inc.php @@ -1,7 +1,8 @@
    @@ -32,14 +33,12 @@ if( $config['twofactor'] && isset($twofactorform) ) {
    'error','message'=>$auth_message,'title'=>'Login error'); } ?>
    diff --git a/html/pages/map.inc.php b/html/pages/map.inc.php index 0fa1cbb5f..115c0600c 100644 --- a/html/pages/map.inc.php +++ b/html/pages/map.inc.php @@ -10,6 +10,5 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -$pagetitle[] = "Map"; -require_once "includes/print-map.inc.php"; -?> +$pagetitle[] = 'Map'; +require_once 'includes/print-map.inc.php'; diff --git a/html/pages/packages.inc.php b/html/pages/packages.inc.php index c3e79c8cf..ab26fd00a 100644 --- a/html/pages/packages.inc.php +++ b/html/pages/packages.inc.php @@ -2,8 +2,7 @@ foreach ($vars as $var => $value) { if ($value != '') { - switch ($var) - { + switch ($var) { case 'name': $where .= " AND `$var` = ?"; $param[] = $value; @@ -26,8 +25,7 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", foreach ($entry['blah'] as $version => $bleu) { $content = '
    '; - foreach ($bleu as $build => $bloo) - { + foreach ($bleu as $build => $bloo) { if ($build) { $dbuild = '-'.$build; } @@ -36,8 +34,7 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", } $content .= '
    '.$version.$dbuild.''; - foreach ($bloo as $device_id => $no) - { + foreach ($bloo as $device_id => $no) { $this_device = device_by_id_cache($device_id); $content .= ''.$this_device['hostname'].' '; } diff --git a/html/pages/plugin.inc.php b/html/pages/plugin.inc.php index daec96f46..1f718acff 100644 --- a/html/pages/plugin.inc.php +++ b/html/pages/plugin.inc.php @@ -1,24 +1,18 @@ 'plugin'); +$link_array = array('page' => 'plugin'); -$pagetitle[] = "Plugin"; +$pagetitle[] = 'Plugin'; -if ($vars['view'] == "admin") -{ - include_once('pages/plugin/admin.inc.php'); +if ($vars['view'] == 'admin') { + include_once 'pages/plugin/admin.inc.php'; } -else -{ - $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); - if(!empty($plugin)) - { - require('plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'); - } - else - { - print_error( "This plugin is either disabled or not available." ); - } +else { + $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); + if (!empty($plugin)) { + include 'plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'; + } + else { + print_error('This plugin is either disabled or not available.'); + } } - -?> diff --git a/html/pages/plugin/admin.inc.php b/html/pages/plugin/admin.inc.php index 1773d641d..e20bec1b6 100644 --- a/html/pages/plugin/admin.inc.php +++ b/html/pages/plugin/admin.inc.php @@ -1,33 +1,26 @@ = '10') -{ - - // Scan for new plugins and add to the database - $new_plugins = scan_new_plugins(); +if ($_SESSION['userlevel'] >= '10') { + // Scan for new plugins and add to the database + $new_plugins = scan_new_plugins(); - // Check if we have to toggle enabled / disable a particular module - $plugin_id = $_POST['plugin_id']; - $plugin_active = $_POST['plugin_active']; - if(is_numeric($plugin_id) && is_numeric($plugin_active)) - { - if( $plugin_active == '0') - { - $plugin_active = 1; - } - elseif( $plugin_active == '1') - { - $plugin_active = 0; - } - else - { - $plugin_active = 0; - } + // Check if we have to toggle enabled / disable a particular module + $plugin_id = $_POST['plugin_id']; + $plugin_active = $_POST['plugin_active']; + if (is_numeric($plugin_id) && is_numeric($plugin_active)) { + if ($plugin_active == '0') { + $plugin_active = 1; + } + else if ($plugin_active == '1') { + $plugin_active = 0; + } + else { + $plugin_active = 0; + } - if(dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) - { - echo(' + if (dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) { + echo ' -'); - } - - } +'; + } + }//end if ?> @@ -49,14 +41,13 @@ $.ajax({ System plugins
    0) - { - echo('
    +if ($new_plugins > 0) { + echo '
    - We have found ' . $new_plugins . ' new plugins that need to be configured and enabled + We have found '.$new_plugins.' new plugins that need to be configured and enabled
    -
    '); - } +
    '; +} ?> @@ -65,24 +56,21 @@ $.ajax({ + echo ' - '); - } - + '; +}//end foreach ?>
    - '. $plugins['plugin_name'] . ' + '.$plugins['plugin_name'].' @@ -91,18 +79,14 @@ $.ajax({
    +else { + include 'includes/error-no-perm.inc.php'; +}//end if diff --git a/html/pages/poll-log.inc.php b/html/pages/poll-log.inc.php index 3abdf05a8..91ef8132e 100644 --- a/html/pages/poll-log.inc.php +++ b/html/pages/poll-log.inc.php @@ -1,5 +1,5 @@ diff --git a/html/pages/pollers.inc.php b/html/pages/pollers.inc.php index de85c2344..3fef3d931 100644 --- a/html/pages/pollers.inc.php +++ b/html/pages/pollers.inc.php @@ -12,25 +12,32 @@ * the source code distribution for details. */ -$no_refresh = TRUE; +$no_refresh = true; -echo(''; if (isset($vars['tab'])) { - require_once "pages/pollers/".mres($vars['tab']).".inc.php"; + include_once 'pages/pollers/'.mres($vars['tab']).'.inc.php'; } diff --git a/html/pages/pollers/groups.inc.php b/html/pages/pollers/groups.inc.php index 50019dfc2..a914650ae 100644 --- a/html/pages/pollers/groups.inc.php +++ b/html/pages/pollers/groups.inc.php @@ -12,7 +12,7 @@ * the source code distribution for details. */ -require_once "includes/modal/poller_groups.inc.php"; +require_once 'includes/modal/poller_groups.inc.php'; ?>
    @@ -28,18 +28,17 @@ require_once "includes/modal/poller_groups.inc.php"; + echo ' + -'); +'; } ?> diff --git a/html/pages/pollers/pollers.inc.php b/html/pages/pollers/pollers.inc.php index c5e0eb279..f948d3a8b 100644 --- a/html/pages/pollers/pollers.inc.php +++ b/html/pages/pollers/pollers.inc.php @@ -24,26 +24,28 @@ = 300) { $row_class = 'danger'; - } elseif ($old >= 280 && $old < 300) { + } + else if ($old >= 280 && $old < 300) { $row_class = 'warning'; - } else { + } + else { $row_class = 'success'; } - echo(' + + echo ' -'); +'; } ?> diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php index 8ff1f7d34..edeea9fbe 100644 --- a/html/pages/ports.inc.php +++ b/html/pages/ports.inc.php @@ -4,29 +4,27 @@ $pagetitle[] = "Ports"; // Set Defaults here -if(!isset($vars['format'])) { $vars['format'] = "list_basic"; } +if(!isset($vars['format'])) { + $vars['format'] = "list_basic"; +} print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', - 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == "list_".$option) { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) { + echo(""); + } + $sep = " | "; } ?> @@ -37,24 +35,21 @@ foreach ($menu_options as $option => $text) 'Bits', - 'upkts' => 'Unicast Packets', - 'nupkts' => 'Non-Unicast Packets', - 'errors' => 'Errors'); + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors'); $sep = ""; -foreach ($menu_options as $option => $text) -{ - echo($sep); - if ($vars['format'] == 'graph_'.$option) - { - echo(''); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) - { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) { + echo($sep); + if ($vars['format'] == 'graph_'.$option) { + echo(''); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) { + echo(""); + } + $sep = " | "; } echo('
    '); @@ -64,29 +59,28 @@ echo('
    '); Update URL | '')).'">Search'); - } else { +} +else { echo('Search'); - } +} - echo(" | "); +echo(" | "); - if (isset($vars['bare']) && $vars['bare'] == "yes") - { +if (isset($vars['bare']) && $vars['bare'] == "yes") { echo('Header'); - } else { +} +else { echo('Header'); - } +} echo('
    '); print_optionbar_end(); print_optionbar_start(); -if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) -{ +if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) { ?>
    @@ -95,67 +89,66 @@ if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars[' = 5) -{ - $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); -} -else -{ - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); -} -foreach ($results as $data) -{ - echo(' "); -} + if($_SESSION['userlevel'] >= 5) { + $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); + } + else { + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); + } + foreach ($results as $data) { + echo(' "); + } -if($_SESSION['userlevel'] < 5) -{ - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); -} -else -{ - $results = array(); -} -foreach ($results as $data) -{ - echo(' "); -} + if($_SESSION['userlevel'] < 5) { + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); + } + else { + $results = array(); + } + foreach ($results as $data) { + echo(' "); + } ?> - placeholder="Hostname" /> + placeholder="Hostname" />
    @@ -164,97 +157,100 @@ foreach (dbFetchRows($sql,$param) as $data) ".$data['ifType'].""); - } -} + if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`"; + } + else { + $sql = "SELECT `ifType` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `ifType` ORDER BY `ifType`"; + $param[] = array($_SESSION['user_id'],$_SESSION['user_id']); + } + foreach (dbFetchRows($sql,$param) as $data) { + if ($data['ifType']) { + echo(' "); + } + } ?>
    - placeholder="Port Description"/> + placeholder="Port Description"/>
    - > + > - > + > - > + >
    @@ -266,95 +262,98 @@ foreach ($sorts as $sort => $sort_text)
    '.$group['id'].' '.$group['group_name'].' '.$group['descr'].'
    '.$poller['poller_name'].' '.$poller['devices'].' '.$poller['time_taken'].' Seconds '.$poller['last_polled'].'
    - $value) -{ - if ($value != "") - { - switch ($var) - { - case 'hostname': - $where .= " AND D.hostname LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'location': - $where .= " AND D.location LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'device_id': - $where .= " AND D.device_id = ?"; - $param[] = $value; - break; - case 'deleted': - if ($value == 1) { - $where .= " AND `I`.`deleted` = 1"; - $ignore_filter = 1; +foreach ($vars as $var => $value) { + if ($value != "") { + switch ($var) { + case 'hostname': + $where .= " AND D.hostname LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'location': + $where .= " AND D.location LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'device_id': + $where .= " AND D.device_id = ?"; + $param[] = $value; + break; + case 'deleted': + if ($value == 1) { + $where .= " AND `I`.`deleted` = 1"; + $ignore_filter = 1; + } + break; + case 'ignore': + if ($value == 1) { + $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; + $ignore_filter = 1; + } + break; + case 'disabled': + if ($value == 1) { + $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; + $disabled_filter = 1; + } + break; + case 'ifSpeed': + if (is_numeric($value)) { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'errors': + if ($value == 1) { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + case 'state': + if ($value == "down") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; + $param[] = "up"; + $param[] = "down"; + } + elseif($value == "up") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = "up"; + $param[] = "up"; + } + elseif($value == "admindown") { + $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; + $param[] = "down"; + } + break; } - break; - case 'ignore': - if ($value == 1) { - $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; - $ignore_filter = 1; - } - break; - case 'disabled': - if ($value == 1) { - $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; - $disabled_filter = 1; - } - break; - case 'ifSpeed': - if (is_numeric($value)) - { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'errors': - if ($value == 1) - { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - case 'state': - if ($value == "down") - { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; - $param[] = "up"; - $param[] = "down"; - } elseif($value == "up") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = "up"; - $param[] = "up"; - } elseif($value == "admindown") { - $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; - $param[] = "down"; - } - break; } - } } if ($ignore_filter == 0 && $disabled_filter == 0) { @@ -369,49 +368,47 @@ list($format, $subformat) = explode("_", $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) -{ - case 'traffic': - $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); - break; - case 'traffic_in': - $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); - break; - case 'traffic_out': - $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); - break; - case 'packets': - $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); - break; - case 'packets_in': - $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); - break; - case 'packets_out': - $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); - break; - case 'errors': - $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); - break; - case 'speed': - $ports = array_sort($ports, 'ifSpeed', SORT_DESC); - break; - case 'port': - $ports = array_sort($ports, 'ifDescr', SORT_ASC); - break; - case 'media': - $ports = array_sort($ports, 'ifType', SORT_ASC); - break; - case 'descr': - $ports = array_sort($ports, 'ifAlias', SORT_ASC); - break; - case 'device': - default: - $ports = array_sort($ports, 'hostname', SORT_ASC); +switch ($vars['sort']) { + case 'traffic': + $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); + break; + case 'traffic_in': + $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); + break; + case 'traffic_out': + $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); + break; + case 'packets': + $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); + break; + case 'packets_in': + $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); + break; + case 'packets_out': + $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); + break; + case 'errors': + $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); + break; + case 'speed': + $ports = array_sort($ports, 'ifSpeed', SORT_DESC); + break; + case 'port': + $ports = array_sort($ports, 'ifDescr', SORT_ASC); + break; + case 'media': + $ports = array_sort($ports, 'ifType', SORT_ASC); + break; + case 'descr': + $ports = array_sort($ports, 'ifAlias', SORT_ASC); + break; + case 'device': + default: + $ports = array_sort($ports, 'hostname', SORT_ASC); } -if(file_exists('pages/ports/'.$format.'.inc.php')) -{ - include('pages/ports/'.$format.'.inc.php'); +if(file_exists('pages/ports/'.$format.'.inc.php')) { + require 'pages/ports/'.$format.'.inc.php'; } ?> diff --git a/html/pages/ports/list.inc.php b/html/pages/ports/list.inc.php index 8ae9c9df3..71f52e618 100644 --- a/html/pages/ports/list.inc.php +++ b/html/pages/ports/list.inc.php @@ -3,68 +3,75 @@ '); +echo ''; -$cols = array('device' => 'Device', - 'port' => 'Port', - 'speed' => 'Speed', - 'traffic_in' => 'Down', - 'traffic_out' => 'Up', - 'media' => 'Media', - 'descr' => 'Description' ); +$cols = array( + 'device' => 'Device', + 'port' => 'Port', + 'speed' => 'Speed', + 'traffic_in' => 'Down', + 'traffic_out' => 'Up', + 'media' => 'Media', + 'descr' => 'Description', +); -foreach ($cols as $sort => $col) -{ - if (isset($vars['sort']) && $vars['sort'] == $sort) - { - echo(''.$col.' *'); - } else { - echo(''.$col.''); - } +foreach ($cols as $sort => $col) { + if (isset($vars['sort']) && $vars['sort'] == $sort) { + echo ''.$col.' *'; + } + else { + echo ''.$col.''; + } } -echo(" "); +echo ' '; -$ports_disabled = 0; $ports_down = 0; $ports_up = 0; $ports_total = 0; +$ports_disabled = 0; +$ports_down = 0; +$ports_up = 0; +$ports_total = 0; -foreach ($ports as $port) -{ +foreach ($ports as $port) { + if (port_permitted($port['port_id'], $port['device_id'])) { + if ($port['ifAdminStatus'] == 'down') { + $ports_disabled++; + } + else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { + $ports_down++; + } + else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { + $ports_up++; + } - if (port_permitted($port['port_id'], $port['device_id'])) - { + $ports_total++; - if ($port['ifAdminStatus'] == "down") { $ports_disabled++; - } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "down") { $ports_down++; - } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "up") { $ports_up++; } - $ports_total++; + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) { + $error_img = generate_port_link($port, "Interface Errors", errors); + } + else { + $error_img = ''; + } - if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) - { - $error_img = generate_port_link($port,"Interface Errors",errors); - } else { $error_img = ""; } + $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); + $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); - $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); - $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); + $port = ifLabel($port, $device); + echo " + ".generate_device_link($port, shorthost($port['hostname'], '20'))." + ".fixIfName($port['label'])." $error_img + $speed + ".$port['in_rate'].' + '.$port['out_rate']." + $type + ".$port['ifAlias']." + \n"; + }//end if +}//end foreach - $port = ifLabel($port, $device); - echo(" - ".generate_device_link($port, shorthost($port['hostname'], "20"))." - ".fixIfName($port['label'])." $error_img - $speed - ".$port['in_rate']." - ".$port['out_rate']." - $type - " . $port['ifAlias'] . " - \n"); - } -} - -echo(''); -echo("Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"); -echo(''); - -?> +echo ''; +echo "Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"; +echo ''; diff --git a/html/pages/preferences.inc.php b/html/pages/preferences.inc.php index f4815df24..ca2f79835 100644 --- a/html/pages/preferences.inc.php +++ b/html/pages/preferences.inc.php @@ -1,48 +1,41 @@ User Preferences"); +echo '

    User Preferences

    '; if ($_SESSION['userlevel'] == 11) { - demo_account(); - -} else { - -if ($_POST['action'] == "changepass") -{ - if (authenticate($_SESSION['username'],$_POST['old_pass'])) - { - if ($_POST['new_pass'] == "" || $_POST['new_pass2'] == "") - { - $changepass_message = "Password must not be blank."; - } - elseif ($_POST['new_pass'] == $_POST['new_pass2']) - { - changepassword($_SESSION['username'],$_POST['new_pass']); - $changepass_message = "Password Changed."; - } - else - { - $changepass_message = "Passwords don't match."; - } - } else { - $changepass_message = "Incorrect password"; - } } +else { + if ($_POST['action'] == 'changepass') { + if (authenticate($_SESSION['username'], $_POST['old_pass'])) { + if ($_POST['new_pass'] == '' || $_POST['new_pass2'] == '') { + $changepass_message = 'Password must not be blank.'; + } + else if ($_POST['new_pass'] == $_POST['new_pass2']) { + changepassword($_SESSION['username'], $_POST['new_pass']); + $changepass_message = 'Password Changed.'; + } + else { + $changepass_message = "Passwords don't match."; + } + } + else { + $changepass_message = 'Incorrect password'; + } + } -include("includes/update-preferences-password.inc.php"); + include 'includes/update-preferences-password.inc.php'; -echo("
    "); + echo "
    "; -if (passwordscanchange($_SESSION['username'])) -{ - echo("

    Change Password

    "); - echo($changepass_message); - echo(" + if (passwordscanchange($_SESSION['username'])) { + echo '

    Change Password

    '; + echo $changepass_message; + echo "
    @@ -69,93 +62,107 @@ if (passwordscanchange($_SESSION['username']))
    -"); - echo("
    "); -} +"; + echo '
    '; + }//end if -if( $config['twofactor'] === true ) { - if( $_POST['twofactorremove'] == 1 ) { - require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); - if( !isset($_POST['twofactor']) ) { - echo '
    '; - echo ''; - echo twofactor_form(false); - echo '
    '; - } else{ - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - if( empty($twofactor['twofactor']) ) { - echo '
    Error: How did you even get here?!
    '; - } else { - $twofactor = json_decode($twofactor['twofactor'],true); - } - if( verify_hotp($twofactor['key'],$_POST['twofactor'],$twofactor['counter']) ) { - if( !dbUpdate(array('twofactor' => ''),'users','username = ?',array($_SESSION['username'])) ) { - echo '
    Error while disabling TwoFactor.
    '; - } else { - echo '
    TwoFactor Disabled.
    '; + if ($config['twofactor'] === true) { + if ($_POST['twofactorremove'] == 1) { + include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; + if (!isset($_POST['twofactor'])) { + echo '
    '; + echo ''; + echo twofactor_form(false); + echo '
    '; + } + else { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + if (empty($twofactor['twofactor'])) { + echo '
    Error: How did you even get here?!
    '; + } + else { + $twofactor = json_decode($twofactor['twofactor'], true); + } + + if (verify_hotp($twofactor['key'], $_POST['twofactor'], $twofactor['counter'])) { + if (!dbUpdate(array('twofactor' => ''), 'users', 'username = ?', array($_SESSION['username']))) { + echo '
    Error while disabling TwoFactor.
    '; + } + else { + echo '
    TwoFactor Disabled.
    '; + } + } + else { + session_destroy(); + echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; + } + }//end if } - } else { - session_destroy(); - echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; - } - } - } else { - $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); - echo ''; - echo '

    Two-Factor Authentication

    '; - if( !empty($twofactor['twofactor']) ) { - $twofactor = json_decode($twofactor['twofactor'],true); - $twofactor['text'] = "
    + else { + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + echo ''; + echo '

    Two-Factor Authentication

    '; + if (!empty($twofactor['twofactor'])) { + $twofactor = json_decode($twofactor['twofactor'], true); + $twofactor['text'] = "
    "; - if( $twofactor['counter'] !== false ) { - $twofactor['uri'] = "otpauth://hotp/".$_SESSION['username']."?issuer=LibreNMS&counter=".$twofactor['counter']."&secret=".$twofactor['key']; - $twofactor['text'] .= "
    + if ($twofactor['counter'] !== false) { + $twofactor['uri'] = 'otpauth://hotp/'.$_SESSION['username'].'?issuer=LibreNMS&counter='.$twofactor['counter'].'&secret='.$twofactor['key']; + $twofactor['text'] .= "
    "; - } else { - $twofactor['uri'] = "otpauth://totp/".$_SESSION['username']."?issuer=LibreNMS&secret=".$twofactor['key']; - } - echo '
    + } + else { + $twofactor['uri'] = 'otpauth://totp/'.$_SESSION['username'].'?issuer=LibreNMS&secret='.$twofactor['key']; + } + + echo '
    '; - echo '
    + echo '
    '.$twofactor['text'].'
    '; - echo ''; - echo '
    + echo ''; + echo '
    '; - } else { - if( isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype']) ) { - require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); - $chk = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); - if( empty($chk['twofactor']) ) { - $twofactor = array('key' => twofactor_genkey()); - if( $_POST['twofactortype'] == "counter" ) { - $twofactor['counter'] = 1; - } else { - $twofactor['counter'] = false; - } - if( !dbUpdate(array('twofactor' => json_encode($twofactor)),'users','username = ?',array($_SESSION['username'])) ) { - echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; - } else { - echo '
    Added TwoFactor credentials. Please reload page.
    '; - } - } else { - echo '
    TwoFactor credentials already exists.
    '; - } - } else { - echo '
    + } + else { + if (isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype'])) { + include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; + $chk = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + if (empty($chk['twofactor'])) { + $twofactor = array('key' => twofactor_genkey()); + if ($_POST['twofactortype'] == 'counter') { + $twofactor['counter'] = 1; + } + else { + $twofactor['counter'] = false; + } + + if (!dbUpdate(array('twofactor' => json_encode($twofactor)), 'users', 'username = ?', array($_SESSION['username']))) { + echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; + } + else { + echo '
    Added TwoFactor credentials. Please reload page.
    '; + } + } + else { + echo '
    TwoFactor credentials already exists.
    '; + } + } + else { + echo '
    @@ -169,32 +176,34 @@ if( $config['twofactor'] === true ) {
    '; - } + }//end if + }//end if + echo '
    '; + }//end if + }//end if +}//end if + +echo "
    '; - } } -} - -echo("
    "); -echo("
    Device Permissions
    "); - -if ($_SESSION['userlevel'] == '10') { echo("Global Administrative Access"); } -if ($_SESSION['userlevel'] == '5') { echo("Global Viewing Access"); } -if ($_SESSION['userlevel'] == '1') -{ - - foreach (dbFetchRows("SELECT * FROM `devices_perms` AS P, `devices` AS D WHERE `user_id` = ? AND P.device_id = D.device_id", array($_SESSION['user_id'])) as $perm) - { - #FIXME generatedevicelink? - echo("" . $perm['hostname'] . "
    "); - $dev_access = 1; - } - - if (!$dev_access) { echo("No access!"); } -} - -echo("
    "); - -?> +echo '
    '; diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index 5dd77f468..3408973fd 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -90,8 +90,7 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I, devices AS D W $pw_a['to'] = $config['time']['now']; $pw_a['bg'] = $bg; $types = array('bits', 'upkts', 'errors'); - foreach ($types as $graph_type) - { + foreach ($types as $graph_type) { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php index ad89593bc..71181a977 100644 --- a/html/pages/public.inc.php +++ b/html/pages/public.inc.php @@ -1,4 +1,5 @@

    System Status

    @@ -50,9 +49,8 @@ $query = "SELECT * FROM `devices` WHERE 1 AND disabled='0' AND `ignore`='0' ORDE Uptime/Location diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index 5e0494562..3268715ec 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -1,260 +1,355 @@ 'routing', 'protocol' => 'bgp'); +else { + $link_array = array( + 'page' => 'routing', + 'protocol' => 'bgp', + ); - print_optionbar_start('', ''); + print_optionbar_start('', ''); - echo('BGP » '); + echo 'BGP » '; - if (!$vars['type']) { $vars['type'] = "all"; } - - if ($vars['type'] == "all") { echo(""); } - echo(generate_link("All",$vars, array('type' => 'all'))); - if ($vars['type'] == "all") { echo(""); } - - echo(" | "); - - if ($vars['type'] == "internal") { echo(""); } - echo(generate_link("iBGP",$vars, array('type' => 'internal'))); - if ($vars['type'] == "internal") { echo(""); } - - echo(" | "); - - if ($vars['type'] == "external") { echo(""); } - echo(generate_link("eBGP",$vars, array('type' => 'external'))); - if ($vars['type'] == "external") { echo(""); } - - echo(" | "); - - if ($vars['adminstatus'] == "stop") - { - echo(""); - echo(generate_link("Shutdown",$vars, array('adminstatus' => NULL))); - echo(""); - } else { - echo(generate_link("Shutdown",$vars, array('adminstatus' => 'stop'))); - } - - echo(" | "); - - if ($vars['adminstatus'] == "start") - { - echo(""); - echo(generate_link("Enabled",$vars, array('adminstatus' => NULL))); - echo(""); - } else { - echo(generate_link("Enabled",$vars, array('adminstatus' => 'start'))); - } - - echo(" | "); - - if ($vars['state'] == "down") - { - echo(""); - echo(generate_link("Down",$vars, array('state' => NULL))); - echo(""); - } else { - echo(generate_link("Down",$vars, array('state' => 'down'))); - } - - // End BGP Menu - - if (!isset($vars['view'])) { $vars['view'] = 'details'; } - - echo('
    '); - - if ($vars['view'] == "details") { echo(""); } - echo(generate_link("No Graphs",$vars, array('view' => 'details', 'graph' => 'NULL'))); - if ($vars['view'] == "details") { echo(""); } - - echo(" | "); - - if ($vars['graph'] == "updates") { echo(""); } - echo(generate_link("Updates",$vars, array('view' => 'graphs', 'graph' => 'updates'))); - if ($vars['graph'] == "updates") { echo(""); } - - echo(" | Prefixes: Unicast ("); - if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } - echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast'))); - if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } - echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast'))); - if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } - echo(generate_link("VPNv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn'))); - if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } - echo(")"); - - echo(" | Multicast ("); - if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } - echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast'))); - if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } - echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast'))); - if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } - echo(")"); - - echo(" | MAC ("); - if ($vars['graph'] == "macaccounting_bits") { echo(""); } - echo(generate_link("Bits",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits'))); - if ($vars['graph'] == "macaccounting_bits") { echo(""); } - - echo("|"); - - if ($vars['graph'] == "macaccounting_pkts") { echo(""); } - echo(generate_link("Packets",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts'))); - if ($vars['graph'] == "macaccounting_pkts") { echo(""); } - echo(")"); - - echo('
    '); - - print_optionbar_end(); - - echo(""); - echo(''); - - if ($vars['type'] == "external") - { - $where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs"; - } elseif ($vars['type'] == "internal") { - $where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs"; - } - - if ($vars['adminstatus'] == "stop") - { - $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; - } elseif ($vars['adminstatus'] == "start") - { - $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; - } - - if ($vars['state'] == "down") - { - $where .= " AND (B.bgpPeerState != 'established')"; - } - - $peer_query = "select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id ".$where." ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"; - foreach (dbFetchRows($peer_query) as $peer) - { - unset ($alert, $bg_image); - - if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } - if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } - if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } - if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; - if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } + if (!$vars['type']) { + $vars['type'] = 'all'; } - $peerhost = dbFetchRow("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($peer['bgpPeerIdentifier'])); - - if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } - - // display overlib graphs - - $graph_type = "bgp_updates"; - $local_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150&&afi=ipv4&safi=unicast"; - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); - } else { - $peer_ip = $peer['bgpLocalAddr']; - } - $localaddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ip . ""; - - $graph_type = "bgp_updates"; - $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; - if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { - $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } else { - $peer_ident = $peer['bgpPeerIdentifier']; + if ($vars['type'] == 'all') { + echo ""; } - $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ident . ""; - - echo('"); - - unset($sep); - foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) - { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep . $afi .".".$safi; - $sep = "
    "; - $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer - } - unset($sep); - - echo(" - - - - - - - - "); - - unset($invalid); - switch ($vars['graph']) - { - case 'prefixes_ipv4unicast': - case 'prefixes_ipv4multicast': - case 'prefixes_ipv4vpn': - case 'prefixes_ipv6unicast': - case 'prefixes_ipv6multicast': - list(,$afisafi) = explode("_", $vars['graph']); - if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } - case 'updates': - $graph_array['type'] = "bgp_" . $vars['graph']; - $graph_array['id'] = $peer['bgpPeer_id']; + echo generate_link('All', $vars, array('type' => 'all')); + if ($vars['type'] == 'all') { + echo ''; } - switch ($vars['graph']) - { - case 'macaccounting_bits': - case 'macaccounting_pkts': - $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - if (is_array($acc) && is_file($database)) - { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['graph']; + echo ' | '; + + if ($vars['type'] == 'internal') { + echo ""; + } + + echo generate_link('iBGP', $vars, array('type' => 'internal')); + if ($vars['type'] == 'internal') { + echo ''; + } + + echo ' | '; + + if ($vars['type'] == 'external') { + echo ""; + } + + echo generate_link('eBGP', $vars, array('type' => 'external')); + if ($vars['type'] == 'external') { + echo ''; + } + + echo ' | '; + + if ($vars['adminstatus'] == 'stop') { + echo ""; + echo generate_link('Shutdown', $vars, array('adminstatus' => null)); + echo ''; + } + else { + echo generate_link('Shutdown', $vars, array('adminstatus' => 'stop')); + } + + echo ' | '; + + if ($vars['adminstatus'] == 'start') { + echo ""; + echo generate_link('Enabled', $vars, array('adminstatus' => null)); + echo ''; + } + else { + echo generate_link('Enabled', $vars, array('adminstatus' => 'start')); + } + + echo ' | '; + + if ($vars['state'] == 'down') { + echo ""; + echo generate_link('Down', $vars, array('state' => null)); + echo ''; + } + else { + echo generate_link('Down', $vars, array('state' => 'down')); + } + + // End BGP Menu + if (!isset($vars['view'])) { + $vars['view'] = 'details'; + } + + echo '
    '; + + if ($vars['view'] == 'details') { + echo ""; + } + + echo generate_link('No Graphs', $vars, array('view' => 'details', 'graph' => 'NULL')); + if ($vars['view'] == 'details') { + echo ''; + } + + echo ' | '; + + if ($vars['graph'] == 'updates') { + echo ""; + } + + echo generate_link('Updates', $vars, array('view' => 'graphs', 'graph' => 'updates')); + if ($vars['graph'] == 'updates') { + echo ''; + } + + echo ' | Prefixes: Unicast ('; + if ($vars['graph'] == 'prefixes_ipv4unicast') { + echo ""; + } + + echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast')); + if ($vars['graph'] == 'prefixes_ipv4unicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv6unicast') { + echo ""; + } + + echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast')); + if ($vars['graph'] == 'prefixes_ipv6unicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv4vpn') { + echo ""; + } + + echo generate_link('VPNv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn')); + if ($vars['graph'] == 'prefixes_ipv4vpn') { + echo ''; + } + + echo ')'; + + echo ' | Multicast ('; + if ($vars['graph'] == 'prefixes_ipv4multicast') { + echo ""; + } + + echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast')); + if ($vars['graph'] == 'prefixes_ipv4multicast') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'prefixes_ipv6multicast') { + echo ""; + } + + echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast')); + if ($vars['graph'] == 'prefixes_ipv6multicast') { + echo ''; + } + + echo ')'; + + echo ' | MAC ('; + if ($vars['graph'] == 'macaccounting_bits') { + echo ""; + } + + echo generate_link('Bits', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits')); + if ($vars['graph'] == 'macaccounting_bits') { + echo ''; + } + + echo '|'; + + if ($vars['graph'] == 'macaccounting_pkts') { + echo ""; + } + + echo generate_link('Packets', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts')); + if ($vars['graph'] == 'macaccounting_pkts') { + echo ''; + } + + echo ')'; + + echo '
    '; + + print_optionbar_end(); + + echo "
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    " . $localaddresslink . "
    ".generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp'))."
    »" . $peeraddresslink . "$peer_type".$peer['afi']."AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    - Updates " . format_si($peer['bgpPeerInUpdates']) . " - " . format_si($peer['bgpPeerOutUpdates']) . "
    "; + echo ''; + + if ($vars['type'] == 'external') { + $where = 'AND D.bgpLocalAs != B.bgpPeerRemoteAs'; + } + else if ($vars['type'] == 'internal') { + $where = 'AND D.bgpLocalAs = B.bgpPeerRemoteAs'; + } + + if ($vars['adminstatus'] == 'stop') { + $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; + } + else if ($vars['adminstatus'] == 'start') { + $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; + } + + if ($vars['state'] == 'down') { + $where .= " AND (B.bgpPeerState != 'established')"; + } + + $peer_query = 'select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id '.$where.' ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier'; + foreach (dbFetchRows($peer_query) as $peer) { + unset($alert, $bg_image); + + if ($peer['bgpPeerState'] == 'established') { + $col = 'green'; + } + else { + $col = 'red'; + $peer['alert'] = 1; } - } - if ($vars['graph'] == 'updates') { $peer['graph'] = 1; } + if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { + $admin_col = 'green'; + } + else { + $admin_col = 'gray'; + } - if ($peer['graph']) - { - $graph_array['height'] = "100"; - $graph_array['width'] = "218"; - $graph_array['to'] = $config['time']['now']; - echo('"); - } - } + $peerhost = dbFetchRow('SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($peer['bgpPeerIdentifier'])); - echo("
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    '); + if ($peer['bgpPeerAdminStatus'] == 'stop') { + $peer['alert'] = 0; + $peer['disabled'] = 1; + } - include("includes/print-graphrow.inc.php"); + if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { + $peer_type = "iBGP"; + } + else { + $peer_type = "eBGP"; + if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { + $peer_type = "Priv eBGP"; + } + } - echo("
    "); -} + if ($peerhost) { + $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); + } + else { + unset($peername); + } + // display overlib graphs + $graph_type = 'bgp_updates'; + $local_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150&&afi=ipv4&safi=unicast'; + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); + } + else { + $peer_ip = $peer['bgpLocalAddr']; + } + + $localaddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ip.''; + + $graph_type = 'bgp_updates'; + $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; + if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { + $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } + else { + $peer_ident = $peer['bgpPeerIdentifier']; + } + + $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ident.''; + + echo ''; + + unset($sep); + foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep.$afi.'.'.$safi; + $sep = '
    '; + $peer['afisafi'][$this_afisafi] = 1; + // Build a list of valid AFI/SAFI for this peer + } + + unset($sep); + + echo ' + '.$localaddresslink.'
    '.generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')).' + » + '.$peeraddresslink." + $peer_type + ".$peer['afi'].' + AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']." + ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    + '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    + Updates ".format_si($peer['bgpPeerInUpdates'])." + ".format_si($peer['bgpPeerOutUpdates']).''; + + unset($invalid); + switch ($vars['graph']) { + case 'prefixes_ipv4unicast': + case 'prefixes_ipv4multicast': + case 'prefixes_ipv4vpn': + case 'prefixes_ipv6unicast': + case 'prefixes_ipv6multicast': + list(,$afisafi) = explode('_', $vars['graph']); + if (isset($peer['afisafi'][$afisafi])) { + $peer['graph'] = 1; + } + + case 'updates': + $graph_array['type'] = 'bgp_'.$vars['graph']; + $graph_array['id'] = $peer['bgpPeer_id']; + } + + switch ($vars['graph']) { + case 'macaccounting_bits': + case 'macaccounting_pkts': + $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; + if (is_array($acc) && is_file($database)) { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['graph']; + } + } + + if ($vars['graph'] == 'updates') { + $peer['graph'] = 1; + } + + if ($peer['graph']) { + $graph_array['height'] = '100'; + $graph_array['width'] = '218'; + $graph_array['to'] = $config['time']['now']; + echo ''; + + include 'includes/print-graphrow.inc.php'; + + echo ''; + } + }//end foreach + + echo ''; +}//end if diff --git a/html/pages/routing/overview.inc.php b/html/pages/routing/overview.inc.php index bd9a9e63e..c16262143 100644 --- a/html/pages/routing/overview.inc.php +++ b/html/pages/routing/overview.inc.php @@ -1,7 +1,7 @@ 'IPv4 Address', 'ipv6' => 'IPv6 Address', 'mac' => 'MAC Address', 'arp' => 'ARP Table'); +$sections = array( + 'ipv4' => 'IPv4 Address', + 'ipv6' => 'IPv6 Address', + 'mac' => 'MAC Address', + 'arp' => 'ARP Table', +); -if( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { - $sections['packages'] = 'Packages'; +if (dbFetchCell('SELECT 1 from `packages` LIMIT 1')) { + $sections['packages'] = 'Packages'; } -if (!isset($vars['search'])) { $vars['search'] = "ipv4"; } +if (!isset($vars['search'])) { + $vars['search'] = 'ipv4'; +} print_optionbar_start('', ''); - echo('Search » '); +echo 'Search » '; unset($sep); -foreach ($sections as $type => $texttype) -{ - echo($sep); - if ($vars['search'] == $type) - { - echo(""); - } +foreach ($sections as $type => $texttype) { + echo $sep; + if ($vars['search'] == $type) { + echo ""; + } -# echo('' . $texttype .''); - echo(generate_link($texttype, array('page'=>'search','search'=>$type))); + // echo('' . $texttype .''); + echo generate_link($texttype, array('page' => 'search', 'search' => $type)); - if ($vars['search'] == $type) { echo(""); } + if ($vars['search'] == $type) { + echo ''; + } - $sep = ' | '; + $sep = ' | '; } -unset ($sep); + +unset($sep); print_optionbar_end('', ''); -if( file_exists('pages/search/'.$vars['search'].'.inc.php') ) { - include('pages/search/'.$vars['search'].'.inc.php'); -} else { - echo(report_this('Unknown search type '.$vars['search'])); +if (file_exists('pages/search/'.$vars['search'].'.inc.php')) { + include 'pages/search/'.$vars['search'].'.inc.php'; +} +else { + echo report_this('Unknown search type '.$vars['search']); } - -?> diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index a4dcbd113..45cd6888a 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -30,21 +30,22 @@ var grid = $("#arp-search").bootgrid({ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -53,18 +54,16 @@ foreach (dbFetchRows($sql,$param) as $data) { " "\" class=\"form-control input-sm\" placeholder=\"Address\" />"+ diff --git a/html/pages/search/ipv4.inc.php b/html/pages/search/ipv4.inc.php index e2ea785c0..843acbd1b 100644 --- a/html/pages/search/ipv4.inc.php +++ b/html/pages/search/ipv4.inc.php @@ -27,22 +27,23 @@ var grid = $("#ipv4-search").bootgrid({ ""+ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -52,18 +53,16 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
     "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ "
     "+ ""+ "
    "+ diff --git a/html/pages/search/ipv6.inc.php b/html/pages/search/ipv6.inc.php index 8ab58d9ff..2b9115013 100644 --- a/html/pages/search/ipv6.inc.php +++ b/html/pages/search/ipv6.inc.php @@ -26,22 +26,23 @@ var grid = $("#ipv6-search").bootgrid({ ""+ '.$data['hostname'].'"+'); + + echo '">'.$data['hostname'].'"+'; } ?> ""+ @@ -51,9 +52,8 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
    "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index c040a1e16..f606e4436 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -26,21 +26,22 @@ var grid = $("#mac-search").bootgrid({ ""+ @@ -50,17 +51,15 @@ foreach (dbFetchRows($sql,$param) as $data) { ""+ ""+ "
    0) { + +if(isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} -else { +} else { $results = 50; } @@ -34,49 +34,37 @@ echo '
    '; if ($_SESSION['userlevel'] >= '10') { - echo ''; + echo(''); } echo ' '); -echo ''; +$count_query = "SELECT COUNT(id)"; +$full_query = "SELECT *"; -$count_query = 'SELECT COUNT(id)'; -$full_query = 'SELECT *'; +$query = " FROM `alert_templates`"; -$query = ' FROM `alert_templates`'; - -$count_query = $count_query.$query; -$count = dbFetchCell($count_query, $param); -if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { +$count_query = $count_query . $query; +$count = dbFetchCell($count_query,$param); +if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} -else { +} else { $page_number = $_POST['page_number']; } +$start = ($page_number - 1) * $results; +$full_query = $full_query . $query . " LIMIT $start,$results"; -$start = (($page_number - 1) * $results); -$full_query = $full_query.$query." LIMIT $start,$results"; - -foreach (dbFetchRows($full_query, $param) as $template) { +foreach( dbFetchRows($full_query, $param) as $template ) { echo ' '.$template['name'].' '; @@ -85,15 +73,14 @@ foreach (dbFetchRows($full_query, $param) as $template) { echo " "; echo ""; } - echo ' '; } -if (($count % $results) > 0) { - echo ' - '.generate_pagination($count, $results, $page_number).' - '; +if($count % $results > 0) { + echo(' + '. generate_pagination($count,$results,$page_number) .' + '); } echo ' diff --git a/html/includes/print-alerts.inc.php b/html/includes/print-alerts.inc.php index d9758a0f3..dcbab4b3d 100644 --- a/html/includes/print-alerts.inc.php +++ b/html/includes/print-alerts.inc.php @@ -1,49 +1,49 @@ - - '.$alert_entry['time_logged'].' - '; +echo(' + + ' . $alert_entry['time_logged'] . ' + '); if (!isset($alert_entry['device'])) { - $dev = device_by_id_cache($alert_entry['device_id']); - echo ' - '.generate_device_link($dev, shorthost($dev['hostname'])).' - '; + $dev = device_by_id_cache($alert_entry['device_id']); + echo(" + " . generate_device_link($dev, shorthost($dev['hostname'])) . " + "); } -echo ''.htmlspecialchars($alert_entry['name']).''; +echo("".htmlspecialchars($alert_entry['name']) . ""); -if ($alert_state != '') { - if ($alert_state == '0') { - $glyph_icon = 'ok'; +if ($alert_state!='') { + if ($alert_state=='0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - else if ($alert_state == '1') { - $glyph_icon = 'remove'; + elseif ($alert_state=='1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - else if ($alert_state == '2') { - $glyph_icon = 'info-sign'; + elseif ($alert_state=='2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - else if ($alert_state == '3') { - $glyph_icon = 'arrow-down'; + elseif ($alert_state=='3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - else if ($alert_state == '4') { - $glyph_icon = 'arrow-up'; + elseif ($alert_state=='4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - }//end if - echo " $text"; -}//end if + $text = 'Better'; + } + echo(" $text"); +} -echo ''; +echo(""); diff --git a/html/includes/print-debug.php b/html/includes/print-debug.php index 7fdbbcc6d..f35cd05bf 100644 --- a/html/includes/print-debug.php +++ b/html/includes/print-debug.php @@ -1,6 +1,6 @@ @@ -14,23 +14,25 @@ @@ -50,25 +52,26 @@ foreach ($sql_debug as $sql_error) { @@ -95,12 +97,10 @@ if ($_SESSION['userlevel'] >= '10') { if (is_admin() === TRUE || is_read() === TRUE) { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; -} -else { +} else { $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`"; $param[] = $_SESSION['user_id']; } - foreach (dbFetchRows($sql,$param) as $devtype) { if (empty($devtype['type'])) { $devtype['type'] = 'generic'; @@ -108,10 +108,9 @@ foreach (dbFetchRows($sql,$param) as $devtype) { echo('
  • ' . ucfirst($devtype['type']) . '
  • '); } -require_once '../includes/device-groups.inc.php'; - +require_once('../includes/device-groups.inc.php'); foreach( GetDeviceGroups() as $group ) { - echo '
  • '.ucfirst($group['name']).'
  • '; + echo '
  • '.ucfirst($group['name']).'
  • '; } unset($group); @@ -119,24 +118,29 @@ unset($group); '); if ($_SESSION['userlevel'] >= '10') { - if ($config['show_locations']) { - echo(' +if ($config['show_locations']) +{ + + echo(' - '); + Locations + + + '); +} + echo('
  • Manage Groups
  • Add Device
  • @@ -151,7 +155,8 @@ if ($_SESSION['userlevel'] >= '10') {
  • Alerts ('.$service_alerts.')
  • '); } -if ($_SESSION['userlevel'] >= '10') { - echo(' +if ($_SESSION['userlevel'] >= '10') +{ + echo('
  • Add Service
  • Edit Service
  • @@ -190,53 +197,36 @@ if ($_SESSION['userlevel'] >= '10') { 0) { - echo('
  • Errored ('.$ports['errored'].')
  • '); +if ($ports['errored'] > 0) +{ + echo('
  • Errored ('.$ports['errored'].')
  • '); } -if ($ports['ignored'] > 0) { - echo('
  • Ignored ('.$ports['ignored'].')
  • '); +if ($ports['ignored'] > 0) +{ + echo('
  • Ignored ('.$ports['ignored'].')
  • '); } if ($config['enable_billing']) { - echo('
  • Traffic Bills
  • '); - $ifbreak = 1; + echo('
  • Traffic Bills
  • '); $ifbreak = 1; } if ($config['enable_pseudowires']) { - echo('
  • Pseudowires
  • '); - $ifbreak = 1; + echo('
  • Pseudowires
  • '); $ifbreak = 1; } ?> = '5') { - echo(' '); - if ($config['int_customers']) { - echo('
  • Customers
  • '); - $ifbreak = 1; - } - if ($config['int_l2tp']) { - echo('
  • L2TP
  • '); - $ifbreak = 1; - } - if ($config['int_transit']) { - echo('
  • Transit
  • '); - $ifbreak = 1; - } - if ($config['int_peering']) { - echo('
  • Peering
  • '); - $ifbreak = 1; - } - if ($config['int_peering'] && $config['int_transit']) { - echo('
  • Peering + Transit
  • '); - $ifbreak = 1; - } - if ($config['int_core']) { - echo('
  • Core
  • '); - $ifbreak = 1; - } +if ($_SESSION['userlevel'] >= '5') +{ + echo(' '); + if ($config['int_customers']) { echo('
  • Customers
  • '); $ifbreak = 1; } + if ($config['int_l2tp']) { echo('
  • L2TP
  • '); $ifbreak = 1; } + if ($config['int_transit']) { echo('
  • Transit
  • '); $ifbreak = 1; } + if ($config['int_peering']) { echo('
  • Peering
  • '); $ifbreak = 1; } + if ($config['int_peering'] && $config['int_transit']) { echo('
  • Peering + Transit
  • '); $ifbreak = 1; } + if ($config['int_core']) { echo('
  • Core
  • '); $ifbreak = 1; } if (is_array($config['custom_descr']) === FALSE) { $config['custom_descr'] = array($config['custom_descr']); } @@ -249,18 +239,21 @@ if ($_SESSION['userlevel'] >= '5') { } if ($ifbreak) { - echo(' '); + echo(' '); } -if (isset($interface_alerts)) { - echo('
  • Alerts ('.$interface_alerts.')
  • '); +if (isset($interface_alerts)) +{ + echo('
  • Alerts ('.$interface_alerts.')
  • '); } $deleted_ports = 0; -foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) { - if (port_permitted($interface['port_id'], $interface['device_id'])) { - $deleted_ports++; - } +foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) +{ + if (port_permitted($interface['port_id'], $interface['device_id'])) + { + $deleted_ports++; + } } ?> @@ -268,9 +261,7 @@ foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`delete
  • Disabled
  • Deleted ('.$deleted_ports.')'); -} +if ($deleted_ports) { echo('
  • Deleted ('.$deleted_ports.')
  • '); } ?> @@ -279,8 +270,9 @@ if ($deleted_ports) { Processor
  • Storage
  • '); +if ($menu_sensors) +{ + $sep = 0; + echo(' '); } $icons = array('fanspeed'=>'tachometer','humidity'=>'tint','temperature'=>'fire','current'=>'bolt','frequency'=>'line-chart','power'=>'power-off','voltage'=>'bolt','charge'=>'plus-square','dbm'=>'sun-o', 'load'=>'spinner','state'=>'bullseye'); -foreach (array('fanspeed','humidity','temperature') as $item) { - if (isset($menu_sensors[$item])) { - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) { - echo(' '); - $sep = 0; -} - -foreach (array('current','frequency','power','voltage') as $item) { - if (isset($menu_sensors[$item])) { - echo('
  • '.nicecase($item).'
  • '); - unset($menu_sensors[$item]);$sep++; - } -} - -if ($sep && array_keys($menu_sensors)) { - echo(' '); - $sep = 0; -} - -foreach (array_keys($menu_sensors) as $item) { +foreach (array('fanspeed','humidity','temperature') as $item) +{ + if (isset($menu_sensors[$item])) + { echo('
  • '.nicecase($item).'
  • '); unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) +{ + echo(' '); + $sep = 0; +} + +foreach (array('current','frequency','power','voltage') as $item) +{ + if (isset($menu_sensors[$item])) + { + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; + } +} + +if ($sep && array_keys($menu_sensors)) +{ + echo(' '); + $sep = 0; +} + +foreach (array_keys($menu_sensors) as $item) +{ + echo('
  • '.nicecase($item).'
  • '); + unset($menu_sensors[$item]);$sep++; } ?> @@ -337,24 +337,27 @@ foreach (array_keys($menu_sensors) as $item) { $app_count = dbFetchCell("SELECT COUNT(`app_id`) FROM `applications`"); -if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") { +if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") +{ ?> + = '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") { +if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf']+$routing_count['cef']+$routing_count['vrf']) > "0") +{ ?> @@ -427,11 +440,16 @@ if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { = '10') { - if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { - echo(''); - } - echo('
  • Plugin Admin
  • '); +if ($_SESSION['userlevel'] >= '10') +{ + if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) { + echo(' + + '); + } + echo(' +
  • Plugin Admin
  • + '); } ?> @@ -439,8 +457,9 @@ if ($_SESSION['userlevel'] >= '10') { @@ -457,42 +476,50 @@ if(is_file("includes/print-menubar-custom.inc.php")) {
    -"; +"); \ No newline at end of file diff --git a/html/includes/print-service-edit.inc.php b/html/includes/print-service-edit.inc.php index d0ad23a56..0954649d6 100644 --- a/html/includes/print-service-edit.inc.php +++ b/html/includes/print-service-edit.inc.php @@ -1,33 +1,35 @@ Edit Service
    - - + +
    - +
    - +
    - +
    -
    "; -}//end if +"); + +} \ No newline at end of file diff --git a/html/includes/print-syslog.inc.php b/html/includes/print-syslog.inc.php index 1a7564920..09467dd7c 100644 --- a/html/includes/print-syslog.inc.php +++ b/html/includes/print-syslog.inc.php @@ -1,18 +1,23 @@ '; +if (device_permitted($entry['device_id'])) +{ + echo(""); - // Stop shortening hostname. Issue #61 - // $entry['hostname'] = shorthost($entry['hostname'], 20); - if ($vars['page'] != 'device') { - echo ''.$entry['date'].''; - echo ''.generate_device_link($entry).''; - echo ''.$entry['program'].' : '.htmlspecialchars($entry['msg']).''; - } - else { - echo ''.$entry['date'].'   '.$entry['program'].'   '.htmlspecialchars($entry['msg']).''; - } + // Stop shortening hostname. Issue #61 + //$entry['hostname'] = shorthost($entry['hostname'], 20); + + if ($vars['page'] != "device") + { + echo("" . $entry['date'] . ""); + echo("".generate_device_link($entry).""); + echo("" . $entry['program'] . " : " . htmlspecialchars($entry['msg']) . ""); + } else { + echo("" . $entry['date'] . "   " . $entry['program'] . "   " . htmlspecialchars($entry['msg']) . ""); + } + + echo(""); - echo ''; } + +?> diff --git a/html/includes/reports/alert-log.pdf.inc.php b/html/includes/reports/alert-log.pdf.inc.php index d293b474b..5ee0e91ea 100644 --- a/html/includes/reports/alert-log.pdf.inc.php +++ b/html/includes/reports/alert-log.pdf.inc.php @@ -1,83 +1,65 @@ AddPage('L'); -$where = '1'; -if (is_numeric($_GET['device_id'])) { - $where .= ' AND E.device_id = ?'; - $param[] = $_GET['device_id']; -} -if ($_GET['string']) { - $where .= ' AND R.rule LIKE ?'; - $param[] = '%'.$_GET['string'].'%'; -} + $where = "1"; + if (is_numeric($_GET['device_id'])) { + $where .= ' AND E.device_id = ?'; + $param[] = $_GET['device_id']; + } + if ($_GET['string']) { + $where .= " AND R.rule LIKE ?"; + $param[] = "%".$_GET['string']."%"; + } -if ($_SESSION['userlevel'] >= '5') { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; -} -else { - $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; - $param[] = $_SESSION['user_id']; -} + if ($_SESSION['userlevel'] >= '5') { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where ORDER BY `humandate` DESC"; + } else { + $query = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ? ORDER BY `humandate` DESC"; + $param[] = $_SESSION['user_id']; + } -if (isset($_GET['start']) && is_numeric($_GET['start'])) { - $start = mres($_GET['start']); -} -else { - $start = 0; -} + if (isset($_GET['start']) && is_numeric($_GET['start'])) { + $start = mres($_GET['start']); + } else { + $start = 0; + } -if (isset($_GET['results']) && is_numeric($_GET['results'])) { - $numresults = mres($_GET['results']); -} -else { - $numresults = 250; -} + if (isset($_GET['results']) && is_numeric($_GET['results'])) { + $numresults = mres($_GET['results']); + } else { + $numresults = 250; + } -$full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; + $full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; -foreach (dbFetchRows($full_query, $param) as $alert_entry) { - $hostname = gethostbyid(mres($alert_entry['device_id'])); - $alert_state = $alert_entry['state']; + foreach (dbFetchRows($full_query, $param) as $alert_entry) { + $hostname = gethostbyid(mres($alert_entry['device_id'])); + $alert_state = $alert_entry['state']; - if ($alert_state != '') { - if ($alert_state == '0') { - $glyph_color = 'green'; - $text = 'Ok'; - } - else if ($alert_state == '1') { - $glyph_color = 'red'; - $text = 'Alert'; - } - else if ($alert_state == '2') { - $glyph_color = 'lightgrey'; - $text = 'Ack'; - } - else if ($alert_state == '3') { - $glyph_color = 'orange'; - $text = 'Worse'; - } - else if ($alert_state == '4') { - $glyph_color = 'khaki'; - $text = 'Better'; + if ($alert_state!='') { + if ($alert_state=='0') { + $glyph_color = 'green'; + $text = 'Ok'; + } elseif ($alert_state=='1') { + $glyph_color = 'red'; + $text = 'Alert'; + } elseif ($alert_state=='2') { + $glyph_color = 'lightgrey'; + $text = 'Ack'; + } elseif ($alert_state=='3') { + $glyph_color = 'orange'; + $text = 'Worse'; + } elseif ($alert_state=='4') { + $glyph_color = 'khaki'; + $text = 'Better'; + } + $data[] = array($alert_entry['time_logged'],$hostname,htmlspecialchars($alert_entry['name']),$text); } + } - $data[] = array( - $alert_entry['time_logged'], - $hostname, - htmlspecialchars($alert_entry['name']), - $text, - ); - }//end if -}//end foreach - -$header = array( - 'Datetime', - 'Device', - 'Log', - 'Status', -); +$header = array('Datetime', 'Device', 'Log', 'Status'); $table = << @@ -92,19 +74,17 @@ EOD; foreach ($data as $log) { if ($log[3] == 'Alert') { $tr_col = '#d39392'; - } - else { + } else { $tr_col = '#bbd392'; } - $table .= ' - + '.$log[0].' '.$log[1].' '.$log[2].' '.$log[3].' - - '; + + '; } $table .= << $value) { - if ($value != '') { - switch ($var) { - case 'hostname': - $where .= ' AND D.hostname LIKE ?'; - $param[] = '%'.$value.'%'; - break; +foreach ($vars as $var => $value) +{ + if ($value != "") + { + switch ($var) + { + case 'hostname': + $where .= " AND D.hostname LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'location': + $where .= " AND D.location LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'device_id': + $where .= " AND D.device_id = ?"; + $param[] = $value; + break; + case 'deleted': + case 'ignore': + if ($value == 1) + { + $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; + } + break; + case 'disable': + case 'ifSpeed': + if (is_numeric($value)) + { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'errors': + if ($value == 1) + { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + case 'state': + if ($value == "down") + { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; + $param[] = "up"; + $param[] = "down"; + } elseif($value == "up") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = "up"; + $param[] = "up"; + } elseif($value == "admindown") { + $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; + $param[] = "down"; + } + break; + } + } +} - case 'location': - $where .= ' AND D.location LIKE ?'; - $param[] = '%'.$value.'%'; - break; - - case 'device_id': - $where .= ' AND D.device_id = ?'; - $param[] = $value; - break; - - case 'deleted': - case 'ignore': - if ($value == 1) { - $where .= ' AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0'; - } - break; - - case 'disable': - case 'ifSpeed': - if (is_numeric($value)) { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = '%'.$value.'%'; - break; - - case 'errors': - if ($value == 1) { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - - case 'state': - if ($value == 'down') { - $where .= 'AND I.ifAdminStatus = ? AND I.ifOperStatus = ?'; - $param[] = 'up'; - $param[] = 'down'; - } - else if ($value == 'up') { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = 'up'; - $param[] = 'up'; - } - else if ($value == 'admindown') { - $where .= 'AND I.ifAdminStatus = ? AND D.ignore = 0'; - $param[] = 'down'; - } - break; - }//end switch - }//end if -}//end foreach - -$query = 'SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id '.$where.' '.$query_sort; +$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ".$query_sort; $row = 1; -list($format, $subformat) = explode('_', $vars['format']); +list($format, $subformat) = explode("_", $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) { -case 'traffic': +switch ($vars['sort']) +{ + case 'traffic': $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); break; - -case 'traffic_in': + case 'traffic_in': $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); break; - -case 'traffic_out': + case 'traffic_out': $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); break; - -case 'packets': + case 'packets': $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); break; - -case 'packets_in': + case 'packets_in': $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); break; - -case 'packets_out': + case 'packets_out': $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); break; - -case 'errors': + case 'errors': $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); break; - -case 'speed': + case 'speed': $ports = array_sort($ports, 'ifSpeed', SORT_DESC); break; - -case 'port': + case 'port': $ports = array_sort($ports, 'ifDescr', SORT_ASC); break; - -case 'media': + case 'media': $ports = array_sort($ports, 'ifType', SORT_ASC); break; - -case 'descr': + case 'descr': $ports = array_sort($ports, 'ifAlias', SORT_ASC); break; - -case 'device': -default: + case 'device': + default: $ports = array_sort($ports, 'hostname', SORT_ASC); -}//end switch - -$csv[] = array( - 'Device', - 'Port', - 'Speed', - 'Down', - 'Up', - 'Media', - 'Description', -); -foreach ($ports as $port) { - if (port_permitted($port['port_id'], $port['device_id'])) { - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); - $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); - $port = ifLabel($port, $device); - $csv[] = array( - $port['hostname'], - fixIfName($port['label']), - $speed, - $port['in_rate'], - $port['out_rate'], - $type, - $port['ifAlias'], - ); - } } + +$csv[] = array('Device','Port','Speed','Down','Up','Media','Description'); +foreach( $ports as $port ) { + if( port_permitted($port['port_id'], $port['device_id']) ) { + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); + $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); + $port = ifLabel($port, $device); + $csv[] = array($port['hostname'],fixIfName($port['label']),$speed,$port['in_rate'],$port['out_rate'],$type,$port['ifAlias']); + } +} +?> diff --git a/html/includes/service-add.inc.php b/html/includes/service-add.inc.php index cf1433b27..3bc9eca63 100644 --- a/html/includes/service-add.inc.php +++ b/html/includes/service-add.inc.php @@ -5,6 +5,6 @@ $updated = '1'; $service_id = add_service(mres($_POST['device']), mres($_POST['type']), mres($_POST['descr']), mres($_POST['ip']), mres($_POST['params'])); if ($service_id) { - $message .= $message_break.'Service added ('.$service_id.')!'; - $message_break .= '
    '; -} + $message .= $message_break . "Service added (".$service_id.")!"; + $message_break .= "
    "; +} \ No newline at end of file diff --git a/html/includes/table/address-search.inc.php b/html/includes/table/address-search.inc.php index 25eb75360..a50d06afc 100644 --- a/html/includes/table/address-search.inc.php +++ b/html/includes/table/address-search.inc.php @@ -2,64 +2,56 @@ $param = array(); -if (is_admin() === false && is_read() === false) { - $perms_sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; - $where .= ' AND `DP`.`user_id`=?'; - $param[] = array($_SESSION['user_id']); +if (is_admin() === FALSE && is_read() === FALSE) { + $perms_sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; + $param[] = array($_SESSION['user_id']); } -list($address,$prefix) = explode('/', $_POST['address']); +list($address,$prefix) = explode("/", $_POST['address']); if ($_POST['search_type'] == 'ipv4') { - $sql = ' FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D'; + $sql = " FROM `ipv4_addresses` AS A, `ports` AS I, `ipv4_networks` AS N, `devices` AS D"; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id $where "; if (!empty($address)) { $sql .= " AND ipv4_address LIKE '%".$address."%'"; } - if (!empty($prefix)) { - $sql .= " AND ipv4_prefixlen='?'"; + $sql .= " AND ipv4_prefixlen='?'"; $param[] = array($prefix); } -} -else if ($_POST['search_type'] == 'ipv6') { - $sql = ' FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D'; +} elseif ($_POST['search_type'] == 'ipv6') { + $sql = " FROM `ipv6_addresses` AS A, `ports` AS I, `ipv6_networks` AS N, `devices` AS D"; $sql .= $perms_sql; $sql .= " WHERE I.port_id = A.port_id AND I.device_id = D.device_id AND N.ipv6_network_id = A.ipv6_network_id $where "; if (!empty($address)) { $sql .= " AND (ipv6_address LIKE '%".$address."%' OR ipv6_compressed LIKE '%".$address."%')"; } - if (!empty($prefix)) { $sql .= " AND ipv6_prefixlen = '$prefix'"; } -} -else if ($_POST['search_type'] == 'mac') { - $sql = ' FROM `ports` AS I, `devices` AS D'; +} elseif ($_POST['search_type'] == 'mac') { + $sql = " FROM `ports` AS I, `devices` AS D"; $sql .= $perms_sql; - $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address']))."%' $where "; -}//end if + $sql .= " WHERE I.device_id = D.device_id AND `ifPhysAddress` LIKE '%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%' $where "; +} if (is_numeric($_POST['device_id'])) { - $sql .= ' AND I.device_id = ?'; + $sql .= " AND I.device_id = ?"; $param[] = array($_POST['device_id']); } - if ($_POST['interface']) { - $sql .= " AND I.ifDescr LIKE '?'"; + $sql .= " AND I.ifDescr LIKE '?'"; $param[] = array($_POST['interface']); } if ($_POST['search_type'] == 'ipv4') { $count_sql = "SELECT COUNT(`ipv4_address_id`) $sql"; -} -else if ($_POST['search_type'] == 'ipv6') { +} elseif ($_POST['search_type'] == 'ipv6') { $count_sql = "SELECT COUNT(`ipv6_address_id`) $sql"; +} elseif ($_POST['search_type'] == 'mac') { + $count_sql = "SELECT COUNT(`port_id`) $sql"; } -else if ($_POST['search_type'] == 'mac') { - $count_sql = "SELECT COUNT(`port_id`) $sql"; -} - -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -71,7 +63,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -83,42 +75,31 @@ $sql = "SELECT *,`I`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $interface) { $speed = humanspeed($interface['ifSpeed']); - $type = humanmedia($interface['ifType']); + $type = humanmedia($interface['ifType']); if ($_POST['search_type'] == 'ipv6') { - list($prefix, $length) = explode('/', $interface['ipv6_network']); - $address = Net_IPv6::compress($interface['ipv6_address']).'/'.$length; - } - else if ($_POST['search_type'] == 'mac') { + list($prefix, $length) = explode("/", $interface['ipv6_network']); + $address = Net_IPv6::compress($interface['ipv6_address']) . '/'.$length; + } elseif ($_POST['search_type'] == 'mac') { $address = formatMac($interface['ifPhysAddress']); - } - else { - list($prefix, $length) = explode('/', $interface['ipv4_network']); - $address = $interface['ipv4_address'].'/'.$length; + } else { + list($prefix, $length) = explode("/", $interface['ipv4_network']); + $address = $interface['ipv4_address'] . '/' .$length; } if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) { - $error_img = generate_port_link($interface, "Interface Errors", errors); + $error_img = generate_port_link($interface,"Interface Errors",errors); + } else { + $error_img = ""; } - else { - $error_img = ''; - } - if (port_permitted($interface['port_id'])) { - $interface = ifLabel($interface, $interface); - $response[] = array( - 'hostname' => generate_device_link($interface), - 'interface' => generate_port_link($interface).' '.$error_img, - 'address' => $address, - 'description' => $interface['ifAlias'], - ); + $interface = ifLabel ($interface, $interface); + $response[] = array('hostname'=>generate_device_link($interface), + 'interface'=>generate_port_link($interface) . ' ' . $error_img, + 'address'=>$address, + 'description'=>$interface['ifAlias']); } -}//end foreach +} -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/alert-schedule.inc.php b/html/includes/table/alert-schedule.inc.php index 5d2bfa9b8..635e67be9 100644 --- a/html/includes/table/alert-schedule.inc.php +++ b/html/includes/table/alert-schedule.inc.php @@ -16,9 +16,8 @@ $where = 1; if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_schedule` AS S WHERE $where"; -} -else { - $sql = " FROM `alert_schedule` AS S WHERE $where"; +} else { + $sql = " FROM `alert_schedule` AS S WHERE $where"; $param[] = $_SESSION['user_id']; } @@ -27,7 +26,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -39,7 +38,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -49,29 +48,20 @@ if ($rowCount != -1) { $sql = "SELECT `S`.`schedule_id`, DATE_FORMAT(`S`.`start`, '".$config['dateformat']['mysql']['compact']."') AS `start`, DATE_FORMAT(`S`.`end`, '".$config['dateformat']['mysql']['compact']."') AS `end`, `S`.`title` $sql"; -foreach (dbFetchRows($sql, $param) as $schedule) { +foreach (dbFetchRows($sql,$param) as $schedule) { $status = 0; if ($schedule['end'] < date('dS M Y H:i::s')) { $status = 1; } - if (date('dS M Y H:i::s') >= $schedule['start'] && date('dS M Y H:i::s') < $schedule['end']) { $status = 2; } - - $response[] = array( - 'title' => $schedule['title'], - 'start' => $schedule['start'], - 'end' => $schedule['end'], - 'id' => $schedule['schedule_id'], - 'status' => $status, - ); + $response[] = array('title'=>$schedule['title'], + 'start'=>$schedule['start'], + 'end'=>$schedule['end'], + 'id'=>$schedule['schedule_id'], + 'status'=>$status); } -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/alertlog.inc.php b/html/includes/table/alertlog.inc.php index 8b4d94d3e..0c8e515e6 100644 --- a/html/includes/table/alertlog.inc.php +++ b/html/includes/table/alertlog.inc.php @@ -3,15 +3,14 @@ $where = 1; if (is_numeric($_POST['device_id'])) { - $where .= ' AND E.device_id = ?'; + $where .= ' AND E.device_id = ?'; $param[] = $_POST['device_id']; } if ($_SESSION['userlevel'] >= '5') { $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where"; -} -else { - $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; +} else { + $sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id RIGHT JOIN devices_perms AS P ON E.device_id = P.device_id WHERE $where AND P.user_id = ?"; $param[] = array($_SESSION['user_id']); } @@ -20,7 +19,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(`E`.`id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -32,7 +31,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -43,49 +42,42 @@ if ($rowCount != -1) { $sql = "SELECT D.device_id,name AS alert,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate,details $sql"; $rulei = 0; -foreach (dbFetchRows($sql, $param) as $alertlog) { - $dev = device_by_id_cache($alertlog['device_id']); +foreach (dbFetchRows($sql,$param) as $alertlog) { + $dev = device_by_id_cache($alertlog['device_id']); $fault_detail = alert_details($alertlog['details']); - $alert_state = $alertlog['state']; - if ($alert_state == '0') { - $glyph_icon = 'ok'; + $alert_state = $alertlog['state']; + if ($alert_state=='0') { + $glyph_icon = 'ok'; $glyph_color = 'green'; - $text = 'Ok'; + $text = 'Ok'; } - else if ($alert_state == '1') { - $glyph_icon = 'remove'; + elseif ($alert_state=='1') { + $glyph_icon = 'remove'; $glyph_color = 'red'; - $text = 'Alert'; + $text = 'Alert'; } - else if ($alert_state == '2') { - $glyph_icon = 'info-sign'; + elseif ($alert_state=='2') { + $glyph_icon = 'info-sign'; $glyph_color = 'lightgrey'; - $text = 'Ack'; + $text = 'Ack'; } - else if ($alert_state == '3') { - $glyph_icon = 'arrow-down'; + elseif ($alert_state=='3') { + $glyph_icon = 'arrow-down'; $glyph_color = 'orange'; - $text = 'Worse'; + $text = 'Worse'; } - else if ($alert_state == '4') { - $glyph_icon = 'arrow-up'; + elseif ($alert_state=='4') { + $glyph_icon = 'arrow-up'; $glyph_color = 'khaki'; - $text = 'Better'; - }//end if - $response[] = array( - 'id' => $rulei++, - 'time_logged' => $alertlog['humandate'], - 'details' => '', - 'hostname' => '
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', - 'alert' => htmlspecialchars($alertlog['alert']), - 'status' => " $text", - ); -}//end foreach + $text = 'Better'; + } + $response[] = array('id'=>$rulei++, + 'time_logged'=>$alertlog['humandate'], + 'details'=>'', + 'hostname'=>'
    '.generate_device_link($dev, shorthost($dev['hostname'])).'
    '.$fault_detail.'
    ', + 'alert'=>htmlspecialchars($alertlog['alert']), + 'status'=>" $text"); +} -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); -echo _json_encode($output); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +echo _json_encode($output); diff --git a/html/includes/table/alerts.inc.php b/html/includes/table/alerts.inc.php index 2efab5d1f..799404b1a 100644 --- a/html/includes/table/alerts.inc.php +++ b/html/includes/table/alerts.inc.php @@ -10,18 +10,18 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { $sql_search .= " AND (`timestamp` LIKE '%$searchPhrase%' OR `rule` LIKE '%$searchPhrase%' OR `name` LIKE '%$searchPhrase%' OR `hostname` LIKE '%$searchPhrase%')"; } -$sql = ' FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`'; +$sql = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`"; -if (is_admin() === false && is_read() === false) { - $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; - $where .= ' AND `DP`.`user_id`=?'; +if (is_admin() === FALSE && is_read() === FALSE) { + $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; $param[] = $_SESSION['user_id']; } $sql .= " RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE $where AND `state` IN (1,2,3,4) $sql_search"; $count_sql = "SELECT COUNT(`alerts`.`id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -33,7 +33,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -43,86 +43,76 @@ if ($rowCount != -1) { $sql = "SELECT `alerts`.*, `devices`.`hostname` AS `hostname`,`alert_rules`.`rule` AS `rule`, `alert_rules`.`name` AS `name`, `alert_rules`.`severity` AS `severity` $sql"; -$rulei = 0; +$rulei = 0; $format = $_POST['format']; -foreach (dbFetchRows($sql, $param) as $alert) { - $log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', array($alert['rule_id'], $alert['device_id'])); +foreach (dbFetchRows($sql,$param) as $alert) { + $log = dbFetchCell("SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1", array($alert['rule_id'],$alert['device_id'])); $fault_detail = alert_details($log); - $ico = 'ok'; - $col = 'green'; - $extra = ''; - $msg = ''; - if ((int) $alert['state'] === 0) { - $ico = 'ok'; - $col = 'green'; - $extra = 'success'; - $msg = 'ok'; - } - else if ((int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { - $ico = 'volume-up'; - $col = 'red'; - $extra = 'danger'; - $msg = 'alert'; - if ((int) $alert['state'] === 3) { - $msg = 'worse'; - } - else if ((int) $alert['state'] === 4) { - $msg = 'better'; + $ico = "ok"; + $col = "green"; + $extra = ""; + $msg = ""; + if ( (int) $alert['state'] === 0 ) { + $ico = "ok"; + $col = "green"; + $extra = "success"; + $msg = "ok"; + } elseif ( (int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { + $ico = "volume-up"; + $col = "red"; + $extra = "danger"; + $msg = "alert"; + if ( (int) $alert['state'] === 3) { + $msg = "worse"; + } elseif ( (int) $alert['state'] === 4) { + $msg = "better"; } + } elseif ( (int) $alert['state'] === 2) { + $ico = "volume-off"; + $col = "#800080"; + $extra = "warning"; + $msg = "muted"; } - else if ((int) $alert['state'] === 2) { - $ico = 'volume-off'; - $col = '#800080'; - $extra = 'warning'; - $msg = 'muted'; - }//end if $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; $severity = $alert['severity']; if ($alert['state'] == 3) { - $severity .= ' +'; - } - else if ($alert['state'] == 4) { - $severity .= ' -'; + $severity .= " +"; + } elseif ($alert['state'] == 4) { + $severity .= " -"; } $ack_ico = 'volume-up'; $ack_col = 'success'; - if ($alert['state'] == 2) { + if($alert['state'] == 2) { $ack_ico = 'volume-off'; $ack_col = 'danger'; - } + } $hostname = ' -
    - '.generate_device_link($alert).' -
    '.$fault_detail.'
    -
    '; +
    + '.generate_device_link($alert).' +
    '.$fault_detail.'
    +
    '; - $response[] = array( - 'id' => $rulei++, - 'rule' => ''.htmlentities($alert['name']).'', - 'details' => '', - 'hostname' => $hostname, - 'timestamp' => ($alert['timestamp'] ? $alert['timestamp'] : 'N/A'), - 'severity' => $severity, - 'ack_col' => $ack_col, - 'state' => $alert['state'], - 'alert_id' => $alert['id'], - 'ack_ico' => $ack_ico, - 'extra' => $extra, - 'msg' => $msg, - ); -}//end foreach + $response[] = array('id'=>$rulei++, + 'rule'=>"".htmlentities($alert['name'])."", + 'details'=>'', + 'hostname'=>$hostname, + 'timestamp'=>($alert['timestamp'] ? $alert['timestamp'] : "N/A"), + 'severity'=>$severity, + 'ack_col'=>$ack_col, + 'state'=>$alert['state'], + 'alert_id'=>$alert['id'], + 'ack_ico'=>$ack_ico, + 'extra'=>$extra, + 'msg'=>$msg); -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +} + +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index 090476048..dd5c6225e 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -2,33 +2,32 @@ $param = array(); -$sql .= ' FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D '; +$sql .= " FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D "; -if (is_admin() === false && is_read() === false) { - $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`'; - $where .= ' AND `DP`.`user_id`=?'; +if (is_admin() === FALSE && is_read() === FALSE) { + $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; $param[] = $_SESSION['user_id']; } $sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where "; -if (isset($_POST['searchby']) && $_POST['searchby'] == 'ip') { - $sql .= ' AND `ipv4_address` LIKE ?'; - $param[] = '%'.trim($_POST['address']).'%'; -} -else if (isset($_POST['searchby']) && $_POST['searchby'] == 'mac') { - $sql .= ' AND `mac_address` LIKE ?'; - $param[] = '%'.str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address'])).'%'; +if (isset($_POST['searchby']) && $_POST['searchby'] == "ip") { + $sql .= " AND `ipv4_address` LIKE ?"; + $param[] = "%".trim($_POST['address'])."%"; +} elseif (isset($_POST['searchby']) && $_POST['searchby'] == "mac") { + $sql .= " AND `mac_address` LIKE ?"; + $param[] = "%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"; } if (is_numeric($_POST['device_id'])) { - $sql .= ' AND P.device_id = ?'; + $sql .= " AND P.device_id = ?"; $param[] = $_POST['device_id']; } $count_sql = "SELECT COUNT(`M`.`port_id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -40,7 +39,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -52,53 +51,39 @@ $sql = "SELECT *,`P`.`ifDescr` AS `interface` $sql"; foreach (dbFetchRows($sql, $param) as $entry) { if (!$ignore) { + if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) { - $error_img = generate_port_link($entry, "Interface Errors", port_errors); - } - else { - $error_img = ''; + $error_img = generate_port_link($entry,"Interface Errors",port_errors); + } else { + $error_img = ""; } - $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($entry['ipv4_address'])); - if ($arp_host) { - $arp_name = generate_device_link($arp_host); - } - else { - unset($arp_name); - } - - if ($arp_host) { - $arp_if = generate_port_link($arp_host); - } - else { - unset($arp_if); - } - - if ($arp_host['device_id'] == $entry['device_id']) { - $arp_name = 'Localhost'; - } - - if ($arp_host['port_id'] == $entry['port_id']) { - $arp_if = 'Local port'; - } - - $response[] = array( - 'mac_address' => formatMac($entry['mac_address']), - 'ipv4_address' => $entry['ipv4_address'], - 'hostname' => generate_device_link($entry), - 'interface' => generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))).' '.$error_img, - 'remote_device' => $arp_name, - 'remote_interface' => $arp_if, - ); - }//end if - + $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($entry['ipv4_address'])); + if ($arp_host) { + $arp_name = generate_device_link($arp_host); + } else { + unset($arp_name); + } + if ($arp_host) { + $arp_if = generate_port_link($arp_host); + } else { + unset($arp_if); + } + if ($arp_host['device_id'] == $entry['device_id']) { + $arp_name = "Localhost"; + } + if ($arp_host['port_id'] == $entry['port_id']) { + $arp_if = "Local port"; + } + $response[] = array('mac_address'=>formatMac($entry['mac_address']), + 'ipv4_address'=>$entry['ipv4_address'], + 'hostname'=>generate_device_link($entry), + 'interface'=>generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, + 'remote_device'=>$arp_name, + 'remote_interface'=>$arp_if); + } unset($ignore); -}//end foreach +} -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/devices.inc.php b/html/includes/table/devices.inc.php index 129e198f2..25cf21bd5 100644 --- a/html/includes/table/devices.inc.php +++ b/html/includes/table/devices.inc.php @@ -3,11 +3,11 @@ $where = 1; $param = array(); -$sql = ' FROM `devices`'; +$sql = " FROM `devices`"; -if (is_admin() === false && is_read() === false) { - $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`'; - $where .= ' AND `DP`.`user_id`=?'; +if (is_admin() === FALSE && is_read() === FALSE) { + $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; $param[] = $_SESSION['user_id']; } @@ -17,87 +17,48 @@ if (!empty($_POST['location'])) { $sql .= " WHERE $where "; -if (!empty($_POST['hostname'])) { - $sql .= ' AND hostname LIKE ?'; - $param[] = '%'.$_POST['hostname'].'%'; +if (!empty($_POST['hostname'])) { $sql .= " AND hostname LIKE ?"; $param[] = "%".$_POST['hostname']."%"; } +if (!empty($_POST['os'])) { $sql .= " AND os = ?"; $param[] = $_POST['os']; } +if (!empty($_POST['version'])) { $sql .= " AND version = ?"; $param[] = $_POST['version']; } +if (!empty($_POST['hardware'])) { $sql .= " AND hardware = ?"; $param[] = $_POST['hardware']; } +if (!empty($_POST['features'])) { $sql .= " AND features = ?"; $param[] = $_POST['features']; } +if (!empty($_POST['type'])) { + if ($_POST['type'] == 'generic') { + $sql .= " AND ( type = ? OR type = '')"; $param[] = $_POST['type']; + } else { + $sql .= " AND type = ?"; $param[] = $_POST['type']; + } } - -if (!empty($_POST['os'])) { - $sql .= ' AND os = ?'; - $param[] = $_POST['os']; -} - -if (!empty($_POST['version'])) { - $sql .= ' AND version = ?'; - $param[] = $_POST['version']; -} - -if (!empty($_POST['hardware'])) { - $sql .= ' AND hardware = ?'; - $param[] = $_POST['hardware']; -} - -if (!empty($_POST['features'])) { - $sql .= ' AND features = ?'; - $param[] = $_POST['features']; -} - -if (!empty($_POST['type'])) { - if ($_POST['type'] == 'generic') { - $sql .= " AND ( type = ? OR type = '')"; - $param[] = $_POST['type']; - } - else { - $sql .= ' AND type = ?'; - $param[] = $_POST['type']; - } -} - if (!empty($_POST['state'])) { - $sql .= ' AND status= ?'; - if (is_numeric($_POST['state'])) { + $sql .= " AND status= ?"; + if( is_numeric($_POST['state']) ) { $param[] = $_POST['state']; - } - else { - $param[] = str_replace(array('up', 'down'), array(1, 0), $_POST['state']); + } else { + $param[] = str_replace(array('up','down'),array(1,0),$_POST['state']); } } - -if (!empty($_POST['disabled'])) { - $sql .= ' AND disabled= ?'; - $param[] = $_POST['disabled']; -} - -if (!empty($_POST['ignore'])) { - $sql .= ' AND `ignore`= ?'; - $param[] = $_POST['ignore']; -} - -if (!empty($_POST['location']) && $_POST['location'] == 'Unset') { - $location_filter = ''; -} - +if (!empty($_POST['disabled'])) { $sql .= " AND disabled= ?"; $param[] = $_POST['disabled']; } +if (!empty($_POST['ignore'])) { $sql .= " AND `ignore`= ?"; $param[] = $_POST['ignore']; } +if (!empty($_POST['location']) && $_POST['location'] == "Unset") { $location_filter = ''; } if (!empty($_POST['location'])) { - $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; + $sql .= " AND (((`DB`.`attrib_value`='1' AND `DA`.`attrib_type`='override_sysLocation_string' AND `DA`.`attrib_value` = ?)) OR `location` = ?)"; $param[] = mres($_POST['location']); $param[] = mres($_POST['location']); } - -if (!empty($_POST['group'])) { - include_once '../includes/device-groups.inc.php'; - $sql .= ' AND ( '; - foreach (GetDevicesFromGroup($_POST['group']) as $dev) { - $sql .= '`devices`.`device_id` = ? OR '; +if( !empty($_POST['group']) ) { + require_once('../includes/device-groups.inc.php'); + $sql .= " AND ( "; + foreach( GetDevicesFromGroup($_POST['group']) as $dev ) { + $sql .= "`devices`.`device_id` = ? OR "; $param[] = $dev['device_id']; } - - $sql = substr($sql, 0, (strlen($sql) - 3)); - $sql .= ' )'; + $sql = substr($sql, 0, strlen($sql)-3); + $sql .= " )"; } $count_sql = "SELECT COUNT(`devices`.`device_id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -109,7 +70,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -120,124 +81,99 @@ if ($rowCount != -1) { $sql = "SELECT DISTINCT(`devices`.`device_id`),`devices`.* $sql"; if (!isset($_POST['format'])) { - $_POST['format'] = 'list_detail'; + $_POST['format'] = "list_detail"; } - -list($format, $subformat) = explode('_', $_POST['format']); +list($format, $subformat) = explode("_", $_POST['format']); foreach (dbFetchRows($sql, $param) as $device) { - if (isset($bg) && $bg == $list_colour_b) { - $bg = $list_colour_a; - } - else { - $bg = $list_colour_b; - } + if (isset($bg) && $bg == $list_colour_b) { + $bg = $list_colour_a; + } else { + $bg = $list_colour_b; + } - if ($device['status'] == '0') { - $extra = 'danger'; - $msg = $device['status_reason']; - } - else { - $extra = 'success'; - $msg = 'up'; - } + if ($device['status'] == '0') { + $extra = "danger"; + $msg = $device['status_reason']; + } else { + $extra = "success"; + $msg = "up"; + } + if ($device['ignore'] == '1') { + $extra = "default"; + $msg = "ignored"; + if ($device['status'] == '1') { + $extra = "warning"; + $msg = "ignored"; + } + } + if ($device['disabled'] == '1') { + $extra = "default"; + $msg = "disabled"; + } - if ($device['ignore'] == '1') { - $extra = 'default'; - $msg = 'ignored'; - if ($device['status'] == '1') { - $extra = 'warning'; - $msg = 'ignored'; - } - } + $type = strtolower($device['os']); + $image = getImage($device); + + if ($device['os'] == "ios") { + formatCiscoHardware($device, true); + } - if ($device['disabled'] == '1') { - $extra = 'default'; - $msg = 'disabled'; - } + $device['os_text'] = $config['os'][$device['os']]['text']; + $port_count = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?", array($device['device_id'])); + $sensor_count = dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?", array($device['device_id'])); - $type = strtolower($device['os']); - $image = getImage($device); + if (get_dev_attrib($device,'override_sysLocation_bool')) { + $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); + } - if ($device['os'] == 'ios') { - formatCiscoHardware($device, true); - } + $actions = ('
    +
    '); + $actions .= ' View device '; + $actions .= ('
    +
    '); + $actions .= ' View alerts '; + $actions .= '
    '; + if ($_SESSION['userlevel'] >= "7") { + $actions .= ('
    + Edit device +
    '); + } + $actions .= ('
    +
    +
    + telnet +
    +
    + ssh +
    +
    + https +
    +
    '); - $device['os_text'] = $config['os'][$device['os']]['text']; - $port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id'])); - $sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id'])); + $hostname = generate_device_link($device); + $platform = $device['hardware'] . '
    ' . $device['features']; + $os = $device['os_text'] . '
    ' . $device['version']; + if (extension_loaded('mbstring')) { + $location = mb_substr($device['location'], 0, 32, 'utf8'); + } else { + $location = truncate($device['location'], 32, ''); + } + $uptime = formatUptime($device['uptime'], 'short') . '
    ' . $location; + if ($subformat == "detail") { + $hostname .= '
    ' . $device['sysName']; + if ($port_count) { + $col_port = ' '.$port_count . '
    '; + } + if ($sensor_count) { + $col_port .= ' '.$sensor_count; + } + } else { - if (get_dev_attrib($device, 'override_sysLocation_bool')) { - $device['location'] = get_dev_attrib($device, 'override_sysLocation_string'); - } + } + $response[] = array('extra'=>$extra,'msg'=>$msg,'icon'=>$image,'hostname'=>$hostname,'ports'=>$col_port,'hardware'=>$platform,'os'=>$os,'uptime'=>$uptime,'actions'=>$actions); +} - $actions = ('
    -
    '); - $actions .= ' View device '; - $actions .= ('
    -
    '); - $actions .= ' View alerts '; - $actions .= '
    '; - if ($_SESSION['userlevel'] >= '7') { - $actions .= ('
    - Edit device -
    '); - } - - $actions .= ('
    -
    -
    - telnet -
    -
    - ssh -
    -
    - https -
    -
    '); - - $hostname = generate_device_link($device); - $platform = $device['hardware'].'
    '.$device['features']; - $os = $device['os_text'].'
    '.$device['version']; - if (extension_loaded('mbstring')) { - $location = mb_substr($device['location'], 0, 32, 'utf8'); - } - else { - $location = truncate($device['location'], 32, ''); - } - - $uptime = formatUptime($device['uptime'], 'short').'
    '.$location; - if ($subformat == 'detail') { - $hostname .= '
    '.$device['sysName']; - if ($port_count) { - $col_port = ' '.$port_count.'
    '; - } - - if ($sensor_count) { - $col_port .= ' '.$sensor_count; - } - } - else { - } - - $response[] = array( - 'extra' => $extra, - 'msg' => $msg, - 'icon' => $image, - 'hostname' => $hostname, - 'ports' => $col_port, - 'hardware' => $platform, - 'os' => $os, - 'uptime' => $uptime, - 'actions' => $actions, - ); -}//end foreach - -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/eventlog.inc.php b/html/includes/table/eventlog.inc.php index 9cae42296..d5e5e7d60 100644 --- a/html/includes/table/eventlog.inc.php +++ b/html/includes/table/eventlog.inc.php @@ -1,22 +1,23 @@ = '5') { $sql = " FROM `eventlog` AS E LEFT JOIN `devices` AS `D` ON `E`.`host`=`D`.`device_id` WHERE $where"; -} -else { - $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; +} else { + $sql = " FROM `eventlog` AS E, devices_perms AS P WHERE $where AND E.host = P.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -25,7 +26,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } $count_sql = "SELECT COUNT(datetime) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -37,7 +38,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -47,28 +48,22 @@ if ($rowCount != -1) { $sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate $sql"; -foreach (dbFetchRows($sql, $param) as $eventlog) { +foreach (dbFetchRows($sql,$param) as $eventlog) { $dev = device_by_id_cache($eventlog['host']); - if ($eventlog['type'] == 'interface') { + if ($eventlog['type'] == "interface") { $this_if = ifLabel(getifbyid($eventlog['reference'])); - $type = ''.generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).''; + $type = "".generate_port_link($this_if, makeshortif(strtolower($this_if['label']))).""; + } else { + $type = "System"; } - else { - $type = 'System'; - } - - $response[] = array( - 'datetime' => $eventlog['humandate'], - 'hostname' => generate_device_link($dev, shorthost($dev['hostname'])), - 'type' => $type, - 'message' => htmlspecialchars($eventlog['message']), - ); + + $response[] = array('datetime'=>$eventlog['humandate'], + 'hostname'=>generate_device_link($dev, shorthost($dev['hostname'])), + 'type'=>$type, + 'message'=>htmlspecialchars($eventlog['message'])); } -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); + +?> diff --git a/html/includes/table/inventory.inc.php b/html/includes/table/inventory.inc.php index 2e4c0b928..6c5b92823 100644 --- a/html/includes/table/inventory.inc.php +++ b/html/includes/table/inventory.inc.php @@ -1,15 +1,14 @@ = '5') { $sql = " FROM entPhysical AS E, devices AS D WHERE $where AND D.device_id = E.device_id"; -} -else { - $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; +} else { + $sql = " FROM entPhysical AS E, devices AS D, devices_perms AS P WHERE $where AND D.device_id = E.device_id AND P.device_id = D.device_id AND P.user_id = ?"; $param[] = $_SESSION['user_id']; } @@ -18,32 +17,32 @@ if (isset($searchPhrase) && !empty($searchPhrase)) { } if (isset($_POST['string']) && strlen($_POST['string'])) { - $sql .= ' AND E.entPhysicalDescr LIKE ?'; - $param[] = '%'.$_POST['string'].'%'; + $sql .= " AND E.entPhysicalDescr LIKE ?"; + $param[] = "%".$_POST['string']."%"; } if (isset($_POST['device_string']) && strlen($_POST['device_string'])) { - $sql .= ' AND D.hostname LIKE ?'; - $param[] = '%'.$_POST['device_string'].'%'; + $sql .= " AND D.hostname LIKE ?"; + $param[] = "%".$_POST['device_string']."%"; } if (isset($_POST['part']) && strlen($_POST['part'])) { - $sql .= ' AND E.entPhysicalModelName = ?'; - $param[] = $_POST['part']; + $sql .= " AND E.entPhysicalModelName = ?"; + $param[] = $_POST['part']; } if (isset($_POST['serial']) && strlen($_POST['serial'])) { - $sql .= ' AND E.entPhysicalSerialNum LIKE ?'; - $param[] = '%'.$_POST['serial'].'%'; + $sql .= " AND E.entPhysicalSerialNum LIKE ?"; + $param[] = "%".$_POST['serial']."%"; } if (isset($_POST['device']) && is_numeric($_POST['device'])) { - $sql .= ' AND D.device_id = ?'; - $param[] = $_POST['device']; + $sql .= " AND D.device_id = ?"; + $param[] = $_POST['device']; } $count_sql = "SELECT COUNT(`entPhysical_id`) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -55,7 +54,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -66,19 +65,12 @@ if ($rowCount != -1) { $sql = "SELECT `D`.`device_id` AS `device_id`, `D`.`hostname` AS `hostname`,`entPhysicalDescr` AS `description`, `entPhysicalName` AS `name`, `entPhysicalModelName` AS `model`, `entPhysicalSerialNum` AS `serial` $sql"; foreach (dbFetchRows($sql, $param) as $invent) { - $response[] = array( - 'hostname' => generate_device_link($invent, shortHost($invent['hostname'])), - 'description' => $invent['description'], - 'name' => $invent['name'], - 'model' => $invent['model'], - 'serial' => $invent['serial'], - ); + $response[] = array('hostname'=>generate_device_link($invent, shortHost($invent['hostname'])), + 'description'=>$invent['description'], + 'name'=>$invent['name'], + 'model'=>$invent['model'], + 'serial'=>$invent['serial']); } -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, - ); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/mempool.inc.php b/html/includes/table/mempool.inc.php index 2afb80edc..d3968a531 100644 --- a/html/includes/table/mempool.inc.php +++ b/html/includes/table/mempool.inc.php @@ -1,88 +1,72 @@ generate_device_link($mempool), - 'mempool_descr' => $mempool['mempool_descr'], - 'graph' => $mini_graph, - 'mempool_used' => $bar_link, - 'mempool_perc' => $perc.'%', - ); - if ($_POST['view'] == 'graphs') { - $graph_array['height'] = '100'; - $graph_array['width'] = '216'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include 'includes/print-graphrow.inc.php'; - unset($return_data); - $response[] = array( - 'hostname' => $graph_data[0], - 'mempool_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'mempool_used' => $graph_data[3], - 'mempool_perc' => '', - ); - } //end if -}//end foreach - -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $count, -); + $response[] = array('hostname' => generate_device_link($mempool), + 'mempool_descr' => $mempool['mempool_descr'], + 'graph' => $mini_graph, + 'mempool_used' => $bar_link, + 'mempool_perc' => $perc . "%"); + if ($_POST['view'] == "graphs") { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include("includes/print-graphrow.inc.php"); + unset($return_data); + $response[] = array('hostname' => $graph_data[0], + 'mempool_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'mempool_used' => $graph_data[3], + 'mempool_perc' => ''); + } # endif graphs +} +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); echo _json_encode($output); diff --git a/html/includes/table/poll-log.inc.php b/html/includes/table/poll-log.inc.php index 3579759b6..3a0ca3213 100644 --- a/html/includes/table/poll-log.inc.php +++ b/html/includes/table/poll-log.inc.php @@ -1,12 +1,11 @@ " 'graphs', 'group' => 'poller'))."'>".$device['hostname'].'', - 'last_polled' => $device['last_polled'], - 'last_polled_timetaken' => $device['last_polled_timetaken'], - ); + $response[] = array('hostname' => " 'graphs', 'group' => 'poller')). "'>" .$device['hostname']. "", + 'last_polled' => $device['last_polled'], + 'last_polled_timetaken' => $device['last_polled_timetaken']); } -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); + +?> diff --git a/html/includes/table/processor.inc.php b/html/includes/table/processor.inc.php index bcedd6196..a7b3d9745 100644 --- a/html/includes/table/processor.inc.php +++ b/html/includes/table/processor.inc.php @@ -1,83 +1,67 @@ generate_device_link($processor), - 'processor_descr' => $processor['processor_descr'], - 'graph' => $mini_graph, - 'processor_usage' => $bar_link, - ); - if ($_POST['view'] == 'graphs') { - $graph_array['height'] = '100'; - $graph_array['width'] = '216'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $processor['processor_id']; - $graph_array['type'] = $graph_type; - $return_data = true; - include 'includes/print-graphrow.inc.php'; - unset($return_data); - $response[] = array( - 'hostname' => $graph_data[0], - 'processor_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'processor_usage' => $graph_data[3], - ); - } //end if -}//end foreach - -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); + $response[] = array('hostname' => generate_device_link($processor), + 'processor_descr' => $processor['processor_descr'], + 'graph' => $mini_graph, + 'processor_usage' => $bar_link); + if ($_POST['view'] == "graphs") { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $processor['processor_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include("includes/print-graphrow.inc.php"); + unset($return_data); + $response[] = array('hostname' => $graph_data[0], + 'processor_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'processor_usage' => $graph_data[3]); + } # endif graphs +} +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); diff --git a/html/includes/table/storage.inc.php b/html/includes/table/storage.inc.php index 3d301456f..a912ba1d2 100644 --- a/html/includes/table/storage.inc.php +++ b/html/includes/table/storage.inc.php @@ -1,14 +1,14 @@ generate_device_link($drive), - 'storage_descr' => $drive['storage_descr'], - 'graph' => $mini_graph, - 'storage_used' => $bar_link, - 'storage_perc' => $perc.'%', - ); - if ($_POST['view'] == 'graphs') { - $graph_array['height'] = '100'; - $graph_array['width'] = '216'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $graph_array['type'] = $graph_type; + $graph_array['id'] = $drive['storage_id']; + $graph_array['from'] = $config['time']['day']; + $graph_array['to'] = $config['time']['now']; + $graph_array['height'] = "20"; + $graph_array['width'] = "80"; + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = "150"; + $graph_array_zoom['width'] = "400"; + $link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/"; + $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); + $background = get_percentage_colours($perc); + $bar_link = overlib_link($link, print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free, "ffffff", $background['right']), generate_graph_tag($graph_array_zoom), NULL); - $return_data = true; - include 'includes/print-graphrow.inc.php'; - unset($return_data); - $response[] = array( - 'hostname' => $graph_data[0], - 'storage_descr' => $graph_data[1], - 'graph' => $graph_data[2], - 'storage_used' => $graph_data[3], - 'storage_perc' => '', - ); - } //end if -}//end foreach + $response[] = array('hostname' => generate_device_link($drive), + 'storage_descr' => $drive['storage_descr'], + 'graph' => $mini_graph, + 'storage_used' => $bar_link, + 'storage_perc' => $perc . "%"); + if ($_POST['view'] == "graphs") { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $count, -); + $return_data = true; + include("includes/print-graphrow.inc.php"); + unset($return_data); + $response[] = array('hostname' => $graph_data[0], + 'storage_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'storage_used' => $graph_data[3], + 'storage_perc' => ''); + + } # endif graphs +} + +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$count); echo _json_encode($output); diff --git a/html/includes/table/syslog.inc.php b/html/includes/table/syslog.inc.php index 987aac65a..81df05d28 100644 --- a/html/includes/table/syslog.inc.php +++ b/html/includes/table/syslog.inc.php @@ -1,44 +1,46 @@ = ?'; - $param[] = $_POST['from']; +if( !empty($_POST['from']) ) { + $where .= " AND timestamp >= ?"; + $param[] = $_POST['from']; +} +if( !empty($_POST['to']) ) { + $where .= " AND timestamp <= ?"; + $param[] = $_POST['to']; } -if (!empty($_POST['to'])) { - $where .= ' AND timestamp <= ?'; - $param[] = $_POST['to']; -} - -if ($_SESSION['userlevel'] >= '5') { - $sql = 'FROM syslog AS S'; - $sql .= ' WHERE '.$where; -} -else { - $sql = 'FROM syslog AS S, devices_perms AS P'; - $sql .= 'WHERE S.device_id = P.device_id AND P.user_id = ?'; - $sql .= $where; - $param = array_merge(array($_SESSION['user_id']), $param); +if ($_SESSION['userlevel'] >= '5') +{ + $sql = "FROM syslog AS S"; + $sql .= " WHERE ".$where; +} else { + $sql = "FROM syslog AS S, devices_perms AS P"; + $sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?"; + $sql .= $where; + $param = array_merge(array($_SESSION['user_id']), $param); } $count_sql = "SELECT COUNT(timestamp) $sql"; -$total = dbFetchCell($count_sql, $param); +$total = dbFetchCell($count_sql,$param); if (empty($total)) { $total = 0; } @@ -50,7 +52,7 @@ if (!isset($sort) || empty($sort)) { $sql .= " ORDER BY $sort"; if (isset($current)) { - $limit_low = (($current * $rowCount) - ($rowCount)); + $limit_low = ($current * $rowCount) - ($rowCount); $limit_high = $rowCount; } @@ -60,20 +62,14 @@ if ($rowCount != -1) { $sql = "SELECT S.*, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date $sql"; -foreach (dbFetchRows($sql, $param) as $syslog) { - $dev = device_by_id_cache($syslog['device_id']); - $response[] = array( - 'timestamp' => $syslog['date'], - 'device_id' => generate_device_link($dev, shorthost($dev['hostname'])), - 'program' => $syslog['program'], - 'msg' => htmlspecialchars($syslog['msg']), - ); +foreach (dbFetchRows($sql,$param) as $syslog) { + $dev = device_by_id_cache($syslog['device_id']); + $response[] = array('timestamp'=>$syslog['date'], + 'device_id'=>generate_device_link($dev, shorthost($dev['hostname'])), + 'program'=>$syslog['program'], + 'msg'=>htmlspecialchars($syslog['msg'])); } -$output = array( - 'current' => $current, - 'rowCount' => $rowCount, - 'rows' => $response, - 'total' => $total, -); +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); echo _json_encode($output); +?> diff --git a/html/includes/vars.inc.php b/html/includes/vars.inc.php index 477f056b4..788915f69 100644 --- a/html/includes/vars.inc.php +++ b/html/includes/vars.inc.php @@ -1,38 +1,40 @@ $get_var) { - if (strstr($key, 'opt')) { - list($name, $value) = explode('|', $get_var); - if (!isset($value)) { - $value = 'yes'; - } - - $vars[$name] = $value; - } +foreach ($_GET as $key=>$get_var) +{ + if (strstr($key, "opt")) + { + list($name, $value) = explode("|", $get_var); + if (!isset($value)) { $value = "yes"; } + $vars[$name] = $value; + } } $segments = explode('/', trim($_SERVER['REQUEST_URI'], '/')); -foreach ($segments as $pos => $segment) { - $segment = urldecode($segment); - if ($pos == '0') { - $vars['page'] = $segment; - } - else { - list($name, $value) = explode('=', $segment); - if ($value == '' || !isset($value)) { - $vars[$name] = yes; - } - else { - $vars[$name] = $value; - } +foreach ($segments as $pos => $segment) +{ + $segment = urldecode($segment); + if ($pos == "0") + { + $vars['page'] = $segment; + } else { + list($name, $value) = explode("=", $segment); + if ($value == "" || !isset($value)) + { + $vars[$name] = yes; + } else { + $vars[$name] = $value; } + } } -foreach ($_GET as $name => $value) { - $vars[$name] = $value; +foreach ($_GET as $name => $value) +{ + $vars[$name] = $value; } -foreach ($_POST as $name => $value) { - $vars[$name] = $value; +foreach ($_POST as $name => $value) +{ + $vars[$name] = $value; } diff --git a/html/index.php b/html/index.php index a3de9ba0c..57fff1b57 100644 --- a/html/index.php +++ b/html/index.php @@ -14,8 +14,7 @@ if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) { $_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']); -} -else { +} else { $_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''); } @@ -32,40 +31,40 @@ function catchFatal() { } } -if (strpos($_SERVER['PATH_INFO'], "debug")) { - $debug = "1"; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 1); - ini_set('log_errors', 1); - ini_set('error_reporting', E_ALL); - set_error_handler('logErrors'); - register_shutdown_function('catchFatal'); -} -else { - $debug = FALSE; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 0); - ini_set('log_errors', 0); - ini_set('error_reporting', 0); +if (strpos($_SERVER['PATH_INFO'], "debug")) +{ + $debug = "1"; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 1); + ini_set('log_errors', 1); + ini_set('error_reporting', E_ALL); + set_error_handler('logErrors'); + register_shutdown_function('catchFatal'); +} else { + $debug = FALSE; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 0); + ini_set('log_errors', 0); + ini_set('error_reporting', 0); } // Set variables $msg_box = array(); // Check for install.inc.php -if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') { - // no config.php does so let's redirect to the install - header('Location: /install.php'); - exit; +if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') +{ + // no config.php does so let's redirect to the install + header('Location: /install.php'); + exit; } -require '../includes/defaults.inc.php'; -require '../config.php'; -require_once '../includes/definitions.inc.php'; -require '../includes/functions.php'; -require 'includes/functions.inc.php'; -require 'includes/vars.inc.php'; -require 'includes/plugins.inc.php'; - +include("../includes/defaults.inc.php"); +include("../config.php"); +include_once("../includes/definitions.inc.php"); +include("../includes/functions.php"); +include("includes/functions.inc.php"); +include("includes/vars.inc.php"); +include('includes/plugins.inc.php'); Plugins::start(); $runtime_start = utime(); @@ -75,33 +74,30 @@ ob_start(); ini_set('allow_url_fopen', 0); ini_set('display_errors', 0); -require 'includes/authenticate.inc.php'; +include("includes/authenticate.inc.php"); -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { - $_SESSION['widescreen'] = 1; -} -if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { - unset($_SESSION['widescreen']); -} +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { $_SESSION['widescreen'] = 1; } +if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { unset($_SESSION['widescreen']); } # Load the settings for Multi-Tenancy. -if (isset($config['branding']) && is_array($config['branding'])) { - if ($config['branding'][$_SERVER['SERVER_NAME']]) { - foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) { - eval("\$config['" . $confitem . "'] = \$confval;"); - } +if (isset($config['branding']) && is_array($config['branding'])) +{ + if ($config['branding'][$_SERVER['SERVER_NAME']]) + { + foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) + { + eval("\$config['" . $confitem . "'] = \$confval;"); } - else { - foreach ($config['branding']['default'] as $confitem => $confval) { - eval("\$config['" . $confitem . "'] = \$confval;"); - } + } else { + foreach ($config['branding']['default'] as $confitem => $confval) + { + eval("\$config['" . $confitem . "'] = \$confval;"); } + } } # page_title_prefix is displayed, unless page_title is set -if (isset($config['page_title'])) { - $config['page_title_prefix'] = $config['page_title']; -} +if (isset($config['page_title'])) { $config['page_title_prefix'] = $config['page_title']; } ?> @@ -123,8 +119,7 @@ if (empty($config['favicon'])) { ' . "\n"); } ?> @@ -174,13 +169,14 @@ else { body { padding-top: 0px !important; - padding-bottom: 0px !important; }"; + padding-bottom: 0px !important; }"; } @@ -192,47 +188,50 @@ else { "); - print_r($_GET); - print_r($vars); - echo(""); +if (isset($devel) || isset($vars['devel'])) +{ + echo("
    ");
    +  print_r($_GET);
    +  print_r($vars);
    +  echo("
    "); } -if ($_SESSION['authenticated']) { - // Authenticated. Print a page. - if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) { - require "pages/" . $vars['page'] . ".inc.php"; - } - else { - if (isset($config['front_page']) && is_file($config['front_page'])) { - require $config['front_page']; - } - else { - require 'pages/front/default.php'; - } +if ($_SESSION['authenticated']) +{ + // Authenticated. Print a page. + if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php")) + { + include("pages/" . $vars['page'] . ".inc.php"); + } else { + if (isset($config['front_page']) && is_file($config['front_page'])) + { + include($config['front_page']); + } else { + include("pages/front/default.php"); } + } -} -else { - // Not Authenticated. Show status page if enabled - if ( $config['public_status'] === true ) { - if (isset($vars['page']) && strstr("login", $vars['page'])) { - require 'pages/logon.inc.php'; - } - else { - echo '
    '; - require 'pages/public.inc.php'; - echo '
    '; - echo ''; - } - } - else { - require 'pages/logon.inc.php'; +} else { + // Not Authenticated. Show status page if enabled + if ( $config['public_status'] === true ) + { + if (isset($vars['page']) && strstr("login", $vars['page'])) + { + include("pages/logon.inc.php"); + } else { + echo '
    '; + include("pages/public.inc.php"); + echo '
    '; + echo ''; } + } + else + { + include("pages/logon.inc.php"); + } } ?> @@ -240,42 +239,37 @@ else { MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. - ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. - ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. - ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); +if ($config['page_gen']) +{ + echo('
    MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'. + ' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'. + ' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'. + ' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s'); - $fullsize = memory_get_usage(); - unset($cache); - $cachesize = $fullsize - memory_get_usage(); - if ($cachesize < 0) { - $cachesize = 0; - } // Silly PHP! + $fullsize = memory_get_usage(); + unset($cache); + $cachesize = $fullsize - memory_get_usage(); + if ($cachesize < 0) { $cachesize = 0; } // Silly PHP! - echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); - echo('
    Generated in ' . $gentime . ' seconds.'); + echo('
    Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.'); + echo('
    Generated in ' . $gentime . ' seconds.'); } -if (isset($pagetitle) && is_array($pagetitle)) { - # if prefix is set, put it in front - if ($config['page_title_prefix']) { - array_unshift($pagetitle,$config['page_title_prefix']); - } +if (isset($pagetitle) && is_array($pagetitle)) +{ + # if prefix is set, put it in front + if ($config['page_title_prefix']) { array_unshift($pagetitle,$config['page_title_prefix']); } - # if suffix is set, put it in the back - if ($config['page_title_suffix']) { - $pagetitle[] = $config['page_title_suffix']; - } + # if suffix is set, put it in the back + if ($config['page_title_suffix']) { $pagetitle[] = $config['page_title_suffix']; } - # create and set the title - $title = join(" - ",$pagetitle); - echo(""); + # create and set the title + $title = join(" - ",$pagetitle); + echo(""); } ?> @@ -301,21 +295,23 @@ if(dbFetchCell("SELECT COUNT(`device_id`) FROM `devices` WHERE `last_polled` <= } if(is_array($msg_box)) { - echo(""); + echo(""); } if (is_array($sql_debug) && is_array($php_debug) && $_SESSION['authenticated'] === TRUE) { - require_once "includes/print-debug.php"; + + include_once "includes/print-debug.php"; + } if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { @@ -371,8 +367,7 @@ if ($no_refresh !== TRUE && $config['page_refresh'] != 0) { }); '); -} -else { +} else { echo(' diff --git a/html/pages/alert-stats.inc.php b/html/pages/alert-stats.inc.php index ab9a0c57f..d392f1dd2 100644 --- a/html/pages/alert-stats.inc.php +++ b/html/pages/alert-stats.inc.php @@ -1,13 +1,12 @@ - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. - */ - -require_once 'includes/print-graph-alerts.inc.php'; +* LibreNMS +* +* Copyright (c) 2015 Søren Friis Rosiak +* This program is free software: you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation, either version 3 of the License, or (at your +* option) any later version. Please see LICENSE.txt at the top level of +* the source code distribution for details. +*/ +require_once('includes/print-graph-alerts.inc.php'); diff --git a/html/pages/alerts.inc.php b/html/pages/alerts.inc.php index 91526b69f..bcc97a32a 100644 --- a/html/pages/alerts.inc.php +++ b/html/pages/alerts.inc.php @@ -1,17 +1,19 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * LibreNMS + * + * Copyright (c) 2014 Neil Lathwood + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ $device['device_id'] = '-1'; -require_once 'includes/print-alerts.php'; +require_once('includes/print-alerts.php'); unset($device['device_id']); + +?> diff --git a/html/pages/api-access.inc.php b/html/pages/api-access.inc.php index 6b8a885a7..a1b6e5a52 100644 --- a/html/pages/api-access.inc.php +++ b/html/pages/api-access.inc.php @@ -12,22 +12,22 @@ * the source code distribution for details. */ -if ($_SESSION['userlevel'] >= '10') { -if (empty($_POST['token'])) { +if ($_SESSION['userlevel'] >= '10') +{ +if(empty($_POST['token'])) { $_POST['token'] = bin2hex(openssl_random_pseudo_bytes(16)); } - ?> -'; -if ($_SESSION['api_token'] === true) { - echo " - "; + "); unset($_SESSION['api_token']); -} - -echo ' + } +echo('
    @@ -125,17 +127,19 @@ echo ' Disabled Remove -'; +'); -foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id') as $api) { - if ($api['disabled'] == '1') { - $api_disabled = 'checked'; + foreach (dbFetchRows("SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN users AS U ON AT.user_id=U.user_id ORDER BY AT.user_id") as $api) + { + if($api['disabled'] == '1') + { + $api_disabled = 'checked'; } - else { - $api_disabled = ''; + else + { + $api_disabled = ''; } - - echo ' + echo(' '.$api['username'].' '.$api['token_hash'].' @@ -143,14 +147,14 @@ foreach (dbFetchRows('SELECT `AT`.*,`U`.`username` FROM `api_tokens` AS AT JOIN -'; -} +'); + } - echo ' + echo('
    -'; +'); ?> diff --git a/html/pages/api-docs.inc.php b/html/pages/api-docs.inc.php index d3bd68b84..c260b73ce 100644 --- a/html/pages/api-docs.inc.php +++ b/html/pages/api-docs.inc.php @@ -17,7 +17,8 @@
    here.'); + print_error('Documentation for the API has now been moved to GitHub, you can go straight to the API Wiki from here.'); ?>
    + diff --git a/html/pages/apps.inc.php b/html/pages/apps.inc.php index cfd2378dd..1a20acc41 100644 --- a/html/pages/apps.inc.php +++ b/html/pages/apps.inc.php @@ -1,91 +1,54 @@ Apps » "; +echo("Apps » "); unset($sep); -$link_array = array( - 'page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'apps', -); +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'apps'); -foreach ($app_list as $app) { - echo $sep; +foreach ($app_list as $app) +{ + echo($sep); - // if (!$vars['app']) { $vars['app'] = $app['app_type']; } - if ($vars['app'] == $app['app_type']) { - echo ""; - // echo(''); - } - else { - // echo(''); - } +# if (!$vars['app']) { $vars['app'] = $app['app_type']; } - echo generate_link(nicecase($app['app_type']), array('page' => 'apps', 'app' => $app['app_type'])); - if ($vars['app'] == $app['app_type']) { - echo ''; - } - - $sep = ' | '; + if ($vars['app'] == $app['app_type']) + { + echo(""); + #echo(''); + } else { + #echo(''); + } + echo(generate_link(nicecase($app['app_type']),array('page'=>'apps','app'=>$app['app_type']))); + if ($vars['app'] == $app['app_type']) { echo(""); } + $sep = " | "; } print_optionbar_end(); -if ($vars['app']) { - if (is_file('pages/apps/'.mres($vars['app']).'.inc.php')) { - include 'pages/apps/'.mres($vars['app']).'.inc.php'; - } - else { - include 'pages/apps/default.inc.php'; - } -} -else { - include 'pages/apps/overview.inc.php'; +if($vars['app']) +{ + if (is_file("pages/apps/".mres($vars['app']).".inc.php")) + { + include("pages/apps/".mres($vars['app']).".inc.php"); + } else { + include("pages/apps/default.inc.php"); + } +} else { + include("pages/apps/overview.inc.php"); } -$pagetitle[] = 'Apps'; +$pagetitle[] = "Apps"; +?> diff --git a/html/pages/apps/default.inc.php b/html/pages/apps/default.inc.php index bf752de29..e33367405 100644 --- a/html/pages/apps/default.inc.php +++ b/html/pages/apps/default.inc.php @@ -1,41 +1,45 @@ '.nicecase($vars['app']).''; -echo ''; -$app_devices = dbFetchRows('SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?', array($vars['app'])); +echo('

    '.nicecase($vars['app']).'

    '); +echo('
    '); +$app_devices = dbFetchRows("SELECT * FROM `devices` AS D, `applications` AS A WHERE D.device_id = A.device_id AND A.app_type = ?", array($vars['app'])); -foreach ($app_devices as $app_device) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''; - echo ''; -}//end foreach + echo(''); + echo(''); +} -echo '
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab' => 'apps', 'app' => $vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '; +foreach ($app_devices as $app_device) +{ + echo('
    '.generate_device_link($app_device, shorthost($app_device['hostname']), array('tab'=>'apps','app'=>$vars['app'])).''.$app_device['app_instance'].''.$app_device['app_status'].'
    '); - foreach ($graphs[$vars['app']] as $graph_type) { - $graph_array['type'] = 'application_'.$vars['app'].'_'.$graph_type; - $graph_array['id'] = $app_device['app_id']; - $graph_array_zoom['type'] = 'application_'.$vars['app'].'_'.$graph_type; - $graph_array_zoom['id'] = $app_device['app_id']; + foreach ($graphs[$vars['app']] as $graph_type) + { + $graph_array['type'] = "application_".$vars['app']."_".$graph_type; + $graph_array['id'] = $app_device['app_id']; + $graph_array_zoom['type'] = "application_".$vars['app']."_".$graph_type; + $graph_array_zoom['id'] = $app_device['app_id']; - $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'], 'tab' => 'apps', 'app' => $vars['app'])); + $link = generate_url(array('page' => 'device', 'device' => $app_device['device_id'],'tab'=>'apps','app'=>$vars['app'])); - echo overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); - } + echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); + } - echo '
    '; +echo(''); + +?> diff --git a/html/pages/authlog.inc.php b/html/pages/authlog.inc.php index 3cffbbea9..64b4080ad 100644 --- a/html/pages/authlog.inc.php +++ b/html/pages/authlog.inc.php @@ -1,37 +1,37 @@ = '10') { - echo ''; +if ($_SESSION['userlevel'] >= '10') +{ + echo("
    "); - foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) { - if ($bg == $list_colour_a) { - $bg = $list_colour_b; - } - else { - $bg = $list_colour_a; - } + foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) + { + if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } - echo " - - - - - - '; - }//end foreach + echo(" + + + + + + "); + } - $pagetitle[] = 'Authlog'; + $pagetitle[] = "Authlog"; - echo '
    - ".$entry['datetime'].' - - '.$entry['user'].' - - '.$entry['address'].' - - '.$entry['result'].' -
    + " . $entry['datetime'] . " + + ".$entry['user']." + + ".$entry['address']." + + ".$entry['result']." +
    '; + echo(""); } -else { - include 'includes/error-no-perm.inc.php'; -}//end if +else +{ + include("includes/error-no-perm.inc.php"); +} + +?> diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index 03faf35c1..13b640057 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -2,274 +2,255 @@ $bill_id = mres($vars['bill_id']); -if ($_SESSION['userlevel'] >= '10') { - include 'pages/bill/actions.inc.php'; +if ($_SESSION['userlevel'] >= "10") +{ + include("pages/bill/actions.inc.php"); } -if (bill_permitted($bill_id)) { - $bill_data = dbFetchRow('SELECT * FROM bills WHERE bill_id = ?', array($bill_id)); +if (bill_permitted($bill_id)) +{ + $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); - $bill_name = $bill_data['bill_name']; + $bill_name = $bill_data['bill_name']; - $today = str_replace('-', '', dbFetchCell('SELECT CURDATE()')); - $yesterday = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)')); - $tomorrow = str_replace('-', '', dbFetchCell('SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)')); - $last_month = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)')); + $today = str_replace("-", "", dbFetchCell("SELECT CURDATE()")); + $yesterday = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)")); + $tomorrow = str_replace("-", "", dbFetchCell("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)")); + $last_month = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)")); - $rightnow = $today.date(His); - $before = $yesterday.date(His); - $lastmonth = $last_month.date(His); + $rightnow = $today . date(His); + $before = $yesterday . date(His); + $lastmonth = $last_month . date(His); - $bill_name = $bill_data['bill_name']; - $dayofmonth = $bill_data['bill_day']; + $bill_name = $bill_data['bill_name']; + $dayofmonth = $bill_data['bill_day']; - $day_data = getDates($dayofmonth); + $day_data = getDates($dayofmonth); - $datefrom = $day_data['0']; - $dateto = $day_data['1']; - $lastfrom = $day_data['2']; - $lastto = $day_data['3']; + $datefrom = $day_data['0']; + $dateto = $day_data['1']; + $lastfrom = $day_data['2']; + $lastto = $day_data['3']; - $rate_95th = $bill_data['rate_95th']; - $dir_95th = $bill_data['dir_95th']; - $total_data = $bill_data['total_data']; - $rate_average = $bill_data['rate_average']; + $rate_95th = $bill_data['rate_95th']; + $dir_95th = $bill_data['dir_95th']; + $total_data = $bill_data['total_data']; + $rate_average = $bill_data['rate_average']; - if ($rate_95th > $paid_kb) { - $over = ($rate_95th - $paid_kb); - $bill_text = $over.'Kbit excess.'; - $bill_color = '#cc0000'; - } - else { - $under = ($paid_kb - $rate_95th); - $bill_text = $under.'Kbit headroom.'; - $bill_color = '#0000cc'; + if ($rate_95th > $paid_kb) + { + $over = $rate_95th - $paid_kb; + $bill_text = $over . "Kbit excess."; + $bill_color = "#cc0000"; + } + else + { + $under = $paid_kb - $rate_95th; + $bill_text = $under . "Kbit headroom."; + $bill_color = "#0000cc"; + } + + $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); + $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); + $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); + $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); + + $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); + $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); + # Speeds up loading for other included pages by setting it before progessing of mysql data! + + $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D + WHERE B.bill_id = ? AND P.port_id = B.port_id + AND D.device_id = P.device_id", array($bill_id)); + + echo("

    + Bill : " . $bill_data['bill_name'] . "

    "); + + print_optionbar_start(); + + echo("Bill » "); + + if (!$vars['view']) { $vars['view'] = "quick"; } + + if ($vars['view'] == "quick") { echo(""); } + echo('Quick Graphs'); + if ($vars['view'] == "quick") { echo(""); } + + echo(" | "); + + if ($vars['view'] == "accurate") { echo(""); } + echo('Accurate Graphs'); + if ($vars['view'] == "accurate") { echo(""); } + + echo(" | "); + + if ($vars['view'] == "transfer") { echo(""); } + echo('Transfer Graphs'); + if ($vars['view'] == "transfer") { echo(""); } + + echo(" | "); + + if ($vars['view'] == "history") { echo(""); } + echo('Historical Usage'); + if ($vars['view'] == "history") { echo(""); } + + if ($_SESSION['userlevel'] >= "10") + { + echo(" | "); + if ($vars['view'] == "edit") { echo(""); } + echo('Edit'); + if ($vars['view'] == "edit") { echo(""); } + + echo(" | "); + if ($vars['view'] == "delete") { echo(""); } + echo('Delete'); + if ($vars['view'] == "delete") { echo(""); } + + echo(" | "); + if ($vars['view'] == "reset") { echo(""); } + echo('Reset'); + if ($vars['view'] == "reset") { echo(""); } + } + + echo(''); + + print_optionbar_end(); + + if ($vars['view'] == "edit" && $_SESSION['userlevel'] >= "10") + { + include("pages/bill/edit.inc.php"); + } + elseif ($vars['view'] == "delete" && $_SESSION['userlevel'] >= "10") + { + include("pages/bill/delete.inc.php"); + } + elseif ($vars['view'] == "reset" && $_SESSION['userlevel'] >= "10") + { + include("pages/bill/reset.inc.php"); + } + elseif ($vars['view'] == "history") + { + include("pages/bill/history.inc.php"); + } + elseif ($vars['view'] == "transfer") + { + include("pages/bill/transfer.inc.php"); + } + elseif ($vars['view'] == "quick" || $vars['view'] == "accurate") { + + echo("

    Billed Ports

    "); + + // Collected Earlier + foreach ($ports as $port) + { + echo(generate_port_link($port) . " on " . generate_device_link($port) . "
    "); } - $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); - $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); - $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); - $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); + echo("

    Bill Summary

    "); - $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); - $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); - // Speeds up loading for other included pages by setting it before progessing of mysql data! - $ports = dbFetchRows( - 'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D - WHERE B.bill_id = ? AND P.port_id = B.port_id - AND D.device_id = P.device_id', - array($bill_id) - ); + if ($bill_data['bill_type'] == "quota") + { + // The Customer is billed based on a pre-paid quota with overage in xB - echo '

    - Bill : '.$bill_data['bill_name'].'

    '; + echo("

    Quota Bill

    "); - print_optionbar_start(); + $percent = round(($total_data) / $bill_data['bill_quota'] * 100, 2); + $unit = "MB"; + $total_data = round($total_data, 2); + echo("Billing Period from " . $fromtext . " to " . $totext); + echo("
    Transferred ".format_bytes_billing($total_data)." of ".format_bytes_billing($bill_data['bill_quota'])." (".$percent."%)"); + echo("
    Average rate " . formatRates($rate_average)); - echo "Bill » "; + $background = get_percentage_colours($percent); - if (!$vars['view']) { - $vars['view'] = 'quick'; + echo("

    ".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); + + $type="&ave=yes"; + } + elseif ($bill_data['bill_type'] == "cdr") + { + // The customer is billed based on a CDR with 95th%ile overage + + echo("

    CDR / 95th Bill

    "); + + $unit = "kbps"; + $cdr = $bill_data['bill_cdr']; + $rate_95th = round($rate_95th, 2); + + $percent = round(($rate_95th) / $cdr * 100, 2); + + $type="&95th=yes"; + + echo("" . $fromtext . " to " . $totext . " +
    Measured ".format_si($rate_95th)."bps of ".format_si($cdr)."bps (".$percent."%) @ 95th %ile"); + + $background = get_percentage_colours($percent); + + echo("

    ".print_percentage_bar (350, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."

    "); + + # echo("

    Billing Period : " . $fromtext . " to " . $totext . "
    + # " . $paidrate_text . "
    + # " . $total_data . "MB transfered in the current billing cycle.
    + # " . $rate_average . "Kbps Average during the current billing cycle.

    + # " . $rate_95th . "Kbps @ 95th Percentile. (" . $dir_95th . ") (" . $bill_text . ") + # + #
    "); } - if ($vars['view'] == 'quick') { - echo ""; + $lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"); + $yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"); + $rightnow = date(U); + + if ($vars['view'] == "accurate") { + + $bi = ""; + + $li = ""; + + $di = ""; + + $mi = ""; + } - echo 'Quick Graphs'; - if ($vars['view'] == 'quick') { - echo ''; - } - - echo ' | '; - - if ($vars['view'] == 'accurate') { - echo ""; - } - - echo 'Accurate Graphs'; - if ($vars['view'] == 'accurate') { - echo ''; - } - - echo ' | '; - - if ($vars['view'] == 'transfer') { - echo ""; - } - - echo 'Transfer Graphs'; - if ($vars['view'] == 'transfer') { - echo ''; - } - - echo ' | '; - - if ($vars['view'] == 'history') { - echo ""; - } - - echo 'Historical Usage'; - if ($vars['view'] == 'history') { - echo ''; - } - - if ($_SESSION['userlevel'] >= '10') { - echo ' | '; - if ($vars['view'] == 'edit') { - echo ""; - } - - echo 'Edit'; - if ($vars['view'] == 'edit') { - echo ''; - } - - echo ' | '; - if ($vars['view'] == 'delete') { - echo ""; - } - - echo 'Delete'; - if ($vars['view'] == 'delete') { - echo ''; - } - - echo ' | '; - if ($vars['view'] == 'reset') { - echo ""; - } - - echo 'Reset'; - if ($vars['view'] == 'reset') { - echo ''; - } - }//end if - - echo ''; - - print_optionbar_end(); - - if ($vars['view'] == 'edit' && $_SESSION['userlevel'] >= '10') { - include 'pages/bill/edit.inc.php'; - } - else if ($vars['view'] == 'delete' && $_SESSION['userlevel'] >= '10') { - include 'pages/bill/delete.inc.php'; - } - else if ($vars['view'] == 'reset' && $_SESSION['userlevel'] >= '10') { - include 'pages/bill/reset.inc.php'; - } - else if ($vars['view'] == 'history') { - include 'pages/bill/history.inc.php'; - } - else if ($vars['view'] == 'transfer') { - include 'pages/bill/transfer.inc.php'; - } - else if ($vars['view'] == 'quick' || $vars['view'] == 'accurate') { - echo '

    Billed Ports

    '; - - // Collected Earlier - foreach ($ports as $port) { - echo generate_port_link($port).' on '.generate_device_link($port).'
    '; - } - - echo '

    Bill Summary

    '; - - if ($bill_data['bill_type'] == 'quota') { - // The Customer is billed based on a pre-paid quota with overage in xB - echo '

    Quota Bill

    '; - - $percent = round((($total_data) / $bill_data['bill_quota'] * 100), 2); - $unit = 'MB'; - $total_data = round($total_data, 2); - echo 'Billing Period from '.$fromtext.' to '.$totext; - echo '
    Transferred '.format_bytes_billing($total_data).' of '.format_bytes_billing($bill_data['bill_quota']).' ('.$percent.'%)'; - echo '
    Average rate '.formatRates($rate_average); - - $background = get_percentage_colours($percent); - - echo '

    '.print_percentage_bar(350, 20, $perc, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'

    '; - - $type = '&ave=yes'; - } - else if ($bill_data['bill_type'] == 'cdr') { - // The customer is billed based on a CDR with 95th%ile overage - echo '

    CDR / 95th Bill

    '; - - $unit = 'kbps'; - $cdr = $bill_data['bill_cdr']; - $rate_95th = round($rate_95th, 2); - - $percent = round((($rate_95th) / $cdr * 100), 2); - - $type = '&95th=yes'; - - echo ''.$fromtext.' to '.$totext.' -
    Measured '.format_si($rate_95th).'bps of '.format_si($cdr).'bps ('.$percent.'%) @ 95th %ile'; - - $background = get_percentage_colours($percent); - - echo '

    '.print_percentage_bar(350, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'

    '; - - // echo("

    Billing Period : " . $fromtext . " to " . $totext . "
    - // " . $paidrate_text . "
    - // " . $total_data . "MB transfered in the current billing cycle.
    - // " . $rate_average . "Kbps Average during the current billing cycle.

    - // " . $rate_95th . "Kbps @ 95th Percentile. (" . $dir_95th . ") (" . $bill_text . ") - // - //
    "); - }//end if - - $lastmonth = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))'); - $yesterday = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))'); - $rightnow = date(U); - - if ($vars['view'] == 'accurate') { - $bi = ""; - - $li = ""; - - $di = ""; - }//end if - - if ($null) { - echo " - @@ -287,32 +268,39 @@ if (bill_permitted($bill_id)) { - "; - }//end if + "); - if ($_GET['all']) { - $ai = ''; - echo "

    Entire Data View

    $ai"; - } - else if ($_GET['custom']) { - $cg = ''; - echo "

    Custom Graph

    $cg"; - } - else { - echo "

    Billing View

    $bi"; - // echo("

    Previous Bill View

    $li"); - echo "

    24 Hour View

    $di"; - echo "

    Monthly View

    $mi"; - // echo("
    Graph All Data (SLOW)"); - }//end if - } //end if + } + + if ($_GET['all']) + { + $ai = ""; + echo("

    Entire Data View

    $ai"); + } + elseif ($_GET['custom']) + { + $cg = ""; + echo("

    Custom Graph

    $cg"); + } + else + { + echo("

    Billing View

    $bi"); +# echo("

    Previous Bill View

    $li"); + echo("

    24 Hour View

    $di"); + echo("

    Monthly View

    $mi"); +# echo("
    Graph All Data (SLOW)"); + } + } # End if details } -else { - include 'includes/error-no-perm.inc.php'; -}//end if +else +{ + include("includes/error-no-perm.inc.php"); +} + +?> diff --git a/html/pages/bill/actions.inc.php b/html/pages/bill/actions.inc.php index 29afb6d3b..d55c2944c 100644 --- a/html/pages/bill/actions.inc.php +++ b/html/pages/bill/actions.inc.php @@ -1,7 +1,8 @@ = 1) { - $quota = array( - 'type' => 'tb', - 'select_tb' => ' selected', - 'data' => $tmp['tb'], - ); - } - else if (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) { - $quota = array( - 'type' => 'gb', - 'select_gb' => ' selected', - 'data' => $tmp['gb'], - ); - } - else if (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) { - $quota = array( - 'type' => 'mb', - 'select_mb' => ' selected', - 'data' => $tmp['mb'], - ); - } -}//end if +$base = $config["billing"]["base"]; -if ($bill_data['bill_type'] == 'cdr') { - $data = $bill_data['bill_cdr']; - $tmp['kbps'] = ($data / $base); - $tmp['mbps'] = ($data / $base / $base); - $tmp['gbps'] = ($data / $base / $base / $base); - if ($tmp['gbps'] >= 1) { - $cdr = array( - 'type' => 'gbps', - 'select_gbps' => ' selected', - 'data' => $tmp['gbps'], - ); - } - else if (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) { - $cdr = array( - 'type' => 'mbps', - 'select_mbps' => ' selected', - 'data' => $tmp['mbps'], - ); - } - else if (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) { - $cdr = array( - 'type' => 'kbps', - 'select_kbps' => ' selected', - 'data' => $tmp['kbps'], - ); - } -}//end if +if ($bill_data['bill_type'] == "quota") { + $data = $bill_data['bill_quota']; + $tmp['mb'] = $data / $base / $base; + $tmp['gb'] = $data / $base / $base / $base; + $tmp['tb'] = $data / $base / $base / $base / $base; + if ($tmp['tb']>=1) { $quota = array("type" => "tb", "select_tb" => " selected", "data" => $tmp['tb']); } + elseif (($tmp['gb']>=1) and ($tmp['gb']<$base)) { $quota = array("type" => "gb", "select_gb" => " selected", "data" => $tmp['gb']); } + elseif (($tmp['mb']>=1) and ($tmp['mb']<$base)) { $quota = array("type" => "mb", "select_mb" => " selected", "data" => $tmp['mb']); } +} +if ($bill_data['bill_type'] == "cdr") { + $data = $bill_data['bill_cdr']; + $tmp['kbps'] = $data / $base; + $tmp['mbps'] = $data / $base / $base; + $tmp['gbps'] = $data / $base / $base / $base; + if ($tmp['gbps']>=1) { $cdr = array("type" => "gbps", "select_gbps" => " selected", "data" => $tmp['gbps']); } + elseif (($tmp['mbps']>=1) and ($tmp['mbps']<$base)) { $cdr = array("type" => "mbps", "select_mbps" => " selected", "data" => $tmp['mbps']); } + elseif (($tmp['kbps']>=1) and ($tmp['kbps']<$base)) { $cdr = array("type" => "kbps", "select_kbps" => " selected", "data" => $tmp['kbps']); } +} ?>
    - +

    Bill Properties

    - + " />
    @@ -86,35 +51,17 @@ function billType() {
    - -
    @@ -124,19 +121,19 @@ if ($unknown) {
    - value="" /> + value="" />
    - /> + />
    - /> + />
    diff --git a/html/pages/device/edit/health.inc.php b/html/pages/device/edit/health.inc.php index 922bb36c7..3d7d21352 100644 --- a/html/pages/device/edit/health.inc.php +++ b/html/pages/device/edit/health.inc.php @@ -30,158 +30,156 @@ $sensor['sensor_id'], - 'sensor_limit' => $sensor['sensor_limit'], - 'sensor_limit_low' => $sensor['sensor_limit_low'], - 'sensor_alert' => $sensor['sensor_alert'], - ); - if ($sensor['sensor_alert'] == 1) { - $alert_status = 'checked'; - } - else { - $alert_status = ''; - } - - if ($sensor['sensor_custom'] == 'No') { - $custom = 'disabled'; - } - else { - $custom = ''; - } - - echo ' - - '.$sensor['sensor_class'].' - '.$sensor['sensor_type'].' - '.$sensor['sensor_descr'].' - '.$sensor['sensor_current'].' - -
    +foreach ( dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND sensor_deleted='0'", array($device['device_id'])) as $sensor) +{ + $rollback[] = array('sensor_id' => $sensor['sensor_id'], 'sensor_limit' => $sensor['sensor_limit'], 'sensor_limit_low' => $sensor['sensor_limit_low'], 'sensor_alert' => $sensor['sensor_alert']); + if($sensor['sensor_alert'] == 1) + { + $alert_status = 'checked'; + } + else + { + $alert_status = ''; + } + if ($sensor['sensor_custom'] == 'No') { + $custom = 'disabled'; + } else { + $custom = ''; + } + echo(' + + '.$sensor['sensor_class'].' + '.$sensor['sensor_type'].' + '.$sensor['sensor_descr'].' + '.$sensor['sensor_current'].' + +
    -
    - - -
    +
    + + +
    -
    - - - - - +
    + + + + + Clear custom - - - '; + + +'); } + ?>
    - - - - '; +foreach($rollback as $reset_data) +{ + echo (' + + + + + '); } ?>
    + diff --git a/html/pages/device/edit/ipmi.inc.php b/html/pages/device/edit/ipmi.inc.php index 0aff50bdd..f3971ca41 100644 --- a/html/pages/device/edit/ipmi.inc.php +++ b/html/pages/device/edit/ipmi.inc.php @@ -1,45 +1,31 @@ '7') { - $ipmi_hostname = mres($_POST['ipmi_hostname']); - $ipmi_username = mres($_POST['ipmi_username']); - $ipmi_password = mres($_POST['ipmi_password']); +if ($_POST['editing']) +{ + if ($_SESSION['userlevel'] > "7") + { + $ipmi_hostname = mres($_POST['ipmi_hostname']); + $ipmi_username = mres($_POST['ipmi_username']); + $ipmi_password = mres($_POST['ipmi_password']); - if ($ipmi_hostname != '') { - set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); - } - else { - del_dev_attrib($device, 'ipmi_hostname'); - } + if ($ipmi_hostname != '') { set_dev_attrib($device, 'ipmi_hostname', $ipmi_hostname); } else { del_dev_attrib($device, 'ipmi_hostname'); } + if ($ipmi_username != '') { set_dev_attrib($device, 'ipmi_username', $ipmi_username); } else { del_dev_attrib($device, 'ipmi_username'); } + if ($ipmi_password != '') { set_dev_attrib($device, 'ipmi_password', $ipmi_password); } else { del_dev_attrib($device, 'ipmi_password'); } - if ($ipmi_username != '') { - set_dev_attrib($device, 'ipmi_username', $ipmi_username); - } - else { - del_dev_attrib($device, 'ipmi_username'); - } - - if ($ipmi_password != '') { - set_dev_attrib($device, 'ipmi_password', $ipmi_password); - } - else { - del_dev_attrib($device, 'ipmi_password'); - } - - $update_message = 'Device IPMI data updated.'; - $updated = 1; - } - else { - include 'includes/error-no-perm.inc.php'; - }//end if -}//end if - -if ($updated && $update_message) { - print_message($update_message); + $update_message = "Device IPMI data updated."; + $updated = 1; + } + else + { + include("includes/error-no-perm.inc.php"); + } } -else if ($update_message) { - print_error($update_message); + +if ($updated && $update_message) +{ + print_message($update_message); +} elseif ($update_message) { + print_error($update_message); } ?> @@ -51,19 +37,19 @@ else if ($update_message) {
    - +
    - +
    - +
    diff --git a/html/pages/device/edit/modules.inc.php b/html/pages/device/edit/modules.inc.php index 319617162..36a53b3f1 100644 --- a/html/pages/device/edit/modules.inc.php +++ b/html/pages/device/edit/modules.inc.php @@ -17,57 +17,68 @@ $module_status) { - echo(' +foreach ($config['poller_modules'] as $module => $module_status) +{ + echo(' '.$module.' - '); +'); - if($module_status == 1) { - echo('Enabled'); - } - else { - echo('Disabled'); - } + if($module_status == 1) + { + echo('Enabled'); + } + else + { + echo('Disabled'); + } - echo(' + echo(' - '); +'); - if (isset($attribs['poll_'.$module])) { - if ($attribs['poll_'.$module]) { - echo('Enabled'); - $module_checked = 'checked'; - } - else { - echo('Disabled'); - $module_checked = ''; - } + if (isset($attribs['poll_'.$module])) + { + if ($attribs['poll_'.$module]) + { + echo('Enabled'); + $module_checked = 'checked'; } - else { - if($module_status == 1) { - echo('Enabled'); - $module_checked = 'checked'; - } - else { - echo('Disabled'); - $module_checked = ''; - } + else + { + echo('Disabled'); + $module_checked = ''; } + } + else + { + if($module_status == 1) + { + echo('Enabled'); + $module_checked = 'checked'; + } + else + { + echo('Disabled'); + $module_checked = ''; + } + } - echo(' + echo(' - '); +'); - echo(''); + echo(' + +'); - echo(' + echo(' - '); +'); } ?> @@ -85,56 +96,71 @@ foreach ($config['poller_modules'] as $module => $module_status) { $module_status) { - echo(' +foreach ($config['discovery_modules'] as $module => $module_status) +{ + + echo(' '.$module.' - '); +'); - if($module_status == 1) { - echo('Enabled'); - } - else { - echo('Disabled'); - } + if($module_status == 1) + { + echo('Enabled'); + } + else + { + echo('Disabled'); + } - echo(' + echo(' - '); + +'); - if (isset($attribs['discover_'.$module])) { - if($attribs['discover_'.$module]) { - echo('Enabled'); - $module_checked = 'checked'; - } - else { - echo('Disabled'); - $module_checked = ''; - } + if (isset($attribs['discover_'.$module])) + { + if($attribs['discover_'.$module]) + { + echo('Enabled'); + $module_checked = 'checked'; } - else { - if($module_status == 1) { - echo('Enabled'); - $module_checked = 'checked'; - } - else { - echo('Disabled'); - $module_checked = ''; - } + else + { + echo('Disabled'); + $module_checked = ''; } + } + else + { + if($module_status == 1) + { + echo('Enabled'); + $module_checked = 'checked'; + } + else + { + echo('Disabled'); + $module_checked = ''; + } + } - echo(' + echo(' - '); + +'); - echo(''); + echo(' + +'); - echo(' + echo(' - '); + +'); } echo(' diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index d8dc562e4..b382cf05a 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -1,26 +1,28 @@ '; +echo('
    '); -if ($_POST['ignoreport']) { - if ($_SESSION['userlevel'] == '10') { - include 'includes/port-edit.inc.php'; - } +if ($_POST['ignoreport']) +{ + if ($_SESSION['userlevel'] == '10') + { + include("includes/port-edit.inc.php"); + } } -if ($updated && $update_message) { - print_message($update_message); -} -else if ($update_message) { - print_error($update_message); +if ($updated && $update_message) +{ + print_message($update_message); +} elseif ($update_message) { + print_error($update_message); } -echo "
    +echo("
    - "; + "); -echo " +echo("
    @@ -39,14 +41,14 @@ echo "
    Index Name
    -"; +"); ?> '; - echo ''; - echo ''; - echo ''; + if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - // Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled - // - as to draw the attention to a possible problem. - $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; - $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; - $outofsync = $dowecare ? " class='red'" : ''; + echo(""); + echo(""); + echo(""); + echo(""); - echo "'; + # Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled + # - as to draw the attention to a possible problem. + $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; + $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; + $outofsync = $dowecare ? " class='red'" : ""; - echo '"); - echo '"); - echo "\n"; + echo(""); + echo(""); - $row++; -}//end foreach + echo("\n"); -echo '
    '.$port['ifIndex'].''.$port['label'].''.$port['ifAdminStatus'].'
    ". $port['ifIndex']."".$port['label'] . "". $port['ifAdminStatus']."'.$port['ifOperStatus'].''; - echo "'; - echo "". $port['ifOperStatus']."'; - echo "'; - echo ""); + echo(""); + echo(""); + echo("
    "); + echo(""); + echo(""); + echo("".$port['ifAlias'] . "
    '; -echo '
    '; -echo '
    '; + $row++; +} + +echo(''); +echo(''); +echo('
    '); + +?> diff --git a/html/pages/device/edit/services.inc.php b/html/pages/device/edit/services.inc.php index 1f2bc1d30..e6969a9fe 100644 --- a/html/pages/device/edit/services.inc.php +++ b/html/pages/device/edit/services.inc.php @@ -1,28 +1,29 @@ = '10') { - include 'includes/service-add.inc.php'; + include("includes/service-add.inc.php"); } } if ($_POST['delsrv']) { if ($_SESSION['userlevel'] >= '10') { - include 'includes/service-delete.inc.php'; + include("includes/service-delete.inc.php"); } } if ($_POST['confirm-editsrv']) { - echo 'yeah'; + echo "yeah"; if ($_SESSION['userlevel'] >= '10') { - include 'includes/service-edit.inc.php'; + include("includes/service-edit.inc.php"); } } - if ($handle = opendir($config['install_dir'].'/includes/services/')) { + if ($handle = opendir($config['install_dir'] . "/includes/services/")) { while (false !== ($file = readdir($handle))) { - if ($file != '.' && $file != '..' && !strstr($file, '.')) { + if ($file != "." && $file != ".." && !strstr($file, ".")) { $servicesform .= ""; } } @@ -30,17 +31,17 @@ if (is_admin() === true || is_read() === true) { closedir($handle); } - $dev = device_by_id_cache($device['device_id']); - $devicesform = "'; + $dev = device_by_id_cache($device['device_id']); + $devicesform = ""; if ($updated) { - print_message('Device Settings Saved'); + print_message("Device Settings Saved"); } - if (dbFetchCell('SELECT COUNT(*) from `services` WHERE `device_id` = ?', array($device['device_id'])) > '0') { - $i = '1'; - foreach (dbFetchRows('select * from services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $service) { - $existform .= "'; + if (dbFetchCell("SELECT COUNT(*) from `services` WHERE `device_id` = ?", array($device['device_id'])) > '0') { + $i = "1"; + foreach (dbFetchRows("select * from services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $service) { + $existform .= ""; } } @@ -48,29 +49,28 @@ if (is_admin() === true || is_read() === true) { if ($existform) { echo '
    '; - if ($_POST['editsrv'] == 'yes') { - include_once 'includes/print-service-edit.inc.php'; - } - else { + if ($_POST['editsrv'] == "yes") { + include_once "includes/print-service-edit.inc.php"; + } else { echo " -

    Edit / Delete Service

    -
    +

    Edit / Delete Service

    +
    -
    - -
    - +
    + +
    + +
    +
    +
    +
    + +
    +
    -
    -
    -
    - -
    -
    -
    -
    "; + "; } echo '
    '; @@ -78,8 +78,8 @@ if (is_admin() === true || is_read() === true) { echo '
    '; - include_once 'includes/print-service-add.inc.php'; -} -else { - include 'includes/error-no-perm.inc.php'; -} + require_once "includes/print-service-add.inc.php"; + +} else { + include("includes/error-no-perm.inc.php"); +} \ No newline at end of file diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php index 59c6bf4cd..9e8a5b7b0 100644 --- a/html/pages/device/edit/snmp.inc.php +++ b/html/pages/device/edit/snmp.inc.php @@ -1,240 +1,225 @@ '7') { - $community = mres($_POST['community']); - $snmpver = mres($_POST['snmpver']); - $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = 'udp'; - $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; - $timeout = mres($_POST['timeout']); - $retries = mres($_POST['retries']); - $poller_group = mres($_POST['poller_group']); - $v3 = array( - 'authlevel' => mres($_POST['authlevel']), - 'authname' => mres($_POST['authname']), - 'authpass' => mres($_POST['authpass']), - 'authalgo' => mres($_POST['authalgo']), - 'cryptopass' => mres($_POST['cryptopass']), - 'cryptoalgo' => mres($_POST['cryptoalgo']), - ); +if ($_POST['editing']) +{ + if ($_SESSION['userlevel'] > "7") + { + $community = mres($_POST['community']); + $snmpver = mres($_POST['snmpver']); + $transport = $_POST['transport'] ? mres($_POST['transport']) : $transport = "udp"; + $port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port']; + $timeout = mres($_POST['timeout']); + $retries = mres($_POST['retries']); + $poller_group = mres($_POST['poller_group']); + $v3 = array ( + 'authlevel' => mres($_POST['authlevel']), + 'authname' => mres($_POST['authname']), + 'authpass' => mres($_POST['authpass']), + 'authalgo' => mres($_POST['authalgo']), + 'cryptopass' => mres($_POST['cryptopass']), + 'cryptoalgo' => mres($_POST['cryptoalgo']) + ); - // FIXME needs better feedback - $update = array( - 'community' => $community, - 'snmpver' => $snmpver, - 'port' => $port, - 'transport' => $transport, - 'poller_group' => $poller_group, - ); + #FIXME needs better feedback + $update = array( + 'community' => $community, + 'snmpver' => $snmpver, + 'port' => $port, + 'transport' => $transport, + 'poller_group' => $poller_group + ); - if ($_POST['timeout']) { - $update['timeout'] = $timeout; - } - else { - $update['timeout'] = array('NULL'); + if ($_POST['timeout']) { $update['timeout'] = $timeout; } + else { $update['timeout'] = array('NULL'); } + if ($_POST['retries']) { $update['retries'] = $retries; } + else { $update['retries'] = array('NULL'); } + + $update = array_merge($update, $v3); + + $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); + if (isSNMPable($device_tmp)) { + $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id'])); + + if ($rows_updated > 0) { + $update_message = $rows_updated . " 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; } + } else { + $update_message = "Could not connect to device with new SNMP details"; + $updated = 0; + } + } +} - if ($_POST['retries']) { - $update['retries'] = $retries; - } - else { - $update['retries'] = array('NULL'); - } - - $update = array_merge($update, $v3); - - $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); - if (isSNMPable($device_tmp)) { - $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id'])); - - if ($rows_updated > 0) { - $update_message = $rows_updated.' Device record updated.'; - $updated = 1; - } - else if ($rows_updated = '-1') { - $update_message = 'Device record unchanged. No update necessary.'; - $updated = -1; - } - else { - $update_message = 'Device record update error.'; - $updated = 0; - } - } - else { - $update_message = 'Could not connect to device with new SNMP details'; - $updated = 0; - } - }//end if -}//end if - -$device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id'])); +$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id'])); $descr = $device['purpose']; -echo '
    -
    '; -if ($updated && $update_message) { - print_message($update_message); -} -else if ($update_message) { - print_error($update_message); +echo('
    +
    '); +if ($updated && $update_message) +{ + print_message($update_message); +} elseif ($update_message) { + print_error($update_message); } +echo('
    +
    '); -echo '
    -
    '; - -echo " -
    - -
    +echo(" + + +
    - +
    - +
    - "); foreach ($config['snmp']['transports'] as $transport) { - echo "'; + echo(">".$transport.""); } - -echo " +echo("
    -
    -
    +
    +
    - +
    - +
    -
    -
    +
    +
    - +
    - -
    - + +
    + +
    -
    -
    -
    +
    +
    - +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - + +
    + +
    -
    -
    '; +
    "); -if ($config['distributed_poller'] === true) { - echo ' -
    - -
    - + + '); - foreach (dbFetchRows('SELECT `id`,`group_name` FROM `poller_groups`') as $group) { - echo ''; + echo '>' . $group['group_name'] . ''; } - echo ' - -
    -
    - '; -}//end if + echo(' + +
    +
    + '); +} -echo ' - - - '; +echo(' + + +'); ?> diff --git a/html/pages/device/entphysical.inc.php b/html/pages/device/entphysical.inc.php index 7b5d956fa..af167b4dd 100644 --- a/html/pages/device/entphysical.inc.php +++ b/html/pages/device/entphysical.inc.php @@ -1,11 +1,13 @@ "; @@ -31,8 +33,7 @@ function printEntPhysical($ent, $level, $class) { if (count($sensor)) { $link = " href='device/device=".$device['device_id'].'/tab=health/metric='.$sensor['sensor_class']."/' onmouseover=\"return overlib('', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\""; } - } - else { + } else { unset($link); } diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index e4bd13d84..a275e71e3 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -1,68 +1,70 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'graphs', -); -$bg = '#ffffff'; +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'graphs'); -echo '
    '; +$bg="#ffffff"; + +echo('
    '); print_optionbar_start(); -echo "Graphs » "; +echo("Graphs » "); -foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph', array($device['device_id'])) as $graph) { - $section = $config['graph_types']['device'][$graph['graph']]['section']; - if ($section != '') { - $graph_enable[$section][$graph['graph']] = $graph['graph']; - } +foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph", array($device['device_id'])) as $graph) +{ + $section = $config['graph_types']['device'][$graph['graph']]['section']; + if ($section != "") { + $graph_enable[$section][$graph['graph']] = $graph['graph']; + } } // These are standard graphs we should have for all systems $graph_enable['poller']['poller_perf'] = 'device_poller_perf'; -$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; +$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; -$sep = ''; -foreach ($graph_enable as $section => $nothing) { - if (isset($graph_enable) && is_array($graph_enable[$section])) { - $type = strtolower($section); - if (!$vars['group']) { - $vars['group'] = $type; - } - - echo $sep; - if ($vars['group'] == $type) { - echo ''; - } - - echo generate_link(ucwords($type), $link_array, array('group' => $type)); - if ($vars['group'] == $type) { - echo ''; - } - - $sep = ' | '; +$sep = ""; +foreach ($graph_enable as $section => $nothing) +{ + if (isset($graph_enable) && is_array($graph_enable[$section])) + { + $type = strtolower($section); + if (!$vars['group']) { $vars['group'] = $type; } + echo($sep); + if ($vars['group'] == $type) + { + echo(''); } + echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); + if ($vars['group'] == $type) + { + echo(""); + } + $sep = " | "; + } } - -unset($sep); +unset ($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -// foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) { - $graph_array = array(); - if ($graph_enable[$graph]) { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = 'device_'.$graph; +#foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) +{ + $graph_array = array(); + if ($graph_enable[$graph]) + { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = "device_" . $graph; - include 'includes/print-device-graph.php'; - } + include("includes/print-device-graph.php"); + } } -$pagetitle[] = 'Graphs'; +$pagetitle[] = "Graphs"; + +?> diff --git a/html/pages/device/graphs/netstats_ip_forward.inc.php b/html/pages/device/graphs/netstats_ip_forward.inc.php index eda137a78..cc728ac77 100644 --- a/html/pages/device/graphs/netstats_ip_forward.inc.php +++ b/html/pages/device/graphs/netstats_ip_forward.inc.php @@ -1,8 +1,11 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'health', -); +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'health'); print_optionbar_start(); -echo "Health » "; +echo("Health » "); -if (!$vars['metric']) { - $vars['metric'] = 'overview'; -} +if (!$vars['metric']) { $vars['metric'] = "overview"; } unset($sep); -foreach ($datas as $type) { - echo $sep; +foreach ($datas as $type) +{ + echo($sep); - if ($vars['metric'] == $type) { - echo ''; - } - - echo generate_link($type_text[$type], $link_array, array('metric' => $type)); - if ($vars['metric'] == $type) { - echo ''; - } - - $sep = ' | '; + if ($vars['metric'] == $type) + { echo(''); } + echo(generate_link($type_text[$type],$link_array,array('metric'=>$type))); + if ($vars['metric'] == $type) { echo(""); } + $sep = " | "; } print_optionbar_end(); -if (is_file('pages/device/health/'.mres($vars['metric']).'.inc.php')) { - include 'pages/device/health/'.mres($vars['metric']).'.inc.php'; -} -else { - foreach ($datas as $type) { - if ($type != 'overview') { - $graph_title = $type_text[$type]; - $graph_array['type'] = 'device_'.$type; +if (is_file("pages/device/health/".mres($vars['metric']).".inc.php")) +{ + include("pages/device/health/".mres($vars['metric']).".inc.php"); +} else { - include 'includes/print-device-graph.php'; - } + foreach ($datas as $type) + { + if ($type != "overview") + { + + $graph_title = $type_text[$type]; + $graph_array['type'] = "device_".$type; + + include("includes/print-device-graph.php"); } + } } -$pagetitle[] = 'Health'; +$pagetitle[] = "Health"; + +?> diff --git a/html/pages/device/health/charge.inc.php b/html/pages/device/health/charge.inc.php index 0750ae593..7282247bf 100644 --- a/html/pages/device/health/charge.inc.php +++ b/html/pages/device/health/charge.inc.php @@ -1,7 +1,9 @@ diff --git a/html/pages/device/health/current.inc.php b/html/pages/device/health/current.inc.php index 70bd4dc42..0fa318a9b 100644 --- a/html/pages/device/health/current.inc.php +++ b/html/pages/device/health/current.inc.php @@ -4,4 +4,6 @@ $class = "current"; $unit = "A"; $graph_type = "sensor_current"; -require 'sensors.inc.php'; +include("sensors.inc.php"); + +?> diff --git a/html/pages/device/health/humidity.inc.php b/html/pages/device/health/humidity.inc.php index ffef7afa6..93b4772a3 100644 --- a/html/pages/device/health/humidity.inc.php +++ b/html/pages/device/health/humidity.inc.php @@ -4,4 +4,6 @@ $class = "humidity"; $unit = "%"; $graph_type = "sensor_humidity"; -require 'sensors.inc.php'; +include("sensors.inc.php"); + +?> diff --git a/html/pages/device/health/load.inc.php b/html/pages/device/health/load.inc.php index 18f5b5f5c..399237aae 100644 --- a/html/pages/device/health/load.inc.php +++ b/html/pages/device/health/load.inc.php @@ -1,7 +1,9 @@ diff --git a/html/pages/device/health/mempool.inc.php b/html/pages/device/health/mempool.inc.php index 613aa1250..6630c3147 100644 --- a/html/pages/device/health/mempool.inc.php +++ b/html/pages/device/health/mempool.inc.php @@ -1,72 +1,66 @@ "; -echo ''; +echo("
    "); +echo("
    "); $i = '1'; -// FIXME css alternating colours -foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($device['device_id'])) as $mempool) { - if (!is_integer($i / 2)) { - $row_colour = $list_colour_a; - } - else { - $row_colour = $list_colour_b; - } +#FIXME css alternating colours - if ($config['memcached']['enable'] === true) { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if ($debug) { - print_r($state); - } +foreach (dbFetchRows("SELECT * FROM `mempools` WHERE device_id = ?", array($device['device_id'])) as $mempool) +{ + if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - if (is_array($state)) { - $mempool = array_merge($mempool, $state); - } + if ($config['memcached']['enable'] === TRUE) + { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if($debug) { print_r($state); } + if(is_array($state)) { $mempool = array_merge($mempool, $state); } + unset($state); + } - unset($state); - } + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + $mempool_url = "graphs/id=".$mempool['mempool_id']."/type=mempool_usage/"; + $mini_url = "graph.php?id=".$mempool['mempool_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; - $mempool_url = 'graphs/id='.$mempool['mempool_id'].'/type=mempool_usage/'; - $mini_url = 'graph.php?id='.$mempool['mempool_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['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();\""; - $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']); - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); + $perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100); - $perc = round(($mempool['mempool_used'] / $mempool['mempool_total'] * 100)); + $background = get_percentage_colours($percent); + $right_background = $background['right']; + $left_background = $background['left']; - $background = get_percentage_colours($percent); - $right_background = $background['right']; - $left_background = $background['left']; + echo(" + + + + "); - echo " - - - - '; + echo(""); - echo ''; + $i++; +} - $i++; -}//end foreach +echo("
    " . $text_descr . " + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $left_background, $free , "ffffff", $right_background)." + ".$perc."%
    ".$text_descr." - ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $left_background, $free, 'ffffff', $right_background).' - '.$perc.'%
    "); - echo "
    "; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; + include("includes/print-graphrow.inc.php"); - include 'includes/print-graphrow.inc.php'; + echo("
    "); +echo("
    "); -echo ''; -echo '
    '; +?> diff --git a/html/pages/device/health/processor.inc.php b/html/pages/device/health/processor.inc.php index 725e37c21..bde4a3b3f 100644 --- a/html/pages/device/health/processor.inc.php +++ b/html/pages/device/health/processor.inc.php @@ -1,43 +1,46 @@ "; -echo ''; +echo("
    "); +echo("
    "); $i = '1'; -foreach (dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', array($device['device_id'])) as $proc) { - $proc_url = 'graphs/id='.$proc['processor_id'].'/type=processor_usage/'; +foreach (dbFetchRows("SELECT * FROM `processors` WHERE device_id = ?", array($device['device_id'])) as $proc) +{ + $proc_url = "graphs/id=".$proc['processor_id']."/type=processor_usage/"; - $mini_url = 'graph.php?id='.$proc['processor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=80&height=20&bg=f4f4f4'; + $mini_url = "graph.php?id=".$proc['processor_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; - $text_descr = $proc['processor_descr']; + $text_descr = $proc['processor_descr']; - $text_descr = rewrite_entity_descr($text_descr); + $text_descr = rewrite_entity_descr($text_descr); - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$text_descr; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$text_descr; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - $percent = round($proc['processor_usage']); + $percent = round($proc['processor_usage']); - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo (" - + echo(" + - '); + "); - echo "
    ".$text_descr."
    " . $text_descr . " - ".print_percentage_bar(400, 20, $percent, $percent.'%', 'ffffff', $background['left'], (100 - $percent).'%', 'ffffff', $background['right']).' + ".print_percentage_bar (400, 20, $percent, $percent."%", "ffffff", $background['left'], (100 - $percent)."%" , "ffffff", $background['right'])."
    "; + echo("
    "); - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; - include 'includes/print-graphrow.inc.php'; -}//end foreach + include("includes/print-graphrow.inc.php"); +} -echo '
    '; -echo ''; +echo(""); +echo(""); + +?> diff --git a/html/pages/device/health/state.inc.php b/html/pages/device/health/state.inc.php index 9781248be..546396219 100644 --- a/html/pages/device/health/state.inc.php +++ b/html/pages/device/health/state.inc.php @@ -1,7 +1,7 @@ '; +echo(""); -echo ' +echo(" - '; + "); $row = 1; -foreach (dbFetchRows('SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr', array($device['device_id'])) as $drive) { - if (is_integer($row / 2)) { - $row_colour = $list_colour_a; - } - else { - $row_colour = $list_colour_b; - } +foreach (dbFetchRows("SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr", array($device['device_id'])) as $drive) +{ + if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - $total = $drive['storage_size']; - $used = $drive['storage_used']; - $free = $drive['storage_free']; - $perc = round($drive['storage_perc'], 0); - $used = formatStorage($used); - $total = formatStorage($total); - $free = formatStorage($free); + $total = $drive['storage_size']; + $used = $drive['storage_used']; + $free = $drive['storage_free']; + $perc = round($drive['storage_perc'], 0); + $used = formatStorage($used); + $total = formatStorage($total); + $free = formatStorage($free); - $fs_url = 'graphs/id='.$drive['storage_id'].'/type=storage_usage/'; + $fs_url = "graphs/id=".$drive['storage_id']."/type=storage_usage/"; - $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$drive['storage_descr']; - $fs_popup .= "
    "; - $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; + $fs_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$drive['storage_descr']; + $fs_popup .= "
    "; + $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; - $background = get_percentage_colours($percent); + $background = get_percentage_colours($percent); - echo "'; + echo(""); - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; - echo "'; + echo(""); - $row++; -}//end foreach + $row++; +} -echo '
    Drive Usage Free
    ".$drive['storage_descr']." - ".print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $perc.'%', 'ffffff', $background['right']).' - '.$free.'
    " . $drive['storage_descr'] . " + ".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $perc . "%", "ffffff", $background['right'])." + " . $free . "
    "; + echo("
    "); - include 'includes/print-graphrow.inc.php'; + include("includes/print-graphrow.inc.php"); - echo '
    '; +echo(""); + +?> diff --git a/html/pages/device/hrdevice.inc.php b/html/pages/device/hrdevice.inc.php index d16a0ba83..68928187b 100644 --- a/html/pages/device/hrdevice.inc.php +++ b/html/pages/device/hrdevice.inc.php @@ -1,69 +1,70 @@ '; +echo(''); // FIXME missing heading -foreach (dbFetchRows('SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`', array($device['device_id'])) as $hrdevice) { - echo "'; - if ($hrdevice['hrDeviceType'] == 'hrDeviceProcessor') { - $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); - $proc_url = 'device/device='.$device['device_id'].'/tab=health/metric=processor/'; - $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname'].' - '.$hrdevice['hrDeviceDescr']; - $proc_popup .= "
    "; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"'; - echo "'; +foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`", array($device['device_id'])) as $hrdevice) +{ + echo(""); - $graph_array['height'] = '20'; - $graph_array['width'] = '100'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc_id; - $graph_array['type'] = 'processor_usage'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; - $graph_array_zoom['height'] = '150'; - $graph_array_zoom['width'] = '400'; + if ($hrdevice['hrDeviceType'] == "hrDeviceProcessor") + { + $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrdevice['hrDeviceIndex']."'"); + $proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/"; + $proc_popup = "onmouseover=\"return overlib('
    ".$device['hostname']." - ".$hrdevice['hrDeviceDescr']; + $proc_popup .= "
    "; + $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; + echo(""); - $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); + $graph_array['height'] = "20"; + $graph_array['width'] = "100"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc_id; + $graph_array['type'] = 'processor_usage'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; - echo ''; + $mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); + + echo(''); + } + elseif ($hrdevice['hrDeviceType'] == "hrDeviceNetwork") + { + $int = str_replace("network interface ", "", $hrdevice['hrDeviceDescr']); + $interface = dbFetchRow("SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?", array($device['device_id'], $int)); + if ($interface['ifIndex']) + { + echo(""); + + $graph_array['height'] = "20"; + $graph_array['width'] = "100"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $interface['port_id']; + $graph_array['type'] = 'port_bits'; + $graph_array['from'] = $config['time']['day']; + $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; + + // FIXME click on graph should also link to port, but can't use generate_port_link here... + $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); + + echo(""); + } else { + echo(""); + echo(""); } - else if ($hrdevice['hrDeviceType'] == 'hrDeviceNetwork') { - $int = str_replace('network interface ', '', $hrdevice['hrDeviceDescr']); - $interface = dbFetchRow('SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?', array($device['device_id'], $int)); - if ($interface['ifIndex']) { - echo ''; + } else { + echo(""); + echo(""); + } - $graph_array['height'] = '20'; - $graph_array['width'] = '100'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $interface['port_id']; - $graph_array['type'] = 'port_bits'; - $graph_array['from'] = $config['time']['day']; - $graph_array_zoom = $graph_array; - $graph_array_zoom['height'] = '150'; - $graph_array_zoom['width'] = '400'; + echo(""); + echo(""); + echo(""); +} - // FIXME click on graph should also link to port, but can't use generate_port_link here... - $mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null); +echo('
    ".$hrdevice['hrDeviceIndex'].'".$hrdevice['hrDeviceDescr'].'
    ".$hrdevice['hrDeviceIndex']."".$hrdevice['hrDeviceDescr']."'.$mini_graph.''.$mini_graph.'".generate_port_link($interface)."$mini_graph".stripslashes($hrdevice['hrDeviceDescr'])."'.generate_port_link($interface).'".stripslashes($hrdevice['hrDeviceDescr'])."".$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus']."".$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad']."
    '); - echo "$mini_graph"; - } - else { - echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; - echo ''; - } - } - else { - echo ''.stripslashes($hrdevice['hrDeviceDescr']).''; - echo ''; - }//end if +$pagetitle[] = "Inventory"; - echo ''.$hrdevice['hrDeviceType'].''.$hrdevice['hrDeviceStatus'].''; - echo ''.$hrdevice['hrDeviceErrors'].''.$hrdevice['hrProcessorLoad'].''; - echo ''; -}//end foreach - -echo ''; - -$pagetitle[] = 'Inventory'; +?> diff --git a/html/pages/device/loadbalancer/ace_rservers.inc.php b/html/pages/device/loadbalancer/ace_rservers.inc.php index c8b4b2acd..52f1773c7 100644 --- a/html/pages/device/loadbalancer/ace_rservers.inc.php +++ b/html/pages/device/loadbalancer/ace_rservers.inc.php @@ -33,10 +33,10 @@ echo ' Graphs: '; // "pkts" => "Packets", // "errors" => "Errors"); $graph_types = array( - 'curr' => 'CurrentConns', - 'failed' => 'FailedConns', - 'total' => 'TotalConns', -); + 'curr' => 'CurrentConns', + 'failed' => 'FailedConns', + 'total' => 'TotalConns', + ); foreach ($graph_types as $type => $descr) { echo "$type_sep"; @@ -66,8 +66,7 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = if ($rserver['StateDescr'] == 'Server is now operational') { $rserver_class = 'green'; - } - else { + } else { $rserver_class = 'red'; } @@ -88,7 +87,7 @@ foreach (dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = $graph_array['id'] = $rserver['rserver_id']; $graph_array['type'] = $graph_type; - require 'includes/print-graphrow.inc.php'; + include 'includes/print-graphrow.inc.php'; // include("includes/print-interface-graphs.inc.php"); echo ' diff --git a/html/pages/device/loadbalancer/ace_vservers.inc.php b/html/pages/device/loadbalancer/ace_vservers.inc.php index 68ebd1d3f..65032709c 100644 --- a/html/pages/device/loadbalancer/ace_vservers.inc.php +++ b/html/pages/device/loadbalancer/ace_vservers.inc.php @@ -2,101 +2,84 @@ print_optionbar_start(); -echo "Serverfarms » "; +echo("Serverfarms » "); -// $auth = TRUE; -$menu_options = array('basic' => 'Basic'); +#$auth = TRUE; -if (!$_GET['opta']) { - $_GET['opta'] = 'basic'; -} +$menu_options = array('basic' => 'Basic', + ); -$sep = ''; -foreach ($menu_options as $option => $text) { - if ($_GET['type'] == $option) { - echo ""; - } +if (!$_GET['opta']) { $_GET['opta'] = "basic"; } - echo ''.$text.''; - if ($_GET['type'] == $option) { - echo ''; - } - - echo ' | '; +$sep = ""; +foreach ($menu_options as $option => $text) +{ + if ($_GET['type'] == $option) { echo(""); } + echo(''.$text.''); + if ($_GET['type'] == $option) { echo(""); } + echo(" | "); } unset($sep); -echo ' Graphs: '; +echo(' Graphs: '); -$graph_types = array( - 'bits' => 'Bits', - 'pkts' => 'Packets', - 'conns' => 'Connections', -); +$graph_types = array("bits" => "Bits", + "pkts" => "Packets", + "conns" => "Connections"); -foreach ($graph_types as $type => $descr) { - echo "$type_sep"; - if ($_GET['opte'] == $type) { - echo ""; - } +foreach ($graph_types as $type => $descr) +{ + echo("$type_sep"); + if ($_GET['opte'] == $type) { echo(""); } + echo(''.$descr.''); + echo(''.$text.''); + if ($_GET['opte'] == $type) { echo(""); } - echo ''.$descr.''; - echo ''.$text.''; - if ($_GET['opte'] == $type) { - echo ''; - } - - $type_sep = ' | '; + $type_sep = " | "; } print_optionbar_end(); -echo "
    "; -$i = '0'; -foreach (dbFetchRows('SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`', array($device['device_id'])) as $vserver) { - if (is_integer($i / 2)) { - $bg_colour = $list_colour_a; - } - else { - $bg_colour = $list_colour_b; - } +echo("
    "); +$i = "0"; +foreach (dbFetchRows("SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ? ORDER BY `classmap`", array($device['device_id'])) as $vserver) +{ +if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } - if ($vserver['serverstate'] == 'inService') { - $vserver_class = 'green'; - } - else { - $vserver_class = 'red'; - } +if($vserver['serverstate'] == "inService") { $vserver_class="green"; } else { $vserver_class="red"; } - echo ""; - // echo(""); - echo ''; - // echo(""); - echo "'; - echo ''; - if ($_GET['type'] == 'graphs') { - echo ''; - echo '"); +#echo(""); +echo(""); +#echo(""); +echo(""); +echo(""); + if ($_GET['type'] == "graphs") + { + echo(''); + echo(" - '; - } + echo(" + + "); + } - echo ''; - echo ''; +echo(""); +echo(""); - $i++; -}//end foreach + $i++; +} -echo '
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "'.$vserver['classmap'].'" . $rserver['farm_id'] . "".$vserver['serverstate'].'
    '; - $graph_type = 'vserver_'.$_GET['opte']; +echo("
    " . $tunnel['local_addr'] . " » " . $tunnel['peer_addr'] . "" . $vserver['classmap'] . "" . $rserver['farm_id'] . "" . $vserver['serverstate'] . "
    "); + $graph_type = "vserver_" . $_GET['opte']; - $graph_array['height'] = '100'; - $graph_array['width'] = '215'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $vserver['classmap_id']; - $graph_array['type'] = $graph_type; +$graph_array['height'] = "100"; +$graph_array['width'] = "215"; +$graph_array['to'] = $config['time']['now']; +$graph_array['id'] = $vserver['classmap_id']; +$graph_array['type'] = $graph_type; - include 'includes/print-graphrow.inc.php'; +include("includes/print-graphrow.inc.php"); - echo ' -
    '; +echo(""); + +?> diff --git a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php index 91abc8204..a67d755b9 100644 --- a/html/pages/device/loadbalancer/netscaler_vsvr.inc.php +++ b/html/pages/device/loadbalancer/netscaler_vsvr.inc.php @@ -1,6 +1,6 @@ VServer » "); // echo('All'); diff --git a/html/pages/device/logs.inc.php b/html/pages/device/logs.inc.php index 11fd6914b..0b8481a68 100644 --- a/html/pages/device/logs.inc.php +++ b/html/pages/device/logs.inc.php @@ -1,43 +1,41 @@ Logging » '; +echo("Logging » "); -if ($vars['section'] == 'eventlog') { - echo ''; +if ($vars['section'] == "eventlog") { + echo(''); } - -echo generate_link('Event Log', $vars, array('section' => 'eventlog')); -if ($vars['section'] == 'eventlog') { - echo ''; +echo(generate_link("Event Log" , $vars, array('section'=>'eventlog'))); +if ($vars['section'] == "eventlog") { + echo(""); } if (isset($config['enable_syslog']) && $config['enable_syslog'] == 1) { - echo ' | '; + echo(" | "); - if ($vars['section'] == 'syslog') { - echo ''; + if ($vars['section'] == "syslog") { + echo(''); } - - echo generate_link('Syslog', $vars, array('section' => 'syslog')); - if ($vars['section'] == 'syslog') { - echo ''; + echo(generate_link("Syslog" , $vars, array('section'=>'syslog'))); + if ($vars['section'] == "syslog") { + echo(""); } } -switch ($vars['section']) { - case 'syslog': - case 'eventlog': - include 'pages/device/logs/'.$vars['section'].'.inc.php'; - break; - - default: - print_optionbar_end(); - echo report_this('Unknown section '.$vars['section']); - break; +switch ($vars['section']) +{ + case 'syslog': + case 'eventlog': + include('pages/device/logs/'.$vars['section'].'.inc.php'); + break; + default: + print_optionbar_end(); + echo(report_this('Unknown section '.$vars['section'])); + break; } + +?> diff --git a/html/pages/device/logs/eventlog.inc.php b/html/pages/device/logs/eventlog.inc.php index 7d5204f1c..aec8bdd98 100644 --- a/html/pages/device/logs/eventlog.inc.php +++ b/html/pages/device/logs/eventlog.inc.php @@ -2,49 +2,51 @@
    +echo('
    Eventlog entries
    - '; +
    '); -foreach ($entries as $entry) { - include 'includes/print-event.inc.php'; +foreach ($entries as $entry) +{ + include("includes/print-event.inc.php"); } -echo '
    -
    '; +echo(' + '); -$pagetitle[] = 'Events'; +$pagetitle[] = "Events"; + +?> diff --git a/html/pages/device/logs/syslog.inc.php b/html/pages/device/logs/syslog.inc.php index 1284ad157..7aae3b8e0 100644 --- a/html/pages/device/logs/syslog.inc.php +++ b/html/pages/device/logs/syslog.inc.php @@ -3,54 +3,53 @@
    +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? $where"; +$sql .= " ORDER BY timestamp DESC LIMIT 1000"; +echo('
    Syslog entries
    - '; -foreach (dbFetchRows($sql, $param) as $entry) { - include 'includes/print-syslog.inc.php'; -} +
    '); +foreach (dbFetchRows($sql, $param) as $entry) { include("includes/print-syslog.inc.php"); } +echo('
    +
    '); +$pagetitle[] = "Syslog"; -echo ' - '; -$pagetitle[] = 'Syslog'; +?> diff --git a/html/pages/device/map.inc.php b/html/pages/device/map.inc.php index 918f62e7f..522de36a5 100644 --- a/html/pages/device/map.inc.php +++ b/html/pages/device/map.inc.php @@ -12,6 +12,8 @@ * the source code distribution for details. */ -$pagetitle[] = 'Map'; +$pagetitle[] = "Map"; -require_once 'includes/print-map.inc.php'; +require_once "includes/print-map.inc.php"; + +?> diff --git a/html/pages/device/munin.inc.php b/html/pages/device/munin.inc.php index e12279687..67fd22d6e 100644 --- a/html/pages/device/munin.inc.php +++ b/html/pages/device/munin.inc.php @@ -1,72 +1,75 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'munin', -); -$bg = '#ffffff'; +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'munin'); -echo '
    '; +$bg="#ffffff"; + +echo('
    '); print_optionbar_start(); -echo "Munin » "; +echo("Munin » "); -$sep = ''; +$sep = ""; -foreach (dbFetchRows('SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type', array($device['device_id'])) as $mplug) { - // if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; - $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; +foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", array($device['device_id'])) as $mplug) +{ +# if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { } + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title']; + $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type']; } -foreach ($graph_enable as $section => $nothing) { - if (isset($graph_enable) && is_array($graph_enable[$section])) { - $type = strtolower($section); - if (!$vars['group']) { - $vars['group'] = $type; - } - - echo $sep; - if ($vars['group'] == $type) { - echo ''; - } - - echo generate_link(ucwords($type), $link_array, array('group' => $type)); - if ($vars['group'] == $type) { - echo ''; - } - - $sep = ' | '; +foreach ($graph_enable as $section => $nothing) +{ + if (isset($graph_enable) && is_array($graph_enable[$section])) + { + $type = strtolower($section); + if (!$vars['group']) { $vars['group'] = $type; } + echo($sep); + if ($vars['group'] == $type) + { + echo(''); } + echo(generate_link(ucwords($type),$link_array,array('group'=>$type))); + if ($vars['group'] == $type) + { + echo(""); + } + $sep = " | "; + } } -unset($sep); +unset ($sep); print_optionbar_end(); $graph_enable = $graph_enable[$vars['group']]; -// foreach ($config['graph_types']['device'] as $graph => $entry) -foreach ($graph_enable as $graph => $entry) { - $graph_array = array(); - if ($graph_enable[$graph]) { - if (!empty($entry['plugin'])) { - $graph_title = $entry['title']; - $graph_array['type'] = 'munin_graph'; - $graph_array['device'] = $device['device_id']; - $graph_array['plugin'] = $entry['plugin']; - } - else { - $graph_title = $config['graph_types']['device'][$graph]['descr']; - $graph_array['type'] = 'device_'.$graph; - } - - include 'includes/print-device-graph.php'; +#foreach ($config['graph_types']['device'] as $graph => $entry) +foreach ($graph_enable as $graph => $entry) +{ + $graph_array = array(); + if ($graph_enable[$graph]) + { + if (!empty($entry['plugin'])) + { + $graph_title = $entry['title']; + $graph_array['type'] = "munin_graph"; + $graph_array['device'] = $device['device_id']; + $graph_array['plugin'] = $entry['plugin']; + } else { + $graph_title = $config['graph_types']['device'][$graph]['descr']; + $graph_array['type'] = "device_" . $graph; } + + include("includes/print-device-graph.php"); + } } -$pagetitle[] = 'Graphs'; +$pagetitle[] = "Graphs"; + +?> diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index 13227e013..aac3b2ca2 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -12,18 +12,8 @@ $services['up'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WH $services['down'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_status` = '0' AND `service_ignore` = '0'", array($device['device_id'])); $services['disabled'] = dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `device_id` = ? AND `service_ignore` = '1'", array($device['device_id'])); -if ($services['down']) { - $services_colour = $warn_colour_a; -} -else { - $services_colour = $list_colour_a; -} -if ($ports['down']) { - $ports_colour = $warn_colour_a; -} -else { - $ports_colour = $list_colour_a; -} +if ($services['down']) { $services_colour = $warn_colour_a; } else { $services_colour = $list_colour_a; } +if ($ports['down']) { $ports_colour = $warn_colour_a; } else { $ports_colour = $list_colour_a; } echo('
    @@ -35,41 +25,39 @@ echo('
    '); -require 'includes/dev-overview-data.inc.php'; +include("includes/dev-overview-data.inc.php"); Plugins::call('device_overview_container',array($device)); -require 'overview/ports.inc.php'; +include("overview/ports.inc.php"); echo('
    '); // Right Pane -require 'overview/processors.inc.php'; -require 'overview/mempools.inc.php'; -require 'overview/storage.inc.php'; +include("overview/processors.inc.php"); +include("overview/mempools.inc.php"); +include("overview/storage.inc.php"); -if(is_array($entity_state['group']['c6kxbar'])) { - require 'overview/c6kxbar.inc.php'; -} +if(is_array($entity_state['group']['c6kxbar'])) { include("overview/c6kxbar.inc.php"); } -require 'overview/toner.inc.php'; -require 'overview/sensors/charge.inc.php'; -require 'overview/sensors/temperatures.inc.php'; -require 'overview/sensors/humidity.inc.php'; -require 'overview/sensors/fanspeeds.inc.php'; -require 'overview/sensors/dbm.inc.php'; -require 'overview/sensors/voltages.inc.php'; -require 'overview/sensors/current.inc.php'; -require 'overview/sensors/power.inc.php'; -require 'overview/sensors/frequencies.inc.php'; -require 'overview/sensors/load.inc.php'; -require 'overview/sensors/state.inc.php'; -require 'overview/eventlog.inc.php'; -require 'overview/services.inc.php'; -require 'overview/syslog.inc.php'; +include("overview/toner.inc.php"); +include("overview/sensors/charge.inc.php"); +include("overview/sensors/temperatures.inc.php"); +include("overview/sensors/humidity.inc.php"); +include("overview/sensors/fanspeeds.inc.php"); +include("overview/sensors/dbm.inc.php"); +include("overview/sensors/voltages.inc.php"); +include("overview/sensors/current.inc.php"); +include("overview/sensors/power.inc.php"); +include("overview/sensors/frequencies.inc.php"); +include("overview/sensors/load.inc.php"); +include("overview/sensors/state.inc.php"); +include("overview/eventlog.inc.php"); +include("overview/services.inc.php"); +include("overview/syslog.inc.php"); echo('
    '); -#require 'overview/current.inc.php"); +#include("overview/current.inc.php"); ?> diff --git a/html/pages/device/overview/c6kxbar.inc.php b/html/pages/device/overview/c6kxbar.inc.php index eb04e0a7d..14f5d54e4 100644 --- a/html/pages/device/overview/c6kxbar.inc.php +++ b/html/pages/device/overview/c6kxbar.inc.php @@ -1,99 +1,102 @@ -
    -
    -
    -
    '; -echo ''; -echo " Catalyst 6k Crossbar"; -echo '
    - '; + echo('
    +
    +
    +
    +
    '); +echo(''); +echo(" Catalyst 6k Crossbar"); +echo('
    +
    '); -foreach ($entity_state['group']['c6kxbar'] as $index => $entry) { - // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> - $entity = dbFetchRow('SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?', array($device['device_id'], $index + 1)); +foreach ($entity_state['group']['c6kxbar'] as $index => $entry) +{ + // FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :> + $entity = dbFetchRow("SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?", array($device['device_id'], $index+1)); - echo " + echo(" - - '; + echo(" + "); - foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) { - if (is_numeric($subindex)) { - if ($fabric['cc6kxbarModuleChannelFabStatus'] == 'ok') { - $fabric['mode_class'] = 'green'; - } - else { - $fabric['mode_class'] = 'red'; - } + foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) + { + if (is_numeric($subindex)) + { + if ($fabric['cc6kxbarModuleChannelFabStatus'] == "ok") + { + $fabric['mode_class'] = "green"; + } else { + $fabric['mode_class'] = "red"; + } - $percent_in = $fabric['cc6kxbarStatisticsInUtil']; - $background_in = get_percentage_colours($percent_in); + $percent_in = $fabric['cc6kxbarStatisticsInUtil']; + $background_in = get_percentage_colours($percent_in); - $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; - $background_out = get_percentage_colours($percent_out); + $percent_out = $fabric['cc6kxbarStatisticsOutUtil']; + $background_out = get_percentage_colours($percent_out); - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['mod'] = $index; - $graph_array['chan'] = $subindex; - $graph_array['type'] = 'c6kxbar_util'; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['mod'] = $index; + $graph_array['chan'] = $subindex; + $graph_array['type'] = "c6kxbar_util"; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $text_descr = $entity['entPhysicalName'].' - Fabric '.$subindex; + $text_descr = $entity['entPhysicalName'] . " - Fabric " . $subindex; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - echo (' - - - + + + + + + + "); + } + } +} + +echo("
    ".$entity['entPhysicalName'].""; + "); - switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) { - case 'busmode': - // echo 'Bus'; + switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) + { + case "busmode": + # echo 'Bus'; break; - - case 'crossbarmode': + case "crossbarmode": echo 'Crossbar'; break; - - case 'dcefmode': + case "dcefmode": echo 'DCEF'; break; - - default: + default: echo $entry['']['cc6kxbarModuleModeSwitchingMode']; } - echo '
    Fabric '.$subindex." + Fabric ".$subindex."". + + $fabric['cc6kxbarModuleChannelFabStatus']."".formatRates($fabric['cc6kxbarModuleChannelSpeed']*1000000)."".overlib_link($link, $minigraph, $overlib_content)."".print_percentage_bar (125, 20, $percent_in, "Ingress", "ffffff", $background['left'], $percent_in . "%", "ffffff", $background['right'])."".print_percentage_bar (125, 20, $percent_out, "Egress", "ffffff", $background['left'], $percent_out . "%", "ffffff", $background['right'])."
    "); +echo("
    "); +echo("
    "); +echo("
    "); +echo("
    "); + +?> diff --git a/html/pages/device/overview/eventlog.inc.php b/html/pages/device/overview/eventlog.inc.php index d55511813..ff235aa4a 100644 --- a/html/pages/device/overview/eventlog.inc.php +++ b/html/pages/device/overview/eventlog.inc.php @@ -1,22 +1,25 @@ '; -echo '
    +echo('
    '); + echo('
    -
    '; -echo ''; -echo " Recent Events"; -echo '
    - '; +
    '); +echo(''); +echo(" Recent Events"); +echo('
    +
    '); $eventlog = dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` WHERE `host` = ? ORDER BY `datetime` DESC LIMIT 0,10", array($device['device_id'])); -foreach ($eventlog as $entry) { - include 'includes/print-event-short.inc.php'; +foreach ($eventlog as $entry) +{ + include("includes/print-event-short.inc.php"); } -echo '
    '; -echo '
    '; -echo '
    '; -echo '
    '; -echo '
    '; +echo(""); +echo('
    '); +echo('
    '); +echo(''); +echo(''); + +?> diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index 36bc05cd5..6194c37c0 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -1,71 +1,75 @@ +if (count($sensors)) +{ + echo('
    -
    -
    -
    '; - echo ' '.$sensor_type.''; - echo '
    - '; - foreach ($sensors as $sensor) { - if ($config['memcached']['enable'] === true) { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - } +
    +
    +
    '); + echo(' ' . $sensor_type . ''); + echo('
    +
    '); + foreach ($sensors as $sensor) + { + if ($config['memcached']['enable'] === TRUE) + { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + } - if (empty($sensor['sensor_current'])) { - $sensor['sensor_current'] = 'NaN'; - } + if (empty($sensor['sensor_current'])) + { + $sensor['sensor_current'] = "NaN"; + } - // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. - // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? - // FIXME - DUPLICATED IN health/sensors - $graph_colour = str_replace('#', '', $row_colour); + // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. + // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? + // FIXME - DUPLICATED IN health/sensors - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $sensor['sensor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $graph_colour = str_replace("#", "", $row_colour); - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $sensor['sensor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; - foreach (array('day', 'week', 'month', 'year') as $period) { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); - } + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content .= '
    '; + $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; + foreach (array('day','week','month','year') as $period) + { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + } + $overlib_content .= "
    "; - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['from'] = $config['time']['day']; + $sensor_minigraph = generate_graph_tag($graph_array); - $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); + $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo ' - - - - '; - }//end foreach + echo(" + + + + "); + } - echo '
    '.overlib_link($link, $sensor['sensor_descr'], $overlib_content).''.overlib_link($link, $sensor_minigraph, $overlib_content).''.overlib_link($link, ' $sensor['sensor_limit'] ? "style='color: red'" : '').'>'.$sensor['sensor_current'].$sensor_unit.'', $overlib_content).'
    ".overlib_link($link, $sensor['sensor_descr'], $overlib_content)."".overlib_link($link, $sensor_minigraph, $overlib_content)."".overlib_link($link, " $sensor['sensor_limit'] ? "style='color: red'" : '') . '>' . $sensor['sensor_current'] . $sensor_unit . "", $overlib_content)."
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; -}//end if + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); +} + +?> diff --git a/html/pages/device/overview/mempools.inc.php b/html/pages/device/overview/mempools.inc.php index 069987241..3d35a8d55 100644 --- a/html/pages/device/overview/mempools.inc.php +++ b/html/pages/device/overview/mempools.inc.php @@ -1,77 +1,76 @@ +if (count($mempools)) +{ + echo('
    -
    -
    -
    - '; - echo ''; - echo " Memory Pools"; - echo ' -
    - - '; +
    +
    +
    +'); + echo(''); + echo(" Memory Pools"); + echo(' +
    +
    +'); - foreach ($mempools as $mempool) { - if ($config['memcached']['enable'] === true) { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if ($debug) { - print_r($state); - } + foreach ($mempools as $mempool) + { - if (is_array($state)) { - $mempool = array_merge($mempool, $state); - } + if ($config['memcached']['enable'] === TRUE) + { + $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); + if($debug) { print_r($state); } + if(is_array($state)) { $mempool = array_merge($mempool, $state); } + unset($state); + } - unset($state); - } + $percent= round($mempool['mempool_perc'],0); + $text_descr = rewrite_entity_descr($mempool['mempool_descr']); + $total = formatStorage($mempool['mempool_total']); + $used = formatStorage($mempool['mempool_used']); + $free = formatStorage($mempool['mempool_free']); + $background = get_percentage_colours($percent); - $percent = round($mempool['mempool_perc'], 0); - $text_descr = rewrite_entity_descr($mempool['mempool_descr']); - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); - $background = get_percentage_colours($percent); + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $mempool['mempool_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $minigraph = generate_graph_tag($graph_array); + $minigraph = generate_graph_tag($graph_array); - echo ' - - - - '; - }//end foreach + echo(" + + + + "); + } - echo '
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' -
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)." +
    + echo('
    -
    '; -}//end if + '); + +} + +?> diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 75cf3ca29..807f8ee4f 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -1,64 +1,68 @@ '; - echo '
    +if ($ports['total']) +{ + echo('
    '); + echo('
    Overall Traffic
    - '; +
    '); - $graph_array['height'] = '100'; - $graph_array['width'] = '485'; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device['device_id']; - $graph_array['type'] = 'device_bits'; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; - $graph = generate_graph_tag($graph_array); + $graph_array['height'] = "100"; + $graph_array['width'] = "485"; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device['device_id']; + $graph_array['type'] = "device_bits"; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; + $graph = generate_graph_tag($graph_array); - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width']); + $link = generate_url($link_array); - $graph_array['width'] = '210'; - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - Device Traffic'); + $graph_array['width'] = "210"; + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - Device Traffic"); - echo ' - - '; + echo(' + + '); - echo ' + echo(' - - - - - '; + + + + + '); - echo ' - + '; - echo ''; - echo '
    '; - echo overlib_link($link, $graph, $overlib_content, null); - echo '
    '); + echo(overlib_link($link, $graph, $overlib_content, NULL)); + echo('
    '.$ports['total'].' '.$ports['up'].' '.$ports['down'].' '.$ports['disabled'].'
    ' . $ports['total'] . ' ' . $ports['up'] . ' ' . $ports['down'] . ' ' . $ports['disabled'] . '
    '; + echo('
    '); - $ifsep = ''; + $ifsep = ""; - foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) { - $data = ifNameDescr($data); - $data = array_merge($data, $device); - echo "$ifsep".generate_port_link($data, makeshortif(strtolower($data['label']))); - $ifsep = ', '; - } + foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) + { + $data = ifNameDescr($data); + $data = array_merge($data, $device); + echo("$ifsep" . generate_port_link($data, makeshortif(strtolower($data['label'])))); + $ifsep = ", "; + } - unset($ifsep); - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; -}//end if + unset($ifsep); + echo(" "); + echo(""); + echo(""); + echo("
    "); + echo(""); + echo(""); + echo(""); +} + +?> diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index 8b4d3f291..3394e263c 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -1,63 +1,66 @@ +if (count($processors)) +{ + echo('
    -'; - echo ''; - echo " Processors"; - echo '
    - '; +'); + echo(''); + echo(" Processors"); + echo(' +
    '); - foreach ($processors as $proc) { - $text_descr = rewrite_entity_descr($proc['processor_descr']); + foreach ($processors as $proc) + { + $text_descr = rewrite_entity_descr($proc['processor_descr']); - // disable short hrDeviceDescr. need to make this prettier. - // $text_descr = short_hrDeviceDescr($proc['processor_descr']); - $percent = $proc['processor_usage']; - $background = get_percentage_colours($percent); - $graph_colour = str_replace('#', '', $row_colour); + # disable short hrDeviceDescr. need to make this prettier. + #$text_descr = short_hrDeviceDescr($proc['processor_descr']); + $percent = $proc['processor_usage']; + $background = get_percentage_colours($percent); + $graph_colour = str_replace("#", "", $row_colour); - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $proc['processor_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $proc['processor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$text_descr); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr); - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - echo ' - - - + + + - '; - }//end foreach + "); + } - echo '
    '.overlib_link($link, $text_descr, $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' + $minigraph = generate_graph_tag($graph_array); + + echo("
    ".overlib_link($link, $text_descr, $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)."
    + echo('
    -
    '; -}//end if + '); + +} + +?> diff --git a/html/pages/device/overview/sensors/charge.inc.php b/html/pages/device/overview/sensors/charge.inc.php index b0df00968..bf4097749 100644 --- a/html/pages/device/overview/sensors/charge.inc.php +++ b/html/pages/device/overview/sensors/charge.inc.php @@ -1,8 +1,10 @@ diff --git a/html/pages/device/overview/sensors/load.inc.php b/html/pages/device/overview/sensors/load.inc.php index 089f93dff..989a305b9 100644 --- a/html/pages/device/overview/sensors/load.inc.php +++ b/html/pages/device/overview/sensors/load.inc.php @@ -1,8 +1,8 @@ '; - echo '
    +if ($services['total']) +{ +echo('
    '); + echo('
    -
    '; - echo " Services"; - echo '
    - '; +
    '); + echo(" Services"); + echo('
    +
    '); - echo " + echo(" @@ -18,32 +19,22 @@ echo '
    ';
    -
    $services[total] $services[up] $services[disabled]
    "; +"); - foreach (dbFetchRows('SELECT * FROM services WHERE device_id = ? ORDER BY service_type', array($device['device_id'])) as $data) { - if ($data['service_status'] == '0' && $data['service_ignore'] == '1') { - $status = 'grey'; - } + foreach (dbFetchRows("SELECT * FROM services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $data) + { + if ($data['service_status'] == "0" && $data['service_ignore'] == "1") { $status = "grey"; } + if ($data['service_status'] == "1" && $data['service_ignore'] == "1") { $status = "green"; } + if ($data['service_status'] == "0" && $data['service_ignore'] == "0") { $status = "red"; } + if ($data['service_status'] == "1" && $data['service_ignore'] == "0") { $status = "blue"; } + echo("$break" . strtolower($data['service_type']) . ""); + $break = ", "; + } + echo('
    '); + echo("
    "); + echo("
    "); + echo("
    "); + echo("
    "); +} - if ($data['service_status'] == '1' && $data['service_ignore'] == '1') { - $status = 'green'; - } - - if ($data['service_status'] == '0' && $data['service_ignore'] == '0') { - $status = 'red'; - } - - if ($data['service_status'] == '1' && $data['service_ignore'] == '0') { - $status = 'blue'; - } - - echo "$break".strtolower($data['service_type']).''; - $break = ', '; - } - - echo ''; - echo '
    '; - echo ''; - echo ''; - echo ''; -}//end if +?> diff --git a/html/pages/device/overview/storage.inc.php b/html/pages/device/overview/storage.inc.php index e81b1b5b5..01c02edb4 100644 --- a/html/pages/device/overview/storage.inc.php +++ b/html/pages/device/overview/storage.inc.php @@ -1,86 +1,91 @@ +if (count($drives)) +{ + echo('
    -
    '; - echo ''; - echo " Storage"; - echo '
    - '; +
    '); + echo(''); + echo(" Storage"); + echo('
    +
    '); - foreach ($drives as $drive) { - $skipdrive = 0; + foreach ($drives as $drive) + { + $skipdrive = 0; - if ($device['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 ($device["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 ($device['os'] == 'freebsd') { - foreach ($config['ignore_bsd_os_drives'] as $jdrive) { - if (preg_match($jdrive, $drive['storage_descr'])) { - $skipdrive = 1; - } - } + if ($device['os'] == "freebsd") + { + foreach ($config['ignore_bsd_os_drives'] as $jdrive) + { + if (preg_match($jdrive, $drive["storage_descr"])) + { + $skipdrive = 1; } + } + } - if ($skipdrive) { - continue; - } + if ($skipdrive) { continue; } + $percent = round($drive['storage_perc'], 0); + $total = formatStorage($drive['storage_size']); + $free = formatStorage($drive['storage_free']); + $used = formatStorage($drive['storage_used']); + $background = get_percentage_colours($percent); - $percent = round($drive['storage_perc'], 0); - $total = formatStorage($drive['storage_size']); - $free = formatStorage($drive['storage_free']); - $used = formatStorage($drive['storage_used']); - $background = get_percentage_colours($percent); + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $drive['storage_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $drive['storage_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $drive['storage_descr']); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$drive['storage_descr']); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $minigraph = generate_graph_tag($graph_array); + $minigraph = generate_graph_tag($graph_array); - echo ' - - - + + + - '; - }//end foreach + "); + } - echo '
    '.overlib_link($link, $drive['storage_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' + echo("
    ".overlib_link($link, $drive['storage_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)."
    + echo('
    -
    '; -}//end if + '); -unset($drive_rows); +} + +unset ($drive_rows); + +?> diff --git a/html/pages/device/overview/syslog.inc.php b/html/pages/device/overview/syslog.inc.php index bcfb6d2c5..1d26fbb2a 100644 --- a/html/pages/device/overview/syslog.inc.php +++ b/html/pages/device/overview/syslog.inc.php @@ -1,24 +1,25 @@ '; - echo '
    +if ($config['enable_syslog']) +{ + $syslog = dbFetchRows("SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? ORDER BY timestamp DESC LIMIT 20", array($device['device_id'])); + if (count($syslog)) + { +echo('
    '); + echo('
    -
    '; - echo ' Recent Syslog'; - echo '
    - '; - foreach ($syslog as $entry) { - include 'includes/print-syslog.inc.php'; - } - - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; - } +
    '); + echo(' Recent Syslog'); +echo('
    + '); + foreach ($syslog as $entry) { include("includes/print-syslog.inc.php"); } + echo("
    "); + echo("
    "); + echo(""); + echo(""); + echo(""); + } } + +?> diff --git a/html/pages/device/overview/toner.inc.php b/html/pages/device/overview/toner.inc.php index 7c789573c..347a63619 100644 --- a/html/pages/device/overview/toner.inc.php +++ b/html/pages/device/overview/toner.inc.php @@ -1,62 +1,64 @@ +if (count($toners)) +{ + echo('
    -
    '; - echo ''; - echo " Toner"; - echo '
    - '; +
    '); + echo(''); + echo(" Toner"); + echo('
    +
    '); - foreach ($toners as $toner) { - $percent = round($toner['toner_current'], 0); - $total = formatStorage($toner['toner_size']); - $free = formatStorage($toner['toner_free']); - $used = formatStorage($toner['toner_used']); + foreach ($toners as $toner) + { + $percent = round($toner['toner_current'], 0); + $total = formatStorage($toner['toner_size']); + $free = formatStorage($toner['toner_free']); + $used = formatStorage($toner['toner_used']); - $background = toner2colour($toner['toner_descr'], $percent); + $background = toner2colour($toner['toner_descr'], $percent); - $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $toner['toner_id']; - $graph_array['type'] = $graph_type; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $toner['toner_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - $link_array = $graph_array; - $link_array['page'] = 'graphs'; - unset($link_array['height'], $link_array['width'], $link_array['legend']); - $link = generate_url($link_array); + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); - $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - '.$toner['toner_descr']); + $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $toner['toner_descr']); - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. - $minigraph = generate_graph_tag($graph_array); + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. - echo ' - - - + + + - '; - }//end foreach + "); + } - echo '
    '.overlib_link($link, $toner['toner_descr'], $overlib_content).''.overlib_link($link, $minigraph, $overlib_content).''.overlib_link($link, print_percentage_bar(200, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).' + $minigraph = generate_graph_tag($graph_array); + + echo("
    ".overlib_link($link, $toner['toner_descr'], $overlib_content)."".overlib_link($link, $minigraph, $overlib_content)."".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)."
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo ''; -}//end if + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); +} -unset($toner_rows); +unset ($toner_rows); + +?> diff --git a/html/pages/device/performance.inc.php b/html/pages/device/performance.inc.php index da2056c54..8686bf803 100644 --- a/html/pages/device/performance.inc.php +++ b/html/pages/device/performance.inc.php @@ -21,9 +21,7 @@ */ -if(!isset($vars['section'])) { - $vars['section'] = "performance"; -} +if(!isset($vars['section'])) { $vars['section'] = "performance"; } if (empty($vars['dtpickerfrom'])) { $vars['dtpickerfrom'] = date($config['dateformat']['byminute'], time() - 3600 * 24 * 2); @@ -59,8 +57,7 @@ if (empty($vars['dtpickerto'])) { if (is_admin() === true || is_read() === true) { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf` WHERE `device_id` = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); -} -else { +} else { $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf`,`devices_perms` WHERE `device_id` = ? AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = ? AND `timestamp` >= ? AND `timestamp` <= ?"; $param = array($device['device_id'], $_SESSION['user_id'], $vars['dtpickerfrom'], $vars['dtpickerto']); } @@ -84,7 +81,7 @@ foreach(dbFetchRows($query, $param) as $return_value) { $avg = $return_value['avg']; if ($max > $max_val) { - $max_val = $max; + $max_val = $max; } $data[] = array('x' => $date,'y' => $loss,'group' => 0); @@ -189,3 +186,4 @@ echo $milisec_diff; var graph2d = new vis.Graph2d(container, items, groups, options); + diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index a70d40a76..ecb25cfd2 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -1,22 +1,15 @@ get('port-'.$port['port_id'].'-state'); - if ($debug) { - print_r($state); - } - - if (is_array($state)) { - $port = array_merge($port, $state); - } - - unset($state); +if ($config['memcached']['enable'] === TRUE) +{ + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if($debug) { print_r($state); } + if(is_array($state)) { $port = array_merge($port, $state); } + unset($state); } $port_details = 1; @@ -24,218 +17,148 @@ $port_details = 1; $hostname = $device['hostname']; $hostid = $device['port_id']; $ifname = $port['ifDescr']; -$ifIndex = $port['ifIndex']; -$speed = humanspeed($port['ifSpeed']); +$ifIndex = $port['ifIndex']; +$speed = humanspeed($port['ifSpeed']); $ifalias = $port['name']; -if ($port['ifPhysAddress']) { - $mac = "$port[ifPhysAddress]"; -} +if ($port['ifPhysAddress']) { $mac = "$port[ifPhysAddress]"; } -$color = 'black'; -if ($port['ifAdminStatus'] == 'down') { - $status = "Disabled"; -} +$color = "black"; +if ($port['ifAdminStatus'] == "down") { $status = "Disabled"; } +if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $status = "Enabled / Disconnected"; } +if ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $status = "Enabled / Connected"; } -if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { - $status = "Enabled / Disconnected"; -} - -if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { - $status = "Enabled / Connected"; -} - -$i = 1; +$i = 1; $inf = fixifName($ifname); -$bg = '#ffffff'; +$bg="#ffffff"; $show_all = 1; -echo "
    "; +echo("
    "); -require 'includes/print-interface.inc.php'; +include("includes/print-interface.inc.php"); -echo '
    '; +echo(""); -$pos = strpos(strtolower($ifname), 'vlan'); -if ($pos !== false) { - $broke = yes; +$pos = strpos(strtolower($ifname), "vlan"); +if ($pos !== false ) +{ + $broke = yes; } -$pos = strpos(strtolower($ifname), 'loopback'); +$pos = strpos(strtolower($ifname), "loopback"); -if ($pos !== false) { - $broke = yes; +if ($pos !== false ) +{ + $broke = yes; } -echo "
    "; +echo("
    "); print_optionbar_start(); -$link_array = array( - 'page' => 'device', - 'device' => $device['device_id'], - 'tab' => 'port', - 'port' => $port['port_id'], -); +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'port', + 'port' => $port['port_id']); $menu_options['graphs'] = 'Graphs'; -$menu_options['realtime'] = 'Real time'; -// FIXME CONDITIONAL -$menu_options['arp'] = 'ARP Table'; -$menu_options['events'] = 'Eventlog'; +$menu_options['realtime'] = 'Real time'; // FIXME CONDITIONAL +$menu_options['arp'] = 'ARP Table'; +$menu_options['events'] = 'Eventlog'; -if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'")) { - $menu_options['adsl'] = 'ADSL'; +if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = '".$port['port_id']."'") ) +{ $menu_options['adsl'] = 'ADSL'; } + +if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'") ) +{ $menu_options['pagp'] = 'PAgP'; } + +if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'") ) +{ $menu_options['vlans'] = 'VLANs'; } + +$sep = ""; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['view'] == $option) { echo(""); } + echo(generate_link($text,$link_array,array('view'=>$option))); + if ($vars['view'] == $option) { echo(""); } + $sep = " | "; } - -if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".$port['ifIndex']."' and `device_id` = '".$device['device_id']."'")) { - $menu_options['pagp'] = 'PAgP'; -} - -if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port['port_id']."' and `device_id` = '".$device['device_id']."'")) { - $menu_options['vlans'] = 'VLANs'; -} - -$sep = ''; -foreach ($menu_options as $option => $text) { - echo $sep; - if ($vars['view'] == $option) { - echo ""; - } - - echo generate_link($text, $link_array, array('view' => $option)); - if ($vars['view'] == $option) { - echo ''; - } - - $sep = ' | '; -} - unset($sep); -if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > '0') { - echo generate_link($descr, $link_array, array('view' => 'macaccounting', 'graph' => $type)); +if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = '".$port['port_id']."'") > "0" ) +{ - echo ' | Mac Accounting : '; - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { - echo ""; - } + echo(generate_link($descr,$link_array,array('view'=>'macaccounting','graph'=>$type))); - echo generate_link('Bits', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'bits')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'graphs') { - echo ''; - } + echo(" | Mac Accounting : "); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } + echo(generate_link("Bits",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'bits'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "graphs") { echo(""); } - echo '('; - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { - echo ""; - } + echo("("); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } + echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'bits'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "minigraphs") { echo(""); } + echo('|'); - echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'bits')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'minigraphs') { - echo ''; - } + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } + echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'bits'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "bits" && $vars['subview'] == "top10") { echo(""); } + echo(") | "); - echo '|'; + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } + echo(generate_link("Packets",$link_array,array('view' => 'macaccounting', 'subview' => 'graphs', 'graph'=>'pkts'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "graphs") { echo(""); } + echo("("); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } + echo(generate_link("Mini",$link_array,array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph'=>'pkts'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "minigraphs") { echo(""); } + echo('|'); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } + echo(generate_link("Top10",$link_array,array('view' => 'macaccounting', 'subview' => 'top10', 'graph'=>'pkts'))); + if ($vars['view'] == "macaccounting" && $vars['graph'] == "pkts" && $vars['subview'] == "top10") { echo(""); } + echo(")"); +} - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { - echo ""; - } +if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > "0" ) +{ - echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'bits')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'bits' && $vars['subview'] == 'top10') { - echo ''; - } + // FIXME ATM VPs + // FIXME URLs BROKEN - echo ') | '; + echo(" | ATM VPs : "); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } + echo("Bits"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } + echo(" | "); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "packets") { echo(""); } + echo("Packets"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } + echo(" | "); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "cells") { echo(""); } + echo("Cells"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } + echo(" | "); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "errors") { echo(""); } + echo("Errors"); + if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } +} - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { - echo ""; - } - - echo generate_link('Packets', $link_array, array('view' => 'macaccounting', 'subview' => 'graphs', 'graph' => 'pkts')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'graphs') { - echo ''; - } - - echo '('; - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { - echo ""; - } - - echo generate_link('Mini', $link_array, array('view' => 'macaccounting', 'subview' => 'minigraphs', 'graph' => 'pkts')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'minigraphs') { - echo ''; - } - - echo '|'; - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { - echo ""; - } - - echo generate_link('Top10', $link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'pkts')); - if ($vars['view'] == 'macaccounting' && $vars['graph'] == 'pkts' && $vars['subview'] == 'top10') { - echo ''; - } - - echo ')'; -}//end if - -if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE port_id = '".$port['port_id']."'") > '0') { - // FIXME ATM VPs - // FIXME URLs BROKEN - echo ' | ATM VPs : '; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { - echo ""; - } - - echo "Bits"; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { - echo ''; - } - - echo ' | '; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'packets') { - echo ""; - } - - echo "Packets"; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { - echo ''; - } - - echo ' | '; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'cells') { - echo ""; - } - - echo "Cells"; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { - echo ''; - } - - echo ' | '; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'errors') { - echo ""; - } - - echo "Errors"; - if ($vars['view'] == 'junose-atm-vp' && $vars['graph'] == 'bits') { - echo ''; - } -}//end if - -if ($_SESSION['userlevel'] >= '10') { - echo " Create Bill"; +if ($_SESSION['userlevel'] >= '10') +{ + echo(" Create Bill"); } print_optionbar_end(); -echo "
    "; +echo("
    "); -require 'pages/device/port/'.mres($vars['view']).'.inc.php'; +include("pages/device/port/".mres($vars['view']).".inc.php"); -echo '
    '; +echo("
    "); + +?> diff --git a/html/pages/device/port/events.inc.php b/html/pages/device/port/events.inc.php index 5a113fafe..6de49ef26 100644 --- a/html/pages/device/port/events.inc.php +++ b/html/pages/device/port/events.inc.php @@ -1,12 +1,15 @@ '; +echo(''); -foreach ($entries as $entry) { - include 'includes/print-event.inc.php'; +foreach ($entries as $entry) +{ + include("includes/print-event.inc.php"); } -echo '
    '; +echo(''); -$pagetitle[] = 'Events'; +$pagetitle[] = "Events"; + +?> diff --git a/html/pages/device/port/pagp.inc.php b/html/pages/device/port/pagp.inc.php index 7a8e41ff5..e64437e2c 100644 --- a/html/pages/device/port/pagp.inc.php +++ b/html/pages/device/port/pagp.inc.php @@ -3,32 +3,34 @@ global $config; // FIXME functions! -if (!$graph_type) { - $graph_type = 'pagp_bits'; + +if (!$graph_type) { $graph_type = "pagp_bits"; } + +$daily_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100"; +$daily_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; + +$weekly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=215&height=100"; +$weekly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['week']."&to=".$config['time']['now']."&width=500&height=150"; + +$monthly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=215&height=100"; +$monthly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['month']."&to=".$config['time']['now']."&width=500&height=150"; + +$yearly_traffic = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=215&height=100"; +$yearly_url = "graph.php?port=" . $port['port_id'] . "&type=$graph_type&from=".$config['time']['year']."&to=".$config['time']['now']."&width=500&height=150"; + +echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "); +echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> + "); +echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "); +echo("', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> + "); + +foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) +{ + echo("$br " . generate_port_link($member) . " (PAgP)"); + $br = "
    "; } -$daily_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=215&height=100'; -$daily_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; - -$weekly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=215&height=100'; -$weekly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['week'].'&to='.$config['time']['now'].'&width=500&height=150'; - -$monthly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=215&height=100'; -$monthly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['month'].'&to='.$config['time']['now'].'&width=500&height=150'; - -$yearly_traffic = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=215&height=100'; -$yearly_url = 'graph.php?port='.$port['port_id']."&type=$graph_type&from=".$config['time']['year'].'&to='.$config['time']['now'].'&width=500&height=150'; - -echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "; -echo "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> - "; -echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "; -echo "', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\"> - "; - -foreach (dbFetchRows('SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?', array($port['ifIndex'], $device['device_id'])) as $member) { - echo "$br ".generate_port_link($member).' (PAgP)'; - $br = '
    '; -} +?> diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index dc941e246..b254b376d 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -1,23 +1,15 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'ports', -); +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'ports'); print_optionbar_start(); @@ -25,136 +17,110 @@ $menu_options['basic'] = 'Basic'; $menu_options['details'] = 'Details'; $menu_options['arp'] = 'ARP Table'; -if (dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) { - $menu_options['neighbours'] = 'Neighbours'; +if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.port_id = L.local_port_id")) +{ + $menu_options['neighbours'] = 'Neighbours'; +} +if(dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) +{ + $menu_options['adsl'] = 'ADSL'; } -if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) { - $menu_options['adsl'] = 'ADSL'; -} - -$sep = ''; -foreach ($menu_options as $option => $text) { - echo $sep; - if ($vars['view'] == $option) { - echo ""; - } - - echo generate_link($text, $link_array, array('view' => $option)); - if ($vars['view'] == $option) { - echo ''; - } - - $sep = ' | '; +$sep = ""; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['view'] == $option) { echo(""); } + echo(generate_link($text,$link_array,array('view'=>$option))); + if ($vars['view'] == $option) { echo(""); } + $sep = " | "; } unset($sep); -echo ' | Graphs: '; +echo(' | Graphs: '); -$graph_types = array( - 'bits' => 'Bits', - 'upkts' => 'Unicast Packets', - 'nupkts' => 'Non-Unicast Packets', - 'errors' => 'Errors', - 'etherlike' => 'Etherlike', -); +$graph_types = array("bits" => "Bits", + "upkts" => "Unicast Packets", + "nupkts" => "Non-Unicast Packets", + "errors" => "Errors", + "etherlike" => "Etherlike"); -foreach ($graph_types as $type => $descr) { - echo "$type_sep"; - if ($vars['graph'] == $type && $vars['view'] == 'graphs') { - echo ""; - } +foreach ($graph_types as $type => $descr) +{ + echo("$type_sep"); + if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } + echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type))); + if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo(""); } - echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type)); - if ($vars['graph'] == $type && $vars['view'] == 'graphs') { - echo ''; - } - - echo ' ('; - if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { - echo ""; - } - - echo generate_link('Mini', $link_array, array('view' => 'minigraphs', 'graph' => $type)); - if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') { - echo ''; - } - - echo ')'; - $type_sep = ' | '; -}//end foreach + echo(' ('); + if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } + echo(generate_link('Mini',$link_array,array('view'=>'minigraphs','graph'=>$type))); + if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo(""); } + echo(')'); + $type_sep = " | "; +} print_optionbar_end(); -if ($vars['view'] == 'minigraphs') { - $timeperiods = array( - '-1day', - '-1week', - '-1month', - '-1year', - ); - $from = '-1day'; - echo "
    "; - unset($seperator); +if ($vars['view'] == 'minigraphs') +{ + $timeperiods = array('-1day','-1week','-1month','-1year'); + $from = '-1day'; + echo("
    "); + unset ($seperator); - // FIXME - FIX THIS. UGLY. - foreach (dbFetchRows('select * from ports WHERE device_id = ? ORDER BY ifIndex', array($device['device_id'])) as $port) { - echo "
    -
    ".makeshortif($port['ifDescr']).'
    - ".$device['hostname'].' - '.$port['ifDescr'].'
    \ - '.$port['ifAlias']." \ - \ - ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >"." - -
    ".truncate(short_port_descr($port['ifAlias']), 32, '').'
    -
    '; + // FIXME - FIX THIS. UGLY. + foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $port) + { + echo("
    +
    ".makeshortif($port['ifDescr'])."
    + ".$device['hostname']." - ".$port['ifDescr']."
    \ + ".$port['ifAlias']." \ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". + " + +
    ".truncate(short_port_descr($port['ifAlias']), 32, '')."
    +
    "); + } + echo("
    "); +} elseif ($vars['view'] == "arp" || $vars['view'] == "adsl" || $vars['view'] == "neighbours") { + include("ports/".$vars['view'].".inc.php"); +} else { + if ($vars['view'] == "details") { $port_details = 1; } + echo("
    "); + $i = "1"; + + global $port_cache, $port_index_cache; + + $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); + // As we've dragged the whole database, lets pre-populate our caches :) + // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. + foreach ($ports as $port) + { + $port_cache[$port['port_id']] = $port; + $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; + } + + foreach ($ports as $port) + { + if ($config['memcached']['enable'] === TRUE) + { + $state = $memcache->get('port-'.$port['port_id'].'-state'); + if($debug) { print_r($state); } + if(is_array($state)) { $port = array_merge($port, $state); } + unset($state); } - echo ''; + include("includes/print-interface.inc.php"); + + $i++; + } + echo("
    "); } -else if ($vars['view'] == 'arp' || $vars['view'] == 'adsl' || $vars['view'] == 'neighbours') { - include 'ports/'.$vars['view'].'.inc.php'; -} -else { - if ($vars['view'] == 'details') { - $port_details = 1; - } - echo "
    "; - $i = '1'; +$pagetitle[] = "Ports"; - global $port_cache, $port_index_cache; - - $ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); - // As we've dragged the whole database, lets pre-populate our caches :) - // FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. - foreach ($ports as $port) { - $port_cache[$port['port_id']] = $port; - $port_index_cache[$port['device_id']][$port['ifIndex']] = $port; - } - - foreach ($ports as $port) { - if ($config['memcached']['enable'] === true) { - $state = $memcache->get('port-'.$port['port_id'].'-state'); - if ($debug) { - print_r($state); - } - - if (is_array($state)) { - $port = array_merge($port, $state); - } - - unset($state); - } - - include 'includes/print-interface.inc.php'; - - $i++; - } - - echo '
    '; -}//end if - -$pagetitle[] = 'Ports'; +?> diff --git a/html/pages/device/ports/neighbours.inc.php b/html/pages/device/ports/neighbours.inc.php index b56136881..5e417eb99 100644 --- a/html/pages/device/ports/neighbours.inc.php +++ b/html/pages/device/ports/neighbours.inc.php @@ -10,7 +10,8 @@ echo 'Local Port Protocol '; -foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) { +foreach (dbFetchRows('SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id', array($device['device_id'])) as $neighbour) +{ if ($bg_colour == $list_colour_b) { $bg_colour = $list_colour_a; } diff --git a/html/pages/device/processes.inc.php b/html/pages/device/processes.inc.php index 0ce8e4c70..41fda9288 100644 --- a/html/pages/device/processes.inc.php +++ b/html/pages/device/processes.inc.php @@ -1,21 +1,19 @@ +/* Copyright (C) 2015 Daniel Preussker * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ + * along with this program. If not, see . */ -/* +/** * Process Listing * @author Daniel Preussker * @copyright 2015 f0o, LibreNMS @@ -24,89 +22,77 @@ * @subpackage Pages */ -switch ($vars['order']) { - case 'vsz': - $order = '`vsz`'; - break; - - case 'rss': - $order = '`rss`'; - break; - - case 'cputime': - $order = '`cputime`'; - break; - - case 'user': - $order = '`user`'; - break; - - case 'command': - $order = '`command`'; - break; - - default: - $order = '`pid`'; - break; -}//end switch - -if ($vars['by'] == 'desc') { - $by = 'desc'; +switch( $vars['order'] ) { + case "vsz": + $order = "`vsz`"; + break; + case "rss": + $order = "`rss`"; + break; + case "cputime": + $order = "`cputime`"; + break; + case "user": + $order = "`user`"; + break; + case "command": + $order = "`command`"; + break; + default: + $order = "`pid`"; + break; } -else { - $by = 'asc'; +if( $vars['by'] == "desc" ) { + $by = "desc"; +} else { + $by = "asc"; } $heads = array( - 'PID' => '', - 'VSZ' => 'Virtual Memory', - 'RSS' => 'Resident Memory', - 'cputime' => '', - 'user' => '', - 'command' => '', + 'PID' => '', + 'VSZ' => 'Virtual Memory', + 'RSS' => 'Resident Memory', + 'cputime' => '', + 'user' => '', + 'command' => '' ); echo "
    "; -foreach ($heads as $head => $extra) { - unset($lhead, $bhead); - $lhead = strtolower($head); - $bhead = 'asc'; - $icon = ''; - if ('`'.$lhead.'`' == $order) { - $icon = " class='glyphicon glyphicon-chevron-"; - if ($by == 'asc') { - $bhead = 'desc'; - $icon .= 'up'; - } - else { - $icon .= 'down'; - } - - $icon .= "'"; - } - - echo ''; -}//end foreach - -echo ''; - -foreach (dbFetchRows('SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY '.$order.' '.$by, array($device['device_id'])) as $entry) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; +foreach( $heads as $head=>$extra ) { + unset($lhead, $bhead); + $lhead = strtolower($head); + $bhead = 'asc'; + $icon = ""; + if( '`'.$lhead.'`' == $order ) { + $icon = " class='glyphicon glyphicon-chevron-"; + if( $by == 'asc' ) { + $bhead = 'desc'; + $icon .= 'up'; + } else { + $icon .= 'down'; + } + $icon .= "'"; + } + echo ''; } +echo ""; -echo '
     '; - if (!empty($extra)) { - echo "$head"; - } - else { - echo $head; - } - - echo '
    '.$entry['pid'].''.format_si(($entry['vsz'] * 1024)).''.format_si(($entry['rss'] * 1024)).''.$entry['cputime'].''.$entry['user'].''.$entry['command'].'
     '; + if( !empty($extra) ) { + echo "$head"; + } else { + echo $head; + } + echo '
    '; +foreach (dbFetchRows("SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY ".$order." ".$by, array($device['device_id'])) as $entry) { + echo ''; + echo ''.$entry['pid'].''; + echo ''.format_si($entry['vsz']*1024).''; + echo ''.format_si($entry['rss']*1024).''; + echo ''.$entry['cputime'].''; + echo ''.$entry['user'].''; + echo ''.$entry['command'].''; + echo ''; +} +echo"
    "; + +?> diff --git a/html/pages/device/pseudowires.inc.php b/html/pages/device/pseudowires.inc.php index c48bca573..c134c8b66 100644 --- a/html/pages/device/pseudowires.inc.php +++ b/html/pages/device/pseudowires.inc.php @@ -89,7 +89,8 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I WHERE P.port_id 'upkts', 'errors', ); - foreach ($types as $graph_type) { + foreach ($types as $graph_type) + { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index 17f0629a0..5b327aca3 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -1,275 +1,203 @@ 'device', - 'device' => $device['device_id'], - 'tab' => 'routing', - 'proto' => 'bgp', -); +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'routing', + 'proto' => 'bgp'); -if (!isset($vars['view'])) { - $vars['view'] = 'basic'; -} +if(!isset($vars['view'])) { $vars['view'] = "basic"; } print_optionbar_start(); -echo 'Local AS : '.$device['bgpLocalAs'].' '; +echo "Local AS : " .$device['bgpLocalAs']." "; -echo "BGP » "; +echo("BGP » "); -if ($vars['view'] == 'basic') { - echo ""; -} +if ($vars['view'] == "basic") { echo(""); } +echo(generate_link("Basic", $link_array,array('view'=>'basic'))); +if ($vars['view'] == "basic") { echo(""); } -echo generate_link('Basic', $link_array, array('view' => 'basic')); -if ($vars['view'] == 'basic') { - echo ''; -} +echo(" | "); -echo ' | '; +if ($vars['view'] == "updates") { echo(""); } +echo(generate_link("Updates", $link_array,array('view'=>'updates'))); +if ($vars['view'] == "updates") { echo(""); } -if ($vars['view'] == 'updates') { - echo ""; -} +echo(" | Prefixes: "); -echo generate_link('Updates', $link_array, array('view' => 'updates')); -if ($vars['view'] == 'updates') { - echo ''; -} +if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } +echo(generate_link("IPv4", $link_array,array('view'=>'prefixes_ipv4unicast'))); +if ($vars['view'] == "prefixes_ipv4unicast") { echo(""); } -echo ' | Prefixes: '; +echo(" | "); -if ($vars['view'] == 'prefixes_ipv4unicast') { - echo ""; -} +if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } +echo(generate_link("VPNv4", $link_array,array('view'=>'prefixes_vpnv4unicast'))); +if ($vars['view'] == "prefixes_vpnv4unicast") { echo(""); } -echo generate_link('IPv4', $link_array, array('view' => 'prefixes_ipv4unicast')); -if ($vars['view'] == 'prefixes_ipv4unicast') { - echo ''; -} +echo(" | "); -echo ' | '; +if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } +echo(generate_link("IPv6", $link_array,array('view'=>'prefixes_ipv6unicast'))); +if ($vars['view'] == "prefixes_ipv6unicast") { echo(""); } -if ($vars['view'] == 'prefixes_vpnv4unicast') { - echo ""; -} +echo(" | Traffic: "); -echo generate_link('VPNv4', $link_array, array('view' => 'prefixes_vpnv4unicast')); -if ($vars['view'] == 'prefixes_vpnv4unicast') { - echo ''; -} - -echo ' | '; - -if ($vars['view'] == 'prefixes_ipv6unicast') { - echo ""; -} - -echo generate_link('IPv6', $link_array, array('view' => 'prefixes_ipv6unicast')); -if ($vars['view'] == 'prefixes_ipv6unicast') { - echo ''; -} - -echo ' | Traffic: '; - -if ($vars['view'] == 'macaccounting_bits') { - echo ""; -} - -echo generate_link('Bits', $link_array, array('view' => 'macaccounting_bits')); -if ($vars['view'] == 'macaccounting_bits') { - echo ''; -} - -echo ' | '; -if ($vars['view'] == 'macaccounting_pkts') { - echo ""; -} - -echo generate_link('Packets', $link_array, array('view' => 'macaccounting_pkts')); -if ($vars['view'] == 'macaccounting_pkts') { - echo ''; -} +if ($vars['view'] == "macaccounting_bits") { echo(""); } +echo(generate_link("Bits", $link_array,array('view'=>'macaccounting_bits'))); +if ($vars['view'] == "macaccounting_bits") { echo(""); } +echo(" | "); +if ($vars['view'] == "macaccounting_pkts") { echo(""); } +echo(generate_link("Packets", $link_array,array('view'=>'macaccounting_pkts'))); +if ($vars['view'] == "macaccounting_pkts") { echo(""); } print_optionbar_end(); -echo ''; -echo ''; +echo('
    Peer addressTypeRemote ASStateUptime
    '); +echo(''); -$i = '1'; +$i = "1"; -foreach (dbFetchRows('SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`', array($device['device_id'])) as $peer) { - $has_macaccounting = dbFetchCell('SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address', array($peer['bgpPeerIdentifier'])); - unset($bg_image); - if (!is_integer($i / 2)) { - $bg_colour = $list_colour_a; - } - else { - $bg_colour = $list_colour_b; - } +foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`", array($device['device_id'])) as $peer) +{ + $has_macaccounting = dbFetchCell("SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address", array($peer['bgpPeerIdentifier'])); + unset($bg_image); + if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } + unset ($alert, $bg_image); + unset ($peerhost, $peername); - unset($alert, $bg_image); - unset($peerhost, $peername); + if (!is_integer($i/2)) { $bg_colour = $list_colour_b; } else { $bg_colour = $list_colour_a; } + if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } + if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } + if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } - if (!is_integer($i / 2)) { - $bg_colour = $list_colour_b; - } - else { - $bg_colour = $list_colour_a; - } + if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; } - if ($peer['bgpPeerState'] == 'established') { - $col = 'green'; - } - else { - $col = 'red'; - $peer['alert'] = 1; - } + $query = "SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE "; + $query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; + $query .= " AND D.device_id = I.device_id"; + $ipv4_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); - if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { - $admin_col = 'green'; - } - else { - $admin_col = 'gray'; - } + $query = "SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE "; + $query .= "(A.ipv6_address = ? AND I.port_id = A.port_id)"; + $query .= " AND D.device_id = I.device_id"; + $ipv6_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); - if ($peer['bgpPeerAdminStatus'] == 'stop') { - $peer['alert'] = 0; - $peer['disabled'] = 1; - } + if ($ipv4_host) + { + $peerhost = $ipv4_host; + } elseif ($ipv6_host) { + $peerhost = $ipv6_host; + } else { + unset($peerhost); + } - if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { - $peer_type = "iBGP"; - } - else { - $peer_type = "eBGP"; - } + if (is_array($peerhost)) + { + #$peername = generate_device_link($peerhost); + $peername = generate_device_link($peerhost) ." ". generate_port_link($peerhost); + $peer_url = "device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/view=updates/"; + } + else + { + #$peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? +# if ($peername == $peer['bgpPeerIdentifier']) +# { +# unset($peername); +# } else { +# $peername = "".$peername.""; +# } + } - $query = 'SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE '; - $query .= '(A.ipv4_address = ? AND I.port_id = A.port_id)'; - $query .= ' AND D.device_id = I.device_id'; - $ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); + unset($peer_af); + unset($sep); - $query = 'SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE '; - $query .= '(A.ipv6_address = ? AND I.port_id = A.port_id)'; - $query .= ' AND D.device_id = I.device_id'; - $ipv6_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'])); + foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) + { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep . $afi .".".$safi; + $sep = "
    "; + $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer + } - if ($ipv4_host) { - $peerhost = $ipv4_host; - } - else if ($ipv6_host) { - $peerhost = $ipv6_host; - } - else { - unset($peerhost); - } + unset($sep); - if (is_array($peerhost)) { - // $peername = generate_device_link($peerhost); - $peername = generate_device_link($peerhost).' '.generate_port_link($peerhost); - $peer_url = 'device/device='.$peer['device_id'].'/tab=routing/proto=bgp/view=updates/'; - } - else { - // FIXME - // $peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery? - // if ($peername == $peer['bgpPeerIdentifier']) - // { - // unset($peername); - // } else { - // $peername = "".$peername.""; - // } - } - - unset($peer_af); - unset($sep); - - foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep.$afi.'.'.$safi; - $sep = '
    '; - $peer['afisafi'][$this_afisafi] = 1; - // Build a list of valid AFI/SAFI for this peer - } - - unset($sep); - - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { - $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { + $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } - $graph_type = 'bgp_updates'; - $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; - $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer['bgpPeerIdentifier'].''; + $graph_type = "bgp_updates"; + $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; + $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpPeerIdentifier'] . ""; - echo '
    - '; + echo(' + "); - echo ' - - - - - - - - '; + echo(" + + + + + + + + "); - unset($invalid); + unset($invalid); - switch ($vars['view']) { + switch ($vars['view']) + { case 'prefixes_ipv4unicast': case 'prefixes_ipv4multicast': case 'prefixes_ipv4vpn': case 'prefixes_ipv6unicast': case 'prefixes_ipv6multicast': - list(,$afisafi) = explode('_', $vars['view']); - if (isset($peer['afisafi'][$afisafi])) { - $peer['graph'] = 1; - } - - // FIXME no break?? + list(,$afisafi) = explode("_", $vars['view']); + if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } + // FIXME no break?? case 'updates': - $graph_array['type'] = 'bgp_'.$vars['view']; - $graph_array['id'] = $peer['bgpPeer_id']; - } + $graph_array['type'] = "bgp_" . $vars['view']; + $graph_array['id'] = $peer['bgpPeer_id']; + } - switch ($vars['view']) { + switch ($vars['view']) + { case 'macaccounting_bits': case 'macaccounting_pkts': - $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; - if (is_array($acc) && is_file($database)) { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['view']; - } - } + $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; + if (is_array($acc) && is_file($database)) + { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['view']; + } + } - if ($vars['view'] == 'updates') { - $peer['graph'] = 1; - } + if ($vars['view'] == 'updates') { $peer['graph'] = 1; } - if ($peer['graph']) { - $graph_array['height'] = '100'; - $graph_array['width'] = '216'; - $graph_array['to'] = $config['time']['now']; - echo ''; - } + echo(""); + } - $i++; + $i++; - unset($valid_afi_safi); -}//end foreach + unset($valid_afi_safi); +} ?>
    Peer addressTypeRemote ASStateUptime
    '.$i.''.$peeraddresslink.'
    '.$peername."
    $peer_type".(isset($peer['afi']) ? $peer['afi'] : '').'AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']."
    ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    - Updates ".$peer['bgpPeerInUpdates']." - ".$peer['bgpPeerOutUpdates'].'
    ".$i."" . $peeraddresslink . "
    ".$peername."
    $peer_type" . (isset($peer['afi']) ? $peer['afi'] : '') . "AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    + Updates " . $peer['bgpPeerInUpdates'] . " + " . $peer['bgpPeerOutUpdates'] . "
    '; + if ($peer['graph']) + { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + echo('
    '); - include 'includes/print-graphrow.inc.php'; + include("includes/print-graphrow.inc.php"); - echo '
    diff --git a/html/pages/device/routing/ospf.inc.php b/html/pages/device/routing/ospf.inc.php index 7bf6798b7..ed126a7fe 100644 --- a/html/pages/device/routing/ospf.inc.php +++ b/html/pages/device/routing/ospf.inc.php @@ -88,7 +88,8 @@ foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', arr // # Loop Ports $i_p = ($i_a + 1); $p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id"; - foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) { + foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport) + { if (!is_integer($i_a / 2)) { if (!is_integer($i_p / 2)) { $port_bg = $list_colour_b_b; diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index 9efc95d63..aed9398dd 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -1,135 +1,134 @@ = '7') { - if (!is_array($config['rancid_configs'])) { - $config['rancid_configs'] = array($config['rancid_configs']); - } - if (isset($config['rancid_configs'][0])) { - foreach ($config['rancid_configs'] as $configs) { - if ($configs[(strlen($configs) - 1)] != '/') { - $configs .= '/'; - } +if ($_SESSION['userlevel'] >= "7") +{ - if (is_file($configs.$device['hostname'])) { - $file = $configs.$device['hostname']; - } - } + if (!is_array($config['rancid_configs'])) { $config['rancid_configs'] = array($config['rancid_configs']); } - echo '
    '; + if (isset($config['rancid_configs'][0])) { - print_optionbar_start('', ''); + foreach ($config['rancid_configs'] as $configs) { + if ($configs[strlen($configs) - 1] != '/') { + $configs .= '/'; + } + if (is_file($configs . $device['hostname'])) { + $file = $configs . $device['hostname']; + } + } - echo "Config » "; + echo('
    '); - if (!$vars['rev']) { - echo ''; - echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); - echo ''; - } - else { - echo generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig')); - } + print_optionbar_start('', ''); - if (function_exists('svn_log')) { - $sep = ' | '; - $svnlogs = svn_log($file, SVN_REVISION_HEAD, null, 8); - $revlist = array(); + echo("Config » "); - foreach ($svnlogs as $svnlog) { - echo $sep; - $revlist[] = $svnlog['rev']; + if (!$vars['rev']) { + echo(''); + echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); + echo(""); + } else { + echo(generate_link('Latest', array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig'))); + } - if ($vars['rev'] == $svnlog['rev']) { - echo ''; - } + if (function_exists('svn_log')) { - $linktext = 'r'.$svnlog['rev'].' '.date($config['dateformat']['byminute'], strtotime($svnlog['date'])).''; - echo generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog['rev'])); + $sep = " | "; + $svnlogs = svn_log($file, SVN_REVISION_HEAD, NULL, 8); + $revlist = array(); - if ($vars['rev'] == $svnlog['rev']) { - echo ''; - } + foreach ($svnlogs as $svnlog) { - $sep = ' | '; - } - }//end if + echo($sep); + $revlist[] = $svnlog["rev"]; - print_optionbar_end(); + if ($vars['rev'] == $svnlog["rev"]) { + echo(''); + } + $linktext = "r" . $svnlog["rev"] . " " . date($config['dateformat']['byminute'], strtotime($svnlog["date"])) . ""; + echo(generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog["rev"]))); - if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { - list($diff, $errors) = svn_diff($file, ($vars['rev'] - 1), $file, $vars['rev']); - if (!$diff) { - $text = 'No Difference'; - } - else { - $text = ''; - while (!feof($diff)) { - $text .= fread($diff, 8192); - } + if ($vars['rev'] == $svnlog["rev"]) { + echo(""); + } - fclose($diff); - fclose($errors); - } - } - else { - $fh = fopen($file, 'r') or die("Can't open file"); - $text = fread($fh, filesize($file)); - fclose($fh); - } + $sep = " | "; + } + } - if ($config['rancid_ignorecomments']) { - $lines = explode("\n", $text); - for ($i = 0; $i < count($lines); $i++) { - if ($lines[$i][0] == '#') { - unset($lines[$i]); - } - } + print_optionbar_end(); - $text = join("\n", $lines); - } - } - else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) { - $node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true); - $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['hostname']); - if ($text == 'node not found') { - $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['os'].'/'.$device['hostname']); - } + if (function_exists('svn_log') && in_array($vars['rev'], $revlist)) { + list($diff, $errors) = svn_diff($file, $vars['rev'] - 1, $file, $vars['rev']); + if (!$diff) { + $text = "No Difference"; + } else { + $text = ""; + while (!feof($diff)) { + $text .= fread($diff, 8192); + } + fclose($diff); + fclose($errors); + } - if (is_array($node_info)) { - echo '
    -
    + } else { + $fh = fopen($file, 'r') or die("Can't open file"); + $text = fread($fh, filesize($file)); + fclose($fh); + } + + if ($config['rancid_ignorecomments']) { + $lines = explode("\n", $text); + for ($i = 0; $i < count($lines); $i++) { + if ($lines[$i][0] == "#") { + unset($lines[$i]); + } + } + $text = join("\n", $lines); + } + } elseif ($config['oxidized']['enabled'] === TRUE && isset($config['oxidized']['url'])) { + $node_info = json_decode(file_get_contents($config['oxidized']['url']."/node/show/".$device['hostname']."?format=json"),TRUE); + $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['hostname']); + if ($text == "node not found") { + $text = file_get_contents($config['oxidized']['url']."/node/fetch/".$device['os']."/".$device['hostname']); + } + + if (is_array($node_info)) { + echo('
    +
    -
    -
    Sync status: '.$node_info['last']['status'].'
    -
      -
    • Node: '.$node_info['name'].'
    • -
    • IP: '.$node_info['ip'].'
    • -
    • Model: '.$node_info['model'].'
    • -
    • Last Sync: '.$node_info['last']['end'].'
    • -
    +
    +
    Sync status: '.$node_info['last']['status'].'
    +
      +
    • Node: '. $node_info['name'].'
    • +
    • IP: '. $node_info['ip'].'
    • +
    • Model: '. $node_info['model'].'
    • +
    • Last Sync: '. $node_info['last']['end'].'
    • +
    +
    -
    -
    '; - } - else { - echo '
    '; - print_error("We couldn't retrieve the device information from Oxidized"); - $text = ''; - } - }//end if +
    '); + } else { + echo "
    "; + print_error("We couldn't retrieve the device information from Oxidized"); + $text = ''; + } - if (!empty($text)) { - $language = 'ios'; - $geshi = new GeSHi($text, $language); - $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); - $geshi->set_overall_style('color: black;'); - // $geshi->set_line_style('color: #999999'); - echo $geshi->parse_code(); - } -}//end if + } -$pagetitle[] = 'Config'; + if (!empty($text)) { + $language = "ios"; + $geshi = new GeSHi($text, $language); + $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); + $geshi->set_overall_style('color: black;'); + #$geshi->set_line_style('color: #999999'); + echo($geshi->parse_code()); + } +} + +$pagetitle[] = "Config"; + +?> diff --git a/html/pages/device/slas.inc.php b/html/pages/device/slas.inc.php index 587c7d743..3cc6cbf11 100644 --- a/html/pages/device/slas.inc.php +++ b/html/pages/device/slas.inc.php @@ -12,7 +12,7 @@ foreach ($slas as $sla) { $sla_type = $sla['rtt_type']; if (!in_array($sla_type, $sla_types)) { - if (isset($config['sla_type_labels'][$sla_type])) { + if (isset($config['sla_type_labels'][$sla_type])) { $text = $config['sla_type_labels'][$sla_type]; } } diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index 0367b8a1c..67a8c39ed 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -2,9 +2,7 @@ // Set Defaults here -if(!isset($vars['format'])) { - $vars['format'] = "list_detail"; -} +if(!isset($vars['format'])) { $vars['format'] = "list_detail"; } $pagetitle[] = "Devices"; @@ -12,19 +10,23 @@ print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', + 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) { - echo($sep); - if ($vars['format'] == "list_".$option) { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['format'] == "list_".$option) + { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) + { + echo(""); + } + $sep = " | "; } ?> @@ -36,26 +38,29 @@ foreach ($menu_options as $option => $text) { 'Bits', - 'processor' => 'CPU', - 'ucd_load' => 'Load', - 'mempool' => 'Memory', - 'uptime' => 'Uptime', - 'storage' => 'Storage', - 'diskio' => 'Disk I/O', - 'poller_perf' => 'Poller', - 'ping_perf' => 'Ping' -); + 'processor' => 'CPU', + 'ucd_load' => 'Load', + 'mempool' => 'Memory', + 'uptime' => 'Uptime', + 'storage' => 'Storage', + 'diskio' => 'Disk I/O', + 'poller_perf' => 'Poller', + 'ping_perf' => 'Ping' + ); $sep = ""; -foreach ($menu_options as $option => $text) { - echo($sep); - if ($vars['format'] == 'graph_'.$option) { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['format'] == 'graph_'.$option) + { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) + { + echo(""); + } + $sep = " | "; } ?> @@ -64,21 +69,21 @@ foreach ($menu_options as $option => $text) { '')).'">Restore Search'); -} -else { + } else { echo('Remove Search'); -} + } -echo(" | "); + echo(" | "); -if (isset($vars['bare']) && $vars['bare'] == "yes") { + if (isset($vars['bare']) && $vars['bare'] == "yes") + { echo('Restore Header'); -} -else { + } else { echo('Remove Header'); -} + } print_optionbar_end(); ?> @@ -89,110 +94,76 @@ print_optionbar_end(); list($format, $subformat) = explode("_", $vars['format'], 2); -if($format == "graph") { - $sql_param = array(); +if($format == "graph") +{ +$sql_param = array(); - if(isset($vars['state'])) { - if($vars['state'] == 'up') { - $state = '1'; - } - elseif($vars['state'] == 'down') { - $state = '0'; - } - } +if(isset($vars['state'])) +{ + if($vars['state'] == 'up') + { + $state = '1'; + } + elseif($vars['state'] == 'down') + { + $state = '0'; + } +} - if (!empty($vars['hostname'])) { - $where .= " AND hostname LIKE ?"; - $sql_param[] = "%".$vars['hostname']."%"; - } - if (!empty($vars['os'])) { - $where .= " AND os = ?"; - $sql_param[] = $vars['os']; - } - if (!empty($vars['version'])) { - $where .= " AND version = ?"; - $sql_param[] = $vars['version']; - } - if (!empty($vars['hardware'])) { - $where .= " AND hardware = ?"; - $sql_param[] = $vars['hardware']; - } - if (!empty($vars['features'])) { - $where .= " AND features = ?"; - $sql_param[] = $vars['features']; - } +if (!empty($vars['hostname'])) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; } +if (!empty($vars['os'])) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; } +if (!empty($vars['version'])) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; } +if (!empty($vars['hardware'])) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; } +if (!empty($vars['features'])) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; } +if (!empty($vars['type'])) { + if ($vars['type'] == 'generic') { + $where .= " AND ( type = ? OR type = '')"; $sql_param[] = $vars['type']; + } else { + $where .= " AND type = ?"; $sql_param[] = $vars['type']; + } +} +if (!empty($vars['state'])) { + $where .= " AND status= ?"; $sql_param[] = $state; + $where .= " AND disabled='0' AND `ignore`='0'"; $sql_param[] = ''; +} +if (!empty($vars['disabled'])) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; } +if (!empty($vars['ignore'])) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; } +if (!empty($vars['location']) && $vars['location'] == "Unset") { $location_filter = ''; } +if (!empty($vars['location'])) { $location_filter = $vars['location']; } +if( !empty($vars['group']) ) { + require_once('../includes/device-groups.inc.php'); + $where .= " AND ( "; + foreach( GetDevicesFromGroup($vars['group']) as $dev ) { + $where .= "device_id = ? OR "; + $sql_param[] = $dev['device_id']; + } + $where = substr($where, 0, strlen($where)-3); + $where .= " )"; +} - if (!empty($vars['type'])) { - if ($vars['type'] == 'generic') { - $where .= " AND ( type = ? OR type = '')"; - $sql_param[] = $vars['type']; - } - else { - $where .= " AND type = ?"; - $sql_param[] = $vars['type']; - } - } - if (!empty($vars['state'])) { - $where .= " AND status= ?"; - $sql_param[] = $state; - $where .= " AND disabled='0' AND `ignore`='0'"; - $sql_param[] = ''; - } - if (!empty($vars['disabled'])) { - $where .= " AND disabled= ?"; - $sql_param[] = $vars['disabled']; - } - if (!empty($vars['ignore'])) { - $where .= " AND `ignore`= ?"; - $sql_param[] = $vars['ignore']; - } - if (!empty($vars['location']) && $vars['location'] == "Unset") { - $location_filter = ''; - } - if (!empty($vars['location'])) { - $location_filter = $vars['location']; - } - if( !empty($vars['group']) ) { - require_once('../includes/device-groups.inc.php'); - $where .= " AND ( "; - foreach( GetDevicesFromGroup($vars['group']) as $dev ) { - $where .= "device_id = ? OR "; - $sql_param[] = $dev['device_id']; - } - $where = substr($where, 0, strlen($where)-3); - $where .= " )"; - } +$query = "SELECT * FROM `devices` WHERE 1 "; - $query = "SELECT * FROM `devices` WHERE 1 "; +if (isset($where)) { + $query .= $where; +} - if (isset($where)) { - $query .= $where; - } +$query .= " ORDER BY hostname"; - $query .= " ORDER BY hostname"; + $row = 1; + foreach (dbFetchRows($query, $sql_param) as $device) + { + if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - $row = 1; - foreach (dbFetchRows($query, $sql_param) as $device) { - if (is_integer($row/2)) { - $row_colour = $list_colour_a; - } - else { - $row_colour = $list_colour_b; - } + if (device_permitted($device['device_id'])) + { + if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) + || $device['location'] == $location_filter)) + { + $graph_type = "device_".$subformat; - if (device_permitted($device['device_id'])) { - if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) - || $device['location'] == $location_filter)) { - $graph_type = "device_".$subformat; + if ($_SESSION['widescreen']) { $width=270; } else { $width=315; } - if ($_SESSION['widescreen']) { - $width=270; - } - else { - $width=315; - } - - echo(""); - } - } + } } -} -else { + } + +} else { ?> @@ -238,23 +209,22 @@ else { ""+ '.$config['os'][$tmp_os]['text'].'"+'); +if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY `os`"; +} else { + $sql = "SELECT `os` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `os` ORDER BY `os`"; + $param[] = $_SESSION['user_id']; +} +foreach (dbFetch($sql,$param) as $data) { + if ($data['os']) { + $tmp_os = clean_bootgrid($data['os']); + echo('""+'); } +} ?> ""+ "
    "+ @@ -263,23 +233,22 @@ else { ""+ '.$tmp_version.'"+'); +if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `version` FROM `devices` AS D WHERE 1 GROUP BY `version` ORDER BY `version`"; +} else { + $sql = "SELECT `version` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `version` ORDER BY `version`"; + $param[] = $_SESSION['user_id']; +} +foreach (dbFetch($sql,$param) as $data) { + if ($data['version']) { + $tmp_version = clean_bootgrid($data['version']); + echo('""+'); + } +} ?> ""+ "
    "+ @@ -288,23 +257,22 @@ else { ""+ '.$tmp_hardware.'"+'); +if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardware` ORDER BY `hardware`"; +} else { + $sql = "SELECT `hardware` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hardware` ORDER BY `hardware`"; + $param[] = $_SESSION['user_id']; +} +foreach (dbFetch($sql,$param) as $data) { + if ($data['hardware']) { + $tmp_hardware = clean_bootgrid($data['hardware']); + echo('""+'); } +} ?> ""+ @@ -314,24 +282,24 @@ else { ""+ '.$tmp_features.'"+'); - } + echo('">'.$tmp_features.'"+'); } +} ?> ""+ @@ -343,16 +311,16 @@ else { '.$location.'"+'); +foreach (getlocations() as $location) { + if ($location) { + $location = clean_bootgrid($location); + echo('""+'); } +} ?> ""+ ""+ @@ -361,22 +329,21 @@ else { ""+ '.ucfirst($data['type']).'"+'); +if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; +} else { + $sql = "SELECT `type` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `type` ORDER BY `type`"; + $param[] = $_SESSION['user_id']; +} +foreach (dbFetch($sql,$param) as $data) { + if ($data['type']) { + echo('""+'); } +} ?> ""+ @@ -390,9 +357,9 @@ else { "

    " var grid = $("#devices").bootgrid({ @@ -433,3 +400,5 @@ var grid = $("#devices").bootgrid({ diff --git a/html/pages/editsrv.inc.php b/html/pages/editsrv.inc.php index 1c04e4510..9c56b96d1 100644 --- a/html/pages/editsrv.inc.php +++ b/html/pages/editsrv.inc.php @@ -1,30 +1,35 @@ '5') { - include 'includes/service-edit.inc.php'; + include "includes/error-no-perm.inc.php"; + +} else { + + $pagetitle[] = "Edit service"; + + if ($_POST['confirm-editsrv']) + { + if ($_SESSION['userlevel'] > "5") + { + include("includes/service-edit.inc.php"); } } - foreach (dbFetchRows('SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname') as $device) { - $servicesform .= "'; + foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname") as $device) + { + $servicesform .= ""; } - if ($updated) { - print_message('Service updated!'); - } + if ($updated) { print_message("Service updated!"); } if ($_POST['editsrv'] == 'yes') { - include_once 'includes/print-service-edit.inc.php'; - } - else { - echo " + + require_once "includes/print-service-edit.inc.php"; + + } else { + + echo("

    Delete Service

    @@ -41,6 +46,7 @@ else { -
    "; - }//end if -}//end if + "); + } + +} diff --git a/html/pages/edituser.inc.php b/html/pages/edituser.inc.php index ec2a3f1c9..6a9a7d283 100644 --- a/html/pages/edituser.inc.php +++ b/html/pages/edituser.inc.php @@ -1,170 +1,167 @@ "; +echo("
    "); -$pagetitle[] = 'Edit user'; +$pagetitle[] = "Edit user"; -if ($_SESSION['userlevel'] != '10') { - include 'includes/error-no-perm.inc.php'; -} -else { - if ($vars['user_id'] && !$vars['edit']) { - $user_data = dbFetchRow('SELECT * FROM users WHERE user_id = ?', array($vars['user_id'])); - echo '

    '.$user_data['realname']."

    Change...

    "; - // Perform actions if requested - if ($vars['action'] == 'deldevperm') { - if (dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { - dbDelete('devices_perms', '`device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id'])); - } - } +if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else +{ + if ($vars['user_id'] && !$vars['edit']) + { + $user_data = dbFetchRow("SELECT * FROM users WHERE user_id = ?", array($vars['user_id'])); + echo("

    " . $user_data['realname'] . "

    Change...

    "); + // Perform actions if requested - if ($vars['action'] == 'adddevperm') { - if (!dbFetchCell('SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?', array($vars['device_id'], $vars['user_id']))) { - dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); - } - } + if ($vars['action'] == "deldevperm") + { + if (dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) + { + dbDelete('devices_perms', "`device_id` = ? AND `user_id` = ?", array($vars['device_id'], $vars['user_id'])); + } + } + if ($vars['action'] == "adddevperm") + { + if (!dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($vars['device_id'] ,$vars['user_id']))) + { + dbInsert(array('device_id' => $vars['device_id'], 'user_id' => $vars['user_id']), 'devices_perms'); + } + } + if ($vars['action'] == "delifperm") + { + if (dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) + { + dbDelete('ports_perms', "`port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id'])); + } + } + if ($vars['action'] == "addifperm") + { + if (!dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?", array($vars['port_id'], $vars['user_id']))) + { + dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); + } + } + if ($vars['action'] == "delbillperm") + { + if (dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) + { + dbDelete('bill_perms', "`bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id'])); + } + } + if ($vars['action'] == "addbillperm") + { + if (!dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($vars['bill_id'], $vars['user_id']))) + { + dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); + } + } - if ($vars['action'] == 'delifperm') { - if (dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { - dbDelete('ports_perms', '`port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id'])); - } - } + echo('
    +
    '); - if ($vars['action'] == 'addifperm') { - if (!dbFetchCell('SELECT COUNT(*) FROM ports_perms WHERE `port_id` = ? AND `user_id` = ?', array($vars['port_id'], $vars['user_id']))) { - dbInsert(array('port_id' => $vars['port_id'], 'user_id' => $vars['user_id']), 'ports_perms'); - } - } + // Display devices this users has access to + echo("

    Device Access

    "); - if ($vars['action'] == 'delbillperm') { - if (dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { - dbDelete('bill_perms', '`bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id'])); - } - } - - if ($vars['action'] == 'addbillperm') { - if (!dbFetchCell('SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?', array($vars['bill_id'], $vars['user_id']))) { - dbInsert(array('bill_id' => $vars['bill_id'], 'user_id' => $vars['user_id']), 'bill_perms'); - } - } - - echo '
    -
    '; - - // Display devices this users has access to - echo '

    Device Access

    '; - - echo "
    + echo("
    - "; + "); - $device_perms = dbFetchRows('SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id', array($vars['user_id'])); - foreach ($device_perms as $device_perm) { - echo '"; - $access_list[] = $device_perm['device_id']; - $permdone = 'yes'; - } + $device_perms = dbFetchRows("SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id", array($vars['user_id'])); + foreach ($device_perms as $device_perm) + { + echo(""); + $access_list[] = $device_perm['device_id']; + $permdone = "yes"; + } - echo '
    Device Action
    '.$device_perm['hostname']."
    " . $device_perm['hostname'] . "
    -
    '; + echo(" +
    "); - if (!$permdone) { - echo 'None Configured'; - } + if (!$permdone) { echo("None Configured"); } - // Display devices this user doesn't have access to - echo '

    Grant access to new device

    '; - echo "
    - + // Display devices this user doesn't have access to + echo("

    Grant access to new device

    "); + echo(" +
    - "); - $devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname'); - foreach ($devices as $device) { - unset($done); - foreach ($access_list as $ac) { - if ($ac == $device['device_id']) { - $done = 1; - } - } + $devices = dbFetchRows("SELECT * FROM `devices` ORDER BY hostname"); + foreach ($devices as $device) + { + unset($done); + foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } } + if (!$done) + { + echo(""); + } + } - if (!$done) { - echo "'; - } - } - - echo " + echo("
    -
    "; + "); - echo "
    -
    "; - echo '

    Interface Access

    '; + echo("
    +
    "); + echo("

    Interface Access

    "); - $interface_perms = dbFetchRows('SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id', array($vars['user_id'])); + $interface_perms = dbFetchRows("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.port_id = P.port_id AND D.device_id = I.device_id", array($vars['user_id'])); - echo "
    + echo("
    - "; - foreach ($interface_perms as $interface_perm) { - echo ' + "); + foreach ($interface_perms as $interface_perm) + { + echo(" - "; - $ipermdone = 'yes'; - } + "); + $ipermdone = "yes"; + } + echo("
    Interface name Action
    - '.$interface_perm['hostname'].' - '.$interface_perm['ifDescr'].''.''.$interface_perm['ifAlias']." + ".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."". + "" . $interface_perm['ifAlias'] . " -    +   
    +
    "); - echo ' -
    '; + if (!$ipermdone) { echo("None Configured"); } - if (!$ipermdone) { - echo 'None Configured'; - } + // Display devices this user doesn't have access to + echo("

    Grant access to new interface

    "); - // Display devices this user doesn't have access to - echo '

    Grant access to new interface

    '; - - echo "
    - + echo(" +
    + echo("
    @@ -179,135 +176,133 @@ else {
    - "; + "); - echo "
    -
    "; - echo '

    Bill Access

    '; + echo("
    +
    "); + echo("

    Bill Access

    "); - $bill_perms = dbFetchRows('SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id', array($vars['user_id'])); + $bill_perms = dbFetchRows("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id", array($vars['user_id'])); - echo "
    + echo("
    - "; + "); - foreach ($bill_perms as $bill_perm) { - echo ' + foreach ($bill_perms as $bill_perm) + { + echo(" - "; - $bill_access_list[] = $bill_perm['bill_id']; + "); + $bill_access_list[] = $bill_perm['bill_id']; - $bpermdone = 'yes'; - } + $bpermdone = "yes"; + } - echo '
    Bill name Action
    - '.$bill_perm['bill_name']."   + ".$bill_perm['bill_name']."  
    -
    '; + echo(" +
    "); - if (!$bpermdone) { - echo 'None Configured'; - } + if (!$bpermdone) { echo("None Configured"); } - // Display devices this user doesn't have access to - echo '

    Grant access to new bill

    '; - echo "
    - + // Display devices this user doesn't have access to + echo("

    Grant access to new bill

    "); + echo(" +
    - "); - $bills = dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_name`'); - foreach ($bills as $bill) { - unset($done); - foreach ($bill_access_list as $ac) { - if ($ac == $bill['bill_id']) { - $done = 1; - } - } + $bills = dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`"); + foreach ($bills as $bill) + { + unset($done); + foreach ($bill_access_list as $ac) { if ($ac == $bill['bill_id']) { $done = 1; } } + if (!$done) + { + echo(""); + } + } - if (!$done) { - echo "'; - } - } - - echo " + echo("
    -
    "; +
    "); + + } elseif ($vars['user_id'] && $vars['edit']) { + + if($_SESSION['userlevel'] == 11) { + demo_account(); + } else { + + if(!empty($vars['new_level'])) + { + if($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } + update_user($vars['user_id'],$vars['new_realname'],$vars['new_level'],$vars['can_modify_passwd'],$vars['new_email']); + print_message("User has been updated"); } - else if ($vars['user_id'] && $vars['edit']) { - if ($_SESSION['userlevel'] == 11) { - demo_account(); + + if(can_update_users() == '1') { + + $users_details = get_user($vars['user_id']); + if(!empty($users_details)) + { + + if(empty($vars['new_realname'])) + { + $vars['new_realname'] = $users_details['realname']; + } + if(empty($vars['new_level'])) + { + $vars['new_level'] = $users_details['level']; + } + if(empty($vars['can_modify_passwd'])) + { + $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; + } elseif($vars['can_modify_passwd'] == 'on') { + $vars['can_modify_passwd'] = '1'; + } + if(empty($vars['new_email'])) + { + $vars['new_email'] = $users_details['email']; } - else { - if (!empty($vars['new_level'])) { - if ($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - update_user($vars['user_id'], $vars['new_realname'], $vars['new_level'], $vars['can_modify_passwd'], $vars['new_email']); - print_message('User has been updated'); + if( $config['twofactor'] ) { + if( $vars['twofactorremove'] ) { + if( dbUpdate(array('twofactor'=>''),users,'user_id = ?',array($vars['user_id'])) ) { + echo "
    TwoFactor credentials removed.
    "; + } else { + echo "
    Couldnt remove user's TwoFactor credentials.
    "; } + } + if( $vars['twofactorunlock'] ) { + $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'],true); + $twofactor['fails'] = 0; + if( dbUpdate(array('twofactor'=>json_encode($twofactor)),users,'user_id = ?',array($vars['user_id'])) ) { + echo "
    User unlocked.
    "; + } else { + echo "
    Couldnt reset user's TwoFactor failures.
    "; + } + } + } - if (can_update_users() == '1') { - $users_details = get_user($vars['user_id']); - if (!empty($users_details)) { - if (empty($vars['new_realname'])) { - $vars['new_realname'] = $users_details['realname']; - } - - if (empty($vars['new_level'])) { - $vars['new_level'] = $users_details['level']; - } - - if (empty($vars['can_modify_passwd'])) { - $vars['can_modify_passwd'] = $users_details['can_modify_passwd']; - } - else if ($vars['can_modify_passwd'] == 'on') { - $vars['can_modify_passwd'] = '1'; - } - - if (empty($vars['new_email'])) { - $vars['new_email'] = $users_details['email']; - } - - if ($config['twofactor']) { - if ($vars['twofactorremove']) { - if (dbUpdate(array('twofactor' => ''), users, 'user_id = ?', array($vars['user_id']))) { - echo "
    TwoFactor credentials removed.
    "; - } - else { - echo "
    Couldnt remove user's TwoFactor credentials.
    "; - } - } - - if ($vars['twofactorunlock']) { - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'], true); - $twofactor['fails'] = 0; - if (dbUpdate(array('twofactor' => json_encode($twofactor)), users, 'user_id = ?', array($vars['user_id']))) { - echo "
    User unlocked.
    "; - } - else { - echo "
    Couldnt reset user's TwoFactor failures.
    "; - } - } - } - - echo "
    - + echo(" +
    - +
    @@ -315,7 +310,7 @@ else {
    - +
    @@ -324,22 +319,10 @@ else {
    @@ -349,10 +332,7 @@ else {
    @@ -360,14 +340,14 @@ else {
    - "; - if ($config['twofactor']) { - echo "

    Two-Factor Authentication

    "; - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE user_id = ?', array($vars['user_id'])); - $twofactor = json_decode($twofactor['twofactor'], true); - if ($twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time() - $twofactor['last']) < $config['twofactor_lock'])) { - echo "
    - +
    "); + if( $config['twofactor'] ) { + echo "

    Two-Factor Authentication

    "; + $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE user_id = ?",array($vars['user_id'])); + $twofactor = json_decode($twofactor['twofactor'],true); + if( $twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time()-$twofactor['last']) < $config['twofactor_lock']) ) { + echo "
    +
    @@ -375,47 +355,43 @@ else {
    "; - } - - if ($twofactor['key']) { - echo "
    - + } + if( $twofactor['key'] ) { + echo " +
    "; - } - else { - echo '

    No TwoFactor key generated for this user, Nothing to do.

    '; - } - }//end if - } - else { - echo print_error('Error getting user details'); - }//end if - } - else { - echo print_error("Authentication method doesn't support updating users"); - }//end if - }//end if + } else { + echo "

    No TwoFactor key generated for this user, Nothing to do.

    "; + } + } + } else { + echo print_error("Error getting user details"); + } + } else { + echo print_error("Authentication method doesn't support updating users"); } - else { - $user_list = get_userlist(); + } + } else { - echo '

    Select a user to edit

    '; + $user_list = get_userlist(); - echo "
    + echo("

    Select a user to edit

    "); + + echo("
    - +
    @@ -423,8 +399,11 @@ else { /
    - "; - }//end if -}//end if + "); + } -echo '
    '; +} + +echo("
    "); + +?> diff --git a/html/pages/eventlog.inc.php b/html/pages/eventlog.inc.php index 2ac41ec91..4e1cad13d 100644 --- a/html/pages/eventlog.inc.php +++ b/html/pages/eventlog.inc.php @@ -1,15 +1,16 @@ = '10') { - dbQuery('TRUNCATE TABLE `eventlog`'); - print_message('Event log truncated'); +if ($vars['action'] == "expunge" && $_SESSION['userlevel'] >= '10') +{ + dbQuery("TRUNCATE TABLE `eventlog`"); + print_message("Event log truncated"); } -$pagetitle[] = 'Eventlog'; +$pagetitle[] = "Eventlog"; print_optionbar_start(); @@ -23,17 +24,15 @@ print_optionbar_start();
    @@ -41,7 +40,9 @@ print_optionbar_start(); diff --git a/html/pages/front/default.php b/html/pages/front/default.php index b69f7f97b..7b17f08a4 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -1,180 +1,174 @@ +function generate_front_box ($frontbox_class, $content) +{ +echo("
    $content -
    "; + "); +} -}//end generate_front_box() - - -echo ' +echo('
    -'; +'); if ($config['vertical_summary']) { - echo '
    '; + echo('
    '); } -else { - echo '
    '; +else +{ + echo('
    '); } - -echo ' +echo('
    -'; +'); -echo '
    '; +echo('
    '); -echo '
    '; +echo('
    '); $count_boxes = 0; // Device down boxes -if ($_SESSION['userlevel'] >= '10') { - $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; +if ($_SESSION['userlevel'] >= '10') +{ + $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0' LIMIT ".$config['front_page_down_box_limit']; +} else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; } -else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '0' AND D.ignore = '0' LIMIT".$config['front_page_down_box_limit']; -} - -foreach (dbFetchRows($sql) as $device) { - generate_front_box( - 'device-down', - generate_device_link($device, shorthost($device['hostname'])).'
    +foreach (dbFetchRows($sql) as $device) +{ + generate_front_box("device-down", generate_device_link($device, shorthost($device['hostname']))."
    Device Down
    - '.truncate($device['location'], 20).'' - ); - ++$count_boxes; + ".truncate($device['location'], 20).""); + ++$count_boxes; } -if ($_SESSION['userlevel'] >= '10') { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; -} -else { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +if ($_SESSION['userlevel'] >= '10') +{ + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; +} else { + $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; } // These things need to become more generic, and more manageable across different frontpages... rewrite inc :> + // Port down boxes -if ($config['warn']['ifdown']) { - foreach (dbFetchRows($sql) as $interface) { - if (!$interface['deleted']) { - $interface = ifNameDescr($interface); - generate_front_box( - 'port-down', - generate_device_link($interface, shorthost($interface['hostname']))."
    +if ($config['warn']['ifdown']) +{ + foreach (dbFetchRows($sql) as $interface) + { + if (!$interface['deleted']) + { + $interface = ifNameDescr($interface); + generate_front_box("port-down", generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    - - ".generate_port_link($interface, truncate(makeshortif($interface['label']), 13, '')).'
    - '.($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '') - ); - ++$count_boxes; - } + + ".generate_port_link($interface, truncate(makeshortif($interface['label']),13,''))."
    + " . ($interface['ifAlias'] ? ''.truncate($interface['ifAlias'], 20, '').'' : '')); + ++$count_boxes; } + } } -/* - FIXME service permissions? seem nonexisting now.. */ +/* FIXME service permissions? seem nonexisting now.. */ // Service down boxes -if ($_SESSION['userlevel'] >= '10') { - $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = ''; +if ($_SESSION['userlevel'] >= '10') +{ + $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = ''; } -else { - $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - $param[] = $_SESSION['user_id']; +else +{ + $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + $param[] = $_SESSION['user_id']; } - -foreach (dbFetchRows($sql, $param) as $service) { - generate_front_box( - 'service-down', - generate_device_link($service, shorthost($service['hostname'])).'
    +foreach (dbFetchRows($sql,$param) as $service) +{ + generate_front_box("service-down", generate_device_link($service, shorthost($service['hostname']))."
    Service Down - '.$service['service_type'].'
    - '.truncate($interface['ifAlias'], 20).'' - ); - ++$count_boxes; + ".$service['service_type']."
    + ".truncate($interface['ifAlias'], 20).""); + ++$count_boxes; } // BGP neighbour down boxes -if (isset($config['enable_bgp']) && $config['enable_bgp']) { - if ($_SESSION['userlevel'] >= '10') { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } - else { - $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; - } - - foreach (dbFetchRows($sql) as $peer) { - generate_front_box( - 'bgp-down', - generate_device_link($peer, shorthost($peer['hostname']))."
    +if (isset($config['enable_bgp']) && $config['enable_bgp']) +{ + if ($_SESSION['userlevel'] >= '10') + { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } else { + $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0 AND `D`.`status` = '1' LIMIT ".$config['front_page_down_box_limit']; + } + foreach (dbFetchRows($sql) as $peer) + { + generate_front_box("bgp-down", generate_device_link($peer, shorthost($peer['hostname']))."
    BGP Down - ".$peer['bgpPeerIdentifier'].'
    - AS'.truncate($peer['bgpPeerRemoteAs'].' '.$peer['astext'], 14, '').'' - ); - ++$count_boxes; - } + ".$peer['bgpPeerIdentifier']."
    + AS".truncate($peer['bgpPeerRemoteAs']." ".$peer['astext'], 14, "").""); + ++$count_boxes; + } } // Device rebooted boxes -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - if ($_SESSION['userlevel'] >= '10') { - $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } - else { - $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '".$_SESSION['user_id']."' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '".$config['uptime_warning']."' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + if ($_SESSION['userlevel'] >= '10') + { + $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } else { + $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" . + $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT ".$config['front_page_down_box_limit']; + } - foreach (dbFetchRows($sql) as $device) { - generate_front_box( - 'device-rebooted', - generate_device_link($device, shorthost($device['hostname'])).'
    + foreach (dbFetchRows($sql) as $device) + { + generate_front_box("device-rebooted", generate_device_link($device, shorthost($device['hostname']))."
    Device Rebooted
    - '.formatUptime($device['uptime'], 'short').'' - ); - ++$count_boxes; - } + ".formatUptime($device['uptime'], 'short').""); + ++$count_boxes; + } } - if ($count_boxes == 0) { - echo "
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none - because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].', you might - want to start by adding one or more devices in the Devices menu.

    '; + echo("
    Nothing here yet

    This is where status notifications about devices and services would normally go. You might have none + because you run such a great network, or perhaps you've just started using ".$config['project_name'].". If you're new to ".$config['project_name'].", you might + want to start by adding one or more devices in the Devices menu.

    "); } - -echo '
    '; -echo '
    '; -echo '
    '; -echo ' +echo('
    '); +echo('
    '); +echo('
    '); +echo('
    -'; +'); -if ($config['vertical_summary']) { - echo '
    '; - include_once 'includes/device-summary-vert.inc.php'; +if ($config['vertical_summary']) +{ + echo('
    '); + include_once("includes/device-summary-vert.inc.php"); } -else { - echo '
    '; - include_once 'includes/device-summary-horiz.inc.php'; +else +{ + echo('
    '); + include_once("includes/device-summary-horiz.inc.php"); } -echo ' +echo('
    -'; +'); -if ($config['enable_syslog']) { - $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; - $query = mysql_query($sql); +if ($config['enable_syslog']) +{ - echo '
    + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; + $query = mysql_query($sql); + + echo('
      @@ -186,34 +180,35 @@ if ($config['enable_syslog']) {
    Syslog entries
    -
    '; +
    '); - foreach (dbFetchRows($sql) as $entry) { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) + { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include 'includes/print-syslog.inc.php'; - } + include("includes/print-syslog.inc.php"); + } + echo("
    "); + echo(""); + echo(""); + echo(""); + echo(""); - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; -} -else { - if ($_SESSION['userlevel'] >= '10') { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15'; - } - else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = ".$_SESSION['user_id'].' ORDER BY `datetime` DESC LIMIT 0,15'; - $alertquery = 'SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = '.$_SESSION['user_id'].' ORDER BY `time_logged` DESC LIMIT 0,15'; - } +} else { - $data = mysql_query($query); - $alertdata = mysql_query($alertquery); + if ($_SESSION['userlevel'] >= '10') + { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15"; + } else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15"; + } - echo '
    + $data = mysql_query($query); + $alertdata = mysql_query($alertquery); + + echo('
      @@ -225,13 +220,13 @@ else {
    Alertlog entries
    - '; +
    '); - foreach (dbFetchRows($alertquery) as $alert_entry) { - include 'includes/print-alerts.inc.php'; - } - - echo '
    + foreach (dbFetchRows($alertquery) as $alert_entry) + { + include("includes/print-alerts.inc.php"); + } + echo('
    @@ -239,21 +234,24 @@ else {
    Eventlog entries
    - '; +
    '); - foreach (dbFetchRows($query) as $entry) { - include 'includes/print-event.inc.php'; - } + foreach (dbFetchRows($query) as $entry) + { + include("includes/print-event.inc.php"); + } - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo ''; -}//end if + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); +} -echo ''; +echo(""); -echo ' +echo(' -'; +'); + +?> diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 6478a566b..1000fbca2 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -4,55 +4,56 @@ '; +echo(""); -$dev_list = array( - '6' => 'Central Fileserver', - '7' => 'NE61 Fileserver', - '34' => 'DE56 Fileserver', -); +$dev_list = array('6' => 'Central Fileserver', + '7' => 'NE61 Fileserver', + '34' => 'DE56 Fileserver'); -foreach ($dev_list as $device_id => $descr) { - echo ''; -}//end foreach + echo("
    "); + $graph_array['type'] = "device_diskio"; + print_graph_popup($graph_array); + echo("
    "); -echo '
    '; - echo "
    ".$descr.'
    '; - $graph_array['height'] = '100'; - $graph_array['width'] = '310'; - $graph_array['to'] = $config['time']['now']; - $graph_array['device'] = $device_id; - $graph_array['type'] = 'device_bits'; - $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; - $graph_array['popup_title'] = $descr; - // $graph_array['link'] = generate_device_link($device_id); - print_graph_popup($graph_array); +foreach ($dev_list as $device_id => $descr) +{ - $graph_array['height'] = '50'; - $graph_array['width'] = '180'; + echo("
    "); + echo("
    ".$descr."
    "); + $graph_array['height'] = "100"; + $graph_array['width'] = "310"; + $graph_array['to'] = $config['time']['now']; + $graph_array['device'] = $device_id; + $graph_array['type'] = "device_bits"; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; + $graph_array['popup_title'] = $descr; +# $graph_array['link'] = generate_device_link($device_id); + print_graph_popup($graph_array); - echo "
    "; - $graph_array['type'] = 'device_ucd_memory'; - print_graph_popup($graph_array); - echo '
    '; + $graph_array['height'] = "50"; + $graph_array['width'] = "180"; - echo "
    "; - $graph_array['type'] = 'device_processor'; - print_graph_popup($graph_array); - echo '
    '; + echo("
    "); + $graph_array['type'] = "device_ucd_memory"; + print_graph_popup($graph_array); + echo("
    "); - echo "
    "; - $graph_array['type'] = 'device_storage'; - print_graph_popup($graph_array); - echo '
    '; + echo("
    "); + $graph_array['type'] = "device_processor"; + print_graph_popup($graph_array); + echo("
    "); - echo "
    "; - $graph_array['type'] = 'device_diskio'; - print_graph_popup($graph_array); - echo '
    '; + echo("
    "); + $graph_array['type'] = "device_storage"; + print_graph_popup($graph_array); + echo("
    "); - echo '
    '; + echo(""); + +} + +echo(""); ?> @@ -61,105 +62,115 @@ echo ''; '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) { - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = 'yes'; - } - - $i++; - } - - if (!$already) { - $nodes[] = $device['device_id']; +foreach (dbFetchRows($sql) as $device) +{ + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = "yes"; } + $i++; + } + if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id'])) { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35).' -
    '; - } +foreach (dbFetchRows($sql) as $device) +{ + if (device_permitted($device['device_id'])) { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35)." +
    "); + } } -if ($config['warn']['ifdown']) { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; - foreach (dbFetchRows($sql) as $interface) { - if (port_permitted($interface['port_id'])) { - echo "
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } +if ($config['warn']['ifdown']) +{ + $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; + foreach (dbFetchRows($sql) as $interface) + { + if (port_permitted($interface['port_id'])) + { + echo("
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    + ".truncate($interface['ifAlias'], 15)." +
    "); } + } } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) { - if (device_permitted($service['device_id'])) { - echo "
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type'].'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } +foreach (dbFetchRows($sql) as $service) +{ + if (device_permitted($service['device_id'])) + { + echo("
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type']."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) { - if (device_permitted($peer['device_id'])) { - echo "
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier'].'
    - AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' -
    '; - } +foreach (dbFetchRows($sql) as $peer) +{ + if (device_permitted($peer['device_id'])) + { + echo("
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier']."
    + AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." +
    "); + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE - A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value']).' -
    '; - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE + A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) + { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") + { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value'])." +
    "); } + } } -echo " -
    $errorboxes
    +echo(" +
    $errorboxes
    -

    Recent Syslog Messages

    - "; +

    Recent Syslog Messages

    +"); $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from `syslog` ORDER BY seq DESC LIMIT 20"; -echo ''; -foreach (dbFetchRows($sql) as $entry) { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); +echo("
    "); +foreach (dbFetchRows($sql) as $entry) +{ + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include 'includes/print-syslog.inc.php'; + include("includes/print-syslog.inc.php"); } -echo '
    '; +echo(""); ?> diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php index e5898ac07..717ee7518 100644 --- a/html/pages/front/example2.php +++ b/html/pages/front/example2.php @@ -4,141 +4,173 @@
    Devices with Alerts
    Host
    Int
    Srv
    +# ?> '0' AND A.attrib_value < '86400'"; -foreach (dbFetchRows($sql) as $device) { - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = 'yes'; - } - - $i++; - } - - if (!$already) { - $nodes[] = $device['device_id']; +foreach (dbFetchRows($sql) as $device) +{ + unset($already); + $i = 0; + while ($i <= count($nodes)) + { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) + { + $already = "yes"; } + $i++; + } + if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) { - echo "
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down - ".truncate($device['location'], 20).' -
    '; +foreach (dbFetchRows($sql) as $device) +{ + echo("
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down + ".truncate($device['location'], 20)." +
    "); + } $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; -foreach (dbFetchRows($sql) as $interface) { - echo "
    -
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down - ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    - '.truncate($interface['ifAlias'], 20).' -
    '; +foreach (dbFetchRows($sql) as $interface) +{ + echo("
    +
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down + ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    + ".truncate($interface['ifAlias'], 20)." +
    "); + } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) { - echo "
    -
    ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down - ".$service['service_type'].'
    - '.truncate($interface['ifAlias'], 20).' -
    '; +foreach (dbFetchRows($sql) as $service) +{ + echo("
    +
    ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down + ".$service['service_type']."
    + ".truncate($interface['ifAlias'], 20)." +
    "); + } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) { - echo "
    -
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down - ".$peer['bgpPeerIdentifier'].'
    - AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' -
    '; +foreach (dbFetchRows($sql) as $peer) +{ + echo("
    +
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down + ".$peer['bgpPeerIdentifier']."
    + AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." +
    "); + } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '".$config['uptime_warning']."'"; - foreach (dbFetchRows($sql) as $device) { - echo "
    -
    ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value']).' -
    '; - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + $sql = "SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'"; + foreach (dbFetchRows($sql) as $device) + { + echo("
    +
    ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value'])." +
    "); + } } -echo " +echo(" -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    - "; +"); $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; -echo '
    Devices with Alerts
    Host
    Int
    Srv
    '; -foreach (dbFetchRows($sql) as $entry) { - include 'includes/print-syslog.inc.php'; +echo("
    "); +foreach (dbFetchRows($sql) as $entry) +{ + include("includes/print-syslog.inc.php"); } +echo("
    "); -echo ''; +echo("
    -echo '
    - - - '; + + "); // this stuff can be customised to show whatever you want.... -if ($_SESSION['userlevel'] >= '5') { - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['l2tp'] .= $seperator.$interface['port_id']; - $seperator = ','; - } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['transit'] .= $seperator.$interface['port_id']; - $seperator = ','; - } +if ($_SESSION['userlevel'] >= '5') +{ + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['l2tp'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; - $sql .= $config['mydomain']."' ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['voip'] .= $seperator.$interface['port_id']; - $seperator = ','; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['transit'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - if ($ports['transit']) { - echo "', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    Internet Transit
    "."
    "; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%"; + $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['voip'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - if ($ports['l2tp']) { - echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    L2TP ADSL
    "."
    "; - } + if ($ports['transit']) + { + echo("', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". + "
    Internet Transit
    ". + "
    "); + } - if ($ports['voip']) { - echo "', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >"."
    VoIP to PSTN
    "."
    "; - } -}//end if + if ($ports['l2tp']) + { + echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". + "
    L2TP ADSL
    ". + "
    "); + } + + if ($ports['voip']) + { + echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". + "
    VoIP to PSTN
    ". + "
    "); + } + +} // END VOSTRON + ?> diff --git a/html/pages/front/globe.php b/html/pages/front/globe.php index 9884b402f..75a5917c7 100644 --- a/html/pages/front/globe.php +++ b/html/pages/front/globe.php @@ -4,17 +4,16 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ + * along with this program. If not, see . */ -/* +/** * Custom Frontpage * @author f0o * @copyright 2014 f0o, LibreNMS @@ -26,111 +25,107 @@ ?> -
    -
    -
    -
    -
    -
    -
    -
    '; - include_once("includes/device-summary-vert.inc.php"); -echo '
    -
    -
    -
    '; - include_once("includes/front/boxes.inc.php"); -echo '
    -
    -
    -
    -
    -
    -
    '; - $device['device_id'] = '-1'; - require_once('includes/print-alerts.php'); - unset($device['device_id']); -echo '
    -
    +
    +
    +
    +
    +
    +
    +
    +
    '; + include_once("includes/device-summary-vert.inc.php"); +echo '
    +
    +
    +
    '; + include_once("includes/front/boxes.inc.php"); +echo '
    +
    +
    +
    +
    +
    +
    '; + $device['device_id'] = '-1'; + require_once('includes/print-alerts.php'); + unset($device['device_id']); +echo '
    +
    '; //From default.php - This code is not part of above license. if ($config['enable_syslog']) { - $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; - $query = mysql_query($sql); - echo('
    +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; +$query = mysql_query($sql); +echo('
      @@ -144,28 +139,29 @@ if ($config['enable_syslog']) {
    '); - foreach (dbFetchRows($sql) as $entry) { - $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); + foreach (dbFetchRows($sql) as $entry) + { + $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); - include 'includes/print-syslog.inc.php'; - } - echo("
    "); - echo("
    "); - echo("
    "); - echo("
    "); - echo(""); -} -else { + include("includes/print-syslog.inc.php"); + } + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); - if ($_SESSION['userlevel'] == '10') { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; - } - else { - $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = - P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; - } +} else { - $data = mysql_query($query); + if ($_SESSION['userlevel'] == '10') + { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + } else { + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = + P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + } + + $data = mysql_query($query); echo('
    @@ -181,13 +177,15 @@ else {
    '); - foreach (dbFetchRows($query) as $entry) { - include 'includes/print-event.inc.php'; - } + foreach (dbFetchRows($query) as $entry) + { + include("includes/print-event.inc.php"); + } - echo("
    "); - echo("
    "); - echo(""); - echo(""); - echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); } +?> diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index cda0b49bb..2256cf085 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -5,209 +5,238 @@ $nodes = array(); -$uptimesql = ''; -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - $uptimesql = " AND A.attrib_value < '".$config['uptime_warning']."'"; +$uptimesql = ""; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + $uptimesql = " AND A.attrib_value < '" . $config['uptime_warning'] . "'"; } -$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql; +$sql = "SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql; -foreach (dbFetchRows($sql) as $device) { - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = 'yes'; - } - - $i++; - } - - if (!$already) { - $nodes[] = $device['device_id']; +foreach (dbFetchRows($sql) as $device) +{ + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = "yes"; } + $i++; + } + if (!$already) { $nodes[] = $device['device_id']; } } $sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"; -foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id'])) { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35).' -
    '; - } +foreach (dbFetchRows($sql) as $device) +{ + if (device_permitted($device['device_id'])) { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35)." +
    "); + } } if ($config['warn']['ifdown']) { - $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; - foreach (dbFetchRows($sql) as $interface) { - if (port_permitted($interface['port_id'])) { - echo "
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } - } + +$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"; +foreach (dbFetchRows($sql) as $interface) +{ + if (port_permitted($interface['port_id'])) { + echo("
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } +} + } $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"; -foreach (dbFetchRows($sql) as $service) { - if (device_permitted($service['device_id'])) { - echo "
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type'].'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } +foreach (dbFetchRows($sql) as $service) +{ + if (device_permitted($service['device_id'])) { + echo("
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type']."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } } $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"; -foreach (dbFetchRows($sql) as $peer) { - if (device_permitted($peer['device_id'])) { - echo "
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier'].'
    - AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' -
    '; - } +foreach (dbFetchRows($sql) as $peer) +{ + if (device_permitted($peer['device_id'])) { + echo("
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier']."
    + AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." +
    "); + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '".$config['uptime_warning']."' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; - foreach (dbFetchRows($sql) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value']).' -
    '; - } - } +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"; + foreach (dbFetchRows($sql) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value'])." +
    "); + } + } } -echo " +echo(" -
    $errorboxes
    +
    $errorboxes
    -

    Recent Syslog Messages

    +

    Recent Syslog Messages

    - "; +"); $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo ''; -foreach (dbFetchRows($sql) as $entry) { - include 'includes/print-syslog.inc.php'; +echo("
    "); +foreach (dbFetchRows($sql) as $entry) +{ + include("includes/print-syslog.inc.php"); } +echo("
    "); -echo ''; +echo("
    -echo '
    - - - '; + + "); // this stuff can be customised to show whatever you want.... -if ($_SESSION['userlevel'] >= '5') { - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['transit'] .= $seperator.$interface['port_id']; - $seperator = ','; - } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['peering'] .= $seperator.$interface['port_id']; - $seperator = ','; - } +if ($_SESSION['userlevel'] >= '5') +{ - $ports['broadband'] = '3294,3295,688,3534'; - $ports['wave_broadband'] = '827'; + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['transit'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - $ports['new_broadband'] = '3659,4149,4121,4108,3676,4135'; + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['peering'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - echo "
    "; + $ports['broadband'] = "3294,3295,688,3534"; + $ports['wave_broadband'] = "827"; - if ($ports['peering'] && $ports['transit']) { - echo ""; - } + $ports['new_broadband'] = "3659,4149,4121,4108,3676,4135"; - echo '
    '; + echo("
    "); - echo ""); - if ($ports['peering']) { - echo ""; - } + echo("
    "); - echo '
    '; + if ($ports['transit']) { + echo(""); + } - echo ""); - echo "
    "; + echo("
    "); - if ($ports['broadband']) { - echo ""; - } + if ($ports['broadband'] && $ports['wave_broadband'] && $ports['new_broadband']) { + echo(""); + } - echo "
    "; + echo("'; + echo("'; -}//end if + echo("
    "); + + if ($ports['wave_broadband']) { + echo(""); + } + + echo("
    "); + +} ?> diff --git a/html/pages/front/traffic.php b/html/pages/front/traffic.php index 6b501cf9c..5f9a8acce 100644 --- a/html/pages/front/traffic.php +++ b/html/pages/front/traffic.php @@ -3,172 +3,200 @@ 0) { - $uptimesql = ' AND A.attrib_value < ?'; - $param = array($config['uptime_warning']); +$nodes = array(); +$param = array(); +$uptimesql = ""; +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + $uptimesql = " AND A.attrib_value < ?"; + $param = array($config['uptime_warning']); } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' ".$uptimesql, $param) as $device) { - unset($already); - $i = 0; - while ($i <= count($nodes)) { - $thisnode = $device['device_id']; - if ($nodes[$i] == $thisnode) { - $already = 'yes'; - } - - $i++; - } - - if (!$already) { - $nodes[] = $device['device_id']; +foreach (dbFetchRows("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql, $param) as $device) +{ + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = "yes"; } + $i++; + } + if (!$already) { $nodes[] = $device['device_id']; } } -foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) { - if (device_permitted($device['device_id'])) { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 35).' -
    '; - } +foreach (dbFetchRows("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'") as $device) +{ + if (device_permitted($device['device_id'])) { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35)." +
    "); + } } if ($config['warn']['ifdown']) { - foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) { - if (port_permitted($interface['port_id'])) { - echo "
    - ".generate_device_link($interface, shorthost($interface['hostname']))."
    - Port Down
    - ".generate_port_link($interface, makeshortif($interface['ifDescr'])).'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } - } + +foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'") as $interface) +{ + if (port_permitted($interface['port_id'])) { + echo("
    + ".generate_device_link($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } } -foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) { - if (device_permitted($service['device_id'])) { - echo "
    - ".generate_device_link($service, shorthost($service['hostname']))."
    - Service Down
    - ".$service['service_type'].'
    - '.truncate($interface['ifAlias'], 15).' -
    '; - } } -foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) { - if (device_permitted($peer['device_id'])) { - echo "
    - ".generate_device_link($peer, shorthost($peer['hostname']))."
    - BGP Down
    - ".$peer['bgpPeerIdentifier'].'
    - AS'.$peer['bgpPeerRemoteAs'].' '.truncate($peer['astext'], 10).' -
    '; - } +foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'") as $service) +{ + if (device_permitted($service['device_id'])) { + echo("
    + ".generate_device_link($service, shorthost($service['hostname']))."
    + Service Down
    + ".$service['service_type']."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } } -if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) { - foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { - if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == 'uptime') { - echo "
    - ".generate_device_link($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['attrib_value']).' -
    '; - } - } +foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id") as $peer) +{ + if (device_permitted($peer['device_id'])) { + echo("
    + ".generate_device_link($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier']."
    + AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." +
    "); + } } -echo " +if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) +{ + foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") { + echo("
    + ".generate_device_link($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value'])." +
    "); + } + } +} -
    $errorboxes
    +echo(" -

    Recent Syslog Messages

    +
    $errorboxes
    - "; +

    Recent Syslog Messages

    + +"); $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; -echo ''; -foreach (dbFetchRows($sql) as $entry) { - include 'includes/print-syslog.inc.php'; +echo("
    "); +foreach (dbFetchRows($sql) as $entry) +{ + include("includes/print-syslog.inc.php"); } +echo("
    "); -echo ''; +echo("
    -echo '
    - - - '; + + "); // this stuff can be customised to show whatever you want.... -if ($_SESSION['userlevel'] >= '5') { - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['transit'] .= $seperator.$interface['port_id']; - $seperator = ','; - } - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['peering'] .= $seperator.$interface['port_id']; - $seperator = ','; - } +if ($_SESSION['userlevel'] >= '5') +{ - $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; - unset($seperator); - foreach (dbFetchRows($sql) as $interface) { - $ports['core'] .= $seperator.$interface['port_id']; - $seperator = ','; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['transit'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - echo "
    "; + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['peering'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - if ($ports['peering'] && $ports['transit']) { - echo ""; - } + $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Core: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; + unset ($seperator); + foreach (dbFetchRows($sql) as $interface) + { + $ports['core'] .= $seperator . $interface['port_id']; + $seperator = ","; + } - echo '
    '; + echo("
    "); - echo ""); - if ($ports['peering']) { - echo ""; - } + echo("'; -}//end if + if ($ports['peering']) + { + echo(""); + } + + if ($ports['core']) + { + echo(""); + } + + echo("
    "); + +} ?> diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 78c6a73e0..0cc268fce 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -4,21 +4,17 @@ unset($vars['page']); // Setup here -if($_SESSION['widescreen']) { - $graph_width=1700; - $thumb_width=180; -} -else { - $graph_width=1075; - $thumb_width=113; +if($_SESSION['widescreen']) +{ + $graph_width=1700; + $thumb_width=180; +} else { + $graph_width=1075; + $thumb_width=113; } -if (!is_numeric($vars['from'])) { - $vars['from'] = $config['time']['day']; -} -if (!is_numeric($vars['to'])) { - $vars['to'] = $config['time']['now']; -} +if (!is_numeric($vars['from'])) { $vars['from'] = $config['time']['day']; } +if (!is_numeric($vars['to'])) { $vars['to'] = $config['time']['now']; } preg_match('/^(?P[A-Za-z0-9]+)_(?P.+)/', $vars['type'], $graphtype); @@ -26,201 +22,208 @@ $type = $graphtype['type']; $subtype = $graphtype['subtype']; $id = $vars['id']; -if(is_numeric($vars['device'])) { - $device = device_by_id_cache($vars['device']); -} -elseif(!empty($vars['device'])) { - $device = device_by_name($vars['device']); +if(is_numeric($vars['device'])) +{ + $device = device_by_id_cache($vars['device']); +} elseif(!empty($vars['device'])) { + $device = device_by_name($vars['device']); } -if (is_file("includes/graphs/".$type."/auth.inc.php")) { - require "includes/graphs/".$type."/auth.inc.php"; +if (is_file("includes/graphs/".$type."/auth.inc.php")) +{ + include("includes/graphs/".$type."/auth.inc.php"); } -if (!$auth) { - require 'includes/error-no-perm.inc.php'; -} -else { - if (isset($config['graph_types'][$type][$subtype]['descr'])) { - $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; - } - else { - $title .= " :: ".ucfirst($subtype); - } +if (!$auth) +{ + include("includes/error-no-perm.inc.php"); +} else { + if (isset($config['graph_types'][$type][$subtype]['descr'])) + { + $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; + } else { + $title .= " :: ".ucfirst($subtype); + } - $graph_array = $vars; - $graph_array['height'] = "60"; - $graph_array['width'] = $thumb_width; - $graph_array['legend'] = "no"; - $graph_array['to'] = $config['time']['now']; + $graph_array = $vars; + $graph_array['height'] = "60"; + $graph_array['width'] = $thumb_width; + $graph_array['legend'] = "no"; + $graph_array['to'] = $config['time']['now']; - print_optionbar_start(); - echo($title); + print_optionbar_start(); + echo($title); - echo('
    '); -?> + echo('
    '); + ?>
    -'); + '); - print_optionbar_end(); + print_optionbar_end(); - print_optionbar_start(); + print_optionbar_start(); - $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', - 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); + $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', + 'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); - echo(''); + echo('
    '); - foreach ($thumb_array as $period => $text) { - $graph_array['from'] = $config['time'][$period]; + foreach ($thumb_array as $period => $text) + { + $graph_array['from'] = $config['time'][$period]; - $link_array = $vars; - $link_array['from'] = $graph_array['from']; - $link_array['to'] = $graph_array['to']; - $link_array['page'] = "graphs"; - $link = generate_url($link_array); + $link_array = $vars; + $link_array['from'] = $graph_array['from']; + $link_array['to'] = $graph_array['to']; + $link_array['page'] = "graphs"; + $link = generate_url($link_array); - echo(''); + echo(''); - } + } - echo('
    '); - echo(''.$text.'
    '); - echo(''); - echo(generate_graph_tag($graph_array)); - echo(''); - echo('
    '); + echo(''.$text.'
    '); + echo(''); + echo(generate_graph_tag($graph_array)); + echo(''); + echo('
    '); + echo(''); - $graph_array = $vars; - $graph_array['height'] = "300"; - $graph_array['width'] = $graph_width; + $graph_array = $vars; + $graph_array['height'] = "300"; + $graph_array['width'] = $graph_width; - echo("
    "); + echo("
    "); - // datetime range picker + // datetime range picker ?> - "); - echo(' + echo(" +
    + "); + echo('
    - - + +
    - - + +
    -
    - '); - echo("
    "); + echo("
    "); - if ($vars['legend'] == "no") { - echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); - } - else { - echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); - } + if ($vars['legend'] == "no") + { + echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); + } else { + echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); + } - // FIXME : do this properly - # if ($type == "port" && $subtype == "bits") - # { + // FIXME : do this properly +# if ($type == "port" && $subtype == "bits") +# { echo(' | '); - if ($vars['previous'] == "yes") { - echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); + if ($vars['previous'] == "yes") + { + echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); + } else { + echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); } - else { - echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); - } - # } +# } - echo('
    '); + echo('
    '); - if ($vars['showcommand'] == "yes") { - echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); - } - else { - echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); - } + if ($vars['showcommand'] == "yes") + { + echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); + } else { + echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); + } - echo('
    '); + echo('
    '); - print_optionbar_end(); + print_optionbar_end(); - echo generate_graph_js_state($graph_array); + echo generate_graph_js_state($graph_array); - echo('
    '); - echo(generate_graph_tag($graph_array)); - echo("
    "); + echo('
    '); + echo(generate_graph_tag($graph_array)); + echo("
    "); - if (isset($config['graph_descr'][$vars['type']])) { + if (isset($config['graph_descr'][$vars['type']])) + { - print_optionbar_start(); - echo('
    -
    + print_optionbar_start(); + echo('
    +
    -
    -
    '); - echo($config['graph_descr'][$vars['type']]); - print_optionbar_end(); - } +
    +
    '); + echo($config['graph_descr'][$vars['type']]); + print_optionbar_end(); + } - if ($vars['showcommand']) { - $_GET = $graph_array; - $command_only = 1; + if ($vars['showcommand']) + { + $_GET = $graph_array; + $command_only = 1; - require 'includes/graphs/graph.inc.php'; - } + include("includes/graphs/graph.inc.php"); + } } + +?> diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index eb13def9b..3b06d4db6 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -30,12 +30,8 @@ $type_text['toner'] = "Toner"; $type_text['dbm'] = "dBm"; $type_text['load'] = "Load"; -if (!$vars['metric']) { - $vars['metric'] = "processor"; -} -if (!$vars['view']) { - $vars['view'] = "detail"; -} +if (!$vars['metric']) { $vars['metric'] = "processor"; } +if (!$vars['view']) { $vars['view'] = "detail"; } $link_array = array('page' => 'health'); @@ -46,44 +42,48 @@ print_optionbar_start('', ''); echo('Health » '); $sep = ""; -foreach ($datas as $texttype) { - $metric = strtolower($texttype); - echo($sep); - if ($vars['metric'] == $metric) { - echo(""); - } +foreach ($datas as $texttype) +{ + $metric = strtolower($texttype); + echo($sep); + if ($vars['metric'] == $metric) + { + echo(""); + } - echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); + echo(generate_link($type_text[$metric],$link_array,array('metric'=> $metric, 'view' => $vars['view']))); - if ($vars['metric'] == $metric) { - echo(""); - } + if ($vars['metric'] == $metric) { echo(""); } - $sep = ' | '; + $sep = ' | '; } unset ($sep); echo('
    '); -if ($vars['view'] == "graphs") { - echo(''); +if ($vars['view'] == "graphs") +{ + echo(''); } echo(generate_link("Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "graphs"))); -if ($vars['view'] == "graphs") { - echo(''); +if ($vars['view'] == "graphs") +{ + echo(''); } echo(' | '); -if ($vars['view'] != "graphs") { - echo(''); +if ($vars['view'] != "graphs") +{ + echo(''); } echo(generate_link("No Graphs",$link_array,array('metric'=> $vars['metric'], 'view' => "detail"))); -if ($vars['view'] != "graphs") { - echo(''); +if ($vars['view'] != "graphs") +{ + echo(''); } echo('
    '); @@ -91,14 +91,16 @@ echo('
    '); print_optionbar_end(); if (in_array($vars['metric'],array_keys($used_sensors)) - || $vars['metric'] == 'processor' - || $vars['metric'] == 'storage' - || $vars['metric'] == 'toner' - || $vars['metric'] == 'mempool') { - include('pages/health/'.$vars['metric'].'.inc.php'); + || $vars['metric'] == 'processor' + || $vars['metric'] == 'storage' + || $vars['metric'] == 'toner' + || $vars['metric'] == 'mempool') +{ + include('pages/health/'.$vars['metric'].'.inc.php'); } -else { - echo("No sensors of type " . $vars['metric'] . " found."); +else +{ + echo("No sensors of type " . $vars['metric'] . " found."); } ?> diff --git a/html/pages/health/charge.inc.php b/html/pages/health/charge.inc.php index 3838d0e79..867b50f9e 100644 --- a/html/pages/health/charge.inc.php +++ b/html/pages/health/charge.inc.php @@ -4,4 +4,6 @@ $graph_type = "sensor_charge"; $unit = "%"; $class = "charge"; -require 'pages/health/sensors.inc.php'; +include("pages/health/sensors.inc.php"); + +?> diff --git a/html/pages/health/load.inc.php b/html/pages/health/load.inc.php index f506e3ca1..d9257519d 100644 --- a/html/pages/health/load.inc.php +++ b/html/pages/health/load.inc.php @@ -1,7 +1,9 @@ diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index 52828b9c1..02224d485 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -1,18 +1,19 @@ = '5') { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; - $param = array(); -} -else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; - $param = array($_SESSION['user_id']); + +if ($_SESSION['userlevel'] >= '5') +{ + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; + $param = array(); +} else { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = ? ORDER BY D.hostname, S.sensor_descr"; + $param = array($_SESSION['user_id']); } -echo ''; +echo('
    '); -echo ' +echo(' @@ -20,102 +21,99 @@ echo ' - '; + '); -foreach (dbFetchRows($sql, $param) as $sensor) { - if ($config['memcached']['enable'] === true) { - $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); - if ($debug) { - echo 'Memcached['.'sensor-'.$sensor['sensor_id'].'-value'.'='.$sensor['sensor_current'].']'; - } - } +foreach (dbFetchRows($sql, $param) as $sensor) +{ - if (empty($sensor['sensor_current'])) { - $sensor['sensor_current'] = 'NaN'; - } - else { - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { - $alert = 'alert'; - } - else { - $alert = ''; - } - } + if ($config['memcached']['enable'] === TRUE) + { + $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + if($debug) { echo("Memcached[".'sensor-'.$sensor['sensor_id'].'-value'."=".$sensor['sensor_current']."]"); } + } + + if (empty($sensor['sensor_current'])) + { + $sensor['sensor_current'] = "NaN"; + } else { + if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } + } // FIXME - make this "four graphs in popup" a function/include and "small graph" a function. // FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? // FIXME - DUPLICATED IN device/overview/sensors - $graph_colour = str_replace('#', '', $row_colour); + + $graph_colour = str_replace("#", "", $row_colour); $graph_array = array(); - $graph_array['height'] = '100'; - $graph_array['width'] = '210'; + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $sensor['sensor_id']; $graph_array['type'] = $graph_type; $graph_array['from'] = $config['time']['day']; - $graph_array['legend'] = 'no'; + $graph_array['legend'] = "no"; - $link_array = $graph_array; - $link_array['page'] = 'graphs'; + $link_array = $graph_array; + $link_array['page'] = "graphs"; unset($link_array['height'], $link_array['width'], $link_array['legend']); $link_graph = generate_url($link_array); - $link = generate_url(array('page' => 'device', 'device' => $sensor['device_id'], 'tab' => 'health', 'metric' => $sensor['sensor_class'])); + $link = generate_url(array("page" => "device", "device" => $sensor['device_id'], "tab" => "health", "metric" => $sensor['sensor_class'])); - $overlib_content = '

    '.$device['hostname'].' - '.$sensor['sensor_descr'].'

    '; - foreach (array('day', 'week', 'month', 'year') as $period) { - $graph_array['from'] = $config['time'][$period]; - $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + $overlib_content = '

    '.$device['hostname']." - ".$sensor['sensor_descr']."

    "; + foreach (array('day','week','month','year') as $period) + { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); } + $overlib_content .= "
    "; - $overlib_content .= '
    '; - - $graph_array['width'] = 80; - $graph_array['height'] = 20; - $graph_array['bg'] = 'ffffff00'; - // the 00 at the end makes the area transparent. + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. $graph_array['from'] = $config['time']['day']; - $sensor_minigraph = generate_graph_tag($graph_array); + $sensor_minigraph = generate_graph_tag($graph_array); $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); - echo ' - - + echo(' + + - - - + + + - '; + '); - if ($vars['view'] == 'graphs') { - echo "'; - } //end if -}//end foreach + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo(""); + } # endif graphs +} -echo '
    Device Sensor
    Current Range limit Notes
    '.generate_device_link($sensor).''.overlib_link($link, $sensor['sensor_descr'], $overlib_content).'
    ' . generate_device_link($sensor) . ''.overlib_link($link, $sensor['sensor_descr'],$overlib_content).' '.overlib_link($link_graph, $sensor_minigraph, $overlib_content).' '.$alert.''.$sensor['sensor_current'].$unit.''.round($sensor['sensor_limit_low'], 2).$unit.' - '.round($sensor['sensor_limit'], 2).$unit.''.(isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '').'' . $sensor['sensor_current'] . $unit . '' . round($sensor['sensor_limit_low'],2) . $unit . ' - ' . round($sensor['sensor_limit'],2) . $unit . '' . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . '
    "; + if ($vars['view'] == "graphs") + { + echo("
    "); - $daily_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=211&height=100'; - $daily_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=400&height=150'; + $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=211&height=100"; + $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150"; - $weekly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=211&height=100'; - $weekly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['week'].'&to='.$config['time']['now'].'&width=400&height=150'; + $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=211&height=100"; + $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=400&height=150"; - $monthly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=211&height=100'; - $monthly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['month'].'&to='.$config['time']['now'].'&width=400&height=150'; + $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=211&height=100"; + $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=400&height=150"; - $yearly_graph = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['now'].'&width=211&height=100'; - $yearly_url = 'graph.php?id='.$sensor['sensor_id'].'&type='.$graph_type.'&from='.$config['time']['year'].'&to='.$config['time']['now'].'&width=400&height=150'; + $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=211&height=100"; + $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['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/iftype.inc.php b/html/pages/iftype.inc.php index 8a6d20201..f4349111c 100644 --- a/html/pages/iftype.inc.php +++ b/html/pages/iftype.inc.php @@ -9,102 +9,92 @@ + Total Graph for ports of type : ".$types."
    "); -echo " - Total Graph for ports of type : ".$types.'
    '; +if ($if_list) +{ + $graph_type = "multiport_bits_separate"; + $port['port_id'] = $if_list; -if ($if_list) { - $graph_type = 'multiport_bits_separate'; - $port['port_id'] = $if_list; + include("includes/print-interface-graphs.inc.php"); - include 'includes/print-interface-graphs.inc.php'; + echo(""); - echo ''; + foreach ($ports as $port) + { + $done = "yes"; + unset($class); + $port['ifAlias'] = str_ireplace($type . ": ", "", $port['ifAlias']); + $port['ifAlias'] = str_ireplace("[PNI]", "Private", $port['ifAlias']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg = "#ffffff"; } + echo(" + " . generate_port_link($port,$port['port_descr_descr']) . "
    + ".generate_device_link($port)." ".generate_port_link($port)." + ".generate_port_link($port, makeshortif($port['ifDescr']))." + ".$port['port_descr_speed']." + ".$port['port_descr_circuit']." + ".$port['port_descr_notes']." + + + - ".generate_port_link($port, $port['port_descr_descr'])."
    - ".generate_device_link($port).' '.generate_port_link($port).' - '.generate_port_link($port, makeshortif($port['ifDescr'])).' - '.$port['port_descr_speed'].' - '.$port['port_descr_circuit'].' - '.$port['port_descr_notes']." - - - MAC Accounting"; - } - - echo '
    '; - - if (file_exists($config['rrd_dir'].'/'.$port['hostname'].'/port-'.$port['ifIndex'].'.rrd')) { - $graph_type = 'port_bits'; - - include 'includes/print-interface-graphs.inc.php'; - } - - echo ''; + if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = ?", array($port['port_id']))) + { + echo(" MAC Accounting"); } + + echo('
    '); + + if (file_exists($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . $port['ifIndex'] . ".rrd")) + { + $graph_type = "port_bits"; + + include("includes/print-interface-graphs.inc.php"); + } + + echo(""); + } + } -else { - echo 'None found.'; +else +{ + echo("None found."); } ?> diff --git a/html/pages/inventory.inc.php b/html/pages/inventory.inc.php index 7fc461e4a..e53daab96 100644 --- a/html/pages/inventory.inc.php +++ b/html/pages/inventory.inc.php @@ -1,6 +1,6 @@ @@ -29,53 +29,46 @@ var grid = $("#inventory").bootgrid({ header: "
    "+ "
    "+ "
    "+ - "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ + "\" placeholder=\"Description\" class=\"form-control input-sm\" />"+ "
    "+ "
    "+ " Part No "+ ""+ "
    "+ "
    "+ - "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ + "\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+ "
    "+ "
    "+ " Device "+ ""+ "
    "+ "
    "+ - " -\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ + "\" placeholder=\"Description\" class=\"form-control input-sm\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/locations.inc.php b/html/pages/locations.inc.php index bbe6adcf9..93dffa0e3 100644 --- a/html/pages/locations.inc.php +++ b/html/pages/locations.inc.php @@ -1,92 +1,88 @@ Locations » '; +echo('Locations » '); -$menu_options = array( - 'basic' => 'Basic', - 'traffic' => 'Traffic', -); +$menu_options = array('basic' => 'Basic', + 'traffic' => 'Traffic'); -if (!$vars['view']) { - $vars['view'] = 'basic'; -} +if (!$vars['view']) { $vars['view'] = "basic"; } -$sep = ''; -foreach ($menu_options as $option => $text) { - echo $sep; - if ($vars['view'] == $option) { - echo ""; - } - - echo ''.$text.''; - if ($vars['view'] == $option) { - echo ''; - } - - $sep = ' | '; +$sep = ""; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['view'] == $option) + { + echo(""); + } + echo('' . $text . ''); + if ($vars['view'] == $option) + { + echo(""); + } + $sep = " | "; } unset($sep); print_optionbar_end(); -echo ''; +echo('
    '); -foreach (getlocations() as $location) { - if ($_SESSION['userlevel'] >= '10') { - $num = dbFetchCell('SELECT COUNT(device_id) FROM devices WHERE location = ?', array($location)); - $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); - $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); - $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); - } - else { - $num = dbFetchCell('SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?', array($_SESSION['user_id'], $location)); - $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); - $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); - $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); - $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); +foreach (getlocations() as $location) +{ + if ($_SESSION['userlevel'] >= '10') + { + $num = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ?", array($location)); + $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'network'", array($location)); + $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'server'", array($location)); + $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND type = 'firewall'", array($location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = ? AND status = '0'", array($location)); + } else { + $num = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ?", array($_SESSION['user_id'], $location)); + $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND D.type = 'network'", array($_SESSION['user_id'], $location)); + $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'server'", array($_SESSION['user_id'], $location)); + $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND type = 'firewall'", array($_SESSION['user_id'], $location)); + $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND location = ? AND status = '0'", array($_SESSION['user_id'], $location)); + } + + if ($hostalerts) { $alert = 'alert'; } else { $alert = ""; } + + if ($location != "") + { + echo(' + + + + + + + + '); + + if ($vars['view'] == "traffic") + { + echo('"); } + $done = "yes"; + } +} - if ($hostalerts) { - $alert = 'alert'; - } - else { - $alert = ''; - } +echo("
    ' . $location . '' . $alert . '' . $num . ' devices' . $net . ' network' . $srv . ' servers' . $fwl . ' firewalls
    '); + + $graph_array['type'] = "location_bits"; + $graph_array['height'] = "100"; + $graph_array['width'] = "220"; + $graph_array['to'] = $config['time']['now']; + $graph_array['legend'] = "no"; + $graph_array['id'] = $location; + + include("includes/print-graphrow.inc.php"); + + echo("
    "); - if ($location != '') { - echo ' - '.$location.' - '.$alert.' - '.$num.' devices - '.$net.' network - '.$srv.' servers - '.$fwl.' firewalls - - '; - - if ($vars['view'] == 'traffic') { - echo ''; - - $graph_array['type'] = 'location_bits'; - $graph_array['height'] = '100'; - $graph_array['width'] = '220'; - $graph_array['to'] = $config['time']['now']; - $graph_array['legend'] = 'no'; - $graph_array['id'] = $location; - - include 'includes/print-graphrow.inc.php'; - - echo ''; - } - - $done = 'yes'; - }//end if -}//end foreach - -echo ''; +?> diff --git a/html/pages/logon.inc.php b/html/pages/logon.inc.php index a8a156574..e9819b1b0 100644 --- a/html/pages/logon.inc.php +++ b/html/pages/logon.inc.php @@ -1,8 +1,7 @@
    @@ -33,12 +32,14 @@ else {
    'error','message'=>$auth_message,'title'=>'Login error'); } ?>
    diff --git a/html/pages/map.inc.php b/html/pages/map.inc.php index 115c0600c..0fa1cbb5f 100644 --- a/html/pages/map.inc.php +++ b/html/pages/map.inc.php @@ -10,5 +10,6 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -$pagetitle[] = 'Map'; -require_once 'includes/print-map.inc.php'; +$pagetitle[] = "Map"; +require_once "includes/print-map.inc.php"; +?> diff --git a/html/pages/packages.inc.php b/html/pages/packages.inc.php index ab26fd00a..c3e79c8cf 100644 --- a/html/pages/packages.inc.php +++ b/html/pages/packages.inc.php @@ -2,7 +2,8 @@ foreach ($vars as $var => $value) { if ($value != '') { - switch ($var) { + switch ($var) + { case 'name': $where .= " AND `$var` = ?"; $param[] = $value; @@ -25,7 +26,8 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", foreach ($entry['blah'] as $version => $bleu) { $content = '
    '; - foreach ($bleu as $build => $bloo) { + foreach ($bleu as $build => $bloo) + { if ($build) { $dbuild = '-'.$build; } @@ -34,7 +36,8 @@ foreach (dbFetchRows("SELECT * FROM `packages` WHERE 1 $where GROUP BY `name`", } $content .= '
    '.$version.$dbuild.''; - foreach ($bloo as $device_id => $no) { + foreach ($bloo as $device_id => $no) + { $this_device = device_by_id_cache($device_id); $content .= ''.$this_device['hostname'].' '; } diff --git a/html/pages/plugin.inc.php b/html/pages/plugin.inc.php index 1f718acff..daec96f46 100644 --- a/html/pages/plugin.inc.php +++ b/html/pages/plugin.inc.php @@ -1,18 +1,24 @@ 'plugin'); +$link_array = array('page' => 'plugin'); -$pagetitle[] = 'Plugin'; +$pagetitle[] = "Plugin"; -if ($vars['view'] == 'admin') { - include_once 'pages/plugin/admin.inc.php'; +if ($vars['view'] == "admin") +{ + include_once('pages/plugin/admin.inc.php'); } -else { - $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); - if (!empty($plugin)) { - include 'plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'; - } - else { - print_error('This plugin is either disabled or not available.'); - } +else +{ + $plugin = dbFetchRow("SELECT `plugin_name` FROM `plugins` WHERE `plugin_name` = '".$vars['p']."' AND `plugin_active`='1'"); + if(!empty($plugin)) + { + require('plugins/'.$plugin['plugin_name'].'/'.$plugin['plugin_name'].'.inc.php'); + } + else + { + print_error( "This plugin is either disabled or not available." ); + } } + +?> diff --git a/html/pages/plugin/admin.inc.php b/html/pages/plugin/admin.inc.php index e20bec1b6..1773d641d 100644 --- a/html/pages/plugin/admin.inc.php +++ b/html/pages/plugin/admin.inc.php @@ -1,26 +1,33 @@ = '10') { - // Scan for new plugins and add to the database - $new_plugins = scan_new_plugins(); +if ($_SESSION['userlevel'] >= '10') +{ + + // Scan for new plugins and add to the database + $new_plugins = scan_new_plugins(); - // Check if we have to toggle enabled / disable a particular module - $plugin_id = $_POST['plugin_id']; - $plugin_active = $_POST['plugin_active']; - if (is_numeric($plugin_id) && is_numeric($plugin_active)) { - if ($plugin_active == '0') { - $plugin_active = 1; - } - else if ($plugin_active == '1') { - $plugin_active = 0; - } - else { - $plugin_active = 0; - } + // Check if we have to toggle enabled / disable a particular module + $plugin_id = $_POST['plugin_id']; + $plugin_active = $_POST['plugin_active']; + if(is_numeric($plugin_id) && is_numeric($plugin_active)) + { + if( $plugin_active == '0') + { + $plugin_active = 1; + } + elseif( $plugin_active == '1') + { + $plugin_active = 0; + } + else + { + $plugin_active = 0; + } - if (dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) { - echo ' + if(dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) + { + echo(' -'; - } - }//end if +'); + } + + } ?> @@ -41,13 +49,14 @@ $.ajax({ System plugins
    0) { - echo '
    + if($new_plugins > 0) + { + echo('
    - We have found '.$new_plugins.' new plugins that need to be configured and enabled + We have found ' . $new_plugins . ' new plugins that need to be configured and enabled
    -
    '; -} +
    '); + } ?> @@ -56,21 +65,24 @@ if ($new_plugins > 0) { + foreach (dbFetchRows("SELECT * FROM plugins") as $plugins) + { + if($plugins['plugin_active'] == 1) + { + $plugin_colour = 'bg-success'; + $plugin_button = 'danger'; + $plugin_label = 'Disable'; + } + else + { + $plugin_colour = 'bg-danger'; + $plugin_button = 'success'; + $plugin_label = 'Enable'; + } + echo(' - '; -}//end foreach + '); + } + ?>
    - '.$plugins['plugin_name'].' + '. $plugins['plugin_name'] . ' @@ -79,14 +91,18 @@ foreach (dbFetchRows('SELECT * FROM plugins') as $plugins) {
    diff --git a/html/pages/poll-log.inc.php b/html/pages/poll-log.inc.php index 91ef8132e..3abdf05a8 100644 --- a/html/pages/poll-log.inc.php +++ b/html/pages/poll-log.inc.php @@ -1,5 +1,5 @@ diff --git a/html/pages/pollers.inc.php b/html/pages/pollers.inc.php index 3fef3d931..de85c2344 100644 --- a/html/pages/pollers.inc.php +++ b/html/pages/pollers.inc.php @@ -12,32 +12,25 @@ * the source code distribution for details. */ -$no_refresh = true; +$no_refresh = TRUE; -echo ''); if (isset($vars['tab'])) { - include_once 'pages/pollers/'.mres($vars['tab']).'.inc.php'; + require_once "pages/pollers/".mres($vars['tab']).".inc.php"; } diff --git a/html/pages/pollers/groups.inc.php b/html/pages/pollers/groups.inc.php index a914650ae..50019dfc2 100644 --- a/html/pages/pollers/groups.inc.php +++ b/html/pages/pollers/groups.inc.php @@ -12,7 +12,7 @@ * the source code distribution for details. */ -require_once 'includes/modal/poller_groups.inc.php'; +require_once "includes/modal/poller_groups.inc.php"; ?>
    @@ -28,17 +28,18 @@ require_once 'includes/modal/poller_groups.inc.php'; + echo(' + -'; +'); } ?> diff --git a/html/pages/pollers/pollers.inc.php b/html/pages/pollers/pollers.inc.php index f948d3a8b..c5e0eb279 100644 --- a/html/pages/pollers/pollers.inc.php +++ b/html/pages/pollers/pollers.inc.php @@ -24,28 +24,26 @@ = 300) { $row_class = 'danger'; - } - else if ($old >= 280 && $old < 300) { + } elseif ($old >= 280 && $old < 300) { $row_class = 'warning'; - } - else { + } else { $row_class = 'success'; } - - echo ' + echo(' -'; +'); } ?> diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php index edeea9fbe..8ff1f7d34 100644 --- a/html/pages/ports.inc.php +++ b/html/pages/ports.inc.php @@ -4,27 +4,29 @@ $pagetitle[] = "Ports"; // Set Defaults here -if(!isset($vars['format'])) { - $vars['format'] = "list_basic"; -} +if(!isset($vars['format'])) { $vars['format'] = "list_basic"; } print_optionbar_start(); echo('Lists » '); -$menu_options = array('basic' => 'Basic', 'detail' => 'Detail'); +$menu_options = array('basic' => 'Basic', + 'detail' => 'Detail'); $sep = ""; -foreach ($menu_options as $option => $text) { - echo($sep); - if ($vars['format'] == "list_".$option) { - echo(""); - } - echo('' . $text . ''); - if ($vars['format'] == "list_".$option) { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['format'] == "list_".$option) + { + echo(""); + } + echo('' . $text . ''); + if ($vars['format'] == "list_".$option) + { + echo(""); + } + $sep = " | "; } ?> @@ -35,21 +37,24 @@ foreach ($menu_options as $option => $text) { 'Bits', - 'upkts' => 'Unicast Packets', - 'nupkts' => 'Non-Unicast Packets', - 'errors' => 'Errors'); + 'upkts' => 'Unicast Packets', + 'nupkts' => 'Non-Unicast Packets', + 'errors' => 'Errors'); $sep = ""; -foreach ($menu_options as $option => $text) { - echo($sep); - if ($vars['format'] == 'graph_'.$option) { - echo(''); - } - echo('' . $text . ''); - if ($vars['format'] == 'graph_'.$option) { - echo(""); - } - $sep = " | "; +foreach ($menu_options as $option => $text) +{ + echo($sep); + if ($vars['format'] == 'graph_'.$option) + { + echo(''); + } + echo('' . $text . ''); + if ($vars['format'] == 'graph_'.$option) + { + echo(""); + } + $sep = " | "; } echo('
    '); @@ -59,28 +64,29 @@ echo('
    '); Update URL | '')).'">Search'); -} -else { + } else { echo('Search'); -} + } -echo(" | "); + echo(" | "); -if (isset($vars['bare']) && $vars['bare'] == "yes") { + if (isset($vars['bare']) && $vars['bare'] == "yes") + { echo('Header'); -} -else { + } else { echo('Header'); -} + } echo('
    '); print_optionbar_end(); print_optionbar_start(); -if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) { +if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['searchbar'])) +{ ?>
    @@ -89,66 +95,67 @@ if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars[' = 5) { - $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); - } - else { - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); - } - foreach ($results as $data) { - echo(' "); - } +if($_SESSION['userlevel'] >= 5) +{ + $results = dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname`"); +} +else +{ + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); +} +foreach ($results as $data) +{ + echo(' "); +} - if($_SESSION['userlevel'] < 5) { - $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); - } - else { - $results = array(); - } - foreach ($results as $data) { - echo(' "); - } +if($_SESSION['userlevel'] < 5) +{ + $results = dbFetchRows("SELECT `D`.`device_id`,`D`.`hostname` FROM `ports` AS `I` JOIN `devices` AS `D` ON `D`.`device_id`=`I`.`device_id` JOIN `ports_perms` AS `PP` ON `PP`.`port_id`=`I`.`port_id` WHERE `PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` GROUP BY `hostname` ORDER BY `hostname`", array($_SESSION['user_id'])); +} +else +{ + $results = array(); +} +foreach ($results as $data) +{ + echo(' "); +} ?> - placeholder="Hostname" /> + placeholder="Hostname" />
    @@ -157,100 +164,97 @@ if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars[' ".$data['ifType'].""); - } - } +if (is_admin() === TRUE || is_read() === TRUE) { + $sql = "SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType`"; +} else { + $sql = "SELECT `ifType` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` GROUP BY `ifType` ORDER BY `ifType`"; + $param[] = array($_SESSION['user_id'],$_SESSION['user_id']); +} +foreach (dbFetchRows($sql,$param) as $data) +{ + if ($data['ifType']) + { + echo(' "); + } +} ?>
    - placeholder="Port Description"/> + placeholder="Port Description"/>
    - > + > - > + > - > + >
    @@ -262,98 +266,95 @@ if((isset($vars['searchbar']) && $vars['searchbar'] != "hide") || !isset($vars['
    '.$group['id'].' '.$group['group_name'].' '.$group['descr'].'
    '.$poller['poller_name'].' '.$poller['devices'].' '.$poller['time_taken'].' Seconds '.$poller['last_polled'].'
    - $value) { - if ($value != "") { - switch ($var) { - case 'hostname': - $where .= " AND D.hostname LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'location': - $where .= " AND D.location LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'device_id': - $where .= " AND D.device_id = ?"; - $param[] = $value; - break; - case 'deleted': - if ($value == 1) { - $where .= " AND `I`.`deleted` = 1"; - $ignore_filter = 1; - } - break; - case 'ignore': - if ($value == 1) { - $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; - $ignore_filter = 1; - } - break; - case 'disabled': - if ($value == 1) { - $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; - $disabled_filter = 1; - } - break; - case 'ifSpeed': - if (is_numeric($value)) { - $where .= " AND I.$var = ?"; - $param[] = $value; - } - break; - case 'ifType': - $where .= " AND I.$var = ?"; - $param[] = $value; - break; - case 'ifAlias': - case 'port_descr_type': - $where .= " AND I.$var LIKE ?"; - $param[] = "%".$value."%"; - break; - case 'errors': - if ($value == 1) { - $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; - } - break; - case 'state': - if ($value == "down") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; - $param[] = "up"; - $param[] = "down"; - } - elseif($value == "up") { - $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; - $param[] = "up"; - $param[] = "up"; - } - elseif($value == "admindown") { - $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; - $param[] = "down"; - } - break; +foreach ($vars as $var => $value) +{ + if ($value != "") + { + switch ($var) + { + case 'hostname': + $where .= " AND D.hostname LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'location': + $where .= " AND D.location LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'device_id': + $where .= " AND D.device_id = ?"; + $param[] = $value; + break; + case 'deleted': + if ($value == 1) { + $where .= " AND `I`.`deleted` = 1"; + $ignore_filter = 1; } + break; + case 'ignore': + if ($value == 1) { + $where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0"; + $ignore_filter = 1; + } + break; + case 'disabled': + if ($value == 1) { + $where .= " AND `I`.`disabled` = 1 AND `I`.`deleted` = 0"; + $disabled_filter = 1; + } + break; + case 'ifSpeed': + if (is_numeric($value)) + { + $where .= " AND I.$var = ?"; + $param[] = $value; + } + break; + case 'ifType': + $where .= " AND I.$var = ?"; + $param[] = $value; + break; + case 'ifAlias': + case 'port_descr_type': + $where .= " AND I.$var LIKE ?"; + $param[] = "%".$value."%"; + break; + case 'errors': + if ($value == 1) + { + $where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')"; + } + break; + case 'state': + if ($value == "down") + { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?"; + $param[] = "up"; + $param[] = "down"; + } elseif($value == "up") { + $where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'"; + $param[] = "up"; + $param[] = "up"; + } elseif($value == "admindown") { + $where .= "AND I.ifAdminStatus = ? AND D.ignore = 0"; + $param[] = "down"; + } + break; } + } } if ($ignore_filter == 0 && $disabled_filter == 0) { @@ -368,47 +369,49 @@ list($format, $subformat) = explode("_", $vars['format']); $ports = dbFetchRows($query, $param); -switch ($vars['sort']) { - case 'traffic': - $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); - break; - case 'traffic_in': - $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); - break; - case 'traffic_out': - $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); - break; - case 'packets': - $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); - break; - case 'packets_in': - $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); - break; - case 'packets_out': - $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); - break; - case 'errors': - $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); - break; - case 'speed': - $ports = array_sort($ports, 'ifSpeed', SORT_DESC); - break; - case 'port': - $ports = array_sort($ports, 'ifDescr', SORT_ASC); - break; - case 'media': - $ports = array_sort($ports, 'ifType', SORT_ASC); - break; - case 'descr': - $ports = array_sort($ports, 'ifAlias', SORT_ASC); - break; - case 'device': - default: - $ports = array_sort($ports, 'hostname', SORT_ASC); +switch ($vars['sort']) +{ + case 'traffic': + $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC); + break; + case 'traffic_in': + $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC); + break; + case 'traffic_out': + $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC); + break; + case 'packets': + $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC); + break; + case 'packets_in': + $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC); + break; + case 'packets_out': + $ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC); + break; + case 'errors': + $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); + break; + case 'speed': + $ports = array_sort($ports, 'ifSpeed', SORT_DESC); + break; + case 'port': + $ports = array_sort($ports, 'ifDescr', SORT_ASC); + break; + case 'media': + $ports = array_sort($ports, 'ifType', SORT_ASC); + break; + case 'descr': + $ports = array_sort($ports, 'ifAlias', SORT_ASC); + break; + case 'device': + default: + $ports = array_sort($ports, 'hostname', SORT_ASC); } -if(file_exists('pages/ports/'.$format.'.inc.php')) { - require 'pages/ports/'.$format.'.inc.php'; +if(file_exists('pages/ports/'.$format.'.inc.php')) +{ + include('pages/ports/'.$format.'.inc.php'); } ?> diff --git a/html/pages/ports/list.inc.php b/html/pages/ports/list.inc.php index 71f52e618..8ae9c9df3 100644 --- a/html/pages/ports/list.inc.php +++ b/html/pages/ports/list.inc.php @@ -3,75 +3,68 @@ '; +echo(''); -$cols = array( - 'device' => 'Device', - 'port' => 'Port', - 'speed' => 'Speed', - 'traffic_in' => 'Down', - 'traffic_out' => 'Up', - 'media' => 'Media', - 'descr' => 'Description', -); +$cols = array('device' => 'Device', + 'port' => 'Port', + 'speed' => 'Speed', + 'traffic_in' => 'Down', + 'traffic_out' => 'Up', + 'media' => 'Media', + 'descr' => 'Description' ); -foreach ($cols as $sort => $col) { - if (isset($vars['sort']) && $vars['sort'] == $sort) { - echo ''.$col.' *'; - } - else { - echo ''.$col.''; - } +foreach ($cols as $sort => $col) +{ + if (isset($vars['sort']) && $vars['sort'] == $sort) + { + echo(''.$col.' *'); + } else { + echo(''.$col.''); + } } -echo ' '; +echo(" "); -$ports_disabled = 0; -$ports_down = 0; -$ports_up = 0; -$ports_total = 0; +$ports_disabled = 0; $ports_down = 0; $ports_up = 0; $ports_total = 0; -foreach ($ports as $port) { - if (port_permitted($port['port_id'], $port['device_id'])) { - if ($port['ifAdminStatus'] == 'down') { - $ports_disabled++; - } - else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'down') { - $ports_down++; - } - else if ($port['ifAdminStatus'] == 'up' && $port['ifOperStatus'] == 'up') { - $ports_up++; - } +foreach ($ports as $port) +{ - $ports_total++; + if (port_permitted($port['port_id'], $port['device_id'])) + { - $speed = humanspeed($port['ifSpeed']); - $type = humanmedia($port['ifType']); - $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); + if ($port['ifAdminStatus'] == "down") { $ports_disabled++; + } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "down") { $ports_down++; + } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus']== "up") { $ports_up++; } + $ports_total++; - if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) { - $error_img = generate_port_link($port, "Interface Errors", errors); - } - else { - $error_img = ''; - } + $speed = humanspeed($port['ifSpeed']); + $type = humanmedia($port['ifType']); + $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - $port['in_rate'] = formatRates(($port['ifInOctets_rate'] * 8)); - $port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8)); + if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) + { + $error_img = generate_port_link($port,"Interface Errors",errors); + } else { $error_img = ""; } - $port = ifLabel($port, $device); - echo " - ".generate_device_link($port, shorthost($port['hostname'], '20'))." - ".fixIfName($port['label'])." $error_img - $speed - ".$port['in_rate'].' - '.$port['out_rate']." - $type - ".$port['ifAlias']." - \n"; - }//end if -}//end foreach + $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); + $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); -echo ''; -echo "Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"; -echo ''; + $port = ifLabel($port, $device); + echo(" + ".generate_device_link($port, shorthost($port['hostname'], "20"))." + ".fixIfName($port['label'])." $error_img + $speed + ".$port['in_rate']." + ".$port['out_rate']." + $type + " . $port['ifAlias'] . " + \n"); + } +} + +echo(''); +echo("Matched Ports: $ports_total ( Up $ports_up | Down $ports_down | Disabled $ports_disabled )"); +echo(''); + +?> diff --git a/html/pages/preferences.inc.php b/html/pages/preferences.inc.php index ca2f79835..f4815df24 100644 --- a/html/pages/preferences.inc.php +++ b/html/pages/preferences.inc.php @@ -1,41 +1,48 @@ User Preferences'; +echo("

    User Preferences

    "); if ($_SESSION['userlevel'] == 11) { + demo_account(); -} -else { - if ($_POST['action'] == 'changepass') { - if (authenticate($_SESSION['username'], $_POST['old_pass'])) { - if ($_POST['new_pass'] == '' || $_POST['new_pass2'] == '') { - $changepass_message = 'Password must not be blank.'; - } - else if ($_POST['new_pass'] == $_POST['new_pass2']) { - changepassword($_SESSION['username'], $_POST['new_pass']); - $changepass_message = 'Password Changed.'; - } - else { - $changepass_message = "Passwords don't match."; - } - } - else { - $changepass_message = 'Incorrect password'; - } + +} else { + +if ($_POST['action'] == "changepass") +{ + if (authenticate($_SESSION['username'],$_POST['old_pass'])) + { + if ($_POST['new_pass'] == "" || $_POST['new_pass2'] == "") + { + $changepass_message = "Password must not be blank."; } + elseif ($_POST['new_pass'] == $_POST['new_pass2']) + { + changepassword($_SESSION['username'],$_POST['new_pass']); + $changepass_message = "Password Changed."; + } + else + { + $changepass_message = "Passwords don't match."; + } + } else { + $changepass_message = "Incorrect password"; + } +} - include 'includes/update-preferences-password.inc.php'; +include("includes/update-preferences-password.inc.php"); - echo "
    "; +echo("
    "); - if (passwordscanchange($_SESSION['username'])) { - echo '

    Change Password

    '; - echo $changepass_message; - echo " +if (passwordscanchange($_SESSION['username'])) +{ + echo("

    Change Password

    "); + echo($changepass_message); + echo("
    @@ -62,107 +69,93 @@ else {
    -"; - echo '
    '; - }//end if +"); + echo("
    "); +} - if ($config['twofactor'] === true) { - if ($_POST['twofactorremove'] == 1) { - include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; - if (!isset($_POST['twofactor'])) { - echo '
    '; - echo ''; - echo twofactor_form(false); - echo '
    '; - } - else { - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - if (empty($twofactor['twofactor'])) { - echo '
    Error: How did you even get here?!
    '; - } - else { - $twofactor = json_decode($twofactor['twofactor'], true); - } - - if (verify_hotp($twofactor['key'], $_POST['twofactor'], $twofactor['counter'])) { - if (!dbUpdate(array('twofactor' => ''), 'users', 'username = ?', array($_SESSION['username']))) { - echo '
    Error while disabling TwoFactor.
    '; - } - else { - echo '
    TwoFactor Disabled.
    '; - } - } - else { - session_destroy(); - echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; - } - }//end if +if( $config['twofactor'] === true ) { + if( $_POST['twofactorremove'] == 1 ) { + require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); + if( !isset($_POST['twofactor']) ) { + echo '
    '; + echo ''; + echo twofactor_form(false); + echo '
    '; + } else{ + $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); + if( empty($twofactor['twofactor']) ) { + echo '
    Error: How did you even get here?!
    '; + } else { + $twofactor = json_decode($twofactor['twofactor'],true); + } + if( verify_hotp($twofactor['key'],$_POST['twofactor'],$twofactor['counter']) ) { + if( !dbUpdate(array('twofactor' => ''),'users','username = ?',array($_SESSION['username'])) ) { + echo '
    Error while disabling TwoFactor.
    '; + } else { + echo '
    TwoFactor Disabled.
    '; } - else { - $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - echo ''; - echo '

    Two-Factor Authentication

    '; - if (!empty($twofactor['twofactor'])) { - $twofactor = json_decode($twofactor['twofactor'], true); - $twofactor['text'] = "
    + } else { + session_destroy(); + echo '
    Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
    '; + } + } + } else { + $twofactor = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); + echo ''; + echo '

    Two-Factor Authentication

    '; + if( !empty($twofactor['twofactor']) ) { + $twofactor = json_decode($twofactor['twofactor'],true); + $twofactor['text'] = "
    "; - if ($twofactor['counter'] !== false) { - $twofactor['uri'] = 'otpauth://hotp/'.$_SESSION['username'].'?issuer=LibreNMS&counter='.$twofactor['counter'].'&secret='.$twofactor['key']; - $twofactor['text'] .= "
    + if( $twofactor['counter'] !== false ) { + $twofactor['uri'] = "otpauth://hotp/".$_SESSION['username']."?issuer=LibreNMS&counter=".$twofactor['counter']."&secret=".$twofactor['key']; + $twofactor['text'] .= "
    "; - } - else { - $twofactor['uri'] = 'otpauth://totp/'.$_SESSION['username'].'?issuer=LibreNMS&secret='.$twofactor['key']; - } - - echo '
    + } else { + $twofactor['uri'] = "otpauth://totp/".$_SESSION['username']."?issuer=LibreNMS&secret=".$twofactor['key']; + } + echo '
    '; - echo '
    + echo '
    '.$twofactor['text'].'
    '; - echo ''; - echo '
    + echo ''; + echo '
    '; - } - else { - if (isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype'])) { - include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php'; - $chk = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username'])); - if (empty($chk['twofactor'])) { - $twofactor = array('key' => twofactor_genkey()); - if ($_POST['twofactortype'] == 'counter') { - $twofactor['counter'] = 1; - } - else { - $twofactor['counter'] = false; - } - - if (!dbUpdate(array('twofactor' => json_encode($twofactor)), 'users', 'username = ?', array($_SESSION['username']))) { - echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; - } - else { - echo '
    Added TwoFactor credentials. Please reload page.
    '; - } - } - else { - echo '
    TwoFactor credentials already exists.
    '; - } - } - else { - echo '
    + } else { + if( isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype']) ) { + require_once($config['install_dir']."/html/includes/authentication/twofactor.lib.php"); + $chk = dbFetchRow("SELECT twofactor FROM users WHERE username = ?", array($_SESSION['username'])); + if( empty($chk['twofactor']) ) { + $twofactor = array('key' => twofactor_genkey()); + if( $_POST['twofactortype'] == "counter" ) { + $twofactor['counter'] = 1; + } else { + $twofactor['counter'] = false; + } + if( !dbUpdate(array('twofactor' => json_encode($twofactor)),'users','username = ?',array($_SESSION['username'])) ) { + echo '
    Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
    '; + } else { + echo '
    Added TwoFactor credentials. Please reload page.
    '; + } + } else { + echo '
    TwoFactor credentials already exists.
    '; + } + } else { + echo '
    @@ -176,34 +169,32 @@ else {
    '; - }//end if - }//end if - echo '
    '; - }//end if - }//end if -}//end if - -echo "
    '; + } } -echo '
    '; +} + +echo("
    "); +echo("
    Device Permissions
    "); + +if ($_SESSION['userlevel'] == '10') { echo("Global Administrative Access"); } +if ($_SESSION['userlevel'] == '5') { echo("Global Viewing Access"); } +if ($_SESSION['userlevel'] == '1') +{ + + foreach (dbFetchRows("SELECT * FROM `devices_perms` AS P, `devices` AS D WHERE `user_id` = ? AND P.device_id = D.device_id", array($_SESSION['user_id'])) as $perm) + { + #FIXME generatedevicelink? + echo("" . $perm['hostname'] . "
    "); + $dev_access = 1; + } + + if (!$dev_access) { echo("No access!"); } +} + +echo("
    "); + +?> diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index 3408973fd..5dd77f468 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -90,7 +90,8 @@ foreach (dbFetchRows('SELECT * FROM pseudowires AS P, ports AS I, devices AS D W $pw_a['to'] = $config['time']['now']; $pw_a['bg'] = $bg; $types = array('bits', 'upkts', 'errors'); - foreach ($types as $graph_type) { + foreach ($types as $graph_type) + { $pw_a['graph_type'] = 'port_'.$graph_type; print_port_thumbnail($pw_a); } diff --git a/html/pages/public.inc.php b/html/pages/public.inc.php index bb2583884..ad89593bc 100644 --- a/html/pages/public.inc.php +++ b/html/pages/public.inc.php @@ -1,14 +1,14 @@ - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. Please see LICENSE.txt at the top level of - * the source code distribution for details. + * This file is part of LibreNMS + * + * Copyright (c) 2014 Bohdan Sanders + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. */ ?> @@ -28,11 +28,14 @@ $(document).ready(function() {

    System Status

    @@ -47,8 +50,9 @@ $query = "SELECT * FROM `devices` WHERE 1 AND disabled='0' AND `ignore`='0' ORDE Uptime/Location diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index 3268715ec..5e0494562 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -1,355 +1,260 @@ 'routing', - 'protocol' => 'bgp', - ); +else +{ + $link_array = array('page' => 'routing', 'protocol' => 'bgp'); - print_optionbar_start('', ''); + print_optionbar_start('', ''); - echo 'BGP » '; + echo('BGP » '); - if (!$vars['type']) { - $vars['type'] = 'all'; + if (!$vars['type']) { $vars['type'] = "all"; } + + if ($vars['type'] == "all") { echo(""); } + echo(generate_link("All",$vars, array('type' => 'all'))); + if ($vars['type'] == "all") { echo(""); } + + echo(" | "); + + if ($vars['type'] == "internal") { echo(""); } + echo(generate_link("iBGP",$vars, array('type' => 'internal'))); + if ($vars['type'] == "internal") { echo(""); } + + echo(" | "); + + if ($vars['type'] == "external") { echo(""); } + echo(generate_link("eBGP",$vars, array('type' => 'external'))); + if ($vars['type'] == "external") { echo(""); } + + echo(" | "); + + if ($vars['adminstatus'] == "stop") + { + echo(""); + echo(generate_link("Shutdown",$vars, array('adminstatus' => NULL))); + echo(""); + } else { + echo(generate_link("Shutdown",$vars, array('adminstatus' => 'stop'))); + } + + echo(" | "); + + if ($vars['adminstatus'] == "start") + { + echo(""); + echo(generate_link("Enabled",$vars, array('adminstatus' => NULL))); + echo(""); + } else { + echo(generate_link("Enabled",$vars, array('adminstatus' => 'start'))); + } + + echo(" | "); + + if ($vars['state'] == "down") + { + echo(""); + echo(generate_link("Down",$vars, array('state' => NULL))); + echo(""); + } else { + echo(generate_link("Down",$vars, array('state' => 'down'))); + } + + // End BGP Menu + + if (!isset($vars['view'])) { $vars['view'] = 'details'; } + + echo('
    '); + + if ($vars['view'] == "details") { echo(""); } + echo(generate_link("No Graphs",$vars, array('view' => 'details', 'graph' => 'NULL'))); + if ($vars['view'] == "details") { echo(""); } + + echo(" | "); + + if ($vars['graph'] == "updates") { echo(""); } + echo(generate_link("Updates",$vars, array('view' => 'graphs', 'graph' => 'updates'))); + if ($vars['graph'] == "updates") { echo(""); } + + echo(" | Prefixes: Unicast ("); + if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } + echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast'))); + if ($vars['graph'] == "prefixes_ipv4unicast") { echo(""); } + + echo("|"); + + if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } + echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast'))); + if ($vars['graph'] == "prefixes_ipv6unicast") { echo(""); } + + echo("|"); + + if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } + echo(generate_link("VPNv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn'))); + if ($vars['graph'] == "prefixes_ipv4vpn") { echo(""); } + echo(")"); + + echo(" | Multicast ("); + if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } + echo(generate_link("IPv4",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast'))); + if ($vars['graph'] == "prefixes_ipv4multicast") { echo(""); } + + echo("|"); + + if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } + echo(generate_link("IPv6",$vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast'))); + if ($vars['graph'] == "prefixes_ipv6multicast") { echo(""); } + echo(")"); + + echo(" | MAC ("); + if ($vars['graph'] == "macaccounting_bits") { echo(""); } + echo(generate_link("Bits",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits'))); + if ($vars['graph'] == "macaccounting_bits") { echo(""); } + + echo("|"); + + if ($vars['graph'] == "macaccounting_pkts") { echo(""); } + echo(generate_link("Packets",$vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts'))); + if ($vars['graph'] == "macaccounting_pkts") { echo(""); } + echo(")"); + + echo('
    '); + + print_optionbar_end(); + + echo(""); + echo(''); + + if ($vars['type'] == "external") + { + $where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs"; + } elseif ($vars['type'] == "internal") { + $where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs"; + } + + if ($vars['adminstatus'] == "stop") + { + $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; + } elseif ($vars['adminstatus'] == "start") + { + $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; + } + + if ($vars['state'] == "down") + { + $where .= " AND (B.bgpPeerState != 'established')"; + } + + $peer_query = "select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id ".$where." ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"; + foreach (dbFetchRows($peer_query) as $peer) + { + unset ($alert, $bg_image); + + if ($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $peer['alert']=1; } + if ($peer['bgpPeerAdminStatus'] == "start" || $peer['bgpPeerAdminStatus'] == "running") { $admin_col = "green"; } else { $admin_col = "gray"; } + if ($peer['bgpPeerAdminStatus'] == "stop") { $peer['alert']=0; $peer['disabled']=1; } + if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; + if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } } - if ($vars['type'] == 'all') { - echo ""; + $peerhost = dbFetchRow("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($peer['bgpPeerIdentifier'])); + + if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } + + // display overlib graphs + + $graph_type = "bgp_updates"; + $local_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150&&afi=ipv4&safi=unicast"; + if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { + $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); + } else { + $peer_ip = $peer['bgpLocalAddr']; + } + $localaddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ip . ""; + + $graph_type = "bgp_updates"; + $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150"; + if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { + $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); + } else { + $peer_ident = $peer['bgpPeerIdentifier']; } - echo generate_link('All', $vars, array('type' => 'all')); - if ($vars['type'] == 'all') { - echo ''; + $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer_ident . ""; + + echo('"); + + unset($sep); + foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) + { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $this_afisafi = $afi.$safi; + $peer['afi'] .= $sep . $afi .".".$safi; + $sep = "
    "; + $peer['afisafi'][$this_afisafi] = 1; // Build a list of valid AFI/SAFI for this peer } + unset($sep); - echo ' | '; - - if ($vars['type'] == 'internal') { - echo ""; - } - - echo generate_link('iBGP', $vars, array('type' => 'internal')); - if ($vars['type'] == 'internal') { - echo ''; - } - - echo ' | '; - - if ($vars['type'] == 'external') { - echo ""; - } - - echo generate_link('eBGP', $vars, array('type' => 'external')); - if ($vars['type'] == 'external') { - echo ''; - } - - echo ' | '; - - if ($vars['adminstatus'] == 'stop') { - echo ""; - echo generate_link('Shutdown', $vars, array('adminstatus' => null)); - echo ''; - } - else { - echo generate_link('Shutdown', $vars, array('adminstatus' => 'stop')); - } - - echo ' | '; - - if ($vars['adminstatus'] == 'start') { - echo ""; - echo generate_link('Enabled', $vars, array('adminstatus' => null)); - echo ''; - } - else { - echo generate_link('Enabled', $vars, array('adminstatus' => 'start')); - } - - echo ' | '; - - if ($vars['state'] == 'down') { - echo ""; - echo generate_link('Down', $vars, array('state' => null)); - echo ''; - } - else { - echo generate_link('Down', $vars, array('state' => 'down')); - } - - // End BGP Menu - if (!isset($vars['view'])) { - $vars['view'] = 'details'; - } - - echo '
    '; - - if ($vars['view'] == 'details') { - echo ""; - } - - echo generate_link('No Graphs', $vars, array('view' => 'details', 'graph' => 'NULL')); - if ($vars['view'] == 'details') { - echo ''; - } - - echo ' | '; - - if ($vars['graph'] == 'updates') { - echo ""; - } - - echo generate_link('Updates', $vars, array('view' => 'graphs', 'graph' => 'updates')); - if ($vars['graph'] == 'updates') { - echo ''; - } - - echo ' | Prefixes: Unicast ('; - if ($vars['graph'] == 'prefixes_ipv4unicast') { - echo ""; - } - - echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast')); - if ($vars['graph'] == 'prefixes_ipv4unicast') { - echo ''; - } - - echo '|'; - - if ($vars['graph'] == 'prefixes_ipv6unicast') { - echo ""; - } - - echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast')); - if ($vars['graph'] == 'prefixes_ipv6unicast') { - echo ''; - } - - echo '|'; - - if ($vars['graph'] == 'prefixes_ipv4vpn') { - echo ""; - } - - echo generate_link('VPNv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn')); - if ($vars['graph'] == 'prefixes_ipv4vpn') { - echo ''; - } - - echo ')'; - - echo ' | Multicast ('; - if ($vars['graph'] == 'prefixes_ipv4multicast') { - echo ""; - } - - echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast')); - if ($vars['graph'] == 'prefixes_ipv4multicast') { - echo ''; - } - - echo '|'; - - if ($vars['graph'] == 'prefixes_ipv6multicast') { - echo ""; - } - - echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast')); - if ($vars['graph'] == 'prefixes_ipv6multicast') { - echo ''; - } - - echo ')'; - - echo ' | MAC ('; - if ($vars['graph'] == 'macaccounting_bits') { - echo ""; - } - - echo generate_link('Bits', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits')); - if ($vars['graph'] == 'macaccounting_bits') { - echo ''; - } - - echo '|'; - - if ($vars['graph'] == 'macaccounting_pkts') { - echo ""; - } - - echo generate_link('Packets', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts')); - if ($vars['graph'] == 'macaccounting_pkts') { - echo ''; - } - - echo ')'; - - echo '
    '; - - print_optionbar_end(); - - echo "
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    "; - echo ''; - - if ($vars['type'] == 'external') { - $where = 'AND D.bgpLocalAs != B.bgpPeerRemoteAs'; - } - else if ($vars['type'] == 'internal') { - $where = 'AND D.bgpLocalAs = B.bgpPeerRemoteAs'; - } - - if ($vars['adminstatus'] == 'stop') { - $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; - } - else if ($vars['adminstatus'] == 'start') { - $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; - } - - if ($vars['state'] == 'down') { - $where .= " AND (B.bgpPeerState != 'established')"; - } - - $peer_query = 'select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id '.$where.' ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier'; - foreach (dbFetchRows($peer_query) as $peer) { - unset($alert, $bg_image); - - if ($peer['bgpPeerState'] == 'established') { - $col = 'green'; - } - else { - $col = 'red'; - $peer['alert'] = 1; - } - - if ($peer['bgpPeerAdminStatus'] == 'start' || $peer['bgpPeerAdminStatus'] == 'running') { - $admin_col = 'green'; - } - else { - $admin_col = 'gray'; - } - - if ($peer['bgpPeerAdminStatus'] == 'stop') { - $peer['alert'] = 0; - $peer['disabled'] = 1; - } - - if ($peer['bgpPeerRemoteAs'] == $peer['bgpLocalAs']) { - $peer_type = "iBGP"; - } - else { - $peer_type = "eBGP"; - if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { - $peer_type = "Priv eBGP"; - } - } - - $peerhost = dbFetchRow('SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($peer['bgpPeerIdentifier'])); - - if ($peerhost) { - $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); - } - else { - unset($peername); - } - - // display overlib graphs - $graph_type = 'bgp_updates'; - $local_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150&&afi=ipv4&safi=unicast'; - if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { - $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); - } - else { - $peer_ip = $peer['bgpLocalAddr']; - } - - $localaddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ip.''; - - $graph_type = 'bgp_updates'; - $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; - if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { - $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); - } - else { - $peer_ident = $peer['bgpPeerIdentifier']; - } - - $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ident.''; - - echo ''; - - unset($sep); - foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { - $afi = $afisafi['afi']; - $safi = $afisafi['safi']; - $this_afisafi = $afi.$safi; - $peer['afi'] .= $sep.$afi.'.'.$safi; - $sep = '
    '; - $peer['afisafi'][$this_afisafi] = 1; - // Build a list of valid AFI/SAFI for this peer - } - - unset($sep); - - echo ' - + echo(" + - + - - - - '; + + + + "); - unset($invalid); - switch ($vars['graph']) { - case 'prefixes_ipv4unicast': - case 'prefixes_ipv4multicast': - case 'prefixes_ipv4vpn': - case 'prefixes_ipv6unicast': - case 'prefixes_ipv6multicast': - list(,$afisafi) = explode('_', $vars['graph']); - if (isset($peer['afisafi'][$afisafi])) { - $peer['graph'] = 1; - } + unset($invalid); + switch ($vars['graph']) + { + case 'prefixes_ipv4unicast': + case 'prefixes_ipv4multicast': + case 'prefixes_ipv4vpn': + case 'prefixes_ipv6unicast': + case 'prefixes_ipv6multicast': + list(,$afisafi) = explode("_", $vars['graph']); + if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } + case 'updates': + $graph_array['type'] = "bgp_" . $vars['graph']; + $graph_array['id'] = $peer['bgpPeer_id']; + } - case 'updates': - $graph_array['type'] = 'bgp_'.$vars['graph']; - $graph_array['id'] = $peer['bgpPeer_id']; + switch ($vars['graph']) + { + case 'macaccounting_bits': + case 'macaccounting_pkts': + $acc = dbFetchRow("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); + $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; + if (is_array($acc) && is_file($database)) + { + $peer['graph'] = 1; + $graph_array['id'] = $acc['ma_id']; + $graph_array['type'] = $vars['graph']; } + } - switch ($vars['graph']) { - case 'macaccounting_bits': - case 'macaccounting_pkts': - $acc = dbFetchRow('SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); - $database = $config['rrd_dir'].'/'.$device['hostname'].'/cip-'.$acc['ifIndex'].'-'.$acc['mac'].'.rrd'; - if (is_array($acc) && is_file($database)) { - $peer['graph'] = 1; - $graph_array['id'] = $acc['ma_id']; - $graph_array['type'] = $vars['graph']; - } - } + if ($vars['graph'] == 'updates') { $peer['graph'] = 1; } - if ($vars['graph'] == 'updates') { - $peer['graph'] = 1; - } + if ($peer['graph']) + { + $graph_array['height'] = "100"; + $graph_array['width'] = "218"; + $graph_array['to'] = $config['time']['now']; + echo('"); + } + } - echo ''; - } - }//end foreach + echo("
    Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
    '.$localaddresslink.'
    '.generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')).'
    " . $localaddresslink . "
    ".generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp'))."
    »'.$peeraddresslink."" . $peeraddresslink . " $peer_type".$peer['afi'].'AS'.$peer['bgpPeerRemoteAs'].'
    '.$peer['astext']."
    ".$peer['bgpPeerAdminStatus']."
    ".$peer['bgpPeerState'].'
    '.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
    - Updates ".format_si($peer['bgpPeerInUpdates'])." - ".format_si($peer['bgpPeerOutUpdates']).'
    ".$peer['afi']."AS" . $peer['bgpPeerRemoteAs'] . "
    " . $peer['astext'] . "
    " . $peer['bgpPeerAdminStatus'] . "
    " . $peer['bgpPeerState'] . "
    " .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
    + Updates " . format_si($peer['bgpPeerInUpdates']) . " + " . format_si($peer['bgpPeerOutUpdates']) . "
    '); - if ($peer['graph']) { - $graph_array['height'] = '100'; - $graph_array['width'] = '218'; - $graph_array['to'] = $config['time']['now']; - echo '
    '; + include("includes/print-graphrow.inc.php"); - include 'includes/print-graphrow.inc.php'; + echo("
    "); +} - echo ''; -}//end if diff --git a/html/pages/routing/overview.inc.php b/html/pages/routing/overview.inc.php index c16262143..bd9a9e63e 100644 --- a/html/pages/routing/overview.inc.php +++ b/html/pages/routing/overview.inc.php @@ -1,7 +1,7 @@ 'IPv4 Address', - 'ipv6' => 'IPv6 Address', - 'mac' => 'MAC Address', - 'arp' => 'ARP Table', -); +$sections = array('ipv4' => 'IPv4 Address', 'ipv6' => 'IPv6 Address', 'mac' => 'MAC Address', 'arp' => 'ARP Table'); -if (dbFetchCell('SELECT 1 from `packages` LIMIT 1')) { - $sections['packages'] = 'Packages'; +if( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) { + $sections['packages'] = 'Packages'; } -if (!isset($vars['search'])) { - $vars['search'] = 'ipv4'; -} +if (!isset($vars['search'])) { $vars['search'] = "ipv4"; } print_optionbar_start('', ''); -echo 'Search » '; + echo('Search » '); unset($sep); -foreach ($sections as $type => $texttype) { - echo $sep; - if ($vars['search'] == $type) { - echo ""; - } +foreach ($sections as $type => $texttype) +{ + echo($sep); + if ($vars['search'] == $type) + { + echo(""); + } - // echo('' . $texttype .''); - echo generate_link($texttype, array('page' => 'search', 'search' => $type)); +# echo('' . $texttype .''); + echo(generate_link($texttype, array('page'=>'search','search'=>$type))); - if ($vars['search'] == $type) { - echo ''; - } + if ($vars['search'] == $type) { echo(""); } - $sep = ' | '; + $sep = ' | '; } - -unset($sep); +unset ($sep); print_optionbar_end('', ''); -if (file_exists('pages/search/'.$vars['search'].'.inc.php')) { - include 'pages/search/'.$vars['search'].'.inc.php'; -} -else { - echo report_this('Unknown search type '.$vars['search']); +if( file_exists('pages/search/'.$vars['search'].'.inc.php') ) { + include('pages/search/'.$vars['search'].'.inc.php'); +} else { + echo(report_this('Unknown search type '.$vars['search'])); } + +?> diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index 45cd6888a..a4dcbd113 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -30,22 +30,21 @@ var grid = $("#arp-search").bootgrid({ '.$data['hostname'].'"+'; + echo('">'.$data['hostname'].'"+'); } ?> ""+ @@ -54,16 +53,18 @@ foreach (dbFetchRows($sql, $param) as $data) { " "\" class=\"form-control input-sm\" placeholder=\"Address\" />"+ diff --git a/html/pages/search/ipv4.inc.php b/html/pages/search/ipv4.inc.php index 843acbd1b..e2ea785c0 100644 --- a/html/pages/search/ipv4.inc.php +++ b/html/pages/search/ipv4.inc.php @@ -27,23 +27,22 @@ var grid = $("#ipv4-search").bootgrid({ ""+ '.$data['hostname'].'"+'; + echo('">'.$data['hostname'].'"+'); } ?> ""+ @@ -53,16 +52,18 @@ foreach (dbFetchRows($sql, $param) as $data) { ""+ ""+ "
     "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv4 Address\"/>"+ "
     "+ ""+ "
    "+ diff --git a/html/pages/search/ipv6.inc.php b/html/pages/search/ipv6.inc.php index 2b9115013..8ab58d9ff 100644 --- a/html/pages/search/ipv6.inc.php +++ b/html/pages/search/ipv6.inc.php @@ -26,23 +26,22 @@ var grid = $("#ipv6-search").bootgrid({ ""+ '.$data['hostname'].'"+'; + echo('">'.$data['hostname'].'"+'); } ?> ""+ @@ -52,8 +51,9 @@ foreach (dbFetchRows($sql, $param) as $data) { ""+ ""+ "
    "+ "
    "+ - "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ + "\" class=\"form-control input-sm\" placeholder=\"IPv6 Address\"/>"+ "
    "+ ""+ "
    "+ diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index f606e4436..c040a1e16 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -26,22 +26,21 @@ var grid = $("#mac-search").bootgrid({ ""+ @@ -51,15 +50,17 @@ foreach (dbFetchRows($sql, $param) as $data) { ""+ ""+ "
    '-1', 'rule' => '%macros.device_down = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Devices up/down'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%devices.uptime < "300" && %macros.device = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Device rebooted'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerState != "established" && %macros.device_up = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session down'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session establised'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.port_down = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Port status up/down'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%macros.port_usage_perc >= "80"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Port utilisation over threshold'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor over limit'); - $default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor under limit'); - foreach( $default_rules as $add_rule ) { - dbInsert($add_rule,'alert_rules'); +if (isset($_POST['create-default'])) { + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%macros.device_down = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Devices up/down', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%devices.uptime < "300" && %macros.device = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Device rebooted', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%bgpPeers.bgpPeerState != "established" && %macros.device_up = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'BGP Session down', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'BGP Session establised', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%macros.port_down = "1"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Port status up/down', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%macros.port_usage_perc >= "80"', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Port utilisation over threshold', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Sensor over limit', + ); + $default_rules[] = array( + 'device_id' => '-1', + 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', + 'severity' => 'critical', + 'extra' => '{"mute":false,"count":"-1","delay":"300"}', + 'disabled' => 0, + 'name' => 'Sensor under limit', + ); + foreach ($default_rules as $add_rule) { + dbInsert($add_rule, 'alert_rules'); } -} - -require_once('includes/modal/new_alert_rule.inc.php'); -require_once('includes/modal/delete_alert_rule.inc.php'); +}//end if +require_once 'includes/modal/new_alert_rule.inc.php'; +require_once 'includes/modal/delete_alert_rule.inc.php'; ?>
    0) { +if (isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { $results = $_POST['results']; -} else { +} +else { $results = 50; } echo '
    - - +
    + @@ -49,126 +103,150 @@ echo '
    - '; + '; -echo (' - + '); -$rulei=1; -$count_query = "SELECT COUNT(id)"; -$full_query = "SELECT *"; -$sql = ''; -$param = array(); -if(isset($device['device_id']) && $device['device_id'] > 0) { - $sql = 'WHERE (device_id=? OR device_id="-1")'; +echo ''; + +$rulei = 1; +$count_query = 'SELECT COUNT(id)'; +$full_query = 'SELECT *'; +$sql = ''; +$param = array(); +if (isset($device['device_id']) && $device['device_id'] > 0) { + $sql = 'WHERE (device_id=? OR device_id="-1")'; $param = array($device['device_id']); } -$query = " FROM alert_rules $sql ORDER BY device_id,id"; -$count_query = $count_query . $query; -$count = dbFetchCell($count_query,$param); -if(!isset($_POST['page_number']) && $_POST['page_number'] < 1) { + +$query = " FROM alert_rules $sql ORDER BY device_id,id"; +$count_query = $count_query.$query; +$count = dbFetchCell($count_query, $param); +if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { $page_number = 1; -} else { +} +else { $page_number = $_POST['page_number']; } -$start = ($page_number - 1) * $results; -$full_query = $full_query . $query . " LIMIT $start,$results"; -foreach( dbFetchRows($full_query, $param) as $rule ) { - $sub = dbFetchRows("SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1", array($rule['id'])); - $ico = "ok"; - $col = "success"; - $extra = ""; - if( sizeof($sub) == 1 ) { - $sub = $sub[0]; - if( (int) $sub['state'] === 0 ) { - $ico = "ok"; - $col = "success"; - } elseif( (int) $sub['state'] === 1 ) { - $ico = "remove"; - $col = "danger"; - $extra = "danger"; - } elseif( (int) $sub['state'] === 2 ) { - $ico = "time"; - $col = "default"; - $extra = "warning"; - } - } - $alert_checked = ''; - $orig_ico = $ico; - $orig_col = $col; - $orig_class = $extra; - if( $rule['disabled'] ) { - $ico = "pause"; - $col = ""; - $extra = "active"; - } else { - $alert_checked = 'checked'; +$start = (($page_number - 1) * $results); +$full_query = $full_query.$query." LIMIT $start,$results"; + +foreach (dbFetchRows($full_query, $param) as $rule) { + $sub = dbFetchRows('SELECT * FROM alerts WHERE rule_id = ? ORDER BY id DESC LIMIT 1', array($rule['id'])); + $ico = 'ok'; + $col = 'success'; + $extra = ''; + if (sizeof($sub) == 1) { + $sub = $sub[0]; + if ((int) $sub['state'] === 0) { + $ico = 'ok'; + $col = 'success'; } - $rule_extra = json_decode($rule['extra'],TRUE); - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + else if ((int) $sub['state'] === 2) { + $ico = 'time'; + $col = 'default'; + $extra = 'warning'; } - echo ""; - echo ""; - echo ""; - echo "\r\n"; + } + + $alert_checked = ''; + $orig_ico = $ico; + $orig_col = $col; + $orig_class = $extra; + if ($rule['disabled']) { + $ico = 'pause'; + $col = ''; + $extra = 'active'; + } + else { + $alert_checked = 'checked'; + } + + $rule_extra = json_decode($rule['extra'], true); + echo ""; + echo ''; + echo ''; + echo "'; + echo ''; + echo ""; + } + + echo ''; + echo ''; + echo ''; + echo "\r\n"; +}//end foreach + +if (($count % $results) > 0) { + echo ' + + '; } -if($count % $results > 0) { - echo(' - - '); -} echo '
    # Name RuleExtra Enabled Action
    '); +echo ''; if ($_SESSION['userlevel'] >= '10') { - echo(''); + echo ''; } -echo ('
    #".((int) $rulei++)."".$rule['name'].""; - if($rule_extra['invert'] === true) { - echo "Inverted "; + else if ((int) $sub['state'] === 1) { + $ico = 'remove'; + $col = 'danger'; + $extra = 'danger'; } - echo "".htmlentities($rule['rule'])."".$rule['severity']." "; - if($rule_extra['mute'] === true) { - echo "Max: ".$rule_extra['count']."
    Delay: ".$rule_extra['delay']."
    Interval: ".$rule_extra['interval']."
    "; - if ($_SESSION['userlevel'] >= '10') { - echo ""; - } - echo ""; - if ($_SESSION['userlevel'] >= '10') { - echo " "; - echo ""; - } - echo "
    #'.((int) $rulei++).''.$rule['name'].'"; + if ($rule_extra['invert'] === true) { + echo 'Inverted '; + } + + echo ''.htmlentities($rule['rule']).''.$rule['severity'].' "; + if ($rule_extra['mute'] === true) { + echo "Max: '.$rule_extra['count'].'
    Delay: '.$rule_extra['delay'].'
    Interval: '.$rule_extra['interval'].'
    '; + if ($_SESSION['userlevel'] >= '10') { + echo ""; + } + + echo ''; + if ($_SESSION['userlevel'] >= '10') { + echo " "; + echo ""; + } + + echo '
    '.generate_pagination($count, $results, $page_number).'
    '. generate_pagination($count,$results,$page_number) .'
    - - - -
    '; + + + +
    '; -if($count < 1) { +if ($count < 1) { if ($_SESSION['userlevel'] >= '10') { echo '
    -
    -
    -

    - -

    -
    -
    -
    '; +
    +
    +

    + +

    +
    +
    +
    '; } } @@ -180,19 +258,19 @@ $('#ack-alert').click('', function(e) { var alert_id = $(this).data("alert_id"); $.ajax({ type: "POST", - url: "/ajax_form.php", - data: { type: "ack-alert", alert_id: alert_id }, - success: function(msg){ - $("#message").html('
    '+msg+'
    '); - if(msg.indexOf("ERROR:") <= -1) { - setTimeout(function() { - location.reload(1); - }, 1000); - } - }, - error: function(){ - $("#message").html('
    An error occurred acking this alert.
    '); - } + url: "/ajax_form.php", + data: { type: "ack-alert", alert_id: alert_id }, + success: function(msg){ + $("#message").html('
    '+msg+'
    '); + if(msg.indexOf("ERROR:") <= -1) { + setTimeout(function() { + location.reload(1); + }, 1000); + } + }, + error: function(){ + $("#message").html('
    An error occurred acking this alert.
    '); + } }); }); @@ -206,42 +284,42 @@ $('input[name="alert-rule"]').on('switchChange.bootstrapSwitch', function(event var orig_class = $(this).data("orig_class"); $.ajax({ type: 'POST', - url: '/ajax_form.php', - data: { type: "update-alert-rule", alert_id: alert_id, state: state }, - dataType: "html", - success: function(msg) { - if(msg.indexOf("ERROR:") <= -1) { - if(state) { - $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).removeClass('text-default'); - $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); - $('#row_'+alert_id).removeClass('active'); - $('#row_'+alert_id).addClass(orig_class); + url: '/ajax_form.php', + data: { type: "update-alert-rule", alert_id: alert_id, state: state }, + dataType: "html", + success: function(msg) { + if(msg.indexOf("ERROR:") <= -1) { + if(state) { + $('#alert-rule-'+alert_id).removeClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).addClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).removeClass('text-default'); + $('#alert-rule-'+alert_id).addClass('text-'+orig_colour); + $('#row_'+alert_id).removeClass('active'); + $('#row_'+alert_id).addClass(orig_class); + } else { + $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); + $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); + $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); + $('#alert-rule-'+alert_id).addClass('text-default'); + $('#row_'+alert_id).removeClass('warning'); + $('#row_'+alert_id).addClass('active'); + } } else { - $('#alert-rule-'+alert_id).removeClass('glyphicon-'+orig_state); - $('#alert-rule-'+alert_id).addClass('glyphicon-pause'); - $('#alert-rule-'+alert_id).removeClass('text-'+orig_colour); - $('#alert-rule-'+alert_id).addClass('text-default'); - $('#row_'+alert_id).removeClass('warning'); - $('#row_'+alert_id).addClass('active'); + $("#message").html('
    '+msg+'
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); + } + }, + error: function() { + $("#message").html('
    This alert could not be updated.
    '); + $('#'+alert_id).bootstrapSwitch('toggleState',true ); } - } else { - $("#message").html('
    '+msg+'
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); - } - }, - error: function() { - $("#message").html('
    This alert could not be updated.
    '); - $('#'+alert_id).bootstrapSwitch('toggleState',true ); - } }); }); function updateResults(results) { - $('#results_amount').val(results.value); - $('#page_number').val(1); - $('#result_form').submit(); + $('#results_amount').val(results.value); + $('#page_number').val(1); + $('#result_form').submit(); } function changePage(page,e) { diff --git a/html/includes/print-alert-templates.php b/html/includes/print-alert-templates.php index 16a3afdd0..8ad6e8265 100644 --- a/html/includes/print-alert-templates.php +++ b/html/includes/print-alert-templates.php @@ -1,6 +1,6 @@ @@ -10,17 +10,17 @@ $no_refresh = TRUE;