From 31cfad371fc96a4af4e5ce621b83678c3b19e2ff Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Wed, 16 Mar 2011 14:21:33 +0000 Subject: [PATCH] fixed r1871 discovery of new devices, thanks to Bill Fenner for testing and fixing, also made some php notices go away. git-svn-id: http://www.observium.org/svn/observer/trunk@1873 61d68cd4-352d-0410-923a-c4978735b2b8 --- discovery.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/discovery.php b/discovery.php index 4651c2bb4..d0eb1eca5 100755 --- a/discovery.php +++ b/discovery.php @@ -26,21 +26,24 @@ echo("Observium v".$config['version']." Discovery\n\n"); $options = getopt("h:t:i:n:d::a::"); -if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; } -elseif ($options['h'] == "even") { $options['n'] = "0"; $options['i'] = "2"; } -elseif ($options['h'] == "all") { $where = " "; $doing = "all"; } -elseif ($options['h'] == "new") { $where = "AND `last_discovered` = NULL"; $doing = "new"; } -elseif ($options['h']) +if (isset($options['h'])) { - if (is_numeric($options['h'])) + if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; } + elseif ($options['h'] == "even") { $options['n'] = "0"; $options['i'] = "2"; } + elseif ($options['h'] == "all") { $where = " "; $doing = "all"; } + elseif ($options['h'] == "new") { $where = "AND `last_discovered` IS NULL"; $doing = "new"; } + elseif ($options['h']) { - $where = "AND `device_id` = '".$options['h']."'"; - $doing = $options['h']; - } - else - { - $where = "AND `hostname` LIKE '".str_replace('*','%',mres($options['h']))."'"; - $doing = $options['h']; + if (is_numeric($options['h'])) + { + $where = "AND `device_id` = '".$options['h']."'"; + $doing = $options['h']; + } + else + { + $where = "AND `hostname` LIKE '".str_replace('*','%',mres($options['h']))."'"; + $doing = $options['h']; + } } }