| Forum Home > Monitoring Tools > NAGIOS Configuration on Ubuntu | ||
|---|---|---|
|
Site Owner Posts: 83 |
There are several different configuration files that you're going to needto create or edit before you start monitoring anything. Sample Configuration File A sample main configuration file (/usr/local/nagios/etc/nagios.cfg) is installed Config File Location The main configuration file is usually named nagios.cfgand located in the /usr/local/nagios/etc/directory. Configuration File Variables Below you will finddescriptions of each main Nagios configuration file option... Log File
Format: log_file= Example: log_file=/usr/local/nagios/var/nagios.log This variablespecifies where Nagios should create its main log file. This shouldbe the first variable that you define in your configuration file, asNagios will try to write errors that it finds in the rest of yourconfiguration data to this file. Object Configuration File
Format: cfg_file= Example: cfg_file=/usr/local/nagios/etc/hosts.cfg cfg_file=/usr/local/nagios/etc/services.cfg cfg_file=/usr/local/nagios/etc/commands.cfg This directive isused to specify an object configuration file containing objectdefinitions that Nagios should use for monitoring. Objectconfiguration files contain definitions for hosts, host groups,contacts, contact groups, services, commands, etc. You can seperateyour configuration information into several files and specifymultiple cfg_file=statements to have each of them processed. Object Configuration Directory
Format: cfg_dir= Example: cfg_dir=/usr/local/nagios/etc/commands cfg_dir=/usr/local/nagios/etc/services cfg_dir=/usr/local/nagios/etc/hosts This directive isused to specify a directory which contains object configuration filesthat Nagios should use for monitoring. All files in the directorywith a .cfgextension are processed as object config files. Additionally, Nagioswill recursively process all config files in subdirectories of thedirectory you specify here. You can seperate your configuration filesinto different directories and specify multiple cfg_dir=statements to have all config files in each directory processed. Adding A New Host:
Create any directory mkdir/usr/local/nagios/etc/config
Createa file: sudo vi/usr/local/nagios/etc/config/hosts.cfg
And,add following lines per host: definehost{ use linux-server host_name jumbo01 alias jumbo01 address 192.168.1.134 contact_groups admins } Now edit your main config file to tell it the location of the new configfile: sudo vi /usr/local/nagios/etc/nagios.cfg
Add thefollowing line to the file cfg_dir=/usr/local/nagios/etc/config
Nowrestart your nagios daemon: sudo /etc/init.d/nagios restart
definehost Here we define a new host: use:We use Linux-Server because its the easiest template to use, more onthis later host_name:This is the host name, this is how you reference your hosts settings,it doesn’t have to be its address just something meaningful relatedto the host alias:This is the long name for the host, this is only used for displaypurposes address:This is important, its the actual address for the host, either a DNSname or IP address will work here. Adding A New Service Create a new file sudo vi/usr/local/nagios/etc/config/services.cfg
And add followinglines for each service: defineservice{ use generic-service host_name jumbo01 service_description check_nimbus normal_check_interval 1 retry_check_interval 1 contact_groups admins notifications_enabled 1 notification_interval 960 notification_period 24x7 notification_options w,u,c,r check_command check_nimbus_jumbo01 } defineservice This is were we define the services on each host, forgoogle we are only going to check if its alive(ping) and check to seeif its web server is running (http). We need to two services forthis, however the settings are the same for each: useThis is the service template, use generic-serivce is the standardtemplate. host_nameThis is where we reference what host we want the service connectedto, use the name of the host defined earlier. service_descriptionThis is the name the user will see on thenagios web page check_commandThis is the command we are going to run to test if the service isrunning, more on commands later. So whatabout the nagios.cfg, why did we add that line to it, well as wecreated a new cfg file we need to tell nagios about it, you caneither have one massive file for each host or make a new file foreach one, however if you make a new file for each one you have to addit to the nagios.cfg. Add Command Definition Create a new file and add following lines per command: sudo vi/usr/local/nagios/etc/config/command.cfg definecommand { command_name check_supervisor_jumbo01 command_line $USER1$/check_jumbo jumbo01 supervisor }
WritePlugin: Writethe plugin as per your requirement and save it in/usr/local/nagios/libexec directory.
Restart Nagios: sudo /etc/init.d/nagios restart Enjoy!
If youget any errors when restarting run the following command to check forproblems with your config files sudo/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg __________________________________________________________________________
Configurationfor Email Notifications: If you want to receive email notifications for Nagios alerts, you need to installthe mailx (Postfix) package.
sudo apt-get install mailx
sudo apt-get install postfix
You'll have to editthe Nagios email notification commands found in/usr/local/nagios/etc/objects/commands.cfgand change any '/bin/mail' references to '/usr/bin/mail'. Once you dothat you'll need to restart Nagios to make the configuration changeslive.
sudo /etc/init.d/nagios restart
| |
| ||