Page 2 of 3

Re: Exclude state=0 from api call

Posted: Fri Dec 03, 2021 10:48 am
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

Re: Exclude state=0 from api call

Posted: Fri Dec 03, 2021 7:00 pm
by DonForigua
Great i can get 800k of entries.

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

Greetings

Re: Exclude state=0 from api call

Posted: Mon Dec 06, 2021 11:37 am
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

Re: Exclude state=0 from api call

Posted: Wed Dec 08, 2021 7:05 pm
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

Re: Exclude state=0 from api call

Posted: Thu Dec 09, 2021 2:04 pm
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

Re: Exclude state=0 from api call

Posted: Thu Dec 09, 2021 6:27 pm
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"
        },

Re: Exclude state=0 from api call

Posted: Fri Dec 10, 2021 11:39 am
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

Re: Exclude state=0 from api call

Posted: Mon Dec 13, 2021 10:29 am
by DonForigua
Good morning

For any strage reason i have the empty groups

Re: Exclude state=0 from api call

Posted: Tue Dec 14, 2021 10:41 am
by benjaminsmith
Hi,

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

--Benjamin

Re: Exclude state=0 from api call

Posted: Tue Dec 14, 2021 11:44 am
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