Skip to content

Instantly share code, notes, and snippets.

@shichao-an
Created November 14, 2014 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shichao-an/3005433d5ad4ee2f6936 to your computer and use it in GitHub Desktop.
Save shichao-an/3005433d5ad4ee2f6936 to your computer and use it in GitHub Desktop.
NRPE plugin script to check Nginx proxy_pass upstream timeout error
#!/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