From e11769584bd5925ae797e82e4580fb83efb14939 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Fri, 18 Jun 2010 18:12:35 +0000 Subject: [PATCH] FS#36: allow hostnames as parameter for discovery and polling git-svn-id: http://www.observium.org/svn/observer/trunk@1211 61d68cd4-352d-0410-923a-c4978735b2b8 --- discovery.php | 9 ++++++++- poll-device.php | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/discovery.php b/discovery.php index 52e4a1722..cd3ecb9c6 100755 --- a/discovery.php +++ b/discovery.php @@ -21,7 +21,14 @@ if ($options['h'] == "odd") { } elseif ($options['h'] == "all") { $where = " "; $doing = "all"; } elseif($options['h']) { - $where = "AND `device_id` = '".$options['h']."'"; $doing = "Host ".$options['h']; + if (is_numeric($options['h'])) + { + $where = "AND `device_id` = '".$options['h']."'"; $doing = "Host ".$options['h']; + } + else + { + $where = "AND `hostname` LIKE '".str_replace('*','%',mres($options['h']))."'"; $doing = "Host ".$options['h']; + } } elseif ($options['i'] && isset($options['n'])) { $where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'"; $doing = "Proc ".$options['n'] ."/".$options['i']; } diff --git a/poll-device.php b/poll-device.php index 79ef536eb..e36ce2694 100755 --- a/poll-device.php +++ b/poll-device.php @@ -17,7 +17,14 @@ if ($options['h'] == "odd") { } elseif ($options['h'] == "all") { $where = " "; $doing = "all"; } elseif ($options['h']) { - $where = "AND `device_id` = '".$options['h']."'"; $doing = "Host ".$options['h']; + if (is_numeric($options['h'])) + { + $where = "AND `device_id` = '".$options['h']."'"; $doing = "Host ".$options['h']; + } + else + { + $where = "AND `hostname` LIKE '".str_replace('*','%',mres($options['h']))."'"; $doing = "Host ".$options['h']; + } } elseif ($options['i'] && isset($options['n'])) { $where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'"; $doing = "Proc ".$options['n'] ."/".$options['i']; }