diff --git a/database-update.sql b/database-update.sql index 96c30a6802..80ad5a4893 100644 --- a/database-update.sql +++ b/database-update.sql @@ -7,3 +7,4 @@ CREATE TABLE IF NOT EXISTS `device_graphs` ( `device_id` int(11) NOT NULL, `gr DROP TABLE IF EXISTS `graph_types`; CREATE TABLE IF NOT EXISTS `graph_types` ( `graph_type` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `graph_subtype` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `graph_section` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `graph_descr` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `graph_order` int(11) NOT NULL, KEY `graph_type` (`graph_type`), KEY `graph_subtype` (`graph_subtype`), KEY `graph_section` (`graph_section`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; INSERT INTO `graph_types` (`graph_type`, `graph_subtype`, `graph_section`, `graph_descr`, `graph_order`) VALUES('device', 'bits', 'netstats', 'Total Traffic', 0),('device', 'hr_users', 'system', 'Users Logged In', 0),('device', 'ucd_load', 'system', 'Load Averages', 0),('device', 'ucd_cpu', 'system', 'Detailed Processor Usage', 0),('device', 'ucd_memory', 'system', 'Detailed Memory Usage', 0),('device', 'netstat_tcp', 'netstats', 'TCP Statistics', 0),('device', 'netstat_icmp_info', 'netstats', 'ICMP Informational Statistics', 0),('device', 'netstat_icmp_stat', 'netstats', 'ICMP Statistics', 0),('device', 'netstat_ip', 'netstats', 'IP Statistics', 0),('device', 'netstat_ip_frag', 'netstats', 'IP Fragmentation Statistics', 0),('device', 'netstat_udp', 'netstats', 'UDP Statistics', 0),('device', 'netstat_snmp', 'netstats', 'SNMP Statistics', 0),('device', 'temperatures', 'system', 'Temperatures', 0),('device', 'mempools', 'system', 'Memory Pool Usage', 0),('device', 'processors', 'system', 'Processor Usage', 0),('device', 'storage', 'system', 'Filesystem Usage', 0),('device', 'hr_processes', 'system', 'Running Processes', 0),('device', 'uptime', 'system', 'System Uptime', ''),('device', 'ipsystemstats_ipv4', 'netstats', 'IPv4 Packet Statistics', 0),('device', 'ipsystemstats_ipv6_frag', 'netstats', 'IPv6 Fragmentation Statistics', 0),('device', 'ipsystemstats_ipv6', 'netstats', 'IPv6 Packet Statistics', 0),('device', 'ipsystemstats_ipv4_frag', 'netstats', 'IPv4 Fragmentation Statistics', 0),('device', 'fortigate_sessions', 'firewall', 'Active Sessions', ''), ('device', 'screenos_settings', 'firewall', 'Active Sessions', ''), ('device', 'fdb_count', 'system', 'MAC Addresses Learnt', '0'); +DROP TABLE `frequency`; diff --git a/html/includes/graphs/device/frequencies.inc.php b/html/includes/graphs/device/frequencies.inc.php index cada8049bf..e7a4ea21f1 100644 --- a/html/includes/graphs/device/frequencies.inc.php +++ b/html/includes/graphs/device/frequencies.inc.php @@ -6,7 +6,7 @@ $device = device_by_id_cache($id); $rrd_options .= " -l 0 -E "; $iter = "1"; -$sql = mysql_query("SELECT * FROM frequency where device_id = '$id'"); +$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='freq' AND device_id = '$id'"); $rrd_options .= " COMMENT:' Cur Min Max\\n'"; while($frequency = mysql_fetch_array($sql)) { @@ -39,15 +39,15 @@ while($frequency = mysql_fetch_array($sql)) $hostname = gethostbyid($frequency['device_id']); - $descr = substr(str_pad($frequency['freq_descr'], 15),0,15); - $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("freq-" . $frequency['freq_descr'] . ".rrd"); - $freq_id = $frequency['freq_id']; + $descr = substr(str_pad($frequency['sensor_descr'], 15),0,15); + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("freq-" . $frequency['sensor_descr'] . ".rrd"); + $sensor_id = $frequency['sensor_id']; - $rrd_options .= " DEF:freq$freq_id=$rrd_filename:freq:AVERAGE"; - $rrd_options .= " LINE1:freq$freq_id#".$colour.":'" . $descr . "'"; - $rrd_options .= " GPRINT:freq$freq_id:AVERAGE:%5.2lfHz"; - $rrd_options .= " GPRINT:freq$freq_id:MIN:%5.2lfHz"; - $rrd_options .= " GPRINT:freq$freq_id:MAX:%5.2lfHz\\\\l"; + $rrd_options .= " DEF:freq$sensor_id=$rrd_filename:freq:AVERAGE"; + $rrd_options .= " LINE1:freq$sensor_id#".$colour.":'" . $descr . "'"; + $rrd_options .= " GPRINT:freq$sensor_id:AVERAGE:%5.2lfHz"; + $rrd_options .= " GPRINT:freq$sensor_id:MIN:%5.2lfHz"; + $rrd_options .= " GPRINT:freq$sensor_id:MAX:%5.2lfHz\\\\l"; $iter++; } diff --git a/html/includes/graphs/sensor/frequency.inc.php b/html/includes/graphs/sensor/frequency.inc.php index 9fb47ce748..a6ad07fa01 100644 --- a/html/includes/graphs/sensor/frequency.inc.php +++ b/html/includes/graphs/sensor/frequency.inc.php @@ -6,16 +6,16 @@ include("includes/graphs/common.inc.php"); $rrd_options .= " COMMENT:' Last Max\\n'"; - $frequency = mysql_fetch_array(mysql_query("SELECT * FROM frequency where freq_id = '".mres($_GET['id'])."'")); + $frequency = mysql_fetch_array(mysql_query("SELECT * FROM sensors where sensor_class='freq' AND sensor_id = '".mres($_GET['id'])."'")); $hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $frequency['device_id'] . "'"),0); - $frequency['freq_descr_fixed'] = substr(str_pad($frequency['freq_descr'], 28),0,28); + $frequency['sensor_descr_fixed'] = substr(str_pad($frequency['sensor_descr'], 28),0,28); - $rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("freq-" . $frequency['freq_descr'] . ".rrd"); + $rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("freq-" . $frequency['sensor_descr'] . ".rrd"); $rrd_options .= " DEF:freq=$rrd_filename:freq:AVERAGE"; - $rrd_options .= " LINE1.5:freq#cc0000:'" . $frequency['freq_descr_fixed']."'"; + $rrd_options .= " LINE1.5:freq#cc0000:'" . $frequency['sensor_descr_fixed']."'"; $rrd_options .= " GPRINT:freq:LAST:%3.0lfHz"; $rrd_options .= " GPRINT:freq:MAX:%3.0lfHz\\\\l"; diff --git a/html/pages/device/health.inc.php b/html/pages/device/health.inc.php index 3e2164efa6..a9e367753a 100644 --- a/html/pages/device/health.inc.php +++ b/html/pages/device/health.inc.php @@ -10,7 +10,7 @@ $humidity = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_ $fans = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='fanspeed' AND device_id = '" . $device['device_id'] . "'"), 0); $volts = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='voltage' AND device_id = '" . $device['device_id'] . "'"), 0); $current = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='current' AND device_id = '" . $device['device_id'] . "'"), 0); -$freqs = mysql_result(mysql_query("select count(*) from frequency WHERE device_id = '" . $device['device_id'] . "'"), 0); +$freqs = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='freq' AND device_id = '" . $device['device_id'] . "'"), 0); $datas[] = 'overview'; if ($processor) { $datas[] = 'processors'; } diff --git a/html/pages/device/health/frequencies.inc.php b/html/pages/device/health/frequencies.inc.php index 98e7eedb1e..036be198ed 100644 --- a/html/pages/device/health/frequencies.inc.php +++ b/html/pages/device/health/frequencies.inc.php @@ -1,6 +1,6 @@ "); diff --git a/html/pages/device/overview/current.inc.php b/html/pages/device/overview/current.inc.php index a503a5d556..3c3f6ce1e1 100644 --- a/html/pages/device/overview/current.inc.php +++ b/html/pages/device/overview/current.inc.php @@ -2,7 +2,6 @@ $graph_type = "sensor_current"; -unset($current_seperator); if($total = mysql_result(mysql_query("SELECT count(sensor_id) from sensors WHERE sensor_class='current' AND device_id = '" . $device['device_id'] . "'"),0)) { $rows = round($total / 2,0); echo("
"); diff --git a/html/pages/device/overview/fanspeeds.inc.php b/html/pages/device/overview/fanspeeds.inc.php index 73b538a57b..ba3ed4b0bd 100644 --- a/html/pages/device/overview/fanspeeds.inc.php +++ b/html/pages/device/overview/fanspeeds.inc.php @@ -2,7 +2,6 @@ $graph_type = "sensor_fanspeed"; -unset($fan_seperator); if($total = mysql_result(mysql_query("SELECT count(sensor_id) from sensors WHERE sensor_class='fanspeed' AND device_id = '" . $device['device_id'] . "'"),0)) { $rows = round($total / 2,0); echo("
"); diff --git a/html/pages/device/overview/frequencies.inc.php b/html/pages/device/overview/frequencies.inc.php index 42241bd11f..2045aa5db3 100644 --- a/html/pages/device/overview/frequencies.inc.php +++ b/html/pages/device/overview/frequencies.inc.php @@ -2,38 +2,38 @@ $graph_type = "sensor_frequency"; -unset($freq_seperator); -if(mysql_result(mysql_query("SELECT count(freq_id) from frequency WHERE device_id = '" . $device['device_id'] . "'"),0)) { - $total = mysql_result(mysql_query("SELECT count(freq_id) from frequency WHERE device_id = '" . $device['device_id'] . "'"),0); +if($total = mysql_result(mysql_query("SELECT count(sensor_id) from sensors WHERE sensor_class='freq' AND device_id = '" . $device['device_id'] . "'"),0)) { $rows = round($total / 2,0); echo("
"); echo("

Frequencies

"); $i = '1'; - $freqs = mysql_query("SELECT * FROM frequency WHERE device_id = '" . $device['device_id'] . "'"); - echo(""); - echo("
"); - echo(""); - while($freq = mysql_fetch_array($freqs)) { + $temps = mysql_query("SELECT * FROM sensors WHERE sensor_class='freq' AND device_id = '" . $device['device_id'] . "' ORDER BY sensor_index"); + echo('
'); + echo('
'); + echo(''); + while($temp = mysql_fetch_array($temps)) { if(is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } $graph_colour = str_replace("#", "", $row_colour); - $freq_day = "graph.php?id=" . $freq['freq_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100"; - $freq_week = "graph.php?id=" . $freq['freq_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100"; - $freq_month = "graph.php?id=" . $freq['freq_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100"; - $freq_year = "graph.php?id=" . $freq['freq_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100"; - $freq_minigraph = ""; + $temp_perc = $temp['sensor_current'] / $temp['sensor_limit'] * 100; + $temp_colour = percent_colour($temp_perc); + $temp_day = "graph.php?id=" . $temp['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100"; + $temp_week = "graph.php?id=" . $temp['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100"; + $temp_month = "graph.php?id=" . $temp['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100"; + $temp_year = "graph.php?id=" . $temp['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100"; + $temp_minigraph = ""; - $freq_link = ""; + $temp_link = ""; - $freq_link_c = $freq_link . " $freq['freq_limit'] ? "style='color: red'" : '') . '>' . $freq['freq_current'] . "Hz"; - $freq_link_b = $freq_link . $freq_minigraph . ""; - $freq_link_a = $freq_link . $freq['freq_descr'] . ""; + $temp_link_c = $temp_link . "" . round($temp['sensor_current'],0) . "Hz"; + $temp_link_b = $temp_link . $temp_minigraph . ""; + $temp_link_a = $temp_link . $temp['sensor_descr'] . ""; - $freq['freq_descr'] = truncate($freq['freq_descr'], 25, ''); - echo(""); + $temp['sensor_descr'] = truncate($temp['sensor_descr'], 25, ''); + echo(""); if($i == $rows) { echo("
$freq_link_a$freq_link_b$freq_link_c
$temp_link_a$temp_link_b$temp_link_c
"); } $i++; } diff --git a/html/pages/device/overview/humidity.inc.php b/html/pages/device/overview/humidity.inc.php index a0ac41d4b3..4cb6feac84 100644 --- a/html/pages/device/overview/humidity.inc.php +++ b/html/pages/device/overview/humidity.inc.php @@ -2,7 +2,6 @@ $graph_type = "sensor_humidity"; -unset($humidity_seperator); if($total = mysql_result(mysql_query("SELECT count(sensor_id) from sensors WHERE sensor_class='humidity' AND device_id = '" . $device['device_id'] . "'"),0)) { $rows = round($total / 2,0); echo("
"); diff --git a/html/pages/device/overview/temperatures.inc.php b/html/pages/device/overview/temperatures.inc.php index 171c23c94e..24cea88ab5 100644 --- a/html/pages/device/overview/temperatures.inc.php +++ b/html/pages/device/overview/temperatures.inc.php @@ -2,7 +2,6 @@ $graph_type = "sensor_temperature"; -unset($temp_seperator); if($total = mysql_result(mysql_query("SELECT count(sensor_id) from sensors WHERE sensor_class='temperature' AND device_id = '" . $device['device_id'] . "'"),0)) { $rows = round($total / 2,0); echo("
"); diff --git a/html/pages/device/overview/voltages.inc.php b/html/pages/device/overview/voltages.inc.php index bd773877e1..3feacaf64b 100644 --- a/html/pages/device/overview/voltages.inc.php +++ b/html/pages/device/overview/voltages.inc.php @@ -2,7 +2,6 @@ $graph_type = "sensor_voltage"; -unset($volt_seperator); if($total = mysql_result(mysql_query("SELECT count(sensor_id) from sensors WHERE sensor_class='voltage' AND device_id = '" . $device['device_id'] . "'"),0)) { $rows = round($total / 2,0); echo("
");