RE: [PHP] SNMP -> LOG

2002-07-15 Thread Mattias Eriksson

Here is a example using snmprealwalk() to make a simple dump to a
textfile.
The script filters out some things that atleast I don't need.

To get more verbose output comment out "$walk = snmp_nice_array($walk);"
and/or change "snmp_set_quick_print(1);" to "snmp_set_quick_print(0);".

Example with most information.

Array
(
[system.sysORTable.sysOREntry.sysORID.1] =>
system.sysORTable.sysOREntry.sysORID.1 = OID: ifMIB
[system.sysORTable.sysOREntry.sysORID.2] =>
system.sysORTable.sysOREntry.sysORID.2 = OID:
.iso.org.dod.internet.snmpV2.snmpModules.snmpMIB
[system.sysORTable.sysOREntry.sysORID.3] =>
system.sysORTable.sysOREntry.sysORID.3 = OID: tcpMIB
[system.sysORTable.sysOREntry.sysORID.4] =>
system.sysORTable.sysOREntry.sysORID.4 = OID: ip
)
  (  )
// Kdr(oo)
/--\/
   / |||
  *  ||---||
 ~~   ~~


 $value) {
$value = preg_replace("/^$key /","",$value);
$array[$key] = $value;
}
return $array;
}

snmp_set_quick_print(1); // Less information.

$walk = snmprealwalk($host,$community,$object); // Fetch the data.

/* Example of what $walk might contain now.
Array
(
[system.sysORTable.sysOREntry.sysORID.1] =>
system.sysORTable.sysOREntry.sysORID.1 ifMIB
[system.sysORTable.sysOREntry.sysORID.2] =>
system.sysORTable.sysOREntry.sysORID.2
.iso.org.dod.internet.snmpV2.snmpModules.snmpMIB
[system.sysORTable.sysOREntry.sysORID.3] =>
system.sysORTable.sysOREntry.sysORID.3 tcpMIB
[system.sysORTable.sysOREntry.sysORID.4] =>
system.sysORTable.sysOREntry.sysORID.4 ip
)
*/

$walk = snmp_nice_array($walk); // Run the result thru
snmp_nice_array().

/* Example of what $walk might contain after snmp_nice_array().
Array
(
[system.sysORTable.sysOREntry.sysORID.1] => ifMIB
[system.sysORTable.sysOREntry.sysORID.2] =>
.iso.org.dod.internet.snmpV2.snmpModules.snmpMIB
[system.sysORTable.sysOREntry.sysORID.3] => tcpMIB
[system.sysORTable.sysOREntry.sysORID.4] => ip
)
*/

foreach($walk as $key => $value) fputs($fp,"$key = $value\n"); // Write
data to file.

/* Example of what the file might contain.
system.sysORTable.sysOREntry.sysORID.1 = ifMIB
system.sysORTable.sysOREntry.sysORID.2 =
.iso.org.dod.internet.snmpV2.snmpModules.snmpMIB
system.sysORTable.sysOREntry.sysORID.3 = tcpMIB
system.sysORTable.sysOREntry.sysORID.4 = ip
*/

fclose($fp); // Close file.
?>


> Hi
> 
> I would like to collect data from snmpget and log it.
> Anyone have a idea how to do this?
> 
> // maas, Sweden


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] SNMP -> LOG

2002-07-15 Thread MAAS


Hi

I would like to collect data from snmpget and log it.
Anyone have a idea how to do this?

// maas, Sweden



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php