Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, May 22, 2013

Nagios Server Configuration for different hosts


In our previous posts, we learn how to install nagios, how to install NRPE or NSClient++. Now let's have a look on configuring hosts in nagios in best practical way Nagios Server Configuration for different hosts.

It will be good practice if we configure the client hosts in groups on Nagios Server.
Steps to Group clients servers:
1. Create locations for host configuration files:
In our configuration, we are grouping servers in 4 main categories:
a. PROD: Production configuration file will be stored in this location.
Location: /usr/local/nagios/etc/objects/cfg-file/prod/
b. UAT: UAT configuration file will be stored in this location.
Location: /usr/local/nagios/etc/objects/cfg-file/uat/
c. STAGE: Stage configuration file will be stored in this location.
Location: /usr/local/nagios/etc/objects/cfg-file/stage/
d. DEV: Dev configuration file will be stored in this location.
Location: /usr/local/nagios/etc/objects/cfg-file/dev/
2. Place Configuration file at specific location:
  • After creating the locations for configuration files, we have to keep the configuration files at their respective location. Example: Staging configuration files will be kept in STAGE (/usr/local/nagios/etc/objects/cfg-file/stage/)
  • Now make necessary settings in configuration (.cfg) file.
3. Create group configuration file:
Create a new group configuration file to specify the host files into various groups
vi group.cfg
define hostgroup{
hostgroup_name Stage-servers ; The name of the hostgroup
alias Stage Servers ; Long name of the group
members Server-172.93, Server-172.96 ; Comma separated list of hosts that belong to this group
}
4. Make required changes in main configuration file:
After the completion of above tasks, now it’s the time to make changes in main configuration (/usr/local/nagios/etc/nagios.cfg) file.
  • Edit main nagios.cfg file using vi command (vi /usr/local/nagios/etc/nagios.cfg)
  • Add configuration path for client host configuration files:
    # Definitions for monitoring the stage (Linux) host
    cfg_file=/usr/local/nagios/etc/objects/cfg-file/stage/172.96.cfg
    cfg_file=/usr/local/nagios/etc/objects/cfg-file/stage/172.93.cfg 
  • Add group configure (group.cfg) file in main configuration file.
    #Group file for clients
    cfg_file=/usr/local/nagios/etc/objects/cfg-file/group.cfg
5. Restart the Nagios service:
In order to reflect changes, we have to restart the nagios services.
service nagios restart
If you are getting error like Running configuration check... CONFIG ERROR! Restart aborted. Check your Nagios configuration. then run this command to debug the error:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

No comments:

Post a Comment