Objects Configuration Files

Editing Files

To access the Objects file editor, click the Objects icon as show below.

../../_images/nagios-obects-tab.png

From here you can edit any existing file within the NAGIOS/obects directory.

../../_images/nagios-obect-select.png

Once you have completed any edits, click the Save and Close button and restart Nagios.

Creating a New File

You can create a new service file from a template via the editor.

Enter a new filename.cfg and click the Create button.

Give your file a name that will make it easy to identify, such as myconf.cfg

../../_images/nagios-new-cfg.png

Click the Create button.

The Create button will load the template below.

../../_images/nagios-obect-select-new.png

The template is commented.

  1. Replace all instances of <HOST> with the host you have added.
  2. Replace <IP> with the host IP
  3. Click Save and Close
  4. Restart Nagios for the new cfg to register

Template File

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
   # Host configuration file

   define host {
     use                          linux-server
     host_name                    <HOST>
     alias                         <HOST>
     address                       <IP>
     register                     1
   }

   define service {
   host_name                       <HOST>
   service_description             PING
   check_command                   check_ping!100.0,20%!500.0,60%
   max_check_attempts              2
   check_interval                  2
   retry_interval                  2
   check_period                    24x7
   check_freshness                 1
   contact_groups                  admins,slackmins
   notification_interval           2
   notification_period             24x7
   notifications_enabled           1
   register                        1
   }

   define service {
   host_name                       <HOST>
   service_description             Check SSH
   check_command                   check_ssh!-p 3838
   max_check_attempts              2
   check_interval                  2
   retry_interval                  2
   check_period                    24x7
   check_freshness                 1
   contact_groups                  admins
   notification_interval           2
   notification_period             24x7
   notifications_enabled           1
   register                        1
   }

   define service {
   host_name                       <HOST>
   service_description             Check HTTP
   check_command                   check_http
   max_check_attempts              2
   check_interval                  2
   retry_interval                  2
   check_period                    24x7
   check_freshness                 1
   contact_groups                  admins
   notification_interval           2
   notification_period             24x7
   notifications_enabled           1
   register                        1
   }

Note

To create your own template, simply update the template.cfg located at /usr/share/webmin/nagios.

Restart Nagios

For the new cfg to register, you must restart Nagios.

This can be done via Servers > Nagios in your control panel.

It can also be done via command line using:

systemctl restart nagios.service

Edit Conf

To edit a Conf File you have created, simply select the conf file from the drop down.

Make the required edits and click Save.

Conf Location

By default, all conf files are saved to /usr/local/nagios/obejcts/