Reconfigure Nagios Files

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Reconfigure Nagios Files

Post 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?
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: Reconfigure Nagios Files

Post 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
Rob Hassing
Image
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Reconfigure Nagios Files

Post 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?
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: Reconfigure Nagios Files

Post by rhassing »

That's correct. Just make .cfg files in those directories and it should work. (please make sure the path is correct).
Rob Hassing
Image
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Reconfigure Nagios Files

Post by bwallace »

Thanks again rhassing!
OP, keep us posted.
Be sure to check out the Knowledgebase for helpful articles and solutions!
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Reconfigure Nagios Files

Post 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?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Reconfigure Nagios Files

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Reconfigure Nagios Files

Post by nathanplatt »

You help has been fantastic, thank you everyone I'll fully reconfigured everything.
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Reconfigure Nagios Files

Post 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.
Be sure to check out the Knowledgebase for helpful articles and solutions!
Locked