#!/usr/bin/php $ifDescr')"); } if ( $old_alias != $ifAlias ) { $update .= $seperator . "`name` = \"$ifAlias\""; $seperator = ", "; mysql_query("INSERT INTO eventlog (host, interface, datetime, message) values ($interface[host], $interface[sqlid], NOW(), 'Desc: $old_alias -> $ifAlias')"); } if ( $old_up != $ifOperStatus && $ifOperStatus != "" ) { $update .= $seperator . "`up` = '$ifOperStatus'"; $seperator = ", "; mysql_query("INSERT INTO eventlog (host, interface, datetime, message) values ($interface[host], $interface[sqlid], NOW(), 'Interface went $ifOperStatus')"); } if ( $old_up_admin != $ifAdminStatus && $ifAdminStatus != "" ) { $update .= $seperator . "`up_admin` = '$ifAdminStatus'"; $seperator = ", "; if($ifAdminStatus == "up") { $admin = "enabled"; } else { $admin = "disabled"; } mysql_query("INSERT INTO eventlog (host, interface, datetime, message) values ($interface[host], $interface[sqlid], NOW(), 'Interface $admin')"); } if ( $old_duplex != $ifDuplex && $ifDuplex != "" ) { $update .= $seperator . "`ifDuplex` = '$ifDuplex'"; $seperator = ", "; mysql_query("INSERT INTO eventlog (host, interface, datetime, message) values ($interface[host], $interface[sqlid], NOW(), 'Duplex changed to $ifDuplex')"); } if ( $old_type != $ifType && $ifType != "" ) { $update .= $seperator . "`ifType` = '$ifType'"; $seperator = ", "; mysql_query("INSERT INTO eventlog (host, interface, datetime, message) values ($interface[host], $interface[sqlid], NOW(), 'Type changed to $ifType')"); } if ( $old_mtu != $ifMtu && $ifMtu != "" ) { $update .= $seperator . "`ifMtu` = '$ifMtu'"; $seperator = ", "; mysql_query("INSERT INTO eventlog (host, interface, datetime, message) values ($interface[host], $interface[sqlid], NOW(), 'MTU changed to $ifMtu')"); } if ( $old_physaddress != $ifPhysAddress && $ifPhysAddress != "" ) { $update .= $seperator . "`ifPhysAddress` = '$ifPhysAddress'"; $seperator = ", "; mysql_query("INSERT INTO eventlog (host, interface, datetime, message) values ($interface[host], $interface[sqlid], NOW(), 'MAC changed to $ifPhysAddress')"); } if ( $old_speed != $ifSpeed && $ifSpeed != "" ) { $update .= $seperator . "`ifSpeed` = '$ifSpeed'"; $seperator = ", "; $prev = humanspeed($old_speed); $now = humanspeed($ifSpeed); mysql_query("INSERT INTO eventlog (host, interface, datetime, message) values ($interface[host], $interface[sqlid], NOW(), 'Speed changed from $prev -> $now')"); } if ($update) { $update_query = "UPDATE `interfaces` SET "; $update_query .= $update; $update_query .= " WHERE `id` = '$id'"; echo("Updating : $hostname $ifDescr\n$update_query\n\n"); $update_result = mysql_query($update_query); } else { echo("Not Updating : $hostname $ifDescr ( $old_if )\n\n"); } if($ifOperStatus == "up") { $snmp_data = `snmpget -O qv -v2c -c $community $hostname ifHCInOctets.$ifIndex ifHCOutOctets.$ifIndex ifInErrors.$ifIndex ifOutErrors.$ifIndex \ ifInUcastPkts.$ifIndex ifOutUcastPkts.$ifIndex ifInNUcastPkts.$ifIndex ifOutNUcastPkts.$ifIndex`; $snmp_data = str_replace("Wrong Type (should be Counter32): ","", $snmp_data); $snmp_data = str_replace("No Such Instance currently exists at this OID","", $snmp_data); list($ifHCInOctets, $ifHCOutOctets, $ifInErrors, $ifOutErrors, $ifInUcastPkts, $ifOutUcastPkts, $ifInNUcastPkts, $ifOutNUcastPkts) = explode("\n", $snmp_data); if($ifHCInOctets == "" || strpos($ifHCInOctets, "No") !== FALSE ) { $fixit = `snmpget -O qv -v2c -c $community $hostname ifInOctets.$ifIndex ifOutOctets.$ifIndex`; list ($ifHCInOctets, $ifHCOutOctets) = explode("\n", $fixit); } $woo = "N:$ifHCInOctets:$ifHCOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts"; $ret = rrd_update("$rrdfile", $woo); } else { echo("Interface $hostname $old_if is down\n"); } } mysql_query("UPDATE interfaces set ifPhysAddress = '' WHERE ifPhysAddress = 'No Such Instance currently exists at this OID'"); ?>