mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2026-02-13 02:20:57 +01:00
Compare commits
21 Commits
nagios-okp
...
nagios-okp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdc1daad6d | ||
|
|
c40bee725a | ||
|
|
892f9c267e | ||
|
|
3501677f20 | ||
|
|
6726f614ad | ||
|
|
ee5adc2363 | ||
|
|
7dc3b57582 | ||
|
|
688e8b8412 | ||
|
|
1ccc433779 | ||
|
|
ee05a4f24a | ||
|
|
871c8348fa | ||
|
|
944d47e18e | ||
|
|
40ba14c4cb | ||
|
|
f986b73474 | ||
|
|
c8e7fbbff8 | ||
|
|
f23ac92b64 | ||
|
|
7ab36cbc66 | ||
|
|
bf0edd899b | ||
|
|
9060a171f0 | ||
|
|
1420e93c5c | ||
|
|
cbcaa14997 |
@@ -251,10 +251,10 @@ if ($ret > 1) {
|
||||
#
|
||||
|
||||
foreach my $l (@output) {
|
||||
next if ($l =~ m/$opt_R/);
|
||||
next if ($l !~ m/$opt_r/);
|
||||
next if ($l =~ m/$exclude_re/);
|
||||
if($l =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+([\/\w\d\.-]+)$/) {
|
||||
next if ($l =~ m/$opt_R/);
|
||||
next if ($l !~ m/$opt_r/);
|
||||
next if ($l =~ m/$exclude_re/);
|
||||
my ($s,$u,$f,$pu,$d) = ($1,$2,$3,$4,$5);
|
||||
$alldisks{$d}->{pused} = $pu;
|
||||
$alldisks{$d}->{pfree} = 100-$pu;
|
||||
@@ -268,10 +268,10 @@ foreach my $l (@output) {
|
||||
# This is the output of df.exe on Windows
|
||||
#C:\ 9097126 6094081 3003045 67% argon-c (ntfs)
|
||||
else {
|
||||
if ($l =~ /(\w)\:\\\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+(.*)$/) {
|
||||
next if ($l =~ m/$opt_R/);
|
||||
next if ($l !~ m/$opt_r/);
|
||||
next if ($l =~ m/$exclude_re/);
|
||||
if ($l =~ /(\w)\:\\\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+(.*)$/) {
|
||||
my ($d,$s,$u,$f,$pu) = ("/$1",$2,$3,$4,$5);
|
||||
$alldisks{$d}->{pused} = $pu;
|
||||
$alldisks{$d}->{pfree} = 100-$pu;
|
||||
@@ -324,7 +324,7 @@ if($opt_f) {
|
||||
if(defined($alldisks{$f})) {
|
||||
$checkdisks{$f}=$alldisks{$f};
|
||||
}
|
||||
} elsif ($f =~ /([\/\w\d]+)\:(\w+)\:(\w+)/) {
|
||||
} elsif ($f =~ /^(.+?)\:(\w+)\:(\w+)/) {
|
||||
if(defined($alldisks{$1})) {
|
||||
$checkdisks{$1}=$alldisks{$1};
|
||||
updateRates($1,$2,$3,$checkdisks{$1}->{somme});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Summary: A Nagios plugin to check disks via NRPE
|
||||
Name: nagios-okplugin-check_disks
|
||||
Version: 1.0.6
|
||||
Version: 1.0.7
|
||||
Release: 1%{?dist}
|
||||
License: GPLv2+
|
||||
Group: Applications/System
|
||||
@@ -40,6 +40,10 @@ rm -rf %{buildroot}
|
||||
%{_libdir}/nagios/plugins/check_disks.pl
|
||||
|
||||
%changelog
|
||||
* Wed Oct 29 2014 Tomas Edwardsson <tommi@tommi.org> 1.0.7-1
|
||||
- Fix invalid regex if mountpoint has . in path (tommi@tommi.org)
|
||||
- Regex filtering broke disk checks (tommi@tommi.org)
|
||||
|
||||
* Tue Mar 25 2014 Tomas Edwardsson <tommi@tommi.org> 1.0.6-1
|
||||
- Bumped version
|
||||
|
||||
|
||||
23
check_firewall_active/check_firewall_active.sh
Executable file
23
check_firewall_active/check_firewall_active.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
EXIT_OK=0
|
||||
EXIT_WARN=1
|
||||
EXIT_CRIT=2
|
||||
|
||||
PATH=/sbin:/usr/sbin:$PATH
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit $EXIT_CRIT
|
||||
fi
|
||||
|
||||
blocks=$(iptables -L -v -n | egrep 'REJECT|DROP' | wc -l)
|
||||
|
||||
if [ $blocks -eq 0 ]; then
|
||||
echo "CRITICAL: No firewall detected"
|
||||
exit $EXIT_CRIT
|
||||
fi
|
||||
|
||||
echo "OK: Firewall is active"
|
||||
exit $EXIT_OK
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
%define debug_package %{nil}
|
||||
|
||||
Summary: A Nagios plugin to check if iptables are actually enforcing rules
|
||||
Name: nagios-okplugin-check_firewall_active
|
||||
Version: 1.0.1
|
||||
Release: 1%{?dist}
|
||||
License: GPLv2+
|
||||
Group: Applications/System
|
||||
URL: https://github.com/opinkerfi/nagios-plugins/issues
|
||||
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_firewall_active/releases/nagios-okplugin-check_firewall_active-%{version}.tar.gz
|
||||
Requires: nagios-nrpe
|
||||
Requires: iptables
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
Packager: Richard Allen <ra@ok.is>
|
||||
|
||||
|
||||
|
||||
%description
|
||||
A Nagios plugin to check if iptables are actually enforcing rules
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
#perl -pi -e "s|/usr/lib64|%{_libdir}|g" nrpe.d/check_firewall_active.cfg
|
||||
|
||||
%build
|
||||
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
install -D -p -m 0755 check_firewall_active.sh %{buildroot}%{_libdir}/nagios/plugins/check_firewall_active.sh
|
||||
install -D -p -m 0755 nrpe.d/check_firewall_active.cfg %{buildroot}/etc/nrpe.d/check_firewall_active.cfg
|
||||
install -D -p -m 0644 sudoers.d/check_firewall_active %{buildroot}/etc/sudoers.d/check_firewall_active
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
#%doc README LICENSE
|
||||
%{_libdir}/nagios/plugins/*
|
||||
/etc/nrpe.d/check_firewall_active.cfg
|
||||
/etc/sudoers.d/check_firewall_active
|
||||
|
||||
%post
|
||||
restorecon -v %{_libdir}/nagios/plugins/check_firewall_active.sh /etc/nrpe.d/check_firewall_active.cfg /etc/sudoers.d/check_firewall_active
|
||||
|
||||
%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 20 2016 Richard Allen <ra@ok.is> 0.1-1
|
||||
- Initial packaging
|
||||
3
check_firewall_active/nrpe.d/check_firewall_active.cfg
Normal file
3
check_firewall_active/nrpe.d/check_firewall_active.cfg
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
command[check_firewall_active]=sudo /usr/lib64/nagios/plugins/check_firewall_active.sh
|
||||
2
check_firewall_active/sudoers.d/check_firewall_active
Normal file
2
check_firewall_active/sudoers.d/check_firewall_active
Normal file
@@ -0,0 +1,2 @@
|
||||
Defaults:nrpe !requiretty
|
||||
nrpe ALL = (root) NOPASSWD: /usr/lib64/nagios/plugins/check_firewall_active.sh
|
||||
@@ -274,6 +274,9 @@ def check_logicaldisks():
|
||||
ld_status = check(i, 'Status')
|
||||
status = max(status, ld_status)
|
||||
|
||||
if i.get('Status') == 'Failed':
|
||||
status = max(status, critical)
|
||||
|
||||
mount_point = i['Mount Points']
|
||||
add_long("- %s (%s) = %s" % (i['name'], mount_point, state[ld_status]))
|
||||
add_summary(". ")
|
||||
|
||||
@@ -81,7 +81,7 @@ check_raid()
|
||||
{
|
||||
raid_ok=`cat $TEMPFILE |grep -i ok|wc -l`
|
||||
raid_warning=`cat $TEMPFILE|grep -i -E 'rebuild|predictive' |wc -l`
|
||||
raid_critical_1=`cat $TEMPFILE|grep -i 'failed|recovery' | wc -l`
|
||||
raid_critical_1=`cat $TEMPFILE|grep -i -E 'failed|recovery' | wc -l`
|
||||
|
||||
err_check=`expr $raid_ok + $raid_warning + $raid_critical_1 `
|
||||
|
||||
@@ -133,7 +133,7 @@ case "$1" in
|
||||
exit 0
|
||||
;;
|
||||
--all)
|
||||
controllers=`sudo -u root hpacucli controller all show | sed 's/.*Slot \([0-9]*\).*/\1/'`
|
||||
controllers=`sudo -u root $HPACUCLI controller all show | sed 's/.*Slot \([0-9]*\).*/\1/'`
|
||||
for i in $controllers ; do sudo -u root $HPACUCLI controller slot=$i pd all show status;done > $TEMPFILE
|
||||
check_raid
|
||||
;;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Summary: A Nagios plugin to check HP Hardware Status
|
||||
Name: nagios-okplugin-check_hpasm
|
||||
Version: 4.1.3
|
||||
Version: 4.1.4
|
||||
Release: 1%{?dist}
|
||||
License: GPLv2+
|
||||
Group: Applications/System
|
||||
@@ -45,6 +45,9 @@ rm -rf %{buildroot}
|
||||
/etc/nrpe.d/check_hpasm.cfg
|
||||
|
||||
%changelog
|
||||
* Fri Oct 03 2014 Tomas Edwardsson <tommi@tommi.org> 4.1.4-1
|
||||
- hpasm invalid nrpe check command name (tommi@tommi.org)
|
||||
|
||||
* Thu May 15 2014 Tomas Edwardsson <tommi@tommi.org> 4.1.3-1
|
||||
- new package built with tito
|
||||
|
||||
|
||||
@@ -46,10 +46,13 @@ except Exception, e:
|
||||
# Loop through replication agreements
|
||||
for rhost in replication:
|
||||
plugin.add_summary("Replica %s Status: %s" % (rhost[1]['nsDS5ReplicaHost'][0], rhost[1]['nsds5replicaLastUpdateStatus'][0]))
|
||||
if rhost[1]['nsds5replicaLastUpdateStatus'][0][:2] != "0 ":
|
||||
plugin.status(critical)
|
||||
else:
|
||||
if rhost[1]['nsds5replicaLastUpdateStatus'][0][:2] == "0 ":
|
||||
plugin.status(ok)
|
||||
elif rhost[1]['nsds5replicaLastUpdateStatus'][0][:2] == "1 ":
|
||||
# Busy Replica is not an error, its "unknown" (but its "ok" for now)
|
||||
plugin.status(ok)
|
||||
else:
|
||||
plugin.status(critical)
|
||||
|
||||
if not len(replication):
|
||||
plugin.add_summary("Warning: No replicas found")
|
||||
|
||||
117
check_lvm_mirror/check_lvm_mirror.py
Normal file
117
check_lvm_mirror/check_lvm_mirror.py
Normal file
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from pynag.Plugins import simple as Plugin, WARNING, CRITICAL, UNKNOWN, OK
|
||||
from subprocess import Popen, PIPE
|
||||
import os
|
||||
|
||||
|
||||
def main():
|
||||
global plugin
|
||||
|
||||
plugin = Plugin(must_threshold=False)
|
||||
plugin.add_arg("l", "logical-volume",
|
||||
"Comma seperated list of VG/LV, eg vg00/data,vg00/snap",
|
||||
required=False)
|
||||
plugin.add_arg("V", "volume-group",
|
||||
"Comma seperated list of VG, eg vg00,vg01",
|
||||
required=False)
|
||||
plugin.add_arg("a", "check-all", "Check all LVs", required=False,
|
||||
action="store_true")
|
||||
plugin.activate()
|
||||
|
||||
lvs = plugin["logical-volume"] and plugin["logical-volume"].split(
|
||||
",") or []
|
||||
vgs = plugin["volume-group"] and plugin["volume-group"].split(",") or []
|
||||
|
||||
if not lvs and not vgs and not plugin['check-all']:
|
||||
plugin.parser.error(
|
||||
"Either logical-volume or volume-group must be specified")
|
||||
elif plugin['check-all'] and ( lvs or vgs ):
|
||||
plugin.parser.error(
|
||||
"Mixing check-all and logical-volume or volume-group does not make sense")
|
||||
|
||||
check_mirror(lvs, vgs, plugin['check-all'], plugin['host'])
|
||||
|
||||
(code, message) = (plugin.check_messages(joinallstr="\n"))
|
||||
plugin.nagios_exit(code, message)
|
||||
|
||||
|
||||
def check_mirror(lv_list, vg_list, check_all, hostname):
|
||||
# Ensure the right locale for text parsing
|
||||
"""
|
||||
|
||||
:rtype : None
|
||||
"""
|
||||
# Change lang setting for string consitency
|
||||
env = os.environ.copy()
|
||||
env['LC_ALL'] = 'C'
|
||||
|
||||
# Remote execution
|
||||
if hostname:
|
||||
cmd = ['check_nrpe', '-H', hostname, '-c', 'get_lvm_mirrors']
|
||||
# Local
|
||||
else:
|
||||
cmd = ["lvs", "--separator", ";", "-o",
|
||||
"vg_name,lv_name,lv_attr,copy_percent"]
|
||||
# Execute lvs
|
||||
ret = None
|
||||
lvs_output = None
|
||||
try:
|
||||
lvs = Popen(cmd, stdout=PIPE, shell=False, env=env)
|
||||
ret = lvs.wait()
|
||||
lvs_output = lvs.stdout.readlines()
|
||||
except Exception, e:
|
||||
plugin.nagios_exit(UNKNOWN, "Unable to execute lvs: %s" % (e))
|
||||
|
||||
if ret != 0:
|
||||
plugin.nagios_exit(CRITICAL,
|
||||
"lvs execution failed, return code %i" % (ret))
|
||||
all_lvs = []
|
||||
all_vgs = []
|
||||
|
||||
# Loop through lvs output
|
||||
linenumber = 0
|
||||
for l in lvs_output:
|
||||
linenumber += 1
|
||||
try:
|
||||
vg_name, lv_name, lv_attr, copy_percent = l.strip().split(";")
|
||||
except ValueError as error:
|
||||
plugin.add_message(UNKNOWN,
|
||||
"Unable to parse lvs line %i: %s\n%s" % (
|
||||
linenumber, error, l))
|
||||
continue
|
||||
all_lvs.append("%s/%s" % (vg_name, lv_name))
|
||||
if vg_name not in all_vgs:
|
||||
all_vgs.append(vg_name)
|
||||
|
||||
if check_all or "%s/%s" % (
|
||||
vg_name, lv_name) in lv_list or vg_name in vg_list:
|
||||
if lv_attr[0] != "m" and lv_attr[0] != "M":
|
||||
plugin.add_message(CRITICAL,
|
||||
"LV %s/%s not mirrored" % (vg_name, lv_name))
|
||||
elif lv_attr[2] != "a":
|
||||
plugin.add_message(CRITICAL,
|
||||
"LV %s/%s not active" % (vg_name, lv_name))
|
||||
elif lv_attr[5] != "o":
|
||||
plugin.add_message(CRITICAL,
|
||||
"LV %s/%s not open" % (vg_name, lv_name))
|
||||
elif float(copy_percent or 0) < 100:
|
||||
plugin.add_message(WARNING, "LV %s/%s Copy Percent %s" % (
|
||||
vg_name, lv_name, copy_percent))
|
||||
else:
|
||||
plugin.add_message(OK, "LV %s/%s functioning" % (vg_name, lv_name))
|
||||
|
||||
# Find lvs that were specified in cmd line but were not found via lvs
|
||||
for v in vg_list:
|
||||
if v not in all_vgs:
|
||||
plugin.add_message(CRITICAL, "VG %s not found" % (v))
|
||||
|
||||
# Find lvs that were specified in cmd line but were not found via lvs
|
||||
for l in lv_list:
|
||||
if l not in all_lvs:
|
||||
plugin.add_message(CRITICAL, "LV %s not found" % (l))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
@@ -45,6 +45,11 @@ def main():
|
||||
for pkg in pkg_updates[update_type]:
|
||||
p.add_long_output(" %s" % pkg)
|
||||
|
||||
for m in known_types:
|
||||
m = m.lower()
|
||||
if not p.get_metric(m):
|
||||
p.add_metric(m, 0)
|
||||
|
||||
p.check_all_metrics()
|
||||
p.exit()
|
||||
|
||||
|
||||
@@ -74,17 +74,17 @@ OUTPUT=`$CHECK_COMMAND`
|
||||
RESULT=$?
|
||||
|
||||
if [ $RESULT -gt 0 ]; then
|
||||
echo "Error - Could not run command $CHECK_COMMAND"
|
||||
echo "Error was: $OUTPUT"
|
||||
echo "UNKNOWN - 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"
|
||||
echo "OK - SELinux status is $OUTPUT"
|
||||
exit 0
|
||||
else
|
||||
echo "warning, selinux status is $OUTPUT (supposed to be $STATUS)"
|
||||
echo "WARNING - SELinux status is $OUTPUT (supposed to be $STATUS)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.6-1 check_disks.pl/
|
||||
1.0.7-1 check_disks.pl/
|
||||
|
||||
@@ -1 +1 @@
|
||||
4.1.3-1 check_hpasm/
|
||||
4.1.4-1 check_hpasm/
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# RHEL 7 Production
|
||||
[production-el7-x86_64]
|
||||
releaser = tito.release.YumRepoReleaser
|
||||
builder = tito.builder.MockBuilder
|
||||
builder.mock = epel-7-x86_64
|
||||
rsync = tito@opensource.is:/var/www/sites/opensource.ok.is/repo/rhel7/x86_64/
|
||||
|
||||
# RHEL 7 Test
|
||||
[test-el7-x86_64]
|
||||
releaser = tito.release.YumRepoReleaser
|
||||
builder = tito.builder.MockBuilder
|
||||
builder.mock = epel-7-x86_64
|
||||
builder.test = 1
|
||||
rsync = tito@opensource.is:/var/www/sites/opensource.ok.is/repo/testing/rhel7/x86_64/
|
||||
|
||||
|
||||
# RHEL 6 Production
|
||||
[production-el6-x86_64]
|
||||
releaser = tito.release.YumRepoReleaser
|
||||
|
||||
Reference in New Issue
Block a user