Backend API Question

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
arnab.roy
Posts: 354
Joined: Sat Apr 30, 2011 10:24 am

Backend API Question

Post 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>
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Backend API Question

Post by scottwilkerson »

These are somewhat hidded but you can call the following cmd=

getcustomhostvariablestatus
getcustomservicevariablestatus
getcustomcontactvariablestatus

That will output the free variables
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
arnab.roy
Posts: 354
Joined: Sat Apr 30, 2011 10:24 am

Re: Backend API Question

Post by arnab.roy »

Brilliant ...Thanks....Just what the Doctor ordered...
User avatar
arnab.roy
Posts: 354
Joined: Sat Apr 30, 2011 10:24 am

Re: Backend API Question

Post 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 :(
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Backend API Question

Post 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.
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.
User avatar
arnab.roy
Posts: 354
Joined: Sat Apr 30, 2011 10:24 am

Re: Backend API Question

Post 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>
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Backend API Question

Post by scottwilkerson »

This would need to be a second call to gethosts to get that information
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
arnab.roy
Posts: 354
Joined: Sat Apr 30, 2011 10:24 am

Re: Backend API Question

Post by arnab.roy »

Yup...just wondering about the performance :(
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Backend API Question

Post 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?
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.
User avatar
arnab.roy
Posts: 354
Joined: Sat Apr 30, 2011 10:24 am

Re: Backend API Question

Post 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.
Locked