This is a tool for reading and parsing NGINX log files and using them in the Nagios monitoring software.
The script is messy, but it has worked for me for some time now.
-h --help Show usage (what you're reading right now)
--logdir=/var/log/nginx The location of logfiles
--last_run_location=/tmp/nagios_nginx_log_last_run The location where a file containing the last (unix epoch) time this script was run will be stored
--warning_percentage=3 The percentage of 5xx errors that wil result in a WARNING
--critical_percentage=10 The percentage of 5xx errors that will result in a CRITICAL
Although the script itself is written in bash, some requirements (may) need to be installed.
- bc: Used for floating point calculations (percentages)
In addition, the user running the script will need write access to last_run_location and (the files located in) logdir.
Clone the repository to a directory that is readable and executable by the user running Nagios/NRPE.
Create a symlink for check-nginx-log to the directory that contains Nagios plugins.
Add check-nginx-log to your Nagios and/or NRPE configuration.
WARNING - 3.91330523780854906600% of requests failing with HTTP 5xx! | 2xx: 71.42283764800321091700%, 4xx: 24.66385711418824001600%
OK | 2xx: 50.00000000000000000000%, 4xx: 50.00000000000000000000%, 5xx: 0%