-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add munin_status shell script to monitor log file
Monitor log file on munin-master based on errors and more.
- Loading branch information
Showing
1 changed file
with
128 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/bin/sh | ||
# -*- sh -*- | ||
: <<=cut | ||
=head1 NAME | ||
munin_status - Plugin to monitor munin updates | ||
=head1 APPLICABLE SYSTEMS | ||
All systems with "sh", "pygtail", "awk" and "munin" | ||
=head1 CONFIGURATION | ||
The following is the default configuration | ||
[munin_status] | ||
user munin | ||
env.muninupdate /var/log/munin/munin-update.log | ||
env.pygtail /opt/local/bin/pygtail | ||
You could trigger alerts on update failures | ||
[munin_status] | ||
env.munin_fatal_critical 0 | ||
env.munin_error_critical 0 | ||
env.munin_warning_warning 0 | ||
env.munin_warning_critical 5 | ||
=head1 INTERPRETATION | ||
This plugin shows a graph with one line per munin state: | ||
INFO, WARNING, ERROR, FATAL. | ||
=head1 MAGIC MARKERS | ||
#%# family=auto | ||
#%# capabilities=autoconf | ||
=head1 VERSION | ||
0.1 | ||
=head1 AUTHOR | ||
Thomas Merkel <tm@core.io> | ||
=head1 LICENSE | ||
GPLv2 | ||
=cut | ||
|
||
|
||
############################## | ||
# Includes | ||
|
||
# shellcheck disable=SC1091 | ||
. "$MUNIN_LIBDIR/plugins/plugin.sh" | ||
|
||
############################## | ||
# Configurable variables | ||
muninupdate=${muninupdate:-/var/log/munin/munin-update.log} | ||
pygtail_bin=${pygtail_bin:-/opt/local/bin/pygtail} | ||
|
||
############################## | ||
# Functions | ||
|
||
# Print the munin values | ||
values() { | ||
# Set offset | ||
"$pygtail_bin" "$muninupdate" | awk ' | ||
BEGIN { split("INFO WARNING ERROR FATAL", a); for (i = 1; a[i]; ++i) A[i] = 0 } | ||
{ for (i = 1; a[i]; ++i) if (match($0, a[i])) ++A[i] } | ||
END { for (i = 1; a[i]; ++i) print "munin_"tolower(a[i])".value " A[i]} | ||
' | ||
chmod 640 "${muninupdate}.offset" | ||
} | ||
|
||
# Print the munin config | ||
config() { | ||
echo 'graph_title Munin update status groupped by log levels' | ||
echo 'graph_info This graph shows INFO, WARNING, ERROR and FATAL status' | ||
echo 'graph_category munin' | ||
echo 'graph_vlabel Number of status' | ||
|
||
echo 'graph_args --base 1000 -l 0' | ||
echo 'graph_total total' | ||
echo 'graph_printf %6.0lf' | ||
|
||
echo 'munin_info.label INFO' | ||
print_warning munin_info | ||
print_critical munin_info | ||
echo 'munin_warning.label WARNING' | ||
print_warning munin_warning | ||
print_critical munin_warning | ||
echo 'munin_error.label ERROR' | ||
print_warning munin_error | ||
print_critical munin_error | ||
echo 'munin_fatal.label FATAL' | ||
print_warning munin_fatal | ||
print_critical munin_fatal | ||
} | ||
|
||
# Print autoconfiguration hint | ||
autoconf() { | ||
if [ -r "${muninupdate}" ] && [ -x "$pygtail_bin" ]; then | ||
echo "yes" | ||
else | ||
echo "missing (${muninupdate} or (${pygtail_bin})" | ||
fi | ||
exit | ||
} | ||
|
||
############################## | ||
# Main | ||
|
||
case "$1" in | ||
config) | ||
config | ||
;; | ||
autoconf) | ||
autoconf | ||
;; | ||
*) | ||
values | ||
;; | ||
esac |