Page 1 of 2

Backend API Question

Posted: Tue Mar 19, 2013 12:16 pm
by arnab.roy
HI Guys,

I am trying to build a component for our XI environment. We use custom/ free variables with Nagios to identify what type of device it is. Is it possible to grab these fields via the backend API. As far as I can see from the xml dump I cant see those free variables. Not very keen on doing direct look ups on the DB .

host id="763">
<instance_id>1</instance_id>
<host_name>www.khipu-networks.com</host_name>
<is_active>1</is_active>
<config_type>1</config_type>
<alias>www.khipu-networks.com</alias>
<display_name>www.khipu-networks.com</display_name>
<address>www.khipu-networks.com</address>
<check_interval>5</check_interval>
<retry_interval>1</retry_interval>
<max_check_attempts>5</max_check_attempts>
<first_notification_delay>0</first_notification_delay>
<notification_interval>60</notification_interval>
<passive_checks_enabled>1</passive_checks_enabled>
<active_checks_enabled>1</active_checks_enabled>
<notifications_enabled>1</notifications_enabled>
<notes/>
<notes_url/>
<action_url/>
<icon_image>www_server.png</icon_image>
<icon_image_alt/>
<statusmap_image>www_server.png</statusmap_image>
</host>

Re: Backend API Question

Posted: Tue Mar 19, 2013 1:21 pm
by scottwilkerson
These are somewhat hidded but you can call the following cmd=

getcustomhostvariablestatus
getcustomservicevariablestatus
getcustomcontactvariablestatus

That will output the free variables

Re: Backend API Question

Posted: Tue Mar 19, 2013 3:44 pm
by arnab.roy
Brilliant ...Thanks....Just what the Doctor ordered...

Re: Backend API Question

Posted: Tue Mar 19, 2013 3:51 pm
by arnab.roy
Ooops spoke to soon I guess, I need the IP address, their does'nt seem to be an address field within that xml data. I definitely need the address and the free variables :( In our case the hostnames are random and doesnt actually resolve :(

Re: Backend API Question

Posted: Tue Mar 19, 2013 4:25 pm
by abrist
Do the hosts have their IPs entered into the CCM, or are you just checking them based on hostname? The XML will return whatever is in the CCM.

Re: Backend API Question

Posted: Tue Mar 19, 2013 4:32 pm
by arnab.roy
Yes they have IP's in CCM

If You look at the difference in output for both getcalls you can see the problem

gethosts
<host id="2127">
<instance_id>1</instance_id>
<host_name>wmin-aruba.wmin.ac.uk</host_name>
<is_active>1</is_active>
<config_type>1</config_type>
<alias>wmin-aruba.wmin.ac.uk</alias>
<display_name>wmin-aruba.wmin.ac.uk</display_name>
<address>161.74.50.10</address> THIS is the field I am missing
<check_interval>5</check_interval>
<retry_interval>1</retry_interval>
<max_check_attempts>10</max_check_attempts>
<first_notification_delay>0</first_notification_delay>
<notification_interval>60</notification_interval>
<passive_checks_enabled>1</passive_checks_enabled>
<active_checks_enabled>1</active_checks_enabled>
<notifications_enabled>1</notifications_enabled>
For getcustomhostvariablestatus
<customhostvarstatus>
<instance_id>1</instance_id>
<contact_id>2127</contact_id>
<host_name>wmin-aruba.wmin.ac.uk</host_name>
<display_name>wmin-aruba.wmin.ac.uk</display_name>
<host_alias>wmin-aruba.wmin.ac.uk</host_alias>
<customvars>
<customvar>

Re: Backend API Question

Posted: Wed Mar 20, 2013 8:59 am
by scottwilkerson
This would need to be a second call to gethosts to get that information

Re: Backend API Question

Posted: Wed Mar 20, 2013 11:32 am
by arnab.roy
Yup...just wondering about the performance :(

Re: Backend API Question

Posted: Wed Mar 20, 2013 11:35 am
by abrist
Performance should not be too bad as long as you are not making that query too often. How many checks will use the query every 5 minutes?

Re: Backend API Question

Posted: Wed Mar 20, 2013 1:12 pm
by arnab.roy
These calls will only be used by my component to populate a list of devices. I have implemented with two calls and the performance is ok...not too bad.