Nagios (centreon) monitors Linux logs
1. Download check_log3.pl and put it in the plug-in folder [root @ SSAVL2475 libexec] # cp/tmp/check_log3.pl/usr/local/nagios/libexec 2 to add execution permissions # chmod + x check_log3.pl [root @ SSAVL2475 libexec] # chmod + x check_log3.pl 3 modify owner # chown nagios. nagios check_log3.pl [root @ SSAVL2475 libexec] # chown nagios. nagios check_log3.pl 4 run check_log3.pl to confirm that it is executable. No error is reported. If the pm file is missing, install check_linux_stats.pl before installing the corresponding perl module. No error is reported here [root @ SSAVL2475 l Ibexec] #./check_log3.pl-h [root @ SSAVL2475 libexec] #./check_log3.pl-hThis is check_log3.pl version 3.11b ....... 5. Test the monitoring message. The following command scans the line with the keyword "Error" or "error" in messages. If multiple keywords exist, use '|' to separate check_log3 and put it in/usr/local/nagios/libexec: root run directly. No problem. [root @ SSAVL2475 libexec] #/usr/local/nagios/libexec/check_log3.pl-l/var/log/messages-p' [Ee] rror '-n nrpeOK: 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 nrpeUnable to open'/var/log/messages ': in Permission denied/etc/sudoers, you need to make the following settings: [root @ SSAVL2475 libexec] # mongodo # zhailiangDefaults requirettynagios 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 nrpeOK: Found 0 lines (limit = 1/0): No matches found. | lines = 0 [root @ SSAVL2475 libexec] #. /check_nrpe-H 127.0.0.1-c check_logOK: 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 nrpeOK: Found 0 lines (limit = 1/0): No matches found. | lines = 0 6 Add nrpe after the test is correct. export 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 and test the check_nrpe command from poller: [root @ SSAVL2521 plugins] #. /check_nrpe-H 10.90.27.8-c check_logOK: Found 0 lines (li Mit = 1/0): No matches found. | lines = 0 [root @ SSAVL2521 plugins] # The result is verified to be normal 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 and introduction: https://exchange.nagios.org/directory/Plugins/Log-Files/check_log3-2Epl/details