Python to create the commands, templates and Nagios Core object config files needed to stand-up lowest common denominator (LCD) monitoring for hosts and services via Nagios Cross Platform Agent (NCPA).
- Requires NagiosCore in proper functioning condition.
- Requires Install of Nagios Enterprises check_ncpa.py monitoring plugin.
- Creating Nagios macros to hold the token for the check_ncpa commands is not required but, strongly recommended.
- Monitoring targets require proper functioning install of NCPA.
-
Download the CoreWizard as a zip archive to the Nagios server.
-
Extract the content of the zip file to the "/usr/local/nagios/etc/objects/" directory.
-
Install required Python3 libraries
- os
- sys
- argparse
- yaml
- jinja2
-
Modify
/usr/local/nagios/etc/nagios.cfgto include CoreWizard generated object configs.- Add CoreWizard path to the read configs from directory section
-
Execute "python3 corewizard -a cmd" to reate corewizard commands.
-
Execute "python3 corewizard.py -a templates"
-
Execute "python3 corewizard.py -a monitor -H "<host_name>:<ip/fqdn> -T <linux/windows>"
-
In the case of an error or needing to overwrite any config files you may have already created you have to use the "-o" command flag.
- DANGER: This will overwrite any object file that is already present in the Nagios Core working directory.
| -a/--action | Choice:[cmd,template,monitor] cmd=Deploy the corewizard-command.cfg,template=Deploy the corewizard-template.cfg,monitor=Create monitoring object.cfg | Required |
| -H/--hostlist | Double quote encapsulated, comma seperated list of hostname or hostname:address pairs:["hostname1,hostname2:192.168.0.0,hostname3"] | Required |
| -T/--ostype | Choice:[linux,windows] linux=use linux definitions from the object yml, windows=use the windows definitons from the objects yml | Required |
| -o/--overwrite | Boolean:[-o] If included the wizard will overwrite configuration files in the app path of the script. Thise is needed to deploy updates to cmds,templates,objects. | Optional |
The "cmd" action, short for generate corewizard commands, takes the object feild values defined in the yml, passes this to the jinja2 template and creates the Nagios Core commands that will be used by the corewizard host and services templates.
- YML
- corewizard-commands.yml
- Template:
- corewizard-commands.j2
- File Generated
- corewizard_commands.cfg
| Name | Description |
|---|---|
| check_ncpa | Command definition as taken from NagiosXI for forward compatability. |
| check_ncpa_hyperv | Command definition as taken from NagiosXI for forward compatability. |
| check_ncpa_core | Modified default command definition that uses Nagios macros to store the token and port used to communicate with NCPA. |
The "template" action, short for generate corewizard templates, takes the object feild values defined in the yml, passes this to the jinja2 template and creates the Nagios Core tewmplates that will be used by the hosts and services monitored. The corewizard templates contain the majority of the settings for the monitored objects generated via the corewizard and are inherited via the use feild in the monitored object cfg.
- Tempate
- corewizard-generic-host.j2
- corewizard-generic-service.j2
- YML
- corewizard-generic-host.yml
- corewizard-generic-service.yml
- Config Files Created
- corewizard-generic-host.cfg
- corewizard-generic-service.cfg
corewizard-generic-host.cfg
| Field | Value |
|---|---|
| name | corewizard-generic-host |
| check_period | 24x7 |
| check_interval | 4 |
| retry_interval | 2 |
| max_check_attempts | 4 |
| notification_period | 24x7 |
| notification_interval | 60 |
| notification_options | u,d,r |
| contact_groups` | admins |
| notifications_enabled | 1 |
| event_handler_enabled | 1 |
| flap_detection_enabled | 0 |
| process_perf_data | 1 |
| retain_status_information | 1 |
| retain_nonstatus_information | 1 |
| notification_period | 24x7 |
| register | 0 |
corewizard-generic-service.cfg
| Field | Value |
|---|---|
| name | corewizard-generic-service |
| active_checks_enabled | 1 |
| passive_checks_enabled | 1 |
| parallelize_check | 1 |
| obsess_over_service | 0 |
| check_freshness | 0 |
| notifications_enabled | 1 |
| event_handler_enabled | 1 |
| flap_detection_enabled | 1 |
| process_perf_data | 1 |
| retain_status_information | 1 |
| retain_nonstatus_information | 1 |
| is_volatile | 0 |
| check_period | 24x7 |
| max_check_attempts | 4 |
| check_interval | 4 |
| retry_interval | 2 |
| contact_groups | admins |
| notification_options | w,u,c,r |
| notification_interval | 60 |
| notification_period | 24x7 |
| register | 0 |
| notes | corewizard generated |
| _wizard | corewizard |
The "monitor" action, takes the input provices by the user in the hostlist and based on the type, reads the object feild values defined in the yml, passes this to the jinja2 template and creates the Nagios Core object (.cfg) containing the host and services defined in the object yml.
<hostname>.cfg
Object will contain a single host stanza.
| Field | Value |
|---|---|
| host_name | user-input |
| address | user-input |
| use | corewizard-generic-host-use |
| command | yml-type-host-command |
| hostgroups | yml-type-host-hostgroups |
Object will caontain a stanza for each service that is defined for the type in the corewizard_object.yml
(n)SERVICE
| name | yml-type-service(n) |
|---|---|
| service_descrition | yml-type-service(n)-service_description |
| command | yml-type-service(n)-command |
| notifications_enabled | yml-type-service(n)-notifications_enabled |
| action_url | yml-type-service(n)-action_url |