From f0a46325fe877e5613ec737da58f8330dfe34f14 Mon Sep 17 00:00:00 2001 From: tmonteyne Date: Tue, 6 Mar 2018 15:33:36 +0100 Subject: [PATCH] Create function show_poller Function for request which poller by hostname curl -s -k -H centreon-auth-token:$TOKEN= -H Content-Type:application/json -d '{"action":"show_poller","object":"host","values":"hostname"}' 'https://serveurcentreon/centreon/api/index.php?action=action&object=centreon_clapi' --- .../core/class/centreonHost.class.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/www/modules/centreon-clapi/core/class/centreonHost.class.php b/www/modules/centreon-clapi/core/class/centreonHost.class.php index c249de0..d2ef33c 100644 --- a/www/modules/centreon-clapi/core/class/centreonHost.class.php +++ b/www/modules/centreon-clapi/core/class/centreonHost.class.php @@ -283,6 +283,26 @@ public function del($objectName) { $this->db->query("DELETE FROM service WHERE service_register = '1' AND service_id NOT IN (SELECT service_service_id FROM host_service_relation)"); } + /** + * show_poller Action + * Must show_poller to the Host + * + * @param string $host + * @return mixed + */ + + public function show_poller($host) { + /* Regular services */ + $sql = "SELECT n.ns_ip_address,n.id FROM ns_host_relation ns,host h, nagios_server n WHERE ns.host_host_id=h.host_id AND ns.nagios_server_id=n.id AND h.host_name = '$host'"; + $res = $this->db->query($sql); + $result = $res->fetchAll(); + foreach ($result as $row) { + echo $row['ns_ip_address']; + return $row; + } + /**var_dump($result);*/ + } + /** * Tie host to instance (poller) *