Created
November 14, 2014 22:21
-
-
Save shichao-an/3005433d5ad4ee2f6936 to your computer and use it in GitHub Desktop.
NRPE plugin script to check Nginx proxy_pass upstream timeout error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script checks nginx error log for "upstream timed out" events | |
# Update $last_num variable to the latest error number after you fixed the issue | |
last_num=75305 | |
log_file=/var/log/nginx/error.log | |
[ -f "$log_file" ] || { echo "WARNING - error log does not exist: $log_file"; exit 1; } | |
current_num=$(grep 'upstream timed out' "$log_file" | tail -1 | awk ' { print $5 }' | tr -d '*') | |
# If $current_num is not empty string and larger than $last_num, then we get an error | |
[ -n "$current_num" ] && [ "$current_num" -gt $last_num ] && \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment