Skip to main content

Setup/Configuration Nagios XI on Centos6.6

Nagios monitors your entire IT infrastructure to ensure systems, applications, services, and business processes are functioning properly. In the event of a failure, Nagios can alert technical staff of the problem, allowing them to begin remediation processes before outages affect business processes, end-users, or customers.

Installation Nagios XI

Installation for Nagios for most of the cases is quite staight forward.
tar xzf xi*.tar.gz
cd nagiosxi
./fullinstall
And the script will do all the hardward and we are done.
Once install is complete, visit the URL displayed to complete the install
Running Full Install
Running full install
Installation Complete
Installation Complete
Initial Configuration
Initial configuration done

Configuration

Checking if NRDS is working fine.

Go to the URL http://nagios-server/nrdp on the nagios server. [NRDP - Nagios Remote Data processor.]
submit a query
This is the response from the server.
Response
These submitted parameters will show up in the Unconfigured Objects page, which can be added directly.
Unconfigured Objects

Creating an inbound configuration.

For servers to send-in their monitoring data, we need to create tokens so that the servers can authenticate themself.

Creating inbound config.

NRDP Configuration
Inbound NRDP Configuration
NSCA Configuration (Optional - Only if you are using this - Not recommended to use this as this is very old and not very reliable)
Inbound NSCA Configuration

Creating NRDP Configuration for Windows and Linux.

Creating Config for Linux
Config for Linux
Selecting Token and add config name
setting up info
Configuration Complete
Config Complete
Now we are ready to setup the Clients.
Once the client starts sending results, if the host/service has not been configured yet it will be found in Unconfigured Objects and can easily be added to the monitoring config.

Monitoring using NRDS on Linux.

Config Complete
The following commands can be run as root on all clients that will use the new_linux_config config.
The install process will perform the following operations:
  • Install NRDS client
  • Add a nagios user and group
  • Add cron job to process checks
  • Download plugins from the NRDP server
There are 2 items you need to modify below, HOSTNAME and INTERVAL.
  • HOSTNAME - The name the client will send to the Nagios server as the host.
  • INTERVAL - The frequency in minutes that you want the checks to be run. (1-59)
Below are the commands.
cd /tmp
Get the tar file from the server.
wget -O new_linux_config.tar.gz "http:///nrdp/?cmd=nrdsgetclient&token=hardtoguess&configname=new_linux_config"
Unzip and install.
gunzip -c new_linux_config.tar.gz | tar xf -
cd clients
./installnrds [HOSTNAME] [INTERVAL_IN_MINUTES]
Command
./installnrds linux-server 5
This install the client and setup a crontab to send the parameters to the server.
When the client linux-server sends the data you will see the details on the Unconfigured Objects page.
Select the parameters and add it to the nagios monitoring.
It would look similar to the page below.
nrds_testing

Monitoring using NRDS on windows.

Download the executable from the link in the image
Config Complete
Agreement
Agreement
Configure Server Name and Interval to send the data
Config
Create ini file and and setup scheduler task
ini file
Install
Install
Once the client starts sending results, if the host/service has not been configured yet it will be found in Unconfigured Objects and can easily be added to the monitoring config. Example below.
testing
Select the parameters and add it to the nagios monitoring.
It would look similar to the page below.

Creating Groups for user to monitor specific servers.

Below are the steps to create a user groups.
  1. Create a contact file in /usr/local/nagios/etc/static
  2. Create a contactgroup file in /usr/local/nagios/etc/static
  3. Create a host file which binds the contact group.
  4. And restart nagios service.
What are we trying to do.
  1. On the nagios server we have 2 server which we monitor, A linux server and a windows server.
  2. We want to make sure that the windows server is monitored by the windows admin team.
  3. We will create a group and a user which can only see window server on the monitoring console.
  4. This will help create set of groups, who can monitor only their servers which they are responsible for.
Location of all the files on the server.
┌─[zahmed][localhost][~]
└─▪ cd /usr/local/nagios/etc/
┌─[zahmed][localhost][/usr/local/nagios/etc]
└─▪ ls
cgi.cfg               hosttemplates.cfg  servicedependencies.cfg
commands.cfg          import             serviceescalations.cfg
contactgroups.cfg     nagios.cfg         serviceextinfo.cfg
contacts.cfg          ndo2db.cfg         servicegroups.cfg
contacttemplates.cfg  ndomod.cfg         services
hostdependencies.cfg  nrpe.cfg           servicetemplates.cfg
hostescalations.cfg   nsca.cfg           static
hostextinfo.cfg       pnp                timeperiods.cfg
hostgroups.cfg        resource.cfg
hosts                 send_nsca.cfg
┌─[zahmed][localhost][/usr/local/nagios/etc]
└─▪
Creating a contact with windowsnagiosadmin user.
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪ cat windows-server-contact.cfg
define contact {
        contact_name                            windowsnagiosadmin
        alias                                   Windows Nagios Administrator
        host_notification_period                nagiosadmin_notification_times
        service_notification_period             nagiosadmin_notification_times
        host_notification_options               d,u,r,f,s
        service_notification_options            w,u,c,r,f,s
        host_notification_commands              xi_host_notification_handler
        service_notification_commands           xi_service_notification_handler
        email                                   ahmed@gmail.com
        #use                                     xi_contact_generic
}
Create a contactgroup and add the above windowsnagiosadmin user as a member.
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪ cat windows-server-contactgroup.cfg
define contactgroup {
    contactgroup_name                   windowsadmins
    alias                               Windows Nagios Admin Group
    members                             windowsnagiosadmin
}
Now finally create a host configuration which is tied to the windowsadmins contact group above.
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪ cat nagios-test-windows.cfg
define host {
        host_name                       nagios-test-wındows
        use                             xiwizard_passive_host
        address                         nagios-test-wındows
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        check_period                    xi_timeperiod_24x7
        contact_groups                 windowsadmins
        notification_interval           60
        notification_period             xi_timeperiod_24x7
        stalking_options                n
        icon_image                      passiveobject.png
        statusmap_image                 passiveobject.png
        _xiwizard                       passiveobject
        register                        1
        }
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪
Files in static directory.
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪ ls -l
total 24
-rwxrwxr-x 1 apache nagios  661 Aug 12 11:27 windows-server-contact.cfg
-rwxrwxr-x 1 apache nagios  211 Aug 12 11:57 windows-server-contactgroup.cfg
-rwxrwxr-x 1 apache nagios  802 Aug 12 11:39 nagios-test-windows.cfg
-rwxrwxr-x 1 apache nagios  878 Jun 14 20:43 xiobjects.cfg
-rwxrwxr-x 1 apache nagios 4002 Jun 14 20:43 xitemplates.cfg
-rwxrwxr-x 1 apache nagios    0 Jun 14 20:43 xitest.cfg
-rwxr-xr-x 1 root   nagios  649 Aug 12 11:59 zahmedcontact.cfg
Check Nagios config.
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪ sudo service nagios checkconfig
[sudo] password for zahmed:
Running configuration check...
 OK.
All OK, then restart nagios
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪ sudo service nagios restart
Running configuration check...
Stopping nagios:. done.
Starting nagios: done.
Finally create a user on nagios which matches our configuration windowsnagiosadmin.
Creating a windowsnagiosadmin user.
windows_user
Host when we login as nagiosadmin
login
Hosts when we login as windowsnagiosadmin
loggedin

Installation and Configuring NSClient++ for Windows.

Download and install NSClient++ on the windows server. https://nsclient.org/download/
First Installing NSClient++
install
Configure NSClient
Update the allowed_hosts and password. And make sure to use check_nt
config
Install Complete
complete
Check service is running
service check

Configuring on the nagios server.

We need to create couple of configurations for the first time a windows machine is setup. After that all we have to do is add the hosts configuration. Everything else will be the same. (Unless we change the password on few of the windows machine then we have to update / create new command configuration)
  1. Create a host configuration.
  2. Add services configuration which will define what we want to monitor.
  3. Create a command configuration.
First lets create a file new-windows-test.cfg in /usr/local/nagios/etc/static directory.
We will be adding the host and service configuration into the same file.
NOTE : check_command in the service definitions should be same as the command_name in commands configuration. Example: check_nt_test
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪ cat new-windows-test.cfg
define host{
    use                    windows-server    ; Inherit default values from a Windows server template (make sure you keep this line!)
    host_name            winservertest
    alias                My Windows Server
    address                172.2.2.35
    max_check_attempts  10
    check_interval      5
    retry_interval      1
    check_period        24x7
    contacts            nagiosadmin
    notification_interval   30
    notification_period     24x7
    notification_options    d,r
    register                1
    }

define service{
    use                    generic-service
    host_name            winserver
    service_description    NSClient++ Version
    check_command        check_nt_test!CLIENTVERSION
    }

define service{
    use                    generic-service
    host_name            winserver
    service_description    Uptime
    check_command        check_nt_test!UPTIME
    }

define service{
    use                    generic-service
    host_name            winserver
    service_description    CPU Load
    check_command        check_nt_test!CPULOAD!-l 5,80,90
    }

define service{
    use                    generic-service
    host_name            winserver
    service_description    Memory Usage
    check_command        check_nt_test!MEMUSE!-w 80 -c 90
    }

define service{
    use                    generic-service
    host_name            winserver
    service_description    C:\ Drive Space
    check_command        check_nt_test!USEDDISKSPACE!-l c -w 80 -c 90
    }

define service{
    use                    generic-service
    host_name            winserver
    service_description    W3SVC
    check_command        check_nt_test!SERVICESTATE!-d SHOWALL -l W3SVC
    }

define service{
    use                    generic-service
    host_name            winserver
    service_description    Explorer
    check_command        check_nt_test!PROCSTATE!-d SHOWALL -l Explorer.exe
    }
First lets create a file new-windows-test-command.cfg, update the password -s below with the password we created on the windows machine. [Check image above]
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪ cat new-windows-test-command.cfg
define command{
        command_name    check_nt_test
        command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s nagios123 -v $ARG1$ $ARG2$
        }
After we have configured new files.
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪ ls -l new*
-rw-r--r-- 1 apache nagios 1301 Aug 15 11:07 new-windows-test.cfg
-rw-r--r-- 1 apache nagios  134 Aug 15 10:57 new-windows-test-command.cfg
Check if our configuration is fine.
┌─[zahmed][localhost][/usr/local/nagios/etc/static]
└─▪ sudo service nagios checkconfig
[sudo] password for zahmed:
Running configuration check...
 OK.
Great!!, we have not errors, now we can restart nagios.
┌─[zahmed][localhost][/usr/local/nagios/etc]
└─▪ sudo service nagios restart
Running configuration check...
Stopping nagios:. done.
Starting nagios: done.
Restart complete and we are done.

Checking the new host on the dashboard.

New host winservertest is added to the dashboard.
service check
We are receiving monitoring data as well.
service check
Performance data.
service check

Comments

Post a Comment

Popular posts from this blog

Zabbix History Table Clean Up

Zabbix history table gets really big, and if you are in a situation where you want to clean it up. Then we can do so, using the below steps. Stop zabbix server. Take table backup - just in case. Create a temporary table. Update the temporary table with data required, upto a specific date using epoch . Move old table to a different table name. Move updated (new temporary) table to original table which needs to be cleaned-up. Drop the old table. (Optional) Restart Zabbix Since this is not offical procedure, but it has worked for me so use it at your own risk. Here is another post which will help is reducing the size of history tables - http://zabbixzone.com/zabbix/history-and-trends/ Zabbix Version : Zabbix v2.4 Make sure MySql 5.1 is set with InnoDB as innodb_file_per_table=ON Step 1 Stop the Zabbix server sudo service zabbix-server stop Script. echo "------------------------------------------" echo " 1. Stopping Zabbix Server ...

Installing Zabbix Version 2.4 Offline (Zabbix Server without Internet).

There might be situations where you have a remote/zabbix server which does not have internet connectivity, due to security or other reasons. So we create a custom repo on the remote/zabbix server so that we can install zabbix using rpms Here is how we are planning to do this. Download all the dependency rpms on a machine which has internet connection, using yum-downloadonly or repotrack . Transfer all the rpms to the remote server. Create a repo on the remote server. Update yum configuration. Install. NOTE: This method can be used to install any application, but here we have used zabbix as we had this requirement for a zabbix server. Download dependent rpms . On a machine which has internet connection install the package below. And download all the rpms . Make sure the system are similar (not required to be identical - At-least the OS should be of same version) mkdir /zabbix_rpms yum install yum-downloadonly Downloading all the rpms to location /zabbix_rpms/ ,...

Access Filter in SSSD `ldap_access_filter` [SSSD Access denied / Permission denied ]

Access Filter Setup with SSSD ldap_access_filter (string) If using access_provider = ldap , this option is mandatory. It specifies an LDAP search filter criteria that must be met for the user to be granted access on this host. If access_provider = ldap and this option is not set, it will result in all users being denied access. Use access_provider = allow to change this default behaviour. Example: access_provider = ldap ldap_access_filter = memberOf=cn=allowed_user_groups,ou=Groups,dc=example,dc=com Prerequisites yum install sssd Single LDAP Group Under domain/default in /etc/sssd/sssd.conf add: access_provider = ldap ldap_access_filter = memberOf=cn=Group Name,ou=Groups,dc=example,dc=com Multiple LDAP Groups Under domain/default in /etc/sssd/sssd.conf add: access_provider = ldap ldap_access_filter = (|(memberOf=cn=System Adminstrators,ou=Groups,dc=example,dc=com)(memberOf=cn=Database Users,ou=Groups,dc=example,dc=com)) ldap_access_filter accepts standa...