Hi,
1) I'm trying to register and add to the host using below Ansible automation but it's not working, please help?
- name: Register Host With XI
uri:
url: http://{{ xi_ip }}/nagiosxi/api/v1/config/host?apikey={{ xi_api_key }}
body: 'host_name={{ ansible_hostname }}&address={{ ansible_hostname }}&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&icon_image=redhat.png&statusmap_image=redhat.png&hostgroup_name=linux-servers'
method: POST
validate_certs: no
timeout: 120
2) Is it possible to remove all alerts for a host from the backend? Currently Nagiosxi keep adding all the old,new checks on to the NCPA UI.
Thanks
Bala
NagiosXi Add host to hostgroup using api
-
Bala.Mutyam
- Posts: 97
- Joined: Wed Apr 29, 2020 12:18 pm
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: NagiosXi Add host to hostgroup using api
Hi Bala,
A couple of suggestions, as I'm not familiar with how the Ansible Automation is setup, but make sure the apply configuration is called at some point. By default, this does not happen when you create objects form the API, you can simply add the applyconfig=1 parameter to the end of the string.
Next, to add the host to an existing hostgoup, add in the hostrgroups parameter, for example hostgroups=linux-servers, so in curl format, it would like this:
For the second question, could you provide a screenshot of the UI. All of the alerts are stored in the nagios log files, so it's not currently possible to completely delete historical data for a host from the UI. However, we can try to correct the issue, it maybe caused by duplicate services
A couple of suggestions, as I'm not familiar with how the Ansible Automation is setup, but make sure the apply configuration is called at some point. By default, this does not happen when you create objects form the API, you can simply add the applyconfig=1 parameter to the end of the string.
Next, to add the host to an existing hostgoup, add in the hostrgroups parameter, for example hostgroups=linux-servers, so in curl format, it would like this:
Code: Select all
curl -XPOST "https://192.168.0.11/nagiosxi/api/v1/config/host?apikey=myapikey&pretty=1" -d "host_name=testapihost4&address=127.0.0.1&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&hostgroups=linux-servers&applyconfig=1"
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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
Bala.Mutyam
- Posts: 97
- Joined: Wed Apr 29, 2020 12:18 pm
Re: NagiosXi Add host to hostgroup using api
Thanks benjaminsmith, hostgroups are working now.
I have attached screenshot of UI, please have a look.
I have attached screenshot of UI, please have a look.
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: NagiosXi Add host to hostgroup using api
Hi,
Perfect. I appreciate the screenshot. So, NCPA will maintain a local log from check results. You have the option to turn this off completely or reduce the number to days store these checks locally.
To change these settings, navigate to the ncpa.cfg file on the remote host. On Linux systems, it's in the following directory:
For Windows, go to:
NCPA Configuration
And then modify the settings below, set check_logging = 0 to disable. Be sure to re-start the NCPA listener after making any changes.
Let me know if you need any assistance.
Benjamin
Perfect. I appreciate the screenshot. So, NCPA will maintain a local log from check results. You have the option to turn this off completely or reduce the number to days store these checks locally.
To change these settings, navigate to the ncpa.cfg file on the remote host. On Linux systems, it's in the following directory:
Code: Select all
/usr/local/ncpa/etc/Code: Select all
C:\Program Files (x86)\Nagios\NCPA\etc\And then modify the settings below, set check_logging = 0 to disable. Be sure to re-start the NCPA listener after making any changes.
Code: Select all
[general]
#
# Check logging (in ncpa.db and the interface) is on by default, you can disable it
# if you do not want to record the check requests that are coming in or checks being
# sent over NRDP.
# Default: check_logging = 1
#
check_logging = 1
#
# Check logging time - how long in DAYS you'd like to keep checks in the database.
# Default: 30
#
check_logging_time = 30
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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
Bala.Mutyam
- Posts: 97
- Joined: Wed Apr 29, 2020 12:18 pm
Re: NagiosXi Add host to hostgroup using api
@benjaminsmith: Thanks.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: NagiosXi Add host to hostgroup using api
Bala.Mutyam May we lock the thread?Bala.Mutyam wrote:@benjaminsmith: Thanks.
-
Bala.Mutyam
- Posts: 97
- Joined: Wed Apr 29, 2020 12:18 pm
Re: NagiosXi Add host to hostgroup using api
Yes,please.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: NagiosXi Add host to hostgroup using api
GreatBala.Mutyam wrote:Yes,please.
Locking thread