Nagios (centreon) monitors Linux logs
1. Download check_log3.pl and put it in the plug-in folder of the client server.
[Root @ SSAVL2475 libexec] # cp/tmp/check_log3.pl/usr/local/nagios/libexec
2. Add execution permission # chmod + x check_log3.pl
[Root @ SSAVL2475 libexec] # chmod + x check_log3.pl
3. Modify the owner # chown nagios. nagios check_log3.pl
[Root @ SSAVL2475 libexec] # chown nagios. nagios check_log3.pl
4. Run check_log3.pl to check whether the task is executable. If the pm file is missing, install the corresponding perl module.
Check_linux_stats.pl has been installed before. No error is reported here.
[Root @ SSAVL2475 libexec] #./check_log3.pl-h
[Root @ SSAVL2475 libexec] #./check_log3.pl-h
This is check_log3.pl version 3.11b
.......
5. Test the monitoring message. The following command is a line that scans the Error or error keywords in messages. Multiple keywords are separated by '| '.
Put check_log3 in/usr/local/nagios/libexec:
Root runs directly. No problem.
[Root @ SSAVL2475 libexec] #/usr/local/nagios/libexec/check_log3.pl-l/var/log/messages-p '[Ee] rror'-n nrpe
OK: Found 0 lines (limit = 1/0): No matches found. | lines = 0
[Root @ SSAVL2475 libexec] #
However, the following error occurs in sudo-u nagios:
Sudo-u nagios/usr/local/nagios/libexec/check_log3.pl-l/var/log/messages-p '[Ee] rror'-n nrpe
[Root @ SSAVL2475 libexec] # sudo-u nagios/usr/local/nagios/libexec/check_log3.pl-l/var/log/messages-p' [Ee] rror '-n nrpe
Unable to open '/var/log/messages': Permission denied
The following settings must be made in/etc/sudoers:
[Root @ SSAVL2475 libexec] # mongodo
# Zhailiang
Defaults requiretty
Nagios ALL = (ALL) NOPASSWD:/usr/local/nagios/libexec/check_log3.pl
Test:
[Nagios @ SSAVL2475 libexec] $ sudo./check_log3.pl-l/var/log/messages-p '[Ee] rror'-n nrpe
OK: Found 0 lines (limit = 1/0): No matches found. | lines = 0
[Root @ SSAVL2475 libexec] #./check_nrpe-H 127.0.0.1-c check_log
OK: Found 0 lines (limit = 1/0): No matches found. | lines = 0
[Nagios @ SSAVL2475 ~] $ Sudo/usr/local/nagios/libexec/check_log3.pl-l/var/log/messages-p '[Ee] rror'-n nrpe
OK: Found 0 lines (limit = 1/0): No matches found. | lines = 0
6. Add nrpe. cfg after the test is correct.
Command [check_log] =/usr/bin/sudo/usr/local/nagios/libexec/check_log3.pl-l/var/log/messages-p' [Ee] rror '-n nrpe
7. Restart xinetd
8 test the check_nrpe command from poller:
[Root @ SSAVL2521 plugins] #./check_nrpe-H 10.90.27.8-c check_log
OK: Found 0 lines (limit = 1/0): No matches found. | lines = 0
[Root @ SSAVL2521 plugins] #
The result is verified normally and can be operated on the centreon console.
9. added the centreon service monitoring template to add log monitoring to related servers.
This script can monitor various other application logs. If you are interested, you can perform further research.
Check_log3.pl script:
Https://exchange.nagios.org/directory/Plugins/Log-Files/check_log3-2Epl/details
-------------------------------------- Split line --------------------------------------
Configure Mrtg in Ubuntu to monitor Nginx and server system resources
Use snmp + Mrtg to monitor Linux systems
Mrtg server construction (Network Traffic Monitoring)
Network Monitor Nagios Overview
Nagios construction and Configuration
Build a Nagios monitoring platform in the Nginx Environment
Configure the basic Nagios System on RHEL5.3 (using Nagios-3.1.2)
CentOS 5.5 + Nginx + Nagios monitoring and control terminal installation and Configuration Guide
Install Nagios Core for Ubuntu 13.10 Server
-------------------------------------- Split line --------------------------------------
Nagios details: click here
Nagios: click here
This article permanently updates the link address: