From 7cd21e9380e21651d6b9a70382c6712e86eab97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1ll=20Gu=C3=B0j=C3=B3n=20Sigur=C3=B0sson?= Date: Thu, 2 Dec 2010 10:37:34 +0000 Subject: [PATCH] --- misc/check_rhcs_manualfencing.sh | 84 +++++++++++++++++++++++++++++ misc/check_selinux.sh | 92 ++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 misc/check_rhcs_manualfencing.sh create mode 100644 misc/check_selinux.sh diff --git a/misc/check_rhcs_manualfencing.sh b/misc/check_rhcs_manualfencing.sh new file mode 100644 index 0000000..7da6a72 --- /dev/null +++ b/misc/check_rhcs_manualfencing.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# +# Copyright 2010, Pall Sigurdsson +# +# This script 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 3 of the License, or +# (at your option) any later version. +# +# This script 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, see . + +# About this script +# +# Checks uptime of a specified host, using NRPE is host is remote + +HOSTN="localhost" # By default check localhost +CHECK_COMMAND="test ! -p /tmp/fence_manual.fifo" # Default command to check selinux status + +print_help() { + echo "check_rhcs_fencing version $VERSION" + echo "This plugin checks if there is Manual ACK is required for RHCS fencing" + echo "" + echo "Usage: $0 [-H ]" + echo "" + echo "Example: Check if fencing is required on localhost" + echo "# check_rhcs_fencing.sh" +} + +#if [ $# -eq 0 ]; then +# print_help ; +# exit $UNKNOWN +#fi + + +# Parse arguments +while [ $# -gt 0 ] +do + case $1 + in + -H) + HOSTN=$2 + shift 2 + ;; + + *) + print_help ; + exit $UNKNOWN + ;; + esac +done + + + +# We we are not checking localhost, lets get remote uptime via NRPE +if [ "$HOSTN" != "localhost" ]; then + export PATH=$PATH:/usr/lib/nagios/plugins:/usr/lib64/nagios/plugins:/nagios/usr/lib/nagios/plugins + CHECK_COMMAND="check_nrpe -H $HOSTN -c check_rhcs_fencing" +fi + + +# Get the uptime, raise error if we are unsuccessful +OUTPUT=`$CHECK_COMMAND` +RESULT=$? + +if [ $RESULT -eq 2 ]; then + echo "Error, could not run command $CHECK_COMMAND" + echo "output:" + echo "$OUTPUT" + exit 3 +fi + +if [ $RESULT -gt 0 ]; then + echo "Warning, /tmp/fence_manual.fifo exists on host $HOSTN. Manual fencing is required" + exit 1 +else + echo "Ok, No fencing required on host $HOSTN" + exit 0 +fi diff --git a/misc/check_selinux.sh b/misc/check_selinux.sh new file mode 100644 index 0000000..5279248 --- /dev/null +++ b/misc/check_selinux.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# +# Copyright 2010, Pall Sigurdsson +# +# This script 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 3 of the License, or +# (at your option) any later version. +# +# This script 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, see . + +# About this script +# +# Checks uptime of a specified host, using NRPE is host is remote + +HOSTN="localhost" # By default check localhost +CHECK_COMMAND="getenforce" # Default command to check selinux status + +print_help() { + echo "check_selinux version $VERSION" + echo "This plugin checks selinux status of a remote host" + echo "" + echo "Usage: $0 -H -s " + echo "" + echo "Example: Check if remote host is Enforcing" + echo "# check_selinux -H remotehost -s Enforcing" +} + +if [ $# -eq 0 ]; then + print_help ; + exit $UNKNOWN +fi + + +# Parse arguments +while [ $# -gt 0 ] +do + case $1 + in + -H) + HOSTN=$2 + shift 2 + ;; + + -s) + STATUS=$2 + shift 2 + ;; + + *) + print_help ; + exit $UNKNOWN + ;; + esac +done + + + +# We we are not checking localhost, lets get remote uptime via NRPE +if [ "$HOSTN" != "localhost" ]; then + export PATH=$PATH:/usr/lib/nagios/plugins:/usr/lib64/nagios/plugins:/nagios/usr/lib/nagios/plugins + CHECK_COMMAND="check_nrpe -H $HOSTN -c get_selinux" +fi + + +# Get the uptime, raise error if we are unsuccessful +OUTPUT=`$CHECK_COMMAND` +RESULT=$? + +if [ $RESULT -gt 0 ]; then + echo "Error - Could not run command $CHECK_COMMAND" + echo "Error was: $OUTPUT" + exit 3 +fi + +# Parse the output from the command +if [ "$OUTPUT" == "$STATUS" ]; then + echo "ok, selinux status is $OUTPUT" + exit 0 +else + echo "warning, selinux status is $OUTPUT (supposed to be $STATUS)" + exit 1 +fi + + +