mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
more db* (and add on-the-fly discovery of ports and removal of OSPF areas)
git-svn-id: http://www.observium.org/svn/observer/trunk@2338 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
|
||||
$sql = "SELECT * FROM `applications` WHERE `device_id` = '".$device['device_id']."'";
|
||||
if ($debug) { echo($sql."\n"); }
|
||||
$app_data = mysql_query($sql);
|
||||
|
||||
if (mysql_affected_rows())
|
||||
$app_rows = dbFetchRows("SELECT * FROM `applications` WHERE `device_id` = ?", array($device['device_id']));
|
||||
|
||||
if (count($app_rows))
|
||||
{
|
||||
echo('Applications: ');
|
||||
while ($app = mysql_fetch_assoc($app_data))
|
||||
foreach ($app_rows as $app)
|
||||
{
|
||||
$app_include = $config['install_dir'].'/includes/polling/applications/'.$app['app_type'].'.inc.php';
|
||||
if (is_file($app_include))
|
||||
@@ -22,4 +23,4 @@ if (mysql_affected_rows())
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
## We should walk, so we can discover here too.
|
||||
|
||||
echo("Polling BGP peers\n");
|
||||
|
||||
if (!$config['enable_bgp'])
|
||||
@@ -8,8 +10,7 @@ if (!$config['enable_bgp'])
|
||||
}
|
||||
else
|
||||
{
|
||||
$peers = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '" . $device['device_id'] . "'");
|
||||
while ($peer = mysql_fetch_assoc($peers))
|
||||
foreach (dbFetchRows("SELECT * FROM bgpPeers WHERE device_id = ?", array($device['device_id'])) as $peer)
|
||||
{
|
||||
### Poll BGP Peer
|
||||
|
||||
@@ -124,16 +125,20 @@ else
|
||||
|
||||
rrdtool_update("$peerrrd", "N:$bgpPeerOutUpdates:$bgpPeerInUpdates:$bgpPeerOutTotalMessages:$bgpPeerInTotalMesages:$bgpPeerFsmEstablishedTime");
|
||||
|
||||
$update = "UPDATE bgpPeers SET bgpPeerState = '$bgpPeerState', bgpPeerAdminStatus = '$bgpPeerAdminStatus', ";
|
||||
$update .= "bgpPeerFsmEstablishedTime = '$bgpPeerFsmEstablishedTime', bgpPeerInUpdates = '$bgpPeerInUpdates' , bgpLocalAddr = '$bgpLocalAddr' , bgpPeerOutUpdates = '$bgpPeerOutUpdates'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'";
|
||||
mysql_query($update);
|
||||
$peer['update']['bgpPeerState'] = $bgpPeerState;
|
||||
$peer['update']['bgpPeerAdminStatus'] = $bgpPeerAdminStatus;
|
||||
$peer['update']['bgpPeerFsmEstablishedTime'] = $bgpPeerFsmEstablishedTime;
|
||||
$peer['update']['bgpPeerInUpdates'] = $bgpPeerInUpdates;
|
||||
$peer['update']['bgpLocalAddr'] = $bgpLocalAddr;
|
||||
$peer['update']['bgpPeerOutUpdates'] = $bgpPeerOutUpdates;
|
||||
|
||||
dbUpdate($peer['update'], 'bgpPeers', '`device_id` = ? AND `bgpPeerIdentifier` = ?', array($device['device_id'], $peer['bgpPeerIdentifier']));
|
||||
|
||||
if ($device['os_group'] == "ios" || $device['os'] == "junos")
|
||||
{
|
||||
## Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB)
|
||||
$afi_query = mysql_query("SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'");
|
||||
while ($peer_afi = mysql_fetch_assoc($afi_query))
|
||||
$peer_afis = dbFetchRows("SELECT * FROM bgpPeers_cbgp WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($device['device_id'], $peer['bgpPeerIdentifier']));
|
||||
foreach ($peer_afis as $peer_afi)
|
||||
{
|
||||
$afi = $peer_afi['afi'];
|
||||
$safi = $peer_afi['safi'];
|
||||
@@ -202,17 +207,16 @@ else
|
||||
|
||||
# FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE!
|
||||
$update = "UPDATE bgpPeers_cbgp SET";
|
||||
$update .= " `cbgpPeerAcceptedPrefixes` = '$cbgpPeerAcceptedPrefixes'";
|
||||
$update .= ", `cbgpPeerDeniedPrefixes` = '$cbgpPeerDeniedPrefixes'";
|
||||
$update .= ", `cbgpPeerPrefixAdminLimit` = '$cbgpPeerAdminLimit'";
|
||||
$update .= ", `cbgpPeerPrefixThreshold` = '$cbgpPeerPrefixThreshold'";
|
||||
$update .= ", `cbgpPeerPrefixClearThreshold` = '$cbgpPeerPrefixClearThreshold'";
|
||||
$update .= ", `cbgpPeerAdvertisedPrefixes` = '$cbgpPeerAdvertisedPrefixes'";
|
||||
$update .= ", `cbgpPeerSuppressedPrefixes` = '$cbgpPeerSuppressedPrefixes'";
|
||||
$update .= ", `cbgpPeerWithdrawnPrefixes` = '$cbgpPeerWithdrawnPrefixes'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "' AND afi = '$afi' AND safi = '$safi'";
|
||||
if ($debug) { echo("MYSQL: $update\n"); }
|
||||
mysql_query($update);
|
||||
$peer['c_update']['AcceptedPrefixes'] = $cbgpPeerAcceptedPrefixes;
|
||||
$peer['c_update']['DeniedPrefixes'] = $cbgpPeerDeniedPrefixes;
|
||||
$peer['c_update']['PrefixAdminLimit'] = $cbgpPeerAdminLimit;
|
||||
$peer['c_update']['PrefixThreshold'] = $cbgpPeerPrefixThreshold;
|
||||
$peer['c_update']['PrefixClearThreshold'] = $cbgpPeerPrefixClearThreshold;
|
||||
$peer['c_update']['AdvertisedPrefixes'] = $cbgpPeerAdvertisedPrefixes;
|
||||
$peer['c_update']['SuppressedPrefixes'] = $cbgpPeerSuppressedPrefixes;
|
||||
$peer['c_update']['WithdrawnPrefixes'] = $cbgpPeerWithdrawnPrefixes;
|
||||
|
||||
dbUpdate($peer['c_update'], 'bgpPeers_cbgp', '`device_id` = ? AND bgpPeerIdentifier = ? AND afi = ? AND safi = ?', array($device['device_id'], $peer['bgpPeerIdentifier'], $afi, $safi));
|
||||
|
||||
$cbgp_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cbgp-" . $peer['bgpPeerIdentifier'] . ".$afi.$safi.rrd");
|
||||
if (!is_file($cbgp_rrd))
|
||||
@@ -240,4 +244,4 @@ else
|
||||
} ## End While loop on peers
|
||||
} ## End check for BGP support
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -21,7 +21,7 @@ if (is_array($cefs))
|
||||
echo(" entPhysicalModelName");
|
||||
$entity_array = snmpwalk_cache_multi_oid($device, "entPhysicalModelName", $entity_array, "ENTITY-MIB");
|
||||
}
|
||||
foreach ($cefs as $entity => $afis)
|
||||
foreach ($cefs as $entity => $afis)
|
||||
{
|
||||
$entity_name = $entity_array[$entity]['entPhysicalName'] ." - ".$entity_array[$entity]['entPhysicalModelName'];
|
||||
echo("\n$entity $entity_name\n");
|
||||
@@ -33,20 +33,13 @@ if (is_array($cefs))
|
||||
echo(" | |-".$path.": ".$cef_stat['cefSwitchingPath']);
|
||||
|
||||
|
||||
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = '".$device['device_id']."' AND `entPhysicalIndex` = '".$entity."'
|
||||
AND `afi` = '".$afi."' AND `cef_index` = '".$path."'"),0) != "1")
|
||||
if(dbFetchCell("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?", array($device['device_id'], $entity, $afi, $path)) != "1")
|
||||
{
|
||||
$sql = "INSERT INTO `cef_switching` (`device_id`, `entPhysicalIndex`, `afi`, `cef_index`, `cef_path`)
|
||||
VALUES ('".$device['device_id']."', '".$entity."', '".$afi."', '".$path."', '".$cef_stat['cefSwitchingPath']."')";
|
||||
mysql_query($sql);
|
||||
dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $entity, 'afi' => $afi, 'cef_index' => $path, 'cef_path' => $cef_stat['cefSwitchingPath']), 'cef_switching');
|
||||
echo("+");
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM `cef_switching` WHERE `device_id` = '".$device['device_id']."' AND `entPhysicalIndex` = '".$entity."'
|
||||
AND `afi` = '".$afi."' AND `cef_index` = '".$path."'";
|
||||
|
||||
$query = mysql_query($sql);
|
||||
$cef_entry = mysql_fetch_assoc($query);
|
||||
$cef_entry = dbFetchRow("SELECT * FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex = ? AND `afi` = ? AND `cef_index` = ?", array($device['device_id'], $entity, $afi, $path));
|
||||
|
||||
$filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cefswitching-".$entity."-".$afi."-".$path.".rrd");
|
||||
|
||||
@@ -67,22 +60,17 @@ if (is_array($cefs))
|
||||
if (is_numeric($cef_stat['cefSwitchingHCPunt'])) { $cef_stat['cefSwitchingPunt'] = $cef_stat['cefSwitchingHCPunt']; }
|
||||
if (is_numeric($cef_stat['cefSwitchingHCPunt2Host'])) { $cef_stat['cefSwitchingPunt2Host'] = $cef_stat['cefSwitchingHCPunt2Host']; }
|
||||
|
||||
$update = " `drop` = '".$cef_stat['cefSwitchingDrop']."'";
|
||||
$update .= ", `punt` = '".$cef_stat['cefSwitchingPunt']."'";
|
||||
$update .= ", `punt2host` = '".$cef_stat['cefSwitchingPunt2Host']."'";
|
||||
$cef_stat['update']['drop'] = $cef_stat['cefSwitchingDrop'];
|
||||
$cef_stat['update']['punt'] = $cef_stat['cefSwitchingPunt'];
|
||||
$cef_stat['update']['punt2host'] = $cef_stat['cefSwitchingPunt2Host'];
|
||||
$cef_stat['update']['drop_prev'] = $cef_entry['drop'];
|
||||
$cef_stat['update']['punt_prev'] = $cef_entry['punt'];
|
||||
$cef_stat['update']['punt2host_prev'] = $cef_entry['punt2host'];
|
||||
$cef_stat['update']['updated'] = $polled;
|
||||
$cef_stat['update']['updated_prev'] = $cef_entry['updated'];
|
||||
|
||||
$update .= ", `drop_prev` = '".$cef_entry['drop']."'";
|
||||
$update .= ", `punt_prev` = '".$cef_entry['punt']."'";
|
||||
$update .= ", `punt2host_prev` = '".$cef_entry['punt2host']."'";
|
||||
dbUpdate($cef_stat['update'], 'cef_switching', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $path));
|
||||
|
||||
$update .= ", `updated` = '".$polled."'";
|
||||
$update .= ", `updated_prev` = '".$cef_entry['updated']."'";
|
||||
|
||||
$update_query = "UPDATE `cef_switching` SET ".$update." WHERE `device_id` = '".$device['device_id']."' AND `entPhysicalIndex` = '".$entity."'
|
||||
AND `afi` = '".$afi."' AND `cef_index` = '".$path."'";
|
||||
@mysql_query($update_query);
|
||||
if ($debug) {echo("\nMYSQL : [ $update_query ]"); }
|
||||
|
||||
$rrd_update = "N:".$cef_stat['cefSwitchingDrop'].":".$cef_stat['cefSwitchingPunt'].":".$cef_stat['cefSwitchingPunt2Host'];
|
||||
$ret = rrdtool_update("$filename", $rrd_update);
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
<?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");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
## FIXME -- we're walking, so we can discover here too.
|
||||
|
||||
$cip_oids = array('cipMacHCSwitchedBytes', 'cipMacHCSwitchedPkts');
|
||||
echo("Caching OID: ");
|
||||
$cip_array = array();
|
||||
@@ -14,9 +16,9 @@ $polled = time();
|
||||
|
||||
$mac_entries = 0;
|
||||
|
||||
$mac_accounting_query = mysql_query("SELECT *, A.poll_time AS poll_time FROM `mac_accounting` as A, `ports` AS I where A.interface_id = I.interface_id AND I.device_id = '".$device['device_id']."'");
|
||||
$acc_rows = dbFetchRows("SELECT *, A.poll_time AS poll_time FROM `mac_accounting` as A, `ports` AS I where A.interface_id = I.interface_id AND I.device_id = ?", array($device['device_id']));
|
||||
|
||||
while ($acc = mysql_fetch_assoc($mac_accounting_query))
|
||||
foreach ($acc_rows as $acc)
|
||||
{
|
||||
$device_id = $acc['device_id'];
|
||||
$ifIndex = $acc['ifIndex'];
|
||||
@@ -26,9 +28,9 @@ while ($acc = mysql_fetch_assoc($mac_accounting_query))
|
||||
|
||||
if ($cip_array[$ifIndex][$mac])
|
||||
{
|
||||
$update .= "`poll_time` = '".$polled."'";
|
||||
$update .= ", `poll_prev` = '".$acc['poll_time']."'";
|
||||
$update .= ", `poll_period` = '".$polled_period."'";
|
||||
$acc['update']['poll_time'] = $polled;
|
||||
$acc['update']['poll_prev'] = $acc['poll_time'];
|
||||
$acc['update']['poll_period'] = $polled_period;
|
||||
|
||||
$mac_entries++;
|
||||
|
||||
@@ -45,15 +47,15 @@ while ($acc = mysql_fetch_assoc($mac_accounting_query))
|
||||
foreach (array('input','output') as $dir)
|
||||
{
|
||||
$oid_dir = $oid . "_" . $dir;
|
||||
$update .= ", `".$oid_dir."` = '".$this_ma[$oid][$dir]."'";
|
||||
$update .= ", `".$oid_dir."_prev` = '".$acc[$oid_dir]."'";
|
||||
$acc['update'][$oid_dir] = $this_ma[$oid][$dir];
|
||||
$acc['update'][$oid_dir.'_prev'] = $acc[$oid_dir];
|
||||
$oid_prev = $oid_dir . "_prev";
|
||||
if ($this_ma[$oid][$dir])
|
||||
{
|
||||
$oid_diff = $this_ma[$oid][$dir] - $acc[$oid_dir];
|
||||
$oid_rate = $oid_diff / $polled_period;
|
||||
$update .= ", `".$oid_dir."_rate` = '".$oid_rate."'";
|
||||
$update .= ", `".$oid_dir."_delta` = '".$oid_diff."'";
|
||||
$acc['update'][$oid_dir.'_rate'] = $oid_rate;
|
||||
$acc['update'][$oid_dir.'_delta'] = $oid_diff;
|
||||
if ($debug) { echo("\n $oid_dir ($oid_diff B) $oid_rate Bps $polled_period secs\n"); }
|
||||
}
|
||||
}
|
||||
@@ -80,14 +82,10 @@ while ($acc = mysql_fetch_assoc($mac_accounting_query))
|
||||
$woo = "N:".($b_in+0).":".($b_out+0).":".($p_in+0).":".($p_out+0);
|
||||
$ret = rrdtool_update("$rrdfile", $woo);
|
||||
|
||||
if ($update)
|
||||
if ($acc['update'])
|
||||
{ /// Do Updates
|
||||
$update_query = "UPDATE `mac_accounting` SET ".$update." WHERE `ma_id` = '" . $acc['ma_id'] . "'";
|
||||
@mysql_query($update_query);
|
||||
if ($debug) { echo("\nMYSQL : [ $update_query ]"); }
|
||||
dbUpdate($acc['update'], 'mac_accounting', 'WHERE `ma_id` = ?', array($acc['ma_id']));
|
||||
} /// End Updates
|
||||
|
||||
unset($update_query); unset($update);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,4 +95,4 @@ if ($mac_entries) { echo(" $mac_entries MAC accounting entries\n"); }
|
||||
|
||||
echo("\n");
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -4,10 +4,7 @@ function poll_sensor($device, $class, $unit)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$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))
|
||||
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'] . "... ");
|
||||
|
||||
@@ -82,7 +79,7 @@ function poll_sensor($device, $class, $unit)
|
||||
log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . " above threshold: " . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $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'] . "'");
|
||||
dbUpdate(array('sensor_current' => $sensor_value), 'sensors', '`sensor_class` = ? AND `sensor_id` = ?', array($class, $sensor['sensor_id']));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
$query = "SELECT * FROM sensors WHERE device_id = '" . $device['device_id'] . "' AND poller_type='ipmi'";
|
||||
$ipmi_data = mysql_query($query);
|
||||
$ipmi_rows = dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND poller_type='ipmi'", array($device['device_id']));
|
||||
|
||||
if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname'))
|
||||
{
|
||||
@@ -19,7 +18,7 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname'))
|
||||
$ipmi_sensor[$desc][$config['ipmi_unit'][$type]]['unit'] = $type;
|
||||
}
|
||||
|
||||
while ($ipmisensors = mysql_fetch_assoc($ipmi_data))
|
||||
foreach ($ipmi_rows as $ipmisensors)
|
||||
{
|
||||
echo("Updating IPMI sensor " . $ipmisensors['sensor_descr'] . "... ");
|
||||
|
||||
@@ -61,10 +60,11 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname'))
|
||||
|
||||
## FIXME warnings in event & mail not done here yet!
|
||||
|
||||
mysql_query("UPDATE sensors SET sensor_current = '$sensor' WHERE poller_type='ipmi' AND sensor_class= AND sensor_id = '" . $ipmisensors['sensor_id'] . "'");
|
||||
dbUpdate(array('sensor_current' => $sensor), 'sensors', 'poller_type = ? AND sensor_class = ? AND sensor_id = ?', array('ipmi', $ipmisensors['sensor_class'], $ipmisensors['sensor_id']));
|
||||
|
||||
}
|
||||
|
||||
unset($ipmi_sensor);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
$sql = "SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = '".$device['device_id']."' AND J.interface_id = P.interface_id";
|
||||
$vp_data = mysql_query($sql);
|
||||
$vp_rows = dbFetchRows("SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = ? AND J.interface_id = P.interface_id", array($device['device_id']));
|
||||
|
||||
if (mysql_affected_rows())
|
||||
if (count($vp_rows))
|
||||
{
|
||||
$vp_cache = array();
|
||||
$vp_cache = snmpwalk_cache_multi_oid($device, "juniAtmVpStatsInCells", $vp_cache, "Juniper-UNI-ATM-MIB" , $config['install_dir']."/mibs/junose");
|
||||
@@ -17,7 +16,7 @@ if (mysql_affected_rows())
|
||||
|
||||
echo("Checking JunOSe ATM vps: ");
|
||||
|
||||
while ($vp = mysql_fetch_assoc($vp_data))
|
||||
foreach ($vp_rows as $vp)
|
||||
{
|
||||
echo(".");
|
||||
|
||||
@@ -31,7 +30,7 @@ if (mysql_affected_rows())
|
||||
$vp_update .= ":".$t_vp['juniAtmVpStatsInPackets'].":".$t_vp['juniAtmVpStatsOutPackets'];
|
||||
$vp_update .= ":".$t_vp['juniAtmVpStatsInPacketOctets'].":".$t_vp['juniAtmVpStatsOutPacketOctets'];
|
||||
$vp_update .= ":".$t_vp['juniAtmVpStatsInPacketErrors'].":".$t_vp['juniAtmVpStatsOutPacketErrors'];
|
||||
|
||||
|
||||
$rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("vp-" . $vp['ifIndex'] . "-".$vp['vp_id'].".rrd");
|
||||
|
||||
if ($debug) { echo("$rrd "); }
|
||||
@@ -69,4 +68,4 @@ if (mysql_affected_rows())
|
||||
unset($vp_cache);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
$query = "SELECT * FROM mempools WHERE device_id = '" . $device['device_id'] . "'";
|
||||
$mempool_data = mysql_query($query);
|
||||
while ($mempool = mysql_fetch_assoc($mempool_data))
|
||||
foreach (dbFetchRows("SELECT * FROM mempools WHERE device_id = ?", array($device['device_id'])) as $mempool)
|
||||
{
|
||||
echo("Mempool ". $mempool['mempool_descr'] . ": ");
|
||||
|
||||
@@ -48,16 +46,9 @@ while ($mempool = mysql_fetch_assoc($mempool_data))
|
||||
|
||||
rrdtool_update($mempoolrrd,"N:".$mempool['used'].":".$mempool['free']);
|
||||
|
||||
$update_query = "UPDATE `mempools` SET `mempool_used` = '".$mempool['used']."'";
|
||||
$update_query .= ", `mempool_perc` = '".$percent."'";
|
||||
$update_query .= ", `mempool_free` = '".$mempool['free']."'";
|
||||
$update_query .= ", `mempool_total` = '".$mempool['total']."'";
|
||||
$update_query .= ", `mempool_largestfree` = '".$mempool['largestfree']."'";
|
||||
$update_query .= ", `mempool_lowestfree` = '".$mempool['lowestfree']."'";
|
||||
$update_query .= " WHERE `mempool_id` = '".$mempool['mempool_id']."'";
|
||||
|
||||
mysql_query($update_query);
|
||||
if ($debug) { echo($update_query); }
|
||||
dbUpdate(array('mempool_used' => $mempool['used'], 'mempool_perc' => $percent, 'mempool_free' => $mempool['free'],
|
||||
'mempool_total' => $mempool['total'], 'mempool_largestfree' => $mempool['largestfree'], 'mempool_lowestfree' => $mempool['lowestfree']),
|
||||
'mempools', '`mempool_id` = ?', array($mempool['mempool_id']));
|
||||
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ $ospf_oids_db = array('ospfRouterId', 'ospfAdminStat', 'ospfVersionNumber', 'osp
|
||||
'ospfExtLsdbLimit', 'ospfMulticastExtensions', 'ospfExitOverflowInterval', 'ospfDemandExtensions');
|
||||
|
||||
### Build array of existing entries
|
||||
$query = mysql_query("SELECT * FROM `ospf_instances` WHERE `device_id` = '".$device['device_id']."'");
|
||||
while ($entry = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", array($device['device_id'])) as $entry)
|
||||
{
|
||||
$ospf_instances_db[$entry['ospf_instance_id']] = $entry;
|
||||
}
|
||||
@@ -26,12 +25,9 @@ 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]))
|
||||
{
|
||||
$query = "INSERT INTO `ospf_instances` (`device_id`, `ospf_instance_id`) VALUES ('".$device['device_id']."','".$ospf_instance_id."')";
|
||||
if ($debug) { echo($query); }
|
||||
mysql_query($query);
|
||||
if ($debug) { echo(mysql_error()); }
|
||||
dbInsert(array('device_id' => $device['device_id'], 'ospf_instance_id' => $ospf_instance_id), 'ospf_instances');
|
||||
echo("+");
|
||||
$entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `ospf_instances` WHERE `device_id` = '".$device['device_id']."' AND `ospf_instance_id` = '".$ospf_instance_id."'"));
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -55,16 +51,13 @@ if (is_array($ospf_instances_db))
|
||||
{ // Loop the OIDs
|
||||
if ($ospf_instance_db[$oid] != $ospf_instance_poll[$oid])
|
||||
{ // If data has changed, build a query
|
||||
$ospf_instance_update .= ", `$oid` = '".mres($ospf_instance_poll[$oid])."'";
|
||||
$ospf_instance_update[$oid] = $ospf_instance_poll[$oid];
|
||||
#log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['interface_id']); ## FIXME
|
||||
}
|
||||
}
|
||||
if ($ospf_instance_update)
|
||||
{
|
||||
$query = "UPDATE `ospf_instances` SET `ospf_instance_id` = '".$ospf_instance_db['ospf_instance_id']."'".$ospf_instance_update." WHERE `device_id` = '".$device['device_id']."' AND `ospf_instance_id` = '".$ospf_instance_id."'";
|
||||
if ($debug) { echo($query); }
|
||||
mysql_query($query);
|
||||
if ($debug) { echo(mysql_error()); }
|
||||
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 {
|
||||
@@ -85,8 +78,7 @@ echo(" Areas: ");
|
||||
$ospf_area_oids = array('ospfAuthType','ospfImportAsExtern','ospfSpfRuns','ospfAreaBdrRtrCount','ospfAsBdrRtrCount','ospfAreaLsaCount','ospfAreaLsaCksumSum','ospfAreaSummary','ospfAreaStatus');
|
||||
|
||||
### Build array of existing entries
|
||||
$query = mysql_query("SELECT * FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'");
|
||||
while ($entry = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id'])) as $entry)
|
||||
{
|
||||
$ospf_areas_db[$entry['ospfAreaId']] = $entry;
|
||||
}
|
||||
@@ -99,9 +91,9 @@ 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]))
|
||||
{
|
||||
mysql_query("INSERT INTO `ospf_areas` (`device_id`, `ospfAreaId`) VALUES ('".$device['device_id']."','".$ospf_area_id."') ");
|
||||
dbInsert(array('device_id' => $device['device_id'], 'ospfAreaId' => $ospf_area_id), 'ospf_areas');
|
||||
echo("+");
|
||||
$entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."' AND `ospfAreaId` = '".$ospf_area_id."'"));
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -121,28 +113,31 @@ if (is_array($ospf_areas_db))
|
||||
{
|
||||
foreach ($ospf_areas_db as $ospf_area_db)
|
||||
{
|
||||
$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` = '".mres($ospf_area_poll[$oid])."'";
|
||||
#log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['interface_id']); ## FIXME
|
||||
}
|
||||
}
|
||||
if ($ospf_area_update)
|
||||
if (is_array($ospf_ports_poll[$ospf_port_db['ospf_port_id']]))
|
||||
{
|
||||
$sql = "UPDATE `ospf_areas` SET `ospfAreaId` = '".$ospf_area_db['ospfAreaId']."'".$ospf_area_update." WHERE `device_id` = '".$device['device_id']."' AND `ospfAreaId` = '".$ospf_area_id."'";
|
||||
mysql_query($sql);
|
||||
if ($debug) { echo("$sql\n"); }
|
||||
echo("U");
|
||||
unset($ospf_area_update);
|
||||
$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['interface_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++;
|
||||
} else {
|
||||
echo(".");
|
||||
dbDelete('ospf_ports', '`device_id` = ? AND `ospfAreaId` = ?', array($device['device_id'], $ospf_area_db['ospfAreaId']));
|
||||
}
|
||||
unset($ospf_area_poll);
|
||||
unset($ospf_area_db);
|
||||
$ospf_area_count++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,8 +153,7 @@ echo(" Ports: ");
|
||||
$ospf_port_oids = array('ospfIfIpAddress','interface_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
|
||||
$query = mysql_query("SELECT * FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."'");
|
||||
while ($entry = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows("SELECT * FROM `ospf_ports` WHERE `device_id` = ?", array($device['device_id'])) as $entry)
|
||||
{
|
||||
$ospf_ports_db[$entry['ospf_port_id']] = $entry;
|
||||
}
|
||||
@@ -172,10 +166,9 @@ 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]))
|
||||
{
|
||||
mysql_query("INSERT INTO `ospf_ports` (`device_id`, `ospf_port_id`) VALUES ('".$device['device_id']."','".$ospf_port_id."') ");
|
||||
dbInsert(array('device_id' => $device['device_id'], 'ospf_port_id' => $ospf_port_id), 'ospf_ports');
|
||||
echo("+");
|
||||
$entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_id."'"));
|
||||
$ospf_ports_db[$entry['ospf_port_id']] = $entry;
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,24 +192,22 @@ if (is_array($ospf_ports_db))
|
||||
|
||||
if ($ospf_port_poll['ospfAddressLessIf'])
|
||||
{
|
||||
$ospf_port_poll['interface_id'] = @mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$ospf_port_poll['ospfAddressLessIf']."'"),0);
|
||||
$ospf_port_poll['interface_id'] = @dbFetchCell("SELECT `interface_id` FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?", array($device['device_id'], $ospf_port_poll['ospfAddressLessIf']));
|
||||
} else {
|
||||
$ospf_port_poll['interface_id'] = @mysql_result(mysql_query("SELECT A.`interface_id` FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '".$ospf_port_poll['ospfIfIpAddress']."' AND I.interface_id = A.interface_id AND I.device_id = '".$device['device_id']."'"),0);
|
||||
$ospf_port_poll['interface_id'] = @dbFetchCell("SELECT A.`interface_id` FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = ? AND I.interface_id = A.interface_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` = '".mres($ospf_port_poll[$oid])."'";
|
||||
$ospf_port_update[$oid] = $ospf_port_poll[$oid];
|
||||
#log_event("$oid -> ".$this_port[$oid], $device, 'ospf', $port['interface_id']); ## FIXME
|
||||
}
|
||||
}
|
||||
if ($ospf_port_update)
|
||||
{
|
||||
$query = "UPDATE `ospf_ports` SET `ospf_port_id` = '".$ospf_port_db['ospf_port_id']."'".$ospf_port_update." WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_id."'";
|
||||
mysql_query($query);
|
||||
if ($debug) { echo("$query"); }
|
||||
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 {
|
||||
@@ -226,7 +217,8 @@ if (is_array($ospf_ports_db))
|
||||
unset($ospf_port_db);
|
||||
$ospf_port_count++;
|
||||
} else {
|
||||
mysql_query("DELETE FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_db['ospf_port_id']."'");
|
||||
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("-");
|
||||
}
|
||||
}
|
||||
@@ -251,8 +243,7 @@ $ospf_nbr_oids_rrd = array();
|
||||
$ospf_nbr_oids = array_merge($ospf_nbr_oids_db, $ospf_nbr_oids_rrd);
|
||||
|
||||
### Build array of existing entries
|
||||
$nbr_query = mysql_query("SELECT * FROM `ospf_nbrs` WHERE `device_id` = '".$device['device_id']."'");
|
||||
while ($nbr_entry = mysql_fetch_assoc($nbr_query))
|
||||
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;
|
||||
}
|
||||
@@ -265,9 +256,9 @@ 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]))
|
||||
{
|
||||
mysql_query("INSERT INTO `ospf_nbrs` (`device_id`, `ospf_nbr_id`) VALUES ('".$device['device_id']."','".$ospf_nbr_id."') ");
|
||||
dbInsert(array('device_id' => $device['device_id'], 'ospf_nbr_id' => $ospf_nbr_id), 'ospf_nbrs');
|
||||
echo("+");
|
||||
$entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `ospf_nbrs` WHERE `device_id` = '".$device['device_id']."' AND `ospf_nbr_id` = '".$ospf_nbr_id."'"));
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -290,7 +281,7 @@ if (is_array($ospf_nbrs_db))
|
||||
{
|
||||
$ospf_nbr_poll = $ospf_nbrs_poll[$ospf_nbr_db['ospf_nbr_id']];
|
||||
|
||||
$ospf_nbr_poll['interface_id'] = @mysql_result(mysql_query("SELECT A.`interface_id` FROM ipv4_addresses AS A, nbrs AS I WHERE A.ipv4_address = '".$ospf_nbr_poll['ospfNbrIpAddr']."' AND I.interface_id = A.interface_id AND I.device_id = '".$device['device_id']."'"),0);
|
||||
$ospf_nbr_poll['interface_id'] = @dbFetchCell("SELECT A.`interface_id` FROM ipv4_addresses AS A, nbrs AS I WHERE A.ipv4_address = ? AND I.interface_id = A.interface_id AND I.device_id = ?", array($ospf_nbr_poll['ospfNbrIpAddr'], $device['device_id']));
|
||||
|
||||
if ($ospf_nbr_db['interface_id'] != $ospf_nbr_poll['interface_id'])
|
||||
{
|
||||
@@ -302,15 +293,13 @@ if (is_array($ospf_nbrs_db))
|
||||
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` = '".mres($ospf_nbr_poll[$oid])."'";
|
||||
$ospf_nbr_update[$oid] = $ospf_nbr_poll[$oid];
|
||||
#log_event("$oid -> ".$this_nbr[$oid], $device, 'ospf', $nbr['interface_id']); ## FIXME
|
||||
}
|
||||
}
|
||||
if ($ospf_nbr_update)
|
||||
{
|
||||
$query = "UPDATE `ospf_nbrs` SET `interface_id` = '".$ospf_nbr_poll['interface_id']."'".$ospf_nbr_update." WHERE `device_id` = '".$device['device_id']."' AND `ospf_nbr_id` = '".$ospf_nbr_id."'";
|
||||
mysql_query($query);
|
||||
if ($debug) { echo("$query"); }
|
||||
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 {
|
||||
@@ -321,7 +310,7 @@ if (is_array($ospf_nbrs_db))
|
||||
unset($ospf_nbr_db);
|
||||
$ospf_nbr_count++;
|
||||
} else {
|
||||
mysql_query("DELETE FROM `ospf_nbrs` WHERE `device_id` = '".$device['device_id']."' AND `ospf_nbr_id` = '".$ospf_nbr_db['ospf_nbr_id']."'");
|
||||
dbDelete('ospf_nbrs', '`device_id` = ? AND `ospf_nbr_id` = ?', array($device['device_id'], $ospf_nbr_db['ospf_nbr_id']));
|
||||
echo("-");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#$ports = snmp_cache_ifIndex($device); // Cache Port List
|
||||
# /FIXME
|
||||
|
||||
#mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`) VALUES ('".$device['device_id']."','$ifIndex')");
|
||||
|
||||
// Build SNMP Cache Array
|
||||
$data_oids = array('ifName','ifDescr','ifAlias', 'ifAdminStatus', 'ifOperStatus', 'ifMtu', 'ifSpeed', 'ifHighSpeed', 'ifType', 'ifPhysAddress',
|
||||
'ifPromiscuousMode','ifConnectorPresent','ifDuplex');
|
||||
@@ -45,7 +43,7 @@ if ($config['enable_ports_etherlike'])
|
||||
|
||||
if ($config['enable_ports_adsl'])
|
||||
{
|
||||
$device['adsl_count'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifType` = 'adsl'"),0);
|
||||
$device['adsl_count'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `ifType` = 'adsl'", array($device['device_id']));
|
||||
}
|
||||
|
||||
if ($device['adsl_count'] > "0")
|
||||
@@ -111,7 +109,6 @@ foreach ($port_stats as $ifIndex => $port)
|
||||
{
|
||||
$interface_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex), 'ports');
|
||||
$ports[$port['ifIndex']] = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($interface_id));
|
||||
mysql_error();
|
||||
echo("Adding: ".$port['ifName']."(".$ifIndex.")(".$ports[$port['ifIndex']]['interface_id'].")");
|
||||
#print_r($ports);
|
||||
} elseif ($ports[$ifIndex]['deleted'] == "1") {
|
||||
@@ -314,13 +311,13 @@ foreach ($ports as $port)
|
||||
if($device['os'] == "aos") { include("port-alcatel.inc.php"); }
|
||||
|
||||
|
||||
// Update MySQL
|
||||
// Update Database
|
||||
if (count($port['update']))
|
||||
{
|
||||
$updated = dbUpdate($port['update'], 'ports', '`interface_id` = ?', array($port['interface_id']));
|
||||
if($debug) { echo("$updated updated"); }
|
||||
}
|
||||
// End Update MySQL
|
||||
// End Update Database
|
||||
|
||||
// Send alerts for interface flaps.
|
||||
if ($config['warn']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus']) && $port['ignore'] == 0)
|
||||
|
||||
Reference in New Issue
Block a user