Skip to content

Customising okconfig templates to your needs

spicysomtam edited this page Jun 12, 2015 · 20 revisions

Introduction

You want to customise the templates attached to a host when you add a host on adagios: Okconfig->Add host->Template. For example Standard Linux checks. The default checks don't fit your needs or you want to add to them. Its pretty easy when you know how.

okconfig configuration

Listing out the files in the okconfig rpm gives an idea of whats in it.The main config file is /etc/okconfig.conf. If you check this file, you will see examples_directory and examples_directory_local; the former is where the default examples files are loaded from, while the latter is where you can put customized versions. The default settings in okconfig.conf is that files under /usr/share/okconfig should not be modified (and will be updated when you update the package), while /etc/nagios/okconfig is where you can put customisations (and adagios modifies in here too). The default services template for linux hosts is /usr/share/okconfig/examples/linux.cfg-example and this is copied to a new host when choose that in the web gui/okconfig command line.

If you wish to customize a template, copy it to /etc/nagios/okconfig/examples/ and modify it there. okconfig/adagios will prefer the local config if a file exists.

Don't touch the template files; they are not the default templates copied to new hosts (confusing huh?). I did not find any way to modify the example templates in the web gui (maybe a feature request?); thus modify them on the Linux command line.

Regarding new services and commands; just define these within the adagios web gui. Once you have them defined they can be added to the example templates. Services can be found under Configure->Services->Show service template. You can add a new service via Configure->Service->Add Service. Commands are more obvious: Configure->Commands.

An example

So we use the gui to add a command called check_snmp_process. Click on Configure->Commands->Add command. On the filesystem it looks like this:

# cat /etc/nagios/okconfig/commands/check_snmp_process.cfg
define command {
   command_name     check_snmp_process            
   command_line     $USER1$/check_snmp_process -H $HOSTADDRESS$ -C $ARG1$ -2 -n $ARG2$ -c $ARG3$
}

Then we add a service using this command. Configure->Services->Add service.

# cat /etc/nagios/okconfig/templates/services.cfg
define service {
   use                 okc-linux-service             
   register            0                             
   name                check_atd                     
   check_command       check_snmp_process!dhMonitor!/usr/sbin/atd -f!0
   service_description Process atd
}

The service can be checked from Configure->Services->Show service templates. Enter 'atd' into the search box.

Check if /etc/nagios/okconfig/examples/linux.cfg-example exists; if not copy /usr/share/okconfig/examples/linux.cfg-example to /etc/nagios/okconfig/examples/.

Now edit /etc/nagios/okconfig/examples/linux.cfg-example from the command line using your favorite editor. In essence we just define the service above via a 'use'. Comments are there just to help us remember what the check is. Config for this:

define service {
       use                  check_atd
       host_name            HOSTNAME
       contact_groups       GROUP
       #check_command       check_snmp_process!dhMonitor!/usr/sbin/atd -f!0
       #service_description Process atd
}

Finally we can test it by adding a new host. Okconfig->Add host. Ensure Template 'Standard linux checks' is selected.

Note that when adding a host a copy is made of the example template.

If you subsequently update the template its not reflected in existing hosts. To do that you will need to add the service to the host/s. You can do this via the gui Okconfig->Add service, select the host and add the service. If you have lots of hosts to update, you can use the command line (or script it) using okconfig command:

# okconfig addservice host_name=somehost use=check_atd