From 015695e724260dcc3900dda817ad8aa2ad6e590c Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Sun, 8 Apr 2012 11:04:43 +0000 Subject: [PATCH] when no snmp version is given on commandline, try v2c first, then v1 git-svn-id: http://www.observium.org/svn/observer/trunk@2991 61d68cd4-352d-0410-923a-c4978735b2b8 --- addhost.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/addhost.php b/addhost.php index d57089186..9fea01537 100755 --- a/addhost.php +++ b/addhost.php @@ -42,13 +42,25 @@ if (isset($argv[1]) && $argv[1]) $transport = $argv[5]; } - if (!$snmpver) $snmpver = "v2c"; if ($community) { $config['snmp']['community'] = array($community); } + + if ($snmpver) + { + $snmpversions[] = $snmpver; + } + else + { + $snmpversions = array('v2c','v1'); + } - $device_id = addHost($host, $snmpver, $port, $transport); + while (!$device_id && count($snmpversions)) + { + $snmpver = array_shift($snmpversions); + $device_id = addHost($host, $snmpver, $port, $transport); + } if ($device_id) {