Exclude state=0 from api call

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Exclude state=0 from api call

Post by benjaminsmith »

Hi Don,

If you're not getting all the data back, please try increasing the PHP defaults, and let me know if that resolved the issue.

We have a knowledgebase article with the instructions.

Nagios XI - Optimizing The PHP Settings File

--Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
DonForigua
Posts: 94
Joined: Thu Oct 07, 2021 8:59 pm

Re: Exclude state=0 from api call

Post by DonForigua »

Great i can get 800k of entries.

Now how can i get a list of hostgroups members from api

Greetings
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Exclude state=0 from api call

Post by benjaminsmith »

Hi Don,

You can use the following GET command ( See Help > API Docs > Config Reference > Groups )

Code: Select all

curl -XGET "http://192.168.23.111/nagiosxi/api/v1/config/hostgroup?apikey=yourapikey&hostgroup_name=yourhostgroupname&pretty=1"
Let me know if that works.
--Ben
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
DonForigua
Posts: 94
Joined: Thu Oct 07, 2021 8:59 pm

Re: Exclude state=0 from api call

Post by DonForigua »

Hi

Here is the output

Code: Select all

{
    "recordcount": 1,
    "hostgroup": [
        {
            "instance_id": "1",
            "config_type": "1",
            "hostgroup_object_id": "79876",
            "alias": "XXX",
            "object_id": "79876",
            "hostgroup_name": "XXX",
            "is_active": "1"
        }
    ]
}
I need the host members.

Greetings
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Exclude state=0 from api call

Post by benjaminsmith »

Hi Don,

What version of Nagios XI are you using? Here's what I'm getting. There should be a field for the members.
hostgroup-api.png
Can you post the full check command (please remove any sensitive info)?

--Ben
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
DonForigua
Posts: 94
Joined: Thu Oct 07, 2021 8:59 pm

Re: Exclude state=0 from api call

Post by DonForigua »

Hi dear benjamin

we have 5.8.7, for example we have 1 host in 3 gruops

Code: Select all

    "recordcount": 172,
    "hostgroup": [
        {
            "instance_id": "1",
            "config_type": "1",
            "hostgroup_object_id": "98389",
            "alias": "XXX",
            "object_id": "98389",
            "hostgroup_name": "XXX",
            "is_active": "1"
        },
        {
            "instance_id": "1",
            "config_type": "1",
            "hostgroup_object_id": "7556",
            "alias": "Correo Corporativo",
            "object_id": "7556",
            "hostgroup_name": "Correo Corporativo",
            "is_active": "1"
        },
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Exclude state=0 from api call

Post by benjaminsmith »

Hi Don,

Thanks for posting that.

I'm not seeing any members, so it must not be in the database. I would double-check the CCM to make sure they are there.

Go to Configure > CCM > Monitoring > HostGroup.. click on the link to the hostgroup and select the Manage Hosts Button to verify.

If you cannot get it worked out, please PM your system profile.

To send us your system profile.
Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button

--Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
DonForigua
Posts: 94
Joined: Thu Oct 07, 2021 8:59 pm

Re: Exclude state=0 from api call

Post by DonForigua »

Good morning

For any strage reason i have the empty groups
You do not have the required permissions to view the files attached to this post.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Exclude state=0 from api call

Post by benjaminsmith »

Hi,

Got the profile, thank you. I'm reviewing the configurations right now and will update you shortly.

--Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Exclude state=0 from api call

Post by benjaminsmith »

Hi,

I found an error in the configuration database.
Error: Template 'xiwizard_windowssnmp_interface' specified in service definition could not be not found (config file '/usr/local/nagios/etc/services/General_DHS_Windows_Inspira_PI.cfg', starting on line 1075)
Error: Contactgroup 'Admin_Linux_Cliente' is not defined anywhere
Error: Could not add contactgroup 'Admin_Linux_Cliente' to host (config file '/usr/local/nagios/etc/hosts/AAG0332_MAIL.cfg', starting on line 16)
To save time, I de-activated some of those services, but I would review the contents of the files shown to help troubleshoot the issue. For example, it looks like your missing a contact group and there's a misconfigured service.

Run through the following steps in Configure > CCM > Tools > Config File Management to resolve configuration errors.
1. Delete Files
2. Write Files
3. Verify Files ( if you see any errors follow the message to correct and repeat steps 1-3 until it passes)
4. Restart Nagios Core

It's an interactive process until you get all the errors worked out.

On the original issue here, there are two ways to define hostgroup membership. One is at the hostgroup object, the other is in the host definition.

The members in this hostgroup, CG_Itops, are defined at the host object level, so when you run the API call against the hostgroup it doesn't not have member assigned, if you run an API call against the host object, you will see the association.

If you'd like to change the association, I would use the Bulk Mods Tool to remove everything at the host level and then re-assign in the hostgroup itself.

--Benjmain
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked