#!/usr/bin/env php [community] [v1|v2c] [port] [udp|udp6|tcp|tcp6] [context] // SNMPv3 : Defaults : add_device.php any v3 [user] [port] [udp|udp6|tcp|tcp6] [context] // No Auth, No Priv : add_device.php nanp v3 [user] [port] [udp|udp6|tcp|tcp6] [context] // Auth, No Priv : add_device.php anp v3 [md5|sha|sha-224|sha-256|sha-384|sha-512] [port] [udp|udp6|tcp|tcp6] [context] // Auth, Priv : add_device.php ap v3 [md5|sha|sha-224|sha-256|sha-384|sha-512] [des|aes|aes-192|aes-192-c|aes-256|aes-256-c] [port] [udp|udp6|tcp|tcp6] [context] } } } if (!$device) { print_error("Unknown device '{$options['h']}'."); exit; } } else { // Unknown device (need pass own snmp auth) $device = []; } if (!$device) { print_message("%n USAGE: $scriptname [-cqdV] -h device [-f filename] EXAMPLE: ./scripts/snmpdump.php -c -h Show snmpwalk commands for make snmpdump specific device (exist in db) ./scripts/snmpdump.php -h Make snmpdump for specific device (exist in db) to file .snmpwalk ./scripts/snmpdump.php -h Make snmpdump for specific hostname with v2 community to file .snmpwalk Can use snmp v1/2c/3 auth params same as for ./add_device.php OPTIONS: -h | Device hostname or id (required). -f Filename for store snmpdump (default: .snmpwalk). For write to stdout use -f stdout -c Show snmpwalk commands for self run. -o Start Numeric Oid (default: .) -q Quiet output. -V Show observium version and exit. -VV Show observium and used programs versions and exit. DEBUGGING OPTIONS: -d Enable debugging output. -dd More verbose debugging output. %rInvalid arguments!%n", 'color', FALSE); exit; } $oid = $options['o'] ?? NULL; if (cli_is_piped()) { $options['f'] = 'stdout'; } elseif (isset($options['c'])) { // show snmpwalk commands snmp_dump($device, 'cmd', $oid); exit; } elseif (!isset($options['f'])) { $options['f'] = $device['hostname'] . '.snmpwalk'; if (!is_writable(dirname($options['f']))) { $options['f'] = $config['temp_dir'] . '/' . $options['f']; } } if (strtolower($options['f']) !== 'stdout') { if ($filename = snmp_dump($device, $options['f'], $oid)) { print_success("SNMP dump completed to file:\n $filename"); } } else { // Just snmpwalk to stdout snmp_dump($device, NULL, $oid); } // EOF