From 995454dd016daa934d0707c321dcb12e7e5bede7 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Thu, 26 Jan 2012 02:03:53 +0100 Subject: [PATCH] First push of files --- README | 23 +++++++ check_md5.sh | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+) create mode 100644 README create mode 100755 check_md5.sh diff --git a/README b/README new file mode 100644 index 0000000..30131fd --- /dev/null +++ b/README @@ -0,0 +1,23 @@ +check_md5 + +A Nagios plugin written in Bash to check the MD5 sum of a single file. +In case the files MD5 change the plugin issues a critical state. This behavior +can be changed by using a --warning argument, so that only a warning state is +issued. + + +Options: +-h +Print detailed help screen +-V +Print version information + +--warning +Issue a warning state instead of a critical state in case of a MD5 failure +Default is critical + +--file /path/to/file +Set which file to monitor + +--md5 md5checksum +Set the MD5 checksum for the file set by --file diff --git a/check_md5.sh b/check_md5.sh new file mode 100755 index 0000000..c06bd1c --- /dev/null +++ b/check_md5.sh @@ -0,0 +1,172 @@ +#!/bin/bash + +################################################################################ +# # +# Copyright (C) 2012 Jack-Benny Persson # +# # +# This program is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +################################################################################ + +############################################################################### +# # +# Nagios plugin to monitor a single files MD5 sum. In case of mismatch # +# the plugin exit with a CRICITAL error code. This behavior can be changed # +# with the --warning argument. # +# Written in Bash (and uses sed & awk). # +# # +############################################################################### + + +VERSION="1.0" +AUTHOR="(c) 2012 Jack-Benny Persson (jack-benny@cyberinfo.se)" + +# Exit codes +STATE_OK=0 +STATE_WARNING=1 +STATE_CRITICAL=2 +STATE_UNKNOWN=3 + +shopt -s extglob + +#### Functions #### + +# Print version information +print_version() +{ + printf "\n\n$0 - $VERSION\n" +} + +#Print help information +print_help() +{ + print_version + printf "$AUTHOR\n" + printf "Monitor the MD5 checksum of a single file\n" +/bin/cat <