Automated Nagios Registering and Service Setup
Posted: Mon Mar 25, 2019 7:09 pm
Hello,
I'm working on a project with Ansible and Nagios. The goal is to automated the registering of servers and services of all the servers in our Ansible cluster and have them report in Nagios XI. We are running Nagios XI 5.5.11 (offline install), on RHEL 7.5 (64 bit) minimal.
So far I have found the example ansible automation provided in the XI installation:
I have managed to register the servers themselves in Nagios via the rest endpoint:
However, when I try and actual register services I am told that the service worked (CCM doesn't show a failure in the config, but the service doesn't show up in the Services UI):
The rest call that I'm trying to make is:
I have a two immediate questions:
1. Am I missing something very easy with the check_xi_service_status module?
2. Should I be using a different module rather than the check_xi_service_status module?
Thank you!
I'm working on a project with Ansible and Nagios. The goal is to automated the registering of servers and services of all the servers in our Ansible cluster and have them report in Nagios XI. We are running Nagios XI 5.5.11 (offline install), on RHEL 7.5 (64 bit) minimal.
So far I have found the example ansible automation provided in the XI installation:
Code: Select all
vim /usr/local/nagiosxi/scripts/automation/ansible/ncpa_autoregister/Code: Select all
- name: Register Host With XI
uri:
url: http://<hostname.domain.of.XI.host>/nagiosxi/api/v1/config/host?apikey=APIKEYHERE&pretty=1
body: 'host_name={{ ansible_fqdn }}&address={{ ansible_default_ipv4.address }}&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&applyconfig=1'
method: POST
validate_certs: no
timeout: 120
Code: Select all
Successfully added <HOSTNAME.DOMAIN>:: Test Service: Apache to the system. Config applied, Nagios Core was restarted.Code: Select all
- name: Register Service example
uri:
url: https://<hostname.domain.of.XI.host>/nagiosxi/api/v1/config/service?apikey=APIKEYHERE&pretty=1
body: 'host_name={{ ansible_fqdn }}&address={{ ansible_default_ipv4.address }}&service_description=Testing&check_command=check_xi_service_status\-t COMMUNITY-STRING-HERE -P 5693 -M services -q service=NetworkManager,status=running%&check_interval=5&retry_interval=5&max_check_attempts=3&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&applyconfig=1'
method: POST
validate_certs: no
timeout: 120
1. Am I missing something very easy with the check_xi_service_status module?
2. Should I be using a different module rather than the check_xi_service_status module?
Thank you!