mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
cleanups
git-svn-id: http://www.observium.org/svn/observer/trunk@2340 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
51
attic/cisco-entity-sensors.inc.php
Executable file
51
attic/cisco-entity-sensors.inc.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
$query = "SELECT * FROM entPhysical WHERE device_id = '" . $device['device_id'] . "' AND entPhysicalClass = 'sensor'";
|
||||
$sensors = mysql_query($query);
|
||||
while ($sensor = mysql_fetch_assoc($sensors))
|
||||
{
|
||||
echo("Checking Entity Sensor " . $sensor['entPhysicalName'] . " - " . $sensor['cempsensorName']);
|
||||
|
||||
$oid = $sensor['entPhysicalIndex'];
|
||||
|
||||
$sensor_cmd = $config['snmpget'] . " -M ".$config['mibdir']." -m CISCO-ENTITY-SENSOR-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$sensor_cmd .= " entSensorValue.$oid entSensorStatus.$oid";
|
||||
|
||||
$sensor_data = trim(shell_exec($sensor_cmd));
|
||||
|
||||
# echo("$sensor_data");
|
||||
|
||||
list($entSensorValue, $entSensorStatus) = explode("\n", $sensor_data);
|
||||
|
||||
$rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ces-" . $oid . ".rrd");
|
||||
|
||||
if (!is_file($rrd))
|
||||
{
|
||||
rrdtool_create($rrd,"--step 300 \
|
||||
DS:value:GAUGE:600:-1000:U \
|
||||
RRA:AVERAGE:0.5:1:2304 \
|
||||
RRA:AVERAGE:0.5:6:1536 \
|
||||
RRA:AVERAGE:0.5:24:2268 \
|
||||
RRA:AVERAGE:0.5:288:1890 \
|
||||
RRA:MAX:0.5:1:2304 \
|
||||
RRA:MAX:0.5:6:1536 \
|
||||
RRA:MAX:0.5:24:2268 \
|
||||
RRA:MAX:0.5:288:1890 \
|
||||
RRA:MIN:0.5:1:2304 \
|
||||
RRA:MIN:0.5:6:1536 \
|
||||
RRA:MIN:0.5:24:2268 \
|
||||
RRA:MIN:0.5:288:1890");
|
||||
}
|
||||
|
||||
$entSensorValue = entPhysical_scale($entSensorValue, $sensor['entSensorScale']);
|
||||
|
||||
$updatecmd = $config['rrdtool'] ." update $rrd N:$entSensorValue";
|
||||
shell_exec($updatecmd);
|
||||
|
||||
$update_query = "UPDATE `entPhysical` SET entSensorValue='$entSensorValue', entSensorStatus='$entSensorStatus' WHERE `entPhysical_id` = '".$sensor['entPhysical_id']."'";
|
||||
mysql_query($update_query);
|
||||
|
||||
echo($entSensorValue . " - " . $entSensorStatus . "\n");
|
||||
}
|
||||
|
||||
?>
|
||||
66
attic/temperatures.inc.php
Executable file
66
attic/temperatures.inc.php
Executable file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
$class = 'temperature';
|
||||
$unit = 'C';
|
||||
|
||||
$query = "SELECT * FROM sensors WHERE sensor_class='$class' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
|
||||
$sensor_data = mysql_query($query);
|
||||
|
||||
while ($sensor = mysql_fetch_assoc($sensor_data))
|
||||
{
|
||||
echo("Checking temp " . $sensor['sensor_descr'] . "... ");
|
||||
|
||||
for ($i = 0;$i < 5;$i++) # Try 5 times to get a valid temp reading
|
||||
{
|
||||
if ($debug) echo("Attempt $i ");
|
||||
$sensor_value = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
|
||||
$sensor_value = trim(str_replace("\"", "", $sensor_value));
|
||||
|
||||
if ($sensor_value != 9999) break; # TME sometimes sends 999.9 when it is right in the middle of an update;
|
||||
sleep(1); # Give the TME some time to reset
|
||||
}
|
||||
|
||||
if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; }
|
||||
if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; }
|
||||
|
||||
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/$class-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
|
||||
|
||||
$rrd_file = get_sensor_rrd($device, $sensor);
|
||||
|
||||
if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
|
||||
|
||||
if (!is_file($rrd_file))
|
||||
{
|
||||
rrdtool_create($rrd_file,"--step 300 \
|
||||
DS:sensor:GAUGE:600:-273:1000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797\
|
||||
RRA:MIN:0.5:1:600 \
|
||||
RRA:MIN:0.5:6:700 \
|
||||
RRA:MIN:0.5:24:775 \
|
||||
RRA:MIN:0.5:288:797");
|
||||
}
|
||||
|
||||
echo("$sensor_value $unit\n");
|
||||
|
||||
rrdtool_update($rrd_file,"N:$sensor_value");
|
||||
|
||||
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit'])
|
||||
{
|
||||
$msg = "Temp Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . " (Limit " . $sensor['sensor_limit'];
|
||||
$msg .= ") at " . date($config['timestamp_format']);
|
||||
notify($device, "Temp Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
|
||||
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
|
||||
log_event('Temperature ' . $sensor['sensor_descr'] . " over threshold: " . $sensor_value . " " . html_entity_decode('°') . "$unit (>= " . $sensor['sensor_limit'] . " " . html_entity_decode('°') . "$unit)", $device, $class, $sensor['sensor_id']);
|
||||
}
|
||||
|
||||
mysql_query("UPDATE sensors SET sensor_current = '$sensor_value' WHERE sensor_class='$class' AND sensor_id = '" . $sensor['sensor_id'] . "'");
|
||||
}
|
||||
|
||||
?>
|
||||
54
attic/voltages.inc.php
Executable file
54
attic/voltages.inc.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
$class = 'voltage';
|
||||
$class_text = "Voltage";
|
||||
$unit = 'V';
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? AND `poller_type` = 'snmp'", array($class, $device['device_id'])) as $sensor)
|
||||
{
|
||||
echo("Checking ".$class." " . $sensor['sensor_descr'] . ": ");
|
||||
|
||||
$sensor_value = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
|
||||
|
||||
if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; }
|
||||
if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; }
|
||||
|
||||
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/$class-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
|
||||
$rrd_file = get_sensor_rrd($device, $sensor);
|
||||
|
||||
if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
|
||||
|
||||
if (!is_file($rrd_file))
|
||||
{
|
||||
rrdtool_create($rrd_file,"--step 300 \
|
||||
DS:sensor:GAUGE:600:-273:1000 \
|
||||
RRA:AVERAGE:0.5:1:1200 \
|
||||
RRA:MIN:0.5:12:2400 \
|
||||
RRA:MAX:0.5:12:2400 \
|
||||
RRA:AVERAGE:0.5:12:2400");
|
||||
}
|
||||
|
||||
echo("$sensor_value $unit\n");
|
||||
|
||||
rrdtool_update($rrd_file,"N:$sensor_value");
|
||||
|
||||
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $sensor_value <= $sensor['sensor_limit_low'])
|
||||
{
|
||||
$msg = $class_text . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . "$unit (Limit " . $sensor['sensor_limit'];
|
||||
$msg .= "$unit) at " . date($config['timestamp_format']);
|
||||
notify($device, $class_text" Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
|
||||
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
|
||||
log_event($class_text.' '.$sensor['sensor_descr'] . " under threshold: " . $sensor_value . " $unit (< " . $sensor['sensor_limit_low'] . " $unit)", $device, $class, $sensor['sensor_id']);
|
||||
}
|
||||
else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit'])
|
||||
{
|
||||
$msg = $class_text." Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . "$unit (Limit " . $sensor['sensor_limit'];
|
||||
$msg .= "$unit) at " . date($config['timestamp_format']);
|
||||
notify($device, $class_text." Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
|
||||
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
|
||||
log_event($class_text." ". $sensor['sensor_descr'] . " above threshold: " . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $unit)", $device, $class, $sensor['sensor_id']);
|
||||
}
|
||||
dbUpdate(array('sensor_current' => $sensor_value), 'sensors', '`sensor_id` = ', array($sensor['sensor_id']));
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1 +1,4 @@
|
||||
ALTER TABLE users ADD can_modify_passwd TINYINT NOT NULL DEFAULT 1;
|
||||
ALTER TABLE `observer_dev`.`storage` ADD UNIQUE `index_unique` ( `device_id` , `storage_mib` , `storage_index` );
|
||||
ALTER TABLE `bgpPeers_cbgp` ADD `AcceptedPrefixes` INT NOT NULL ,ADD `DeniedPrefixes` INT NOT NULL ,ADD `PrefixAdminLimit` INT NOT NULL ,ADD `PrefixThreshold` INT NOT NULL ,ADD `PrefixClearThreshold` INT NOT NULL ,ADD `AdvertisedPrefixes` INT NOT NULL ,ADD `SuppressedPrefixes` INT NOT NULL ,ADD `WithdrawnPrefixes` INT NOT NULL;
|
||||
ALTER TABLE `observer_dev`.`bgpPeers_cbgp` ADD UNIQUE `unique_index` ( `device_id` , `bgpPeerIdentifier` , `afi` , `safi` );
|
||||
|
||||
@@ -13,12 +13,18 @@ function get_percentage_colours($percentage)
|
||||
|
||||
}
|
||||
|
||||
function generate_device_url($device, $linksuffix="")
|
||||
{
|
||||
return "device/" . $device['device_id'] . "/" . $linksuffix;
|
||||
}
|
||||
|
||||
function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0)
|
||||
{
|
||||
global $twoday, $day, $now, $config;
|
||||
global $config;
|
||||
|
||||
if (!$start) { $start = $config['time']['day']; }
|
||||
if (!$end) { $end = $config['time']['now']; }
|
||||
|
||||
if (!$start) { $start = $day; }
|
||||
if (!$end) { $end = $now; }
|
||||
$class = devclass($device);
|
||||
if (!$text) { $text = $device['hostname']; }
|
||||
|
||||
@@ -35,7 +41,7 @@ function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0
|
||||
$graphs = $config['os']['default']['over'];
|
||||
}
|
||||
|
||||
$url = "device/" . $device['device_id'] . "/" . $linksuffix;
|
||||
$url = generate_device_url($device, $linksuffix);
|
||||
$contents = "<div class=list-large>".$device['hostname'];
|
||||
if ($device['hardware']) { $contents .= " - ".$device['hardware']; }
|
||||
$contents .= "</div>";
|
||||
@@ -55,7 +61,7 @@ function generate_device_link($device, $text=0, $linksuffix="", $start=0, $end=0
|
||||
$contents .= '<div style="width: 708px">';
|
||||
$contents .= '<span style="margin-left: 5px; font-size: 12px; font-weight: bold;">'.$graphhead.'</span><br />';
|
||||
$contents .= "<img src=\"graph.php?id=" . $device['device_id'] . "&from=$start&to=$end&width=275&height=100&type=$graph&legend=no" . '" style="margin: 2px;">';
|
||||
$contents .= "<img src=\"graph.php?id=" . $device['device_id'] . "&from=".$config['week']."&to=$end&width=275&height=100&type=$graph&legend=no" . '" style="margin: 2px;">';
|
||||
$contents .= "<img src=\"graph.php?id=" . $device['device_id'] . "&from=".$config['time']['week']."&to=$end&width=275&height=100&type=$graph&legend=no" . '" style="margin: 2px;">';
|
||||
$contents .= '</div>';
|
||||
}
|
||||
|
||||
@@ -95,13 +101,13 @@ function generate_graph_popup($graph_array)
|
||||
$graph_array['legend'] = "yes";
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "340";
|
||||
$graph_array['from'] = $config['day'];
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['week'];
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['month'];
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['year'];
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= "</div>";
|
||||
|
||||
@@ -236,7 +242,7 @@ function print_percentage_bar($width, $height, $percent, $left_text, $left_colou
|
||||
|
||||
function generate_port_link($args, $text = NULL, $type = NULL)
|
||||
{
|
||||
global $twoday, $now, $config, $day, $month;
|
||||
global $config;
|
||||
|
||||
$args = ifNameDescr($args);
|
||||
if (!$text) { $text = fixIfName($args['label']); }
|
||||
@@ -253,19 +259,19 @@ function generate_port_link($args, $text = NULL, $type = NULL)
|
||||
$graph_array['legend'] = "yes";
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "340";
|
||||
$graph_array['to'] = $config['now'];
|
||||
$graph_array['from'] = $config['day'];
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['id'] = $args['interface_id'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['week'];
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['month'];
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['year'];
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= "</div>";
|
||||
|
||||
$url = "device/".$args['device_id']."/port/" . $args['interface_id'] . "/";
|
||||
$url = generate_port_url($args);
|
||||
|
||||
if (port_permitted($args['interface_id'])) {
|
||||
return overlib_link($url, $text, $content, $class);
|
||||
@@ -274,6 +280,10 @@ function generate_port_link($args, $text = NULL, $type = NULL)
|
||||
}
|
||||
}
|
||||
|
||||
function generate_port_url($args) {
|
||||
return $url = "device/".$args['device_id']."/port/" . $args['interface_id'] . "/";
|
||||
}
|
||||
|
||||
function generate_port_thumbnail($args)
|
||||
{
|
||||
if (!$args['bg']) { $args['bg'] = "FFFFF"; }
|
||||
|
||||
@@ -35,7 +35,7 @@ if ($port_details)
|
||||
echo("$break <a class=interface-desc href=\"javascript:popUp('netcmd.php?cmd=whois&query=".$ip['ipv4_address']."')\">".$ip['ipv4_address']."/".$ip['ipv4_prefixlen']."</a>");
|
||||
$break = ",";
|
||||
}
|
||||
foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ?", array($interface['interface_id']) as $ip6);
|
||||
foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = ?", array($interface['interface_id'])) as $ip6);
|
||||
{
|
||||
echo("$break <a class=interface-desc href=\"javascript:popUp('netcmd.php?cmd=whois&query=".$ip6['ipv6_address']."')\">".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen']."</a>");
|
||||
$break = ",";
|
||||
@@ -44,48 +44,48 @@ if ($port_details)
|
||||
|
||||
echo("</span>");
|
||||
|
||||
$width="120"; $height="40"; $from = $day;
|
||||
$width="120"; $height="40"; $from = $config['time']['day'];
|
||||
|
||||
echo("</td><td width=135>");
|
||||
echo(formatRates($interface['ifInOctets_rate'] * 8)." <img class='optionicon' src='images/icons/arrow_updown.png' /> ".formatRates($interface['ifOutOctets_rate'] * 8));
|
||||
echo("<br />");
|
||||
$interface['graph_type'] = "port_bits";
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$now."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$config['time']['now']."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
|
||||
|
||||
echo("</td><td width=135>");
|
||||
echo("".formatRates($interface['adslAturChanCurrTxRate']) . "/". formatRates($interface['adslAtucChanCurrTxRate']));
|
||||
echo("<br />");
|
||||
$interface['graph_type'] = "port_adsl_speed";
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$now."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$config['time']['now']."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
|
||||
|
||||
echo("</td><td width=135>");
|
||||
echo("".formatRates($interface['adslAturCurrAttainableRate']) . "/". formatRates($interface['adslAtucCurrAttainableRate']));
|
||||
echo("<br />");
|
||||
$interface['graph_type'] = "port_adsl_attainable";
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$now."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$config['time']['now']."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
|
||||
|
||||
echo("</td><td width=135>");
|
||||
echo("".$interface['adslAturCurrAtn'] . "dB/". $interface['adslAtucCurrAtn'] . "dB");
|
||||
echo("<br />");
|
||||
$interface['graph_type'] = "port_adsl_attenuation";
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$now."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$config['time']['now']."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
|
||||
|
||||
echo("</td><td width=135>");
|
||||
echo("".$interface['adslAturCurrSnrMgn'] . "dB/". $interface['adslAtucCurrSnrMgn'] . "dB");
|
||||
echo("<br />");
|
||||
$interface['graph_type'] = "port_adsl_snr";
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$now."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$config['time']['now']."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
|
||||
|
||||
echo("</td><td width=135>");
|
||||
echo("".$interface['adslAturCurrOutputPwr'] . "dBm/". $interface['adslAtucCurrOutputPwr'] . "dBm");
|
||||
echo("<br />");
|
||||
$interface['graph_type'] = "port_adsl_power";
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$now."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$config['time']['now']."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
|
||||
|
||||
# if ($interface[ifDuplex] != unknown) { echo("<span class=box-desc>Duplex " . $interface['ifDuplex'] . "</span>"); } else { echo("-"); }
|
||||
@@ -103,41 +103,4 @@ str_replace("#","", $row_colour)."'>", $interface['graph_type']));
|
||||
|
||||
echo("</td>");
|
||||
|
||||
if ($graph_type == "etherlike")
|
||||
{
|
||||
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/etherlike-". safename($interface['ifIndex']) . ".rrd";
|
||||
} else {
|
||||
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/". safename($interface['ifIndex']) . ".rrd";
|
||||
}
|
||||
|
||||
if ($graph_type && is_file($graph_file))
|
||||
{
|
||||
$type = $graph_type;
|
||||
|
||||
$daily_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$from&to=$now&width=210&height=100";
|
||||
$daily_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$from&to=$now&width=500&height=150";
|
||||
|
||||
$weekly_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=210&height=100";
|
||||
$weekly_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=500&height=150";
|
||||
|
||||
$monthly_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=210&height=100";
|
||||
$monthly_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=500&height=150";
|
||||
|
||||
$yearly_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=210&height=100";
|
||||
$yearly_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=500&height=150";
|
||||
|
||||
echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=7>");
|
||||
|
||||
echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\"
|
||||
onmouseout=\"return nd();\"> <img src='$daily_traffic' border=0></a>");
|
||||
echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\"
|
||||
onmouseout=\"return nd();\"> <img src='$weekly_traffic' border=0></a>");
|
||||
echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT, WIDTH, 350".$config['overlib_defaults'].");\"
|
||||
onmouseout=\"return nd();\"> <img src='$monthly_traffic' border=0></a>");
|
||||
echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT, WIDTH, 350".$config['overlib_defaults'].");\"
|
||||
onmouseout=\"return nd();\"> <img src='$yearly_traffic' border=0></a>");
|
||||
|
||||
echo("</td></tr>");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -4,10 +4,10 @@ global $config;
|
||||
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "215";
|
||||
$graph_array['to'] = $now;
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['id'] = $interface['interface_id'];
|
||||
$graph_array['type'] = $graph_type;
|
||||
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -59,11 +59,11 @@ echo("</td><td width=100>");
|
||||
if ($port_details)
|
||||
{
|
||||
$interface['graph_type'] = "port_bits";
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=port_bits&id=".$interface['interface_id']."&from=".$day."&to=".$now."&width=100&height=20&legend=no&bg=".str_replace("#","", $row_colour)."'>"));
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=port_bits&id=".$interface['interface_id']."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=100&height=20&legend=no&bg=".str_replace("#","", $row_colour)."'>"));
|
||||
$interface['graph_type'] = "port_upkts";
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=port_upkts&id=".$interface['interface_id']."&from=".$day."&to=".$now."&width=100&height=20&legend=no&bg=".str_replace("#","", $row_colour)."'>"));
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=port_upkts&id=".$interface['interface_id']."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=100&height=20&legend=no&bg=".str_replace("#","", $row_colour)."'>"));
|
||||
$interface['graph_type'] = "port_errors";
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=port_errors&id=".$interface['interface_id']."&from=".$day."&to=".$now."&width=100&height=20&legend=no&bg=".str_replace("#","", $row_colour)."'>"));
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=port_errors&id=".$interface['interface_id']."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=100&height=20&legend=no&bg=".str_replace("#","", $row_colour)."'>"));
|
||||
}
|
||||
|
||||
echo("</td><td width=120>");
|
||||
@@ -259,31 +259,10 @@ if ($graph_type && is_file($graph_file))
|
||||
{
|
||||
$type = $graph_type;
|
||||
|
||||
$daily_traffic = "graph.php?id=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=210&height=100";
|
||||
$daily_url = "graph.php?id=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=500&height=150";
|
||||
|
||||
$weekly_traffic = "graph.php?id=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=210&height=100";
|
||||
$weekly_url = "graph.php?id=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=500&height=150";
|
||||
|
||||
$monthly_traffic = "graph.php?id=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=210&height=100";
|
||||
$monthly_url = "graph.php?id=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=500&height=150";
|
||||
|
||||
$yearly_traffic = "graph.php?id=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=210&height=100";
|
||||
$yearly_url = "graph.php?id=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=500&height=150";
|
||||
|
||||
echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=7>");
|
||||
echo("<tr style='background-color: $row_colour; padding: 0px;'><td colspan=7>");
|
||||
|
||||
include("includes/print-interface-graphs.inc.php");
|
||||
|
||||
# echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\"
|
||||
# onmouseout=\"return nd();\"> <img src='$daily_traffic' border=0></a>");
|
||||
# echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\"
|
||||
# onmouseout=\"return nd();\"> <img src='$weekly_traffic' border=0></a>");
|
||||
# echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT, WIDTH, 350".$config['overlib_defaults'].");\"
|
||||
# onmouseout=\"return nd();\"> <img src='$monthly_traffic' border=0></a>");
|
||||
# echo("<a href='device/" . $interface['device_id'] . "/port/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT, WIDTH, 350".$config['overlib_defaults'].");\"
|
||||
# onmouseout=\"return nd();\"> <img src='$yearly_traffic' border=0></a>");
|
||||
|
||||
echo("</td></tr>");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$service_alerts = dbFetchCell("SELECT COUNT(service_id) FROM services WHERE service_status = '0'");
|
||||
$if_alerts = dbFetchCell("SELECT count(*) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'");
|
||||
$if_alerts = dbFetchCell("SELECT COUNT(interface_id) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'");
|
||||
|
||||
$device_alerts = "0";
|
||||
$device_alert_sql = "WHERE 0";
|
||||
@@ -16,8 +16,11 @@ foreach (dbFetchRows("SELECT * FROM `devices`") as $device)
|
||||
$this_alert = 0;
|
||||
if ($device['status'] == 0 && $device['ignore'] == '0') { $this_alert = "1"; } elseif ($device['ignore'] == '0')
|
||||
{
|
||||
if (dbFetchCell("SELECT count(service_id) FROM services WHERE service_status = '0' AND device_id = ?", array($device['device_id']))) { $this_alert = "1"; }
|
||||
if (dbFetchCell("SELECT count(*) FROM ports WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND device_id = ? AND `ignore` = '0'", array($device['device_id']))) { $this_alert = "1"; }
|
||||
|
||||
## sluggish. maybe we cache this at poll-time?
|
||||
|
||||
# if (dbFetchCell("SELECT count(service_id) FROM services WHERE service_status = '0' AND device_id = ?", array($device['device_id']))) { $this_alert = "1"; }
|
||||
# if (dbFetchCell("SELECT count(*) FROM ports WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND device_id = ? AND `ignore` = '0'", array($device['device_id']))) { $this_alert = "1"; }
|
||||
}
|
||||
if ($this_alert)
|
||||
{
|
||||
|
||||
@@ -5,18 +5,18 @@ global $config;
|
||||
if(!$graph_array['height']) { $graph_array['height'] = "100"; }
|
||||
if(!$graph_array['width']) { $graph_array['width'] = "215"; }
|
||||
|
||||
$graph_array['to'] = $now;
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
|
||||
$periods = array('day', 'week', 'month', 'year');
|
||||
|
||||
foreach ($periods as $period)
|
||||
{
|
||||
$graph_array['from'] = $config[$period];
|
||||
$graph_array['from'] = $config['time'][$period];
|
||||
$graph_array_zoom = $graph_array;
|
||||
$graph_array_zoom['height'] = "150";
|
||||
$graph_array_zoom['width'] = "400";
|
||||
|
||||
$link = "graphs/" . $graph_array['id'] . "/" . $graph_array['type'] . "/" . $graph_array['from'] . "/" . $config['now'] . "/";
|
||||
$link = "graphs/" . $graph_array['id'] . "/" . $graph_array['type'] . "/" . $graph_array['from'] . "/" . $config['to'] . "/";
|
||||
|
||||
echo(overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL));
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ if ($service['service_checked'])
|
||||
$checked = formatUptime($checked);
|
||||
} else { $checked = "Never"; }
|
||||
|
||||
$mini_url = "graph.php?id=".$service['service_id']."&type=service_availability&from=".$day."&to=".$now."&width=80&height=20&bg=efefef";
|
||||
$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('<div class=list-large>".$device['hostname']." - ".$service['service_type'];
|
||||
$popup .= "</div><img src=\'graph.php?id=" . $service['service_id'] . "&type=service_availability&from=$day&to=$now&width=400&height=125\'>";
|
||||
$popup .= "</div><img src=\'graph.php?id=" . $service['service_id'] . "&type=service_availability&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=125\'>";
|
||||
$popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"";
|
||||
|
||||
echo("
|
||||
@@ -59,4 +59,4 @@ echo("
|
||||
|
||||
$i++;
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -26,7 +26,9 @@ include("../includes/functions.php");
|
||||
include("includes/functions.inc.php");
|
||||
|
||||
$start = utime();
|
||||
|
||||
$now = time();
|
||||
$fourhour = time() - (4 * 60 * 60);
|
||||
$day = time() - (24 * 60 * 60);
|
||||
$twoday = time() - (2 * 24 * 60 * 60);
|
||||
$week = time() - (7 * 24 * 60 * 60);
|
||||
|
||||
@@ -56,12 +56,17 @@ foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GRO
|
||||
unset($customer_name);
|
||||
}
|
||||
|
||||
echo("<tr bgcolor='$bg_colour'><td></td><td colspan=6>
|
||||
<img src='graph.php?id=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$day&to=$now&width=215&height=100'>
|
||||
<img src='graph.php?id=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$week&to=$now&width=215&height=100'>
|
||||
<img src='graph.php?id=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$month&to=$now&width=215&height=100'>
|
||||
<img src='graph.php?id=".rawurlencode($customer['port_descr_descr'])."&type=customer_bits&from=$year&to=$now&width=215&height=100'>
|
||||
</td></tr>");
|
||||
echo("<tr bgcolor='$bg_colour'><td></td><td colspan=6>");
|
||||
|
||||
$graph_array['type'] = "customer_bits";
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "220";
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['id'] = $customer['port_descr_descr'];
|
||||
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
|
||||
echo("</tr>");
|
||||
}
|
||||
|
||||
echo("</table>");
|
||||
|
||||
@@ -89,24 +89,24 @@ print_optionbar_end();
|
||||
}
|
||||
echo("</div>");
|
||||
|
||||
$daily_traffic = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$day&to=$now&width=215&height=100";
|
||||
$daily_traffic = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100";
|
||||
$daily_traffic .= $args;
|
||||
$daily_url = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$day&to=$now&width=400&height=150";
|
||||
$daily_url = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150";
|
||||
$daily_url .= $args;
|
||||
|
||||
$weekly_traffic = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$week&to=$now&width=215&height=100";
|
||||
$weekly_traffic = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100";
|
||||
$weekly_traffic .= $args;
|
||||
$weekly_url = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$week&to=$now&width=400&height=150";
|
||||
$weekly_url = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150";
|
||||
$weekly_url .= $args;
|
||||
|
||||
$monthly_traffic = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$month&to=$now&width=215&height=100";
|
||||
$monthly_traffic = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100";
|
||||
$monthly_traffic .= $args;
|
||||
$monthly_url = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$month&to=$now&width=400&height=150";
|
||||
$monthly_url = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150";
|
||||
$monthly_url .= $args;
|
||||
|
||||
$yearly_traffic = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$year&to=$now&width=215&height=100";
|
||||
$yearly_traffic = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=215&height=100";
|
||||
$yearly_traffic .= $args;
|
||||
$yearly_url = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$year&to=$now&width=400&height=150";
|
||||
$yearly_url = "collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150";
|
||||
$yearly_url .= $args;
|
||||
|
||||
|
||||
|
||||
@@ -17,11 +17,17 @@ foreach (dbFetchRows("SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY di
|
||||
|
||||
$fs_url = "device/".$device['device_id']."/health/diskio/";
|
||||
|
||||
$fs_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$drive['diskio_descr'];
|
||||
$fs_popup .= "</div><img src=\'graph.php?id=" . $drive['diskio_id'] . "&type=diskio_ops&from=$month&to=$now&width=400&height=125\'>";
|
||||
$fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"";
|
||||
$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("<tr bgcolor='$row_colour'><th><a href='$fs_url' $fs_popup>" . $drive['diskio_descr'] . "</a></td></tr>");
|
||||
echo("<tr bgcolor='$row_colour'><th>");
|
||||
echo(overlib_link($fs_url, $drive['diskio_descr'], generate_graph_tag($graph_array_zoom), NULL));
|
||||
echo("</th></tr>");
|
||||
|
||||
$types = array("diskio_bits", "diskio_ops");
|
||||
|
||||
@@ -29,6 +35,7 @@ foreach (dbFetchRows("SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY di
|
||||
{
|
||||
echo('<tr bgcolor="'.$row_colour.'"><td colspan=5>');
|
||||
|
||||
$graph_array = array();
|
||||
$graph_array['id'] = $drive['diskio_id'];
|
||||
$graph_array['type'] = $graph_type;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `h
|
||||
$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_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
|
||||
$mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
|
||||
|
||||
echo("<td>$mini_graph</td>");
|
||||
} else {
|
||||
|
||||
@@ -12,17 +12,19 @@ if (count($sensors))
|
||||
{
|
||||
if (is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
### FIXME - make this "four graphs in popup" a function/include and "small graph" a function.
|
||||
|
||||
$graph_colour = str_replace("#", "", $row_colour);
|
||||
|
||||
$sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100";
|
||||
$sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100";
|
||||
$sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100";
|
||||
$sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100";
|
||||
$sensor_minigraph = "<img src='graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=80&height=20&bg=$graph_colour' align='absmiddle'>";
|
||||
$sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=210&height=100";
|
||||
$sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=210&height=100";
|
||||
$sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=210&height=100";
|
||||
$sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=210&height=100";
|
||||
$sensor_minigraph = "<img src='graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=$graph_colour' align='absmiddle'>";
|
||||
|
||||
$sensor_link = "<a href='graphs/".$sensor['sensor_id']."/" . $graph_type . "/' onmouseover=\"return ";
|
||||
$sensor_link .= "overlib('<div class=list-large>".$device['hostname']." - ".$sensor['sensor_descr'];
|
||||
$sensor_link .= "</div><div style=\'width: 750px\'><img src=\'$sensor_day\'><img src=\'$sensor_week\'><img src=\'$sensor_month\'><img src=\'$sensor_year\'></div>', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >";
|
||||
$sensor_link .= "</div><div style=\'width: 570px\'><img src=\'$sensor_day\'><img src=\'$sensor_week\'><img src=\'$sensor_month\'><img src=\'$sensor_year\'></div>', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >";
|
||||
|
||||
$sensor_link_c = $sensor_link . "<span " . ($sensor['sensor_current'] < $sensor['sensor_limit_low'] || $sensor['sensor_current'] > $sensor['sensor_limit'] ? "style='color: red'" : '') . '>' . $sensor['sensor_current'] . $sensor_unit . "</span></a>";
|
||||
$sensor_link_b = $sensor_link . $sensor_minigraph . "</a>";
|
||||
|
||||
@@ -17,13 +17,13 @@ if ($ports['total'])
|
||||
$content .= "<div style=\'width: 850px\'>";
|
||||
$graph_array['legend'] = "yes";
|
||||
$graph_array['width'] = "340";
|
||||
$graph_array['from'] = $day;
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $week;
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $month;
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $year;
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= "</div>";
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
$id = $_GET['opta'];
|
||||
$graph_type = $_GET['optb'];
|
||||
if (is_numeric($_GET['optc'])) { $from = $_GET['optc']; } else { $from = $day; }
|
||||
if (is_numeric($_GET['optd'])) { $to = $_GET['optd']; } else { $to = $now; }
|
||||
if (is_numeric($_GET['optc'])) { $from = $_GET['optc']; } else { $from = $config['time']['day']; }
|
||||
if (is_numeric($_GET['optd'])) { $to = $_GET['optd']; } else { $to = $config['time']['now']; }
|
||||
|
||||
preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', mres($graph_type), $graphtype);
|
||||
|
||||
@@ -28,13 +28,15 @@ if (!$auth)
|
||||
if (isset($config['graph_types'][$type][$subtype]['descr'])) { $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; } else { $title .= " :: ".$graph_type; }
|
||||
|
||||
$graph_array['height'] = "60";
|
||||
$graph_array['width'] = "150";
|
||||
$graph_array['width'] = "125";
|
||||
$graph_array['legend'] = "no";
|
||||
$graph_array['to'] = $now;
|
||||
$graph_array['id'] = $id;
|
||||
$graph_array['type'] = $graph_type;
|
||||
$graph_array['from'] = $day;
|
||||
$graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400";
|
||||
|
||||
$graph_array_zoom = $graph_array;
|
||||
$graph_array_zoom['height'] = "150";
|
||||
$graph_array_zoom['width'] = "400";
|
||||
|
||||
print_optionbar_start();
|
||||
echo($title);
|
||||
@@ -44,55 +46,64 @@ if (!$auth)
|
||||
|
||||
echo("<div style='width: 1200px; margin:10px;'>");
|
||||
|
||||
echo("<div style='width: 150px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
$graph_array['from'] = $config['time']['sixhour'];
|
||||
echo("<div style='width: ${width}px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
<span class=device-head>6 Hour</span><br />
|
||||
<a href='".$config['base_url']."/graphs/$id/$graph_type/".$graph_array['from']."/$to/'>");
|
||||
echo(generate_graph_tag($graph_array));
|
||||
echo(" </a>
|
||||
</div>");
|
||||
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
echo("<div style='width: ${width}px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
<span class=device-head>24 Hour</span><br />
|
||||
<a href='".$config['base_url']."/graphs/$id/$graph_type/".$graph_array['from']."/$to/'>");
|
||||
echo(generate_graph_tag($graph_array));
|
||||
echo(" </a>
|
||||
</div>");
|
||||
|
||||
$graph_array['from'] = $twoday;
|
||||
echo("<div style='width: 150px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
$graph_array['from'] = $config['time']['twoday'];
|
||||
echo("<div style='width: ${width}px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
<span class=device-head>48 Hour</span><br />
|
||||
<a href='".$config['base_url']."/graphs/$id/$graph_type/".$graph_array['from']."/$to/'>");
|
||||
echo(generate_graph_tag($graph_array));
|
||||
echo(" </a>
|
||||
</div>");
|
||||
|
||||
$graph_array['from'] = $week;
|
||||
echo("<div style='width: 150px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
echo("<div style='width: ${width}px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
<span class=device-head>Week</span><br />
|
||||
<a href='".$config['base_url']."/graphs/$id/$graph_type/".$graph_array['from']."/$to/'>");
|
||||
echo(generate_graph_tag($graph_array));
|
||||
echo(" </a>
|
||||
</div>");
|
||||
|
||||
$graph_array['from'] = $config['twoweek'];
|
||||
echo("<div style='width: 150px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
$graph_array['from'] = $config['time']['twoweek'];
|
||||
echo("<div style='width: ${width}px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
<span class=device-head>Two Week</span><br />
|
||||
<a href='".$config['base_url']."/graphs/$id/$graph_type/".$graph_array['from']."/$to/'>");
|
||||
echo(generate_graph_tag($graph_array));
|
||||
echo(" </a>
|
||||
</div>");
|
||||
|
||||
$graph_array['from'] = $month;
|
||||
echo("<div style='width: 150px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
echo("<div style='width: ${width}px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
<span class=device-head>Month</span><br />
|
||||
<a href='".$config['base_url']."/graphs/$id/$graph_type/".$graph_array['from']."/$to/'>");
|
||||
echo(generate_graph_tag($graph_array));
|
||||
echo(" </a>
|
||||
</div>");
|
||||
|
||||
$graph_array['from'] = $config['twomonth'];
|
||||
echo("<div style='width: 150px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
$graph_array['from'] = $config['time']['twomonth'];
|
||||
echo("<div style='width: ${width}px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
<span class=device-head>Two Month</span><br />
|
||||
<a href='".$config['base_url']."/graphs/$id/$graph_type/".$graph_array['from']."/$to/'>");
|
||||
echo(generate_graph_tag($graph_array));
|
||||
echo(" </a>
|
||||
</div>");
|
||||
|
||||
$graph_array['from'] = $year;
|
||||
echo("<div style='width: 150px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
echo("<div style='width: ${width}px; margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5; float: left;'>
|
||||
<span class=device-head>Year</span><br />
|
||||
<a href='".$config['base_url']."/graphs/$id/$graph_type/".$graph_array['from']."/$to/'>");
|
||||
echo(generate_graph_tag($graph_array));
|
||||
|
||||
@@ -52,15 +52,22 @@ foreach (dbFetchRows("SELECT * FROM `storage` AS S, `devices` AS D WHERE S.devic
|
||||
$free = formatStorage($drive['storage_free']);
|
||||
$used = formatStorage($drive['storage_used']);
|
||||
|
||||
$store_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=125";
|
||||
$store_popup = "onmouseover=\"return overlib('<img src=\'$store_url\'>', LEFT);\" onmouseout=\"return nd();\"";
|
||||
|
||||
$mini_graph = $config['base_url'] . "/graph.php?id=".$drive['storage_id']."&type=".$graph_type."&from=".$day."&to=".$now."&width=80&height=20&bg=f4f4f4";
|
||||
$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/" . $graph_array['id'] . "/" . $graph_array['type'] . "/" . $graph_array['from'] . "/" . $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);
|
||||
|
||||
echo("<tr bgcolor='$row_colour'><td>" . generate_device_link($drive) . "</td><td class=tablehead>" . $drive['storage_descr'] . "</td>
|
||||
<td><img src='$mini_graph'></td>
|
||||
<td>$mini_graph</td>
|
||||
<td>
|
||||
<a href='#' $store_popup>".print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free, "ffffff", $background['right'])."</a>
|
||||
</td><td>$perc"."%</td></tr>");
|
||||
@@ -70,26 +77,14 @@ foreach (dbFetchRows("SELECT * FROM `storage` AS S, `devices` AS D WHERE S.devic
|
||||
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=5>");
|
||||
|
||||
$daily_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100";
|
||||
$daily_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150";
|
||||
$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;
|
||||
|
||||
$weekly_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100";
|
||||
$weekly_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150";
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
|
||||
$monthly_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100";
|
||||
$monthly_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150";
|
||||
|
||||
$yearly_graph = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100";
|
||||
$yearly_url = "graph.php?id=" . $drive['storage_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150";
|
||||
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$daily_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$weekly_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$monthly_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$yearly_graph' border=0></a>");
|
||||
echo("</td></tr>");
|
||||
|
||||
} # endif graphs
|
||||
|
||||
@@ -72,7 +72,7 @@ function dbInsert($data, $table) {
|
||||
return $id;
|
||||
} else {
|
||||
if($table != 'Contact') {
|
||||
trigger_error('QDB - Insert failed.', E_WARNING);
|
||||
trigger_error('QDB - Insert failed.', E_USER_WARNING);
|
||||
}
|
||||
dbRollbackTransaction();
|
||||
return false;
|
||||
@@ -113,7 +113,7 @@ function dbUpdate($data, $table, $where = null, $parameters = array()) {
|
||||
return mysql_affected_rows();
|
||||
} else {
|
||||
#echo("$fullSql");
|
||||
trigger_error('QDB - Update failed.', E_WARNING);
|
||||
trigger_error('QDB - Update failed.', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,21 +7,23 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
|
||||
|
||||
if ($debug) { echo("Discover sensor: $oid, $index, $type, $descr, $precision\n"); }
|
||||
|
||||
if (mysql_result(mysql_query("SELECT count(sensor_id) FROM `sensors` WHERE poller_type='" . mres($poller_type) . "' AND sensor_class='" . mres($class) . "' AND device_id = '".$device['device_id']."' AND sensor_type = '$type' AND `sensor_index` = '$index'"),0) == '0')
|
||||
if (dbFetchCell("SELECT COUNT(sensor_id) FROM `sensors` WHERE `poller_type`= ? AND `sensor_class` = ? AND `device_id` = ? AND sensor_type = ? AND `sensor_index` = ?", array($poller_type, $class, $device['device_id'], $type, $index)) == '0')
|
||||
{
|
||||
if (!$high_limit) { $high_limit = sensor_limit($class, $current); }
|
||||
if (!$low_limit) { $low_limit = sensor_low_limit($class, $current); }
|
||||
|
||||
$query = "INSERT INTO sensors (`poller_type`,`sensor_class`, `device_id`, `sensor_oid`, `sensor_index`, `sensor_type`, `sensor_descr`, `sensor_divisor`, `sensor_multiplier`, `sensor_limit`, `sensor_limit_warn`, `sensor_limit_low`, `sensor_limit_low_warn`, `sensor_current`) ";
|
||||
$query .= " VALUES ('" . mres($poller_type) . "','" . mres($class) . "', '".$device['device_id']."', '$oid', '$index', '$type', '$descr', '$divisor', '$multiplier', '$high_limit', '$warn_limit', '$low_limit', '$low_warn_limit', '$current')";
|
||||
mysql_query($query);
|
||||
if ($debug) { echo("$query\n". mysql_affected_rows() . " inserted\n"); }
|
||||
$insert = array('poller_type' => $poller_type, 'sensor_class' => $class, 'device_id' => $device['device_id'], 'sensor_oid' => $oid, 'sensor_index' => $index, 'sensor_type' => $type, 'sensor_descr' => $descr,
|
||||
'sensor_divisor' => $divisor, 'sensor_multiplier' => $multiplier, 'sensor_limit' => $high_limit, 'sensor_limit_warn' => $warn_limit, 'sensor_limit_low' => $low_limit, 'sensor_limit_low_warn' => $low_warn_limit, 'current' => $current);
|
||||
|
||||
$inserted = dbInsert($insert, 'sensors');
|
||||
|
||||
if ($debug) { echo("( $inserted inserted )\n"); }
|
||||
echo("+");
|
||||
log_event("Sensor Added: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr), $device, 'sensor', mysql_insert_id());
|
||||
}
|
||||
else
|
||||
{
|
||||
$sensor_entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `sensors` WHERE sensor_class='" . mres($class) . "' AND device_id = '".$device['device_id']."' AND sensor_type = '$type' AND `sensor_index` = '$index'"));
|
||||
$sensor_entry = dbFetchRow("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? AND `sensor_type` = ? AND `sensor_index` = ?", array($class, $device['device_id'], $type, $index));
|
||||
|
||||
if (!$high_limit)
|
||||
{
|
||||
@@ -35,9 +37,10 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
|
||||
|
||||
if ($high_limit != $sensor_entry['sensor_limit'])
|
||||
{
|
||||
$query = "UPDATE sensors SET `sensor_limit` = " . ($high_limit == NULL ? 'NULL' : "'".$high_limit."'") . " WHERE `sensor_id` = '".$sensor_entry['sensor_id']."'";
|
||||
mysql_query($query);
|
||||
if ($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); }
|
||||
|
||||
$update = array('sensor_limit' => ($high_limit == NULL ? NULL : $high_limit));
|
||||
$updated = dbUpdate($update, '`sensor_id` = ?', array($sensor_entry['sensor_id']));
|
||||
if ($debug) { echo("( $updated updated )\n"); }
|
||||
echo("H");
|
||||
log_event("Sensor High Limit Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr)." (".$high_limit.")", $device, 'sensor', $sensor_id);
|
||||
}
|
||||
@@ -54,9 +57,9 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
|
||||
|
||||
if ($sensor_entry['sensor_limit_low'] != $low_limit)
|
||||
{
|
||||
$query = "UPDATE sensors SET `sensor_limit_low` = " . ($low_limit == NULL ? 'NULL' : "'".$low_limit."'") . " WHERE `sensor_id` = '".$sensor_entry['sensor_id']."'";
|
||||
mysql_query($query);
|
||||
if ($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); }
|
||||
$update = array('sensor_limit_low' => ($low_limit == NULL ? NULL : $low_limit));
|
||||
$updated = dbUpdate($update, '`sensor_id` = ?', array($sensor_entry['sensor_id']));
|
||||
if ($debug) { echo("( $updated updated )\n"); }
|
||||
echo("L");
|
||||
log_event("Sensor Low Limit Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr)." (".$low_limit.")", $device, 'sensor', $sensor_id);
|
||||
}
|
||||
@@ -67,11 +70,12 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = "UPDATE sensors SET `sensor_descr` = '$descr', `sensor_oid` = '$oid', `sensor_multiplier` = '$multiplier', `sensor_divisor` = '$divisor' WHERE `sensor_class` = '" . mres($class) . "' AND `device_id` = '" . $device['device_id'] . "' AND sensor_type = '$type' AND `sensor_index` = '$index'";
|
||||
mysql_query($query);
|
||||
echo("U");
|
||||
|
||||
$update = array('sensor_oid' => $oid, 'sensor_descr' => $descr, 'sensor_multiplier' => $multiplier, 'sensor_divisor' => $divisor);
|
||||
$updated = dbUpdate($update, '`sensor_id` = ?', array($sensor_entry['sensor_id']));
|
||||
echo("U");
|
||||
log_event("Sensor Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr), $device, 'sensor', $sensor_id);
|
||||
if ($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); }
|
||||
if ($debug) { echo("( $updated updated )\n"); }
|
||||
}
|
||||
}
|
||||
$valid[$class][$type][$index] = 1;
|
||||
@@ -142,19 +146,20 @@ function sensor_limit($class, $current)
|
||||
|
||||
function check_valid_sensors($device, $class, $valid)
|
||||
{
|
||||
$sql = "SELECT * FROM sensors AS S, devices AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = '".$device['device_id']."'";
|
||||
if ($query = mysql_query($sql))
|
||||
$entries = dbFetchRows("SELECT * FROM sensors AS S, devices AS D WHERE S.sensor_class=? AND S.device_id = D.device_id AND D.device_id = ?", array($class, $device['device_id']));
|
||||
|
||||
if (count($entries))
|
||||
{
|
||||
while ($test = mysql_fetch_assoc($query))
|
||||
foreach ($entries as $entry)
|
||||
{
|
||||
$index = $test['sensor_index'];
|
||||
$type = $test['sensor_type'];
|
||||
$index = $entry['sensor_index'];
|
||||
$type = $entry['sensor_type'];
|
||||
if ($debug) { echo($index . " -> " . $type . "\n"); }
|
||||
if (!$valid[$class][$type][$index])
|
||||
{
|
||||
echo("-");
|
||||
mysql_query("DELETE FROM `sensors` WHERE sensor_class='".$class."' AND sensor_id = '" . $test['sensor_id'] . "'");
|
||||
log_event("Sensor Deleted: ".$test['sensor_class']." ".$test['sensor_type']." ". $test['sensor_index']." ".$test['sensor_descr'], $device, 'sensor', $sensor_id);
|
||||
dbDelete('sensors', "`sensor_id` = ?", array($entry['sensor_id']));
|
||||
log_event("Sensor Deleted: ".$entry['sensor_class']." ".$entry['sensor_type']." ". $entry['sensor_index']." ".$entry['sensor_descr'], $device, 'sensor', $sensor_id);
|
||||
}
|
||||
unset($oid); unset($type);
|
||||
}
|
||||
@@ -165,11 +170,10 @@ function discover_juniAtmVp(&$valid, $interface_id, $vp_id, $vp_descr)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `juniAtmVp` WHERE `interface_id` = '".$interface_id."' AND `vp_id` = '".$vp_id."'"),0) == "0")
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM `juniAtmVp` WHERE `interface_id` = ? AND `vp_id` = ?", array($interface_id, $vp_id)) == "0")
|
||||
{
|
||||
$sql = "INSERT INTO `juniAtmVp` (`interface_id`,`vp_id`,`vp_descr`) VALUES ('".$interface_id."','".$vp_id."','".$vp_descr."')";
|
||||
mysql_query($sql); echo("+");
|
||||
if ($debug) { echo($sql . " - " . mysql_affected_rows() . "inserted "); }
|
||||
$inserted = dbInsert(array('interface_id' => $interface_id,'vp_id' => $vp_id,'vp_descr' => $vp_descr), 'juniAtmVp');
|
||||
if ($debug) { echo("( $inserted inserted )\n"); }
|
||||
#FIXME vv no $device!
|
||||
log_event("Juniper ATM VP Added: port ".mres($interface_id)." vp ".mres($vp_id)." descr". mres($vp_descr), 'juniAtmVp', mysql_insert_id());
|
||||
}
|
||||
@@ -184,27 +188,26 @@ function discover_link($local_interface_id, $protocol, $remote_interface_id, $re
|
||||
{
|
||||
global $config, $debug, $link_exists;
|
||||
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `links` WHERE `remote_hostname` = '$remote_hostname' AND `local_interface_id` = '$local_interface_id'
|
||||
AND `protocol` = '$protocol' AND `remote_port` = '$remote_port'"),0) == "0")
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM `links` WHERE `remote_hostname` = ? AND `local_interface_id` = ? AND `protocol` = ? AND `remote_port` = ?",
|
||||
array($remote_hostname, $local_interface_id, $protocol, $remote_port)) == "0")
|
||||
{
|
||||
$sql = "INSERT INTO `links` (`local_interface_id`,`protocol`,`remote_interface_id`,`remote_hostname`,`remote_port`,`remote_platform`,`remote_version`)
|
||||
VALUES ('$local_interface_id','$protocol','$remote_interface_id','$remote_hostname','$remote_port','$remote_platform','$remote_version')";
|
||||
mysql_query($sql);
|
||||
echo("+"); if ($debug) { echo("$sql"); }
|
||||
|
||||
$inserted = dbInsert(array('local_interface_id' => $local_interface_id,'protocol' => $protocol,'remote_interface_id' => $remote_interface_id,'remote_hostname' => $remote_hostname,
|
||||
'remote_port' => $remote_port,'remote_platform' => $remote_platform,'remote_version' => $remote_version), 'links');
|
||||
|
||||
echo("+"); if ($debug) { echo("( $inserted inserted )"); }
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = mysql_fetch_assoc(mysql_query("SELECT * FROM `links` WHERE `remote_hostname` = '$remote_hostname' AND `local_interface_id` = '$local_interface_id'
|
||||
AND `protocol` = '$protocol' AND `remote_port` = '$remote_port'"));
|
||||
$data = dbFetchRow("SELECT * FROM `links` WHERE `remote_hostname` = ? AND `local_interface_id` = ? AND `protocol` = ? AND `remote_port` = ?", array($remote_hostname, $local_interface_id, $protocol, $remote_port));
|
||||
if ($data['remote_interface_id'] == $remote_interface_id && $data['remote_platform'] == $remote_platform && $remote_version == $remote_version)
|
||||
{
|
||||
echo(".");
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "UPDATE `links` SET `remote_interface_id` = $remote_interface_id, `remote_platform` = '$remote_platform', `remote_version` = '$remote_version' WHERE `id` = '".$data['id']."'";
|
||||
mysql_query($sql);
|
||||
echo("U"); if ($debug) {echo("$sql"); }
|
||||
$updated = dbUpdate(array('remote_interface_id' => $remote_interface_id, 'remote_platform' => $remote_platform, 'remote_version' => $remote_version), 'links', '`id` = ?', array($data['id']));
|
||||
echo("U"); if ($debug) { echo("( $updated updated )"); }
|
||||
}
|
||||
}
|
||||
$link_exists[$local_interface_id][$remote_hostname][$remote_port] = 1;
|
||||
@@ -217,21 +220,18 @@ function discover_storage(&$valid, $device, $index, $type, $mib, $descr, $size,
|
||||
if ($debug) { echo("$device, $index, $type, $mib, $descr, $units, $used, $size\n"); }
|
||||
if ($descr && $size > "0")
|
||||
{
|
||||
if (mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE `storage_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `storage_mib` = '$mib'"),0) == '0')
|
||||
$storage = dbFetchRow("SELECT * FROM `storage` WHERE `storage_index` = ? AND `device_id` = ? AND `storage_mib` = ?", array($index, $device['device_id'], $mib));
|
||||
if (!count($storage))
|
||||
{
|
||||
$query = "INSERT INTO storage (`device_id`, `storage_descr`, `storage_index`, `storage_mib`, `storage_type`, `storage_units`,`storage_size`,`storage_used`)
|
||||
values ('".$device['device_id']."', '$descr', '$index', '$mib','$type', '$units', '$size', '$used')";
|
||||
mysql_query($query);
|
||||
if ($debug) { print $query . "\n"; mysql_error(); }
|
||||
$insert = dbInsert(array('device_id' => $device['device_id'], 'storage_descr' => $descr, 'storage_index' => $index, 'storage_mib' => $mib, 'storage_type' => $type,
|
||||
'storage_units' => $units, 'storage_size' => $size, 'storage_used' => $used), 'storage');
|
||||
if ($debug) { mysql_error(); }
|
||||
echo("+");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo(".");
|
||||
$query = "UPDATE `storage` SET `storage_descr` = '".$descr."', `storage_type` = '".$type."', `storage_units` = '".$units."', `storage_size` = '".$size."'
|
||||
WHERE `device_id` = '".$device['device_id']."' AND `storage_index` = '".$index."' AND `storage_mib` = '".$mib."'";
|
||||
mysql_query($query);
|
||||
if ($debug) { print $query . "\n"; }
|
||||
$updated = dbUpdate(array('storage_descr' => $descr, 'storage_type' => $type, 'storage_units' => $units, 'storage_size' => $size), 'storage', '`device_id` = ? AND `storage_index` = ? AND `storage_mib` = ?', array($device['device_id'], $index, $mib));
|
||||
if($updated) { echo("U"); } else { echo("."); }
|
||||
}
|
||||
$valid[$mib][$index] = 1;
|
||||
}
|
||||
|
||||
@@ -938,6 +938,8 @@ $observium_db = mysql_select_db($config['db_name'], $observium_link);
|
||||
|
||||
# Set some times needed by loads of scripts (it's dynamic, so we do it here!)
|
||||
|
||||
## Please remove these where found replacing with $config['time']
|
||||
|
||||
$now = time();
|
||||
$day = time() - (24 * 60 * 60);
|
||||
$twoday = time() - (2 * 24 * 60 * 60);
|
||||
@@ -945,16 +947,20 @@ $week = time() - (7 * 24 * 60 * 60);
|
||||
$month = time() - (31 * 24 * 60 * 60);
|
||||
$year = time() - (365 * 24 * 60 * 60);
|
||||
|
||||
$config['now'] = time();
|
||||
$config['day'] = time() - (24 * 60 * 60);
|
||||
$config['twoday'] = time() - (2 * 24 * 60 * 60);
|
||||
$config['week'] = time() - (7 * 24 * 60 * 60);
|
||||
$config['twoweek'] = time() - (2 * 7 * 24 * 60 * 60);
|
||||
$config['month'] = time() - (31 * 24 * 60 * 60);
|
||||
$config['twomonth'] = time() - (2 * 31 * 24 * 60 * 60);
|
||||
$config['threemonth'] = time() - (3 * 31 * 24 * 60 * 60);
|
||||
$config['sixmonth'] = time() - (6 * 31 * 24 * 60 * 60);
|
||||
$config['year'] = time() - (365 * 24 * 60 * 60);
|
||||
|
||||
$config['time']['now'] = time();
|
||||
$config['time']['fourhour'] = time() - (4 * 60 * 60);
|
||||
$config['time']['sixhour'] = time() - (6 * 60 * 60);
|
||||
$config['time']['twelvehour'] = time() - (12 * 60 * 60);
|
||||
$config['time']['day'] = time() - (24 * 60 * 60);
|
||||
$config['time']['twoday'] = time() - (2 * 24 * 60 * 60);
|
||||
$config['time']['week'] = time() - (7 * 24 * 60 * 60);
|
||||
$config['time']['twoweek'] = time() - (2 * 7 * 24 * 60 * 60);
|
||||
$config['time']['month'] = time() - (31 * 24 * 60 * 60);
|
||||
$config['time']['twomonth'] = time() - (2 * 31 * 24 * 60 * 60);
|
||||
$config['time']['threemonth'] = time() - (3 * 31 * 24 * 60 * 60);
|
||||
$config['time']['sixmonth'] = time() - (6 * 31 * 24 * 60 * 60);
|
||||
$config['time']['year'] = time() - (365 * 24 * 60 * 60);
|
||||
|
||||
# IPMI sensor type mappings
|
||||
$config['ipmi_unit']['Volts'] = 'voltage';
|
||||
|
||||
Reference in New Issue
Block a user