1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2026-02-13 02:20:57 +01:00

Compare commits

..

16 Commits

Author SHA1 Message Date
Samúel Jón Gunnarsson
6c344fe7e8 WIP: trial and error 2017-09-27 16:22:39 +02:00
Samúel Jón Gunnarsson
090c4ed475 WIP: Almost there 2017-09-27 13:54:48 +02:00
Samúel Jón Gunnarsson
3733ab15ed wip: baby steps getting rpmbuild to work 2017-09-27 13:44:30 +02:00
Samúel Jón Gunnarsson
a50eb30511 Tweaking parameters 2017-09-27 13:21:46 +02:00
Samúel Jón Gunnarsson
662532ff1f Tweaking parameters 2017-09-27 13:14:07 +02:00
Samúel Jón Gunnarsson
ef4b65a81b Initial copr test. Bound to fail :-D 2017-09-27 13:09:40 +02:00
Samúel Jón Gunnarsson
484e5c3c71 Started testing docker executions 2017-09-27 11:24:48 +02:00
Samúel Jón Gunnarsson
d661046464 Changed permissions 2017-09-27 11:02:17 +02:00
Samúel Jón Gunnarsson
2a2c3f7dff Rename test folder to tests 2017-09-27 10:59:41 +02:00
Samúel Jón Gunnarsson
802a8a138e Testing setup_tests.sh script 2017-09-27 10:56:33 +02:00
Samúel Jón Gunnarsson
365576221a Added initial travis.yml definition 2017-09-27 10:14:01 +02:00
Garðar Þorsteinsson
51c659990b Merge pull request #31 from eythori-sensa/fix_rhel6_multipatch_check
Fix rhel6 multipath check
2017-03-24 15:34:04 +00:00
Admin - Eyþór Ívarsson
343c42339f Fix syntax error 2017-03-23 12:18:25 +00:00
Admin - Eyþór Ívarsson
8f89f773e3 Changes after multipath upgrade. Use multipath -ll and fix a regex counter for ok lines 2017-03-23 12:18:18 +00:00
gardart
24518a74e7 version update - package release 2016-12-22 20:11:19 +00:00
gardart
cdc1daad6d version fix 2016-12-21 21:47:29 +00:00
9 changed files with 81 additions and 7 deletions

BIN
.copr.enc Normal file

Binary file not shown.

47
.travis.yml Normal file
View File

@@ -0,0 +1,47 @@
#sudo: required
#env:
# matrix:
# - OS_TYPE=centos OS_VERSION=6
# - OS_TYPE=centos OS_VERSION=7
#
#services:
# - docker
#
#before_install:
# - sudo apt-get update
# - echo 'DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -s devicemapper"' | sudo tee /etc/default/docker > /dev/null
# - sudo service docker restart
# - sleep 5
# - sudo docker pull centos:centos${OS_VERSION}
#
#
#script:
# # Run tests in Container
# - tests/setup_tests.sh ${OS_VERSION}
#
sudo: required
language: python
env:
global:
- DOCKER_IMAGE=alectolytic/rpmbuilder
- COPR_REPOSITORY=opinkerfi/nagios-plugins
- OS_ARCH=x86_64
matrix:
# - OS_TYPE=fedora OS_DIST=fedora OS_VERSION=24
- OS_TYPE=centos OS_DIST=epel OS_VERSION=7
services:
- docker
install: true
script:
- docker run -v ${PWD}/check_firewall_active:/sources -v ${PWD}:/output:Z -e "SRPM_ONLY=1" ${DOCKER_IMAGE}:${OS_TYPE}-${OS_VERSION}
# - docker run -v ${PWD}/check_firewall_active:/sources:ro -v ${PWD}:/output:rw -v ${PWD}/workspace:/workspace:rw -v ${PWD}/rpmbuild:/rpmbuild:rw -e "SRPM_ONLY=1" ${DOCKER_IMAGE}:${OS_TYPE}-${OS_VERSION}
after_success:
- pip install copr-cli simplejson
- openssl aes-256-cbc -K $encrypted_f965aefb5778_key -iv $encrypted_f965aefb5778_iv -in .copr.enc -out .copr -d
- if [ ! -z "${TRAVIS_TAG}" ]; then copr-cli --config .copr build -r ${OS_DIST}-${OS_VERSION}-${OS_ARCH} ${COPR_REPOSITORY} *.src.rpm; fi

View File

@@ -1,10 +1,9 @@
%define debug_package %{nil} %define debug_package %{nil}
%define release 3
Summary: A Nagios plugin to check if iptables are actually enforcing rules Summary: A Nagios plugin to check if iptables are actually enforcing rules
Name: nagios-okplugin-check_firewall_active Name: nagios-okplugin-check_firewall_active
Version: 1.0.0 Version: 1.0.2
Release: %{release}%{?dist} Release: 1%{?dist}
License: GPLv2+ License: GPLv2+
Group: Applications/System Group: Applications/System
URL: https://github.com/opinkerfi/nagios-plugins/issues URL: https://github.com/opinkerfi/nagios-plugins/issues
@@ -47,6 +46,7 @@ rm -rf %{buildroot}
restorecon -v %{_libdir}/nagios/plugins/check_firewall_active.sh /etc/nrpe.d/check_firewall_active.cfg /etc/sudoers.d/check_firewall_active restorecon -v %{_libdir}/nagios/plugins/check_firewall_active.sh /etc/nrpe.d/check_firewall_active.cfg /etc/sudoers.d/check_firewall_active
%changelog %changelog
* Thu Dec 21 2016 Gardar Thorsteinsson <gardart@gmail.com> 1.0.1-1
* Thu Dec 21 2016 Gardar Thorsteinsson <gardart@gmail.com> 1.0.0-3 * Thu Dec 21 2016 Gardar Thorsteinsson <gardart@gmail.com> 1.0.0-3
* Thu Dec 20 2016 Richard Allen <ra@ok.is> 0.1-1 * Thu Dec 20 2016 Richard Allen <ra@ok.is> 0.1-1
- Initial packaging - Initial packaging

View File

@@ -48,9 +48,9 @@ print_help() {
echo "Add this to your sudoers file by running visudo to add access:" echo "Add this to your sudoers file by running visudo to add access:"
if [ -r /proc/modules ]; then if [ -r /proc/modules ]; then
echo "Cmnd_Alias MULTIPATH=$MULTIPATH -l" echo "Cmnd_Alias MULTIPATH=$MULTIPATH -ll"
else else
echo "Cmnd_Alias MULTIPATH=$MULTIPATH -l, $SUDO" echo "Cmnd_Alias MULTIPATH=$MULTIPATH -ll, $SUDO"
fi fi
echo "nagios ALL= NOPASSWD: MULTIPATH" echo "nagios ALL= NOPASSWD: MULTIPATH"
echo "The user nagios may very well be nobody or someone else depending on your configuration" echo "The user nagios may very well be nobody or someone else depending on your configuration"
@@ -98,7 +98,7 @@ if [ $(id -un) != "root" ]; then
fi fi
fi fi
OUTPUT=$($MULTIPATH -l 2>/dev/null) OUTPUT=$($MULTIPATH -ll 2>/dev/null)
if [ $? != 0 ]; then if [ $? != 0 ]; then
# Failed. grab more info why # Failed. grab more info why
if [ $(id -un) != "root" ] && [ `$SUDO -l | grep -c multipath` -eq 0 ]; then if [ $(id -un) != "root" ] && [ `$SUDO -l | grep -c multipath` -eq 0 ]; then
@@ -112,7 +112,7 @@ if [ $? != 0 ]; then
exit $STATE_UNKNOWN exit $STATE_UNKNOWN
fi fi
echo "MULTIPATH: $(MULTIPATH -l 2>&1)" echo "MULTIPATH: $($MULTIPATH -ll 2>&1)"
exit $STATE_UNKNOWN exit $STATE_UNKNOWN
fi fi
@@ -137,6 +137,7 @@ if [ "$NUMPATHS" ]; then
/^ \\/ {targets++; next} # count targets (lenny) /^ \\/ {targets++; next} # count targets (lenny)
/[0-9]+:[0-9]+:[0-9]+:[0-9]+/ { /[0-9]+:[0-9]+:[0-9]+:[0-9]+/ {
if (/active undef running/) { targets++ } # count targets (squeeze) if (/active undef running/) { targets++ } # count targets (squeeze)
if (/active ready running/) { targets++ } # count targets (RHEL6)
next next
} }
{ {

0
output/.gitkeep Normal file
View File

0
rpmbuild/.gitkeep Normal file
View File

24
tests/setup_tests.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/sh -xe
# This script starts docker and systemd (if el7)
# Version of CentOS/RHEL
el_version=$1
# Run tests in Container
if [ "$el_version" = "6" ]; then
sudo docker run --rm=true -v `pwd`:/nagios-plugins:rw centos:centos${OS_VERSION} /bin/bash -c "bash -xe /nagios-plugins/tests/test_inside_docker.sh ${OS_VERSION}"
elif [ "$el_version" = "7" ]; then
docker run --privileged -d -ti -e "container=docker" -v /sys/fs/cgroup:/sys/fs/cgroup -v `pwd`:/nagios-plugins:rw centos:centos${OS_VERSION} /usr/sbin/init
DOCKER_CONTAINER_ID=$(docker ps | grep centos | awk '{print $1}')
docker logs $DOCKER_CONTAINER_ID
docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "bash -xe /nagios-plugins/tests/test_inside_docker.sh ${OS_VERSION};
echo -ne \"------\nEND NAGIOS-PLUGINS TESTS\n\";"
docker ps -a
docker stop $DOCKER_CONTAINER_ID
docker rm -v $DOCKER_CONTAINER_ID
fi

2
tests/test_inside_docker.sh Executable file
View File

@@ -0,0 +1,2 @@
echo "Keyrsla fyrir CentOS $1"
ls -l /

0
workspace/.gitkeep Normal file
View File