From 750799c64d5f3b404b826bebadc7958ae7298e84 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Wed, 28 Oct 2009 13:51:15 +0000 Subject: [PATCH] remove some old files git-svn-id: http://www.observium.org/svn/observer/trunk@493 61d68cd4-352d-0410-923a-c4978735b2b8 --- get-apache.sh | 41 ------ html/graphs | 1 - html/includes/graphs/collectd_cpu.inc.php | 10 -- html/rrd | 1 - includes/polling/ports-etherlike.inc.php | 67 +++++++++ new-mac.php | 112 --------------- new-poller.php | 162 ---------------------- remove-deleted-interfaces.php | 23 --- 8 files changed, 67 insertions(+), 350 deletions(-) delete mode 100755 get-apache.sh delete mode 120000 html/graphs delete mode 100644 html/includes/graphs/collectd_cpu.inc.php delete mode 120000 html/rrd create mode 100755 includes/polling/ports-etherlike.inc.php delete mode 100755 new-mac.php delete mode 100755 new-poller.php delete mode 100755 remove-deleted-interfaces.php diff --git a/get-apache.sh b/get-apache.sh deleted file mode 100755 index c1d1b86a87..0000000000 --- a/get-apache.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/perl - -# depends on availability of status and extended status info from your -# Apache webserver -- your httpd.conf needs to include something like the -# following: (uncommented) -# -# SetHandler server-status -# Order allow,deny -# Allow from localhost -# -#ExtendedStatus On - -# can return hits or bytes (counters) - -@res = `/usr/bin/lynx -dump http://$ARGV[0]:80/server-status`; - -foreach $res (@res) { - if ($res =~ /Server uptime: (.*)$/) { $up = $1; last } else { next } - if ($res =~ /Server at/) { $server = $res; last } else { next } -} - -@res = `/usr/bin/lynx -dump http://$ARGV[0]:80/server-status?auto`; - -foreach $res (@res) { - if ($res =~ /Total Accesses: (\d+)/) { $d1 = $1; next } - if ($res =~ /Total kBytes: (\d+)/) { $d2 = $1 * 1024; next } -} - -$d1 = int($d1); -$d2 = int($d2); - -#if ($ARGV[1] eq "hits") { - print "$d1\n"; -# print "$d1\n"; -#} elsif ($ARGV[1] eq "bytes") { - print "$d2\n"; -# print "$d2\n"; -#} - -print "$up\n"; -print "$server"; diff --git a/html/graphs b/html/graphs deleted file mode 120000 index 08ab9b260e..0000000000 --- a/html/graphs +++ /dev/null @@ -1 +0,0 @@ -../graphs \ No newline at end of file diff --git a/html/includes/graphs/collectd_cpu.inc.php b/html/includes/graphs/collectd_cpu.inc.php deleted file mode 100644 index a7986278b0..0000000000 --- a/html/includes/graphs/collectd_cpu.inc.php +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/html/rrd b/html/rrd deleted file mode 120000 index 70c6b9ed64..0000000000 --- a/html/rrd +++ /dev/null @@ -1 +0,0 @@ -../rrd/ \ No newline at end of file diff --git a/includes/polling/ports-etherlike.inc.php b/includes/polling/ports-etherlike.inc.php new file mode 100755 index 0000000000..850a12d4d7 --- /dev/null +++ b/includes/polling/ports-etherlike.inc.php @@ -0,0 +1,67 @@ + (count($ports)*2.5)) { /// If there are 2.5x more interfaces than OIDs, do per-OID + $sub_start = utime(); + echo("Caching Ports: "); + foreach($ports as $port) { echo("$port "); $array = snmp_cache_port_oids($etherlike_oids, $port, $device, $array, "EtherLike-MIB"); } + $end = utime(); $run = $end - $sub_start; $proctime = substr($run, 0, 5); + echo("\n$proctime secs\n"); + } else { + $sub_start = utime(); + echo("Caching Oids: "); + foreach ($etherlike_oids as $oid) { echo("$oid "); $array = snmp_cache_oid($oid, $device, $array, "EtherLike-MIB"); } + $end = utime(); $run = $end - $sub_start; $proctime = substr($run, 0, 5); + echo("\n$proctime secs\n"); + } + + $polled = time(); + + /// Loop interfaces in the DB and update where necessary + $port_query = mysql_query("SELECT * FROM `interfaces` WHERE `device_id` = '".$device['device_id']."'"); + while ($port = mysql_fetch_array($port_query)) { + + echo(" --> " . $port['ifDescr'] . " "); + if($array[$device[device_id]][$port[ifIndex]]) { // Check to make sure Port data is cached. + + $this_port = &$array[$device[device_id]][$port[ifIndex]]; + + $rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/etherlike-".$port['ifIndex'].".rrd"; + + $rrd_create = $config['rrdtool'] . " create $rrdfile "; + $rrd_create .= "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"; + + if(!file_exists($rrdfile)) { + foreach($etherlike_oids as $oid){ + $oid = truncate(str_replace("dot3Stats", "", $oid), 19, ''); + $rrd_create .= " DS:$oid:COUNTER:600:U:100000000000"; + } + shell_exec($rrd_create); + } + + $rrdupdate = "N"; + foreach($etherlike_oids as $oid) { + $data = $this_port[$oid] + 0; + $rrdupdate .= ":$data"; + } + rrdtool_update($rrdfile, $rrdupdate); + + #AlignmentErrors|FCSErrors|SingleCollisionFram|MultipleCollisionFr|SQETestErrors|DeferredTransmissio|LateCollisions|ExcessiveCollisions + #InternalMacTransmit|CarrierSenseErrors|FrameTooLongs|InternalMacReceiveE|SymbolErrors + + } else { + echo("Port Deleted?"); // Port missing from SNMP cache? + } + echo("\n"); + } + +?> diff --git a/new-mac.php b/new-mac.php deleted file mode 100755 index 26768baf0c..0000000000 --- a/new-mac.php +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/php - " . $device['hostname'] . "\n"); - $i++; - $cip_oids = array('cipMacHCSwitchedBytes', 'cipMacHCSwitchedPkts'); - foreach ($cip_oids as $oid) { $array = snmp_cache_cip($oid, $device, $array, "CISCO-IP-STAT-MIB"); } - echo("\n"); -} - -$mac_accounting_query = mysql_query("SELECT * FROM `mac_accounting` as A, `interfaces` AS I, `devices` AS D where A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.status = '1'"); -while ($acc = mysql_fetch_array($mac_accounting_query)) { - - $device_id = $acc['device_id']; - $ifIndex = $acc['ifIndex']; - $mac = $acc['mac']; - if($array[$device_id][$ifIndex][$mac]) { - - $b_in = $array[$device_id][$ifIndex][$mac]['cipMacHCSwitchedBytes']['input']; - $b_out = $array[$device_id][$ifIndex][$mac]['cipMacHCSwitchedBytes']['output']; - $p_in = $array[$device_id][$ifIndex][$mac]['cipMacHCSwitchedPkts']['input']; - $p_out = $array[$device_id][$ifIndex][$mac]['cipMacHCSwitchedPkts']['output']; - - #echo($acc['hostname']." ".$acc['ifDescr'] . " $mac -> $b_in:$b_out:$p_in:$p_out "); - - $acc_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting"; - if(!is_dir($acc_rrd)) { mkdir($acc_rrd); echo("Created directory : $acc_rrd\n"); } - $old_rrdfile = $acc_rrd . "/" . $acc['ifIndex'] . "-" . $acc['ip'] . ".rrd"; - $rrdfile = $acc_rrd . "/" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - if(is_file($old_rrdfile) && !is_file($rrdfile)) { rename($old_rrdfile, $rrdfile); echo("Moved $old_rrdfile -> $rrdfile \n"); }; - $pkts_rrdfile = $acc_rrd . "/" . $acc['ifIndex'] . "-" . $acc['mac'] . "-pkts.rrd"; - - if(!is_file($pkts_rrdfile)) { - $woo = shell_exec($config['rrdtool'] ." create $pkts_rrdfile \ - DS:IN:COUNTER:600:0:12500000000 \ - DS:OUT:COUNTER:600:0:12500000000 \ - 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"); - } - - if(!is_file($rrdfile)) { - $woo = shell_exec($config['rrdtool'] ." create $rrdfile \ - DS:IN:COUNTER:600:0:12500000000 \ - DS:OUT:COUNTER:600:0:12500000000 \ - 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"); - } - - $woo = "N:".($b_in+0).":".($b_out+0); - $ret = rrdtool_update("$rrdfile", $woo); - - $woo = "N:".($p_in+0).":".($p_out+0); - $ret = rrdtool_update("$pkts_rrdfile", $woo); - - #echo(" R!\n"); - - } - -} - -echo("$i devices polled"); - -?> diff --git a/new-poller.php b/new-poller.php deleted file mode 100755 index e2a95c3f00..0000000000 --- a/new-poller.php +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/php - " . $device['hostname'] . "\n"); - $i++; - - // Build SNMP Cache Array - $data_oids = array('ifName','ifDescr','ifAlias', 'ifAdminStatus', 'ifOperStatus', 'ifMtu', 'ifSpeed', 'ifHighSpeed', 'ifType', 'ifPhysAddress', - 'ifPromiscuousMode','ifConnectorPresent'); - $stat_oids = array('ifHCInOctets', 'ifHCOutOctets', 'ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts', 'ifInNUcastPkts', 'ifOutNUcastPkts', - 'ifHCInMulticastPkts', 'ifHCInBroadcastPkts', 'ifHCOutMulticastPkts', 'ifHCOutBroadcastPkts'); - $etherlike_oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', 'dot3StatsMultipleCollisionFrames', - 'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions', - 'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors', - 'dot3StatsSymbolErrors', 'dot3StatsDuplexStatus'); - $cisco_oids = array('locIfHardType', 'locIfInRunts', 'locIfInGiants', 'locIfInCRC', 'locIfInFrame', 'locIfInOverrun', 'locIfInIgnored', 'locIfInAbort', - 'locIfCollisions', 'locIfInputQueueDrops', 'locIfOutputQueueDrops'); - $pagp_oids = array('pagpOperationMode', 'pagpPortState', 'pagpPartnerDeviceId', 'pagpPartnerLearnMethod', 'pagpPartnerIfIndex', 'pagpPartnerGroupIfIndex', - 'pagpPartnerDeviceName', 'pagpEthcOperationMode', 'pagpDeviceId', 'pagpGroupIfIndex'); - - $cip_oids = array('cipMacHCSwitchedBytes', 'cipMacHCSwitchedBytes', 'cipMacHCSwitchedPkts', 'cipMacHCSwitchedPkts'); - - $array = snmp_cache_portIfIndex ($device, $array); - $array = snmp_cache_portName ($device, $array); - foreach ($data_oids as $oid) { $array = snmp_cache($oid, $device, $array, "IF-MIB"); } - #foreach ($cip_oids as $oid) { $array = snmp_cache($oid, $device, $array, "CISCO-IP-STAT-MIB"); } - foreach ($stat_oids as $oid) { $array = snmp_cache($oid, $device, $array, "IF-MIB"); } - foreach ($etherlike_oids as $oid) { $array = snmp_cache($oid, $device, $array, "EtherLike-MIB"); } - foreach ($cisco_oids as $oid) { $array = snmp_cache($oid, $device, $array, "OLD-CISCO-INTERFACES-MIB"); } - foreach ($pagp_oids as $oid) { $array = snmp_cache($oid, $device, $array, "CISCO-PAGP-MIB"); } - - snmp_cache("vmVlan", $device, $array, "CISCO-VLAN-MEMBERSHIP-MIB"); - snmp_cache("vlanTrunkPortEncapsulationOperType", $device, $array, "CISCO-VTP-MIB"); - snmp_cache("vlanTrunkPortNativeVlan", $device, $array, "CISCO-VTP-MIB"); - - // End Building SNMP Cache Array - - // New interface detection - ///// TO DO - // End New interface detection - - // Loop interfaces in the DB and update where necessary - - $port_query = mysql_query("SELECT * FROM `interfaces` WHERE `device_id` = '".$device['device_id']."'"); - while ($port = mysql_fetch_array($port_query)) { - - echo(" --> " . $port['ifDescr'] . " "); - if($array[$device[device_id]][$port[ifIndex]]) { // Check to make sure Port data is cached. - $this_port = $array[$device[device_id]][$port[ifIndex]]; - - /// Update IF-MIB - foreach ($data_oids as $oid) { - if ( $port[$oid] != $this_port[$oid]) { - $update .= $separator . "`$oid` = '".$this_port[$oid]."'"; - $separator = ", "; - mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $port['device_id'] . "', '" . $port['interface_id'] . "', NOW(), '".$oid . ": ".$port[$oid]." -> " . $this_port[$oid]."')"); - #eventlog($device['device_id'], 'interface', $port['interface_id'], $oid . ": ".$port[$oid]." -> " . $this_port[$oid]); - echo($oid . " "); - } - } - /// End Update IF-MIB - - /// Update PAgP - if($this_port['pagpOperationMode']) { - unset($separator); unset($update); - foreach ($pagp_oids as $oid) { // Loop the OIDs - if ( $this_port[$oid] != $port[$oid] ) { // If data has changed, build a query - $update .= $separator . "`$oid` = '".$this_port[$oid]."'"; - $separator = ", "; - echo("PAgP "); - } - } - } - // End Update PAgP - - - if ($update) { /// Do Updates - $update_query = "UPDATE `interfaces` SET "; - $update_query .= $update; - $update_query .= " WHERE `interface_id` = '" . $port['interface_id'] . "'"; - #@mysql_query($update_query); - #echo("$update_query"); - if(mysql_affected_rows > '0') { echo("Updated "); } - } /// End Updates - - unset($separator); unset($update_query); unset($update); - } else { - echo("Port Deleted?"); // Port missing from SNMP cache? - } - echo("\n"); - } - - #unset($array); - echo("\n"); -} - -echo("$i devices polled"); - -?> diff --git a/remove-deleted-interfaces.php b/remove-deleted-interfaces.php deleted file mode 100755 index eb1c964979..0000000000 --- a/remove-deleted-interfaces.php +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/php - -### Purge deleted interfaces from the database - -