Real-world monitoring of Linux system resources using NagiosNSCA-Nagios configuration-NagiosServer

Source: Internet
Author: User

Real-world monitoring of Linux system resources using NagiosNSCA-Nagios configuration-NagiosServer
There have been many good summaries about the nrpe method on the Internet. I am now talking about how to use the NSCA method in our system to obtain the resource usage information of the monitored node we need.
Let's talk about the basic configuration of Nagios Server:

1. nagios web gui access configuration. The system uses the recommended configuration method in nagios core to access nagios web through apache httpd. When nagios is installed, the system will automatically find the httpd installed in the system, put the httpd file of nagios into the conf file of httpd. d directory. In this way, you can use http: // localhost/nagios/to access the nagios web by generating a password for one nagios web access.

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
2. Add the machine to be monitored and the service to be monitored 2.1/usr/local/nagios/etc/nagios. cfg: add the object configuration FILEs to be configured
cfg_file=/usr/local/nagios/etc/objects/localhost.cfgcfg_file=/usr/local/nagios/etc/objects/system_1.cfg
cfg_file=/usr/local/nagios/etc/objects/system_2.cfg 
......
nagios_user=nagios
nagios_group=nagios
lock_file=/usr/local/nagios/var/nagios.lock
status_update_interval=10
2. 2 Add the services to be listened on to the monitored node, for example:/usr/local/nagios/etc/objects/system_1.cfg
## define hosts
# system_1 oam_1define host{        use                     linux-server,host-pnp        host_name               system_1_oam_1        address                 <ip>contact_groupssystem_1_admins,systems_admins        }......# system_1 traffic_1define host{        use                     linux-server,host-pnp        host_name               system_1_traffic_1        address                 <ip>contact_groupssystem_1_admins,systems_admins        }...... 
## define services
# system_1 oam_1define service{        use                      passive_service,srv-pnp        service_description      CPU_Status        host_name                system_1_oam_1contact_groups system_1_admins,systems_admins        }define service{        use                      passive_service,srv-pnp        service_description      Memory_Status        host_name                system_1_oam_1contact_groups system_1_admins,systems_admins        }......# system_1 traffic_1define service{        use                      passive_service,srv-pnp        service_description      CPU_Status        host_name                system_1_traffic_1contact_groups system_1_admins,systems_admins        }
Note:
Host-pnp and srv-pnp are the configurations used by pnp4nagios. Other configurations of pnp4nagios will be introduced later.
3. Add System Monitoring administrators to different systems
3.1/usr/local/nagios/etc/objects/contactgroups. cfg
define contactgroup{        contactgroup_name       system_1_admins        alias                   system_1_admins        members                 oam-1,traffic-1        }......
3.2/usr/local/nagios/etc/objects/contacts. cfg
define contact{        contact_name                    oam-1                  ; Short name of user        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)        alias                           oam-1                  ; Full name of user        service_notification_options    c                              host_notification_options       d        email                           nobody@localhost.com   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******        }define contact{        contact_name                    traffic-1           ; Short name of user        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)        alias                           traffic-1           ; Full name of user        email                           nobody@localhost.com  ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******        }...... 
Note:
Service_icationication_options: This directive is used to define the service states for which communications can be sent out to this contact. valid options are a combination of one or more of the following: w = running y on WARNING service states, u = running y on UNKNOWN service states, c = running y on CRITICAL service states, r = Policy on service recoveries (OK states), and f = policy when the service starts and stopsflapping. if you specify n (none) as an option, the contact will not receive any type of service specifications.
Host_icationication_options: This directive is used to define the host states for which configurations can be sent out to this contact. Valid options are a combination of one or more of the following: D= Running y on DOWN host states, U= Policy on UNREACHABLE host states, R= Policy on host recoveries (UP states ), F= Notify when the host starts and stopsflapping, and S= Send notifications when host or servicescheduled downtime starts and ends. If you specify N(None) as an option, the contact will not receive any type of host communications.
4. If NSCA has no problems such as port conflict, use the default configuration directly.
5. Check that the host and service added in Nagios GUI already exist and the status is UNKNOWN.
6. added the pnp4nagios bulk + npcd mode listening system.
6.1 Modify/usr/local/nagios/etc/nagios. cfg
# Processing performance data process_performance_data = 1 # host_perfdata_command = process-host-perfdata # service_perfdata_command = process-service-perfdata # performance data storage file volumes =/usr/local/pnp4nagios/var/host-perfdataservice_perfdata_file =/usr/local/pnp4nagios/var/service-perfdata # performance data storage format host_perfdata_file_template = DATATYPE:: HOSTPERFDATA \ tTIMET: $ TIMET $ \ tHOSTNAME ::$ HOSTNAME $ \ tHOSTPERFDATA ::$ HOSTPERFDATA $ \ tHOSTCHECKCOMMAND :$ HOSTCHECKCOMMAND $ \ tHOSTSTATE ::$ HOSTSTATE $ \ tHOSTSTATETYPE:: $ HOSTSTATETYPE $ service_perfdata_file_template = DATATYPE: SERVICEPERFDATA \ tTIMET ::$ TIMET $ \ tHOSTNAME ::$ HOSTNAME $ \ tSERVICEDESC ::$ SERVICEDESC $ \ tSERVICEPERFDATA :: $ SERVICEPERFDATA $ \ tSERVICECHECKCOMMAND: $ SERVICECHECKCOMMAND $ \ tHOSTSTATE: $ HOSTSTATE $ \ tHOSTSTATETYPE ::$ HOSTSTATETYPE $ \ tSERVICESTATE: $ SERVICESTATE $ \ tSERVICESTATETYPE :: $ SERVICESTATETYPE $ \ tSERVICEOUTPUT :: $ SERVICEOUTPUT $ # performance File Storage Method host_perfdata_file_mode = aservice_perfdata_file_mode = a # performance File Processing Interval Duration = milliseconds = 15 <pre name = "code" class = "plain"> # performance File processing Command
Host_perfdata_file_processing_command = process-host-perfdata-fileservice_perfdata_file_processing_command = process-service-perfdata-file
6.2 Modify/usr/local/nagios/etc/objects/commands. cfg and add the performance File Processing Command 
define command{       command_name    process-service-perfdata-file       command_line    /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$}define command{       command_name    process-host-perfdata-file       command_line    /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$}
6.3 modify nagios. cfg and set how to display the pnp4nagios icon in the nagios web gui.

The first method is to add the following content to templates. cfg. The image data can only be opened in a new window.

define host {  name       host-pnp  action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_  register   0 }define service {  name       srv-pnp  action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$  register   0 } 

The second method can be used to open the Real-Time icon when you move the mouse over the pnp4nagios icon. However, the effect is not very good. Follow the instructions to add the following:

Copy the status-header.ssi to the/usr/local/nagios/share/ssi/directory and modify templates. cfg to add the following content:

define host {     name       host-pnp     action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_     register   0 }define service {     name       srv-pnp     action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$     register   0 } 

Note: The definition of small windows that appear automatically is not clear. I like the first method.

Note: The email configuration is not involved here. Remember to be careful when designing the notification...

Article 1: Introduction to Nagios

Article 3: Nagios monitored Client configuration and script implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.