Skip to content

About

Python script that creates the commands, templates and Nagios Core config files needed for monitoring hosts with NCPA.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

28 Commits

Folders and files

Repository files navigation

CoreWizard

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).

Usage

Nagios:

  1. Requires NagiosCore in proper functioning condition.
  2. 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.
  3. Monitoring targets require proper functioning install of NCPA.

CoreWizard:

  1. Download the CoreWizard as a zip archive to the Nagios server.

  2. Extract the content of the zip file to the "/usr/local/nagios/etc/objects/" directory.

  3. Install required Python3 libraries

    • os
    • sys
    • argparse
    • yaml
    • jinja2
  4. Modify /usr/local/nagios/etc/nagios.cfg to include CoreWizard generated object configs.

    • Add CoreWizard path to the read configs from directory section
  5. Execute "python3 corewizard -a cmd" to reate corewizard commands.

  6. Execute "python3 corewizard.py -a templates"

  7. Execute "python3 corewizard.py -a monitor -H "<host_name>:<ip/fqdn> -T <linux/windows>"

  8. 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.

CoreWizard.py

Input

-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

Generate CoreWizard Commands

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

Command File Content

NameDescription
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.

Generate CoreWizard Templates

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 Template Content

corewizard-generic-host.cfg

FieldValue
namecorewizard-generic-host
check_period24x7
check_interval4
retry_interval2
max_check_attempts4
notification_period24x7
notification_interval60
notification_optionsu,d,r
contact_groups`admins
notifications_enabled1
event_handler_enabled1
flap_detection_enabled0
process_perf_data1
retain_status_information1
retain_nonstatus_information1
notification_period24x7
register0

corewizard-generic-service.cfg

FieldValue
namecorewizard-generic-service
active_checks_enabled1
passive_checks_enabled1
parallelize_check 1
obsess_over_service0
check_freshness0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information1
is_volatile0
check_period24x7
max_check_attempts4
check_interval4
retry_interval2
contact_groupsadmins
notification_optionsw,u,c,r
notification_interval60
notification_period24x7
register0
notescorewizard generated
_wizardcorewizard

Corewizard Objects

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.

CoreWizard Object Content

<hostname>.cfg

Object will contain a single host stanza.

FieldValue
host_nameuser-input
addressuser-input
usecorewizard-generic-host-use
commandyml-type-host-command
hostgroupsyml-type-host-hostgroups

Object will caontain a stanza for each service that is defined for the type in the corewizard_object.yml

(n)SERVICE

nameyml-type-service(n)
service_descritionyml-type-service(n)-service_description
commandyml-type-service(n)-command
notifications_enabledyml-type-service(n)-notifications_enabled
action_urlyml-type-service(n)-action_url

About

Python script that creates the commands, templates and Nagios Core config files needed for monitoring hosts with NCPA.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages