1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2026-02-05 14:45:19 +01:00

Closes #2 - Initial packaging and fix typos

This commit is contained in:
Tomas Edwardsson
2013-05-22 20:48:27 +00:00
parent 190a9726b1
commit c0ef6774ad
2 changed files with 42 additions and 3 deletions

View File

@@ -0,0 +1,92 @@
#!/bin/bash
#
# Copyright 2010, Pall Sigurdsson <palli@opensource.is>
#
# 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 <http://www.gnu.org/licenses/>.
# About this script
#
# Checks selinux status of a specified host, using NRPE if the 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 <host> -s <status>"
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 selinux status 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 selinux status, 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

View File

@@ -0,0 +1,39 @@
%define debug_package %{nil}
Summary: A Nagios plugin to check SELinux status on Linux servers
Name: nagios-plugins-check_selinux
Version: 1.0
Release: 1%{?dist}
License: GPLv3+
Group: Applications/System
URL: https://github.com/opinkerfi/nagios-plugins/tree/master/check_selinux
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_selinux/releases/nagios-plugins-check_selinux-%{version}.tar.gz
Requires: nagios-plugins-nrpe libselinux-utils
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Packager: Tomas Edwardsson <tommi@ok.is>
BuildArch: noarch
%description
This plugin check the enforcing selinux status of a specified host, using NRPE
if the host is remote.
%prep
%setup -q
%build
%install
rm -rf %{buildroot}
install -D -p -m 0755 check_selinux %{buildroot}%{_libdir}/nagios/plugins/check_selinux
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{_libdir}/nagios/plugins/*
%changelog
* Wed May 22 2013 Tomas Edwardsson <tommi@opensource.is> 1.0-1
- Initial packaging