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>
Backend API Question
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Backend API Question
These are somewhat hidded but you can call the following cmd=
getcustomhostvariablestatus
getcustomservicevariablestatus
getcustomcontactvariablestatus
That will output the free variables
getcustomhostvariablestatus
getcustomservicevariablestatus
getcustomcontactvariablestatus
That will output the free variables
Re: Backend API Question
Brilliant ...Thanks....Just what the Doctor ordered...
Re: Backend API Question
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
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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Backend API Question
Yes they have IP's in CCM
If You look at the difference in output for both getcalls you can see the problem
gethosts
If You look at the difference in output for both getcalls you can see the problem
gethosts
For getcustomhostvariablestatus<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>
<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>
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Backend API Question
This would need to be a second call to gethosts to get that information
Re: Backend API Question
Yup...just wondering about the performance 
Re: Backend API Question
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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Backend API Question
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.