Page 1 of 1

Reconfigure Nagios Files

Posted: Tue Mar 22, 2016 8:56 am
by nathanplatt
HI Guys,

I already have a fully working version of Nagios Core 4.1.1 and configured the way I saw best from a DIY stand point. I recently purchased for myself a copy of the Student Edition to learn more about the more advance features in Nagios, and found the layout and the way it creates the Hosts much more visiable. I want to change how my current Nagios views hosts and need some help.

Currently I have a very simple structure.

Code: Select all

root@nagios:/usr/local/nagios# tree
├── bin
│   ├── nagios
│   └── nagiostats
├── etc
│   ├── cgi.cfg
│   ├── cgi.cfg~
│   ├── htpasswd.users
│   ├── nagios.cfg
│   ├── nagios.cfg~
│   ├── objects
│   │   ├── commands.cfg
│   │   ├── commands.cfg.save
│   │   ├── contacts.cfg
│   │   ├── localhost.cfg
│   │   ├── printer.cfg
│   │   ├── switch.cfg
│   │   ├── templates.cfg
│   │   ├── timeperiods.cfg
│   │   ├── windows
│   │   └── windows.cfg
│   ├── resource.cfg
│   └── resource.cfg~
├── include
├── libexec
│   ├── check_apt
│   ├── check_breeze
│   ├── check_by_ssh
│   ├── check_clamd -> check_tcp
│   ├── check_cluster
│   ├── check_dhcp
│   ├── check_dig
│   ├── check_disk
│   ├── check_disk_smb
│   ├── check_dns
│   ├── check_dummy
│   ├── check_file_age
│   ├── check_flexlm
│   ├── check_ftp -> check_tcp
│   ├── check_http
│   ├── check_icmp
│   ├── check_ide_smart
│   ├── check_ifoperstatus
│   ├── check_ifstatus
│   ├── check_imap -> check_tcp
│   ├── check_ircd
│   ├── check_jabber -> check_tcp
│   ├── check_load
│   ├── check_log
│   ├── check_mailq
│   ├── check_mrtg
│   ├── check_mrtgtraf
│   ├── check_nagios
│   ├── check-netapp-ng.pl
│   ├── check_nntp -> check_tcp
│   ├── check_nntps -> check_tcp
│   ├── check_nt
│   ├── check_ntp
│   ├── check_ntp_peer
│   ├── check_ntp_time
│   ├── check_nwstat
│   ├── check_oracle
│   ├── check_overcr
│   ├── check_ping
│   ├── check_pop -> check_tcp
│   ├── check_procs
│   ├── check_real
│   ├── check_rpc
│   ├── check_sensors
│   ├── check_simap -> check_tcp
│   ├── check_smtp
│   ├── check_snmp_printer
│   ├── check_spop -> check_tcp
│   ├── check_ssh
│   ├── check_ssmtp -> check_tcp
│   ├── check_swap
│   ├── check_tcp
│   ├── check_time
│   ├── check_udp -> check_tcp
│   ├── check_ups
│   ├── check_uptime
│   ├── check_users
│   ├── check_wave
│   ├── eventhandlers
│   │   ├── error.log
│   │   ├── host_notify_otrs.sh
│   │   ├── host_otrs_event_ok.sh
│   │   ├── notify_otrs.sh
│   │   └── otrs_event_ok.sh
│   ├── nagios_send_host_mail.pl
│   ├── nagios_send_service_mail.pl
│   ├── negate
│   ├── urlize
│   ├── utils.pm
│   └── utils.sh
I notice on my VM it uses a HOST Folder with individual host files, is this easy enough to change to?

Re: Reconfigure Nagios Files

Posted: Tue Mar 22, 2016 9:28 am
by rhassing
In your nagios.conf file there should be a pointer to the hosts.cfg file.
This could be changed in the nagios.conf file to look in a directory.

Code: Select all

cfg_dir=/etc/nagios/hosts
cfg_dir=/etc/nagios/services

Re: Reconfigure Nagios Files

Posted: Tue Mar 22, 2016 9:40 am
by nathanplatt
And then i can just do 1 file for each Host and a Services file for each service or a service file for all, does it just scan the folder for *.cfg and processes them?

Re: Reconfigure Nagios Files

Posted: Tue Mar 22, 2016 9:54 am
by rhassing
That's correct. Just make .cfg files in those directories and it should work. (please make sure the path is correct).

Re: Reconfigure Nagios Files

Posted: Tue Mar 22, 2016 1:59 pm
by bwallace
Thanks again rhassing!
OP, keep us posted.

Re: Reconfigure Nagios Files

Posted: Wed Mar 23, 2016 8:16 am
by nathanplatt
Hi Rob,

That was perfect, thank you for all the help. Now fully reconfigured...

Is there a way for services to be attached to hostgroups rather than myself having to define the hosts in the service?
define service{
use generic-service ; Defnes the service used
host_name ACTS1,DR1,DR2,DR3,DR Mail,SQL_DR,AD1,AD3,AD4,TS1,TS1-V,TS2,TS2-V,TS3,TS3-V,TS4,TS4-V,TS5,TS5-V,TS6,TS6-V,TS7,TS7-V,TS8,etc...
service_description Check Uptime ; What is displayed in Nagios
check_command check_nt!UPTIME ; Command refered from the commands.cfg file
contact_groups admins ; Which Contact Group gets notified
}
I'll much prefer to configure it so it said

Code: Select all

define service{
        use                                  generic-service ; Defnes the service used
        host_name                       windows-servers
        service_description          Check Uptime    ; What is displayed in Nagios
        check_command               check_nt!UPTIME ; Command refered from the commands.cfg file
        contact_groups                admins                  ; Which Contact Group gets notified
        }
Is this do-able?

Re: Reconfigure Nagios Files

Posted: Wed Mar 23, 2016 1:46 pm
by lmiltchev
Yes, you can add a service to a hostgroup. For example, you have a hostgroup "HostgroupABC" with 3 hosts (members):

Code: Select all

define hostgroup {
	hostgroup_name                		HostgroupABC
	alias                         		Host Group ABC
	members                       		HostA,HostB,HostC
	}
You can add the "Check Uptime" service to this houstgroup:

Code: Select all

define service{
	use					generic-service
	hostgroup_name		HostgroupABC
	service_description	Check Uptime
	check_command 		check_nt!UPTIME
	contact_groups 		admins
	}
This way, the service will be added automatically to each host, member of HostgroupABC.

For more information on how to define objects in Nagios Core, review our documentation here:

https://assets.nagios.com/downloads/nag ... tions.html

Re: Reconfigure Nagios Files

Posted: Thu Mar 24, 2016 6:16 am
by nathanplatt
You help has been fantastic, thank you everyone I'll fully reconfigured everything.

Re: Reconfigure Nagios Files

Posted: Thu Mar 24, 2016 10:42 am
by bwallace
Glad we were able to help. We'll lock this thread now and feel free to open another should you require assistance with anything else.