Skip to content

Instantly share code, notes, and snippets.

@ryanchapman
Created November 13, 2012 09:25
Show Gist options
  • Save ryanchapman/4064825 to your computer and use it in GitHub Desktop.
Save ryanchapman/4064825 to your computer and use it in GitHub Desktop.
Nagios nsca incoming statistics
mmdd=`date | sed 's|^\(... \)\(... ..\)\( ..:..:.. ... ....\)|\2|'`; hour=`date +%H`; echo; echo -n "Number of hosts sending us nsca results: "; cat /var/log/messages | egrep 'START:.*from=' | sed 's|\(.*from=\)\(.*\..*\..*\..*\)$|\2|g' | sort -u | wc -l; echo " ATTEMPTS/MIN FAILS/MIN"; min=0; while [ $min -lt 61 ]; do min_formatted=`printf "%2.2d" $min`; echo -n "${mmdd} ${hour}:${min_formatted} "; printf "%8.8s" `cat /var/log/messages | grep 'START: nsca pid=' | grep "${mmdd} ${hour}:${min_formatted}:" | wc -l`; printf " %8.8s\n" `cat /var/log/messages | grep 'FAIL: nsca' | grep "${mmdd} ${hour}:${min_formatted}:" | wc -l`;min=$((min+1)); done
@ryanchapman
Copy link
Author

Shows stats for nsca (passive nagios results) coming into a server. Output looks like:

Number of hosts sending us nsca results: 39
       ATTEMPTS/MIN     FAILS/MIN
14:00           229             7
14:01             6             0
14:02             6             0
14:03            18             0
14:04             6             0
14:05           256             0
14:06            18             0
14:07             6             0
14:08             6             0
14:09            18             0
14:10           246             0
14:11             6             0
14:12            15             0
14:13             0             0
14:14             0             0
14:15             0             0
14:16             0             0
14:17             0             0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment