git.lirion.de

Of git, get, and gud

summaryrefslogtreecommitdiffstats
path: root/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs
diff options
context:
space:
mode:
authormail_redacted_for_web 2019-04-17 19:07:19 +0200
committermail_redacted_for_web 2019-04-17 19:07:19 +0200
commit1e2387474a449452b78520b9ad96a8b4b5e99722 (patch)
tree836889471eec7d2aac177405068e2a8f1e2b1978 /nagios-plugins-contrib-24.20190301~bpo9+1/check_libs
downloadnagios-plugins-contrib-1e2387474a449452b78520b9ad96a8b4b5e99722.tar.bz2
initial commit of source fetch
Diffstat (limited to 'nagios-plugins-contrib-24.20190301~bpo9+1/check_libs')
-rw-r--r--nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/Makefile16
-rw-r--r--nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/control7
-rw-r--r--nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/copyright52
-rw-r--r--nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/nagios-check-libs199
-rw-r--r--nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/nagios-check-libs.conf21
-rw-r--r--nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/tests2
-rwxr-xr-xnagios-plugins-contrib-24.20190301~bpo9+1/check_libs/update-check_libs-status90
-rwxr-xr-xnagios-plugins-contrib-24.20190301~bpo9+1/check_libs/update_files.sh10
8 files changed, 397 insertions, 0 deletions
diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/Makefile b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/Makefile
new file mode 100644
index 0000000..da38d4b
--- /dev/null
+++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/Makefile
@@ -0,0 +1,16 @@
+#!/usr/bin/make -f
+
+INIFILES = check-libs.conf
+PLUGIN = check_libs
+CLEANFILES = $(INIFILES) $(PLUGIN)
+CRONJOBS:= update-check_libs-status
+
+include ../common.mk
+
+check_libs:
+ cp nagios-check-libs $@
+ chmod 755 $@
+
+check-libs.conf:
+ cp nagios-check-libs.conf $@
+
diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/control b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/control
new file mode 100644
index 0000000..96b590e
--- /dev/null
+++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/control
@@ -0,0 +1,7 @@
+Homepage: https://gitweb.noreply.org/tools/monitoring.git/
+Watch: https://gitweb.noreply.org/tools/monitoring.git/plain/nagios-checks/nagios-check-libs VERSION = '([0-9.]+)';
+Uploaders: Bernd Zeimetz <bzed@debian.org>
+Description: plugin to report the usage of no longer existing
+ libraries by running processes
+Recommends: lsof, libyaml-syck-perl
+Version: 0.2015012901
diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/copyright b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/copyright
new file mode 100644
index 0000000..d2777fd
--- /dev/null
+++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/copyright
@@ -0,0 +1,52 @@
+
+check_libs:
+
+Copyright (C) 2005, 2006, 2007, 2008, 2012 Peter Palfrader <peter@palfrader.org>
+ 2012 Uli Martens <uli@youam.net>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+update-check_libs-status:
+
+Based on update-apt-status
+Copyright 2009 Peter Palfrader
+
+Copyright 2014 conova communications GmbH
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/nagios-check-libs b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/nagios-check-libs
new file mode 100644
index 0000000..89d7f3a
--- /dev/null
+++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/nagios-check-libs
@@ -0,0 +1,199 @@
+#!/usr/bin/perl -w
+
+# Copyright (C) 2005, 2006, 2007, 2008, 2012, 2015 Peter Palfrader <peter@palfrader.org>
+# 2012 Uli Martens <uli@youam.net>
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+use strict;
+use English;
+use Getopt::Long;
+
+$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/sbin';
+delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
+
+my $LSOF = '/usr/bin/lsof -F0';
+my $VERSION = '0.2015012901';
+
+# nagios exit codes
+my $OK = 0;
+my $WARNING = 1;
+my $CRITICAL = 2;
+my $UNKNOWN = 3;
+
+my $params;
+my $config;
+
+Getopt::Long::config('bundling');
+
+sub dief {
+ print STDERR @_;
+ exit $UNKNOWN;
+}
+
+if (!GetOptions (
+ '--help' => \$params->{'help'},
+ '--version' => \$params->{'version'},
+ '--quiet' => \$params->{'quiet'},
+ '--verbose' => \$params->{'verbose'},
+ '--config=s' => \$params->{'config'},
+ )) {
+ dief ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose] [--quiet] [--config=<CONFIGFILE>]\n");
+};
+if ($params->{'help'}) {
+ print "$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--verbose] [--quiet] [--config=<CONFIGFILE>]\n";
+ print "Reports processes that are linked against libraries that no longer exist.\n";
+ print "The optional config file can specify ignore rules - see the sample config file.\n";
+ exit (0);
+};
+if ($params->{'version'}) {
+ print "nagios-check-libs $VERSION\n";
+ print "nagios check for availability of debian (security) updates\n";
+ print "Copyright (c) 2005, 2006, 2007, 2008, 2012 Peter Palfrader <peter\@palfrader.org>\n";
+ exit (0);
+};
+
+if (! defined $params->{'config'}) {
+ $params->{'config'} = '/etc/nagios/check-libs.conf';
+} elsif (! -e $params->{'config'}) {
+ dief("Config file $params->{'config'} does not exist.\n");
+}
+
+if (-e $params->{'config'}) {
+ eval "use YAML::Syck; 1" or dief "you need YAML::Syck (libyaml-syck-perl) to load a config file";
+ open(my $fh, '<', $params->{'config'}) or dief "Cannot open config file $params->{'config'}: $!";
+ $config = LoadFile($fh);
+ close($fh);
+ if (!(ref($config) eq "HASH")) {
+ dief("Loaded config is not a hash!\n");
+ }
+} else {
+ $config = {
+ 'ignorelist' => [
+ '$path =~ m#^/proc/#',
+ '$path =~ m#^/var/tmp/#',
+ '$path =~ m#^/SYS#',
+ '$path =~ m#^/drm$# # xserver stuff',
+ '$path =~ m#^/dev/zero#',
+ '$path =~ m#^/dev/shm/#',
+ ]
+ };
+}
+
+if (! exists $config->{'ignorelist'}) {
+ $config->{'ignorelist'} = [];
+} elsif (! (ref($config->{'ignorelist'}) eq 'ARRAY')) {
+ dief("Config->ignorelist is not an array!\n");
+}
+
+
+my %processes;
+
+sub getPIDs($$) {
+ my ($user, $process) = @_;
+ return join(', ', sort keys %{ $processes{$user}->{$process} });
+};
+sub getProcs($) {
+ my ($user) = @_;
+
+ return join(', ', map { $_.' ('.getPIDs($user, $_).')' } (sort {$a cmp $b} keys %{ $processes{$user} }));
+};
+sub getUsers() {
+ return join('; ', (map { $_.': '.getProcs($_) } (sort {$a cmp $b} keys %processes)));
+};
+sub inVserver() {
+ my ($f, $key);
+ if (-e "/proc/self/vinfo" ) {
+ $f = "/proc/self/vinfo";
+ $key = "XID";
+ } else {
+ $f = "/proc/self/status";
+ $key = "s_context";
+ };
+ open(F, "< $f") or return 0;
+ while (<F>) {
+ my ($k, $v) = split(/: */, $_, 2);
+ if ($k eq $key) {
+ close F;
+ return ($v > 0);
+ };
+ };
+ close F;
+ return 0;
+}
+
+my $INVSERVER = inVserver();
+
+print STDERR "Running $LSOF -n\n" if $params->{'verbose'};
+open (LSOF, "$LSOF -n|") or dief ("Cannot run $LSOF -n: $!\n");
+my @lsof=<LSOF>;
+close LSOF;
+if ($CHILD_ERROR) { # program failed
+ dief("$LSOF -n returned with non-zero exit code: ".($CHILD_ERROR / 256)."\n");
+};
+
+my ($process, $pid, $user);
+LINE: for my $line (@lsof) {
+ if ( $line =~ /^p/ ) {
+ my %fields = map { m/^(.)(.*)$/ ; $1 => $2 } grep { defined $_ and length $_ >1} split /\0/, $line;
+ $process = $fields{c};
+ $pid = $fields{p};
+ $user = $fields{L};
+ next;
+ }
+
+ unless ( $line =~ /^f/ ) {
+ dief("UNKNOWN strange line read from lsof\n");
+ # don't print it because it contains NULL characters...
+ }
+
+ my %fields = map { m/^(.)(.*)$/ ; $1 => $2 } grep { defined $_ and length $_ >1} split /\0/, $line;
+
+ my $fd = $fields{f};
+ my $inode = $fields{i};
+ my $path = $fields{n};
+ if ($path =~ m/\.dpkg-/ || $path =~ m/\(deleted\)/ || $path =~ /path inode=/ || $path =~ m#/\.nfs# || $fd eq 'DEL') {
+ $path =~ s/^\(deleted\)//; # in some cases "(deleted)" is at the beginning of the string
+ for my $i (@{$config->{'ignorelist'}}) {
+ my $ignore = eval($i);
+ next LINE if $ignore;
+ }
+ next if ($INVSERVER && ($process eq 'init') && ($pid == 1) && ($user eq 'root'));
+ if ( $params->{'verbose'} ) {
+ print STDERR "adding $process($pid) because of [$path]:\n";
+ print STDERR $line;
+ }
+ $processes{$user}->{$process}->{$pid} = 1;
+ };
+};
+
+
+
+my $message='';
+my $exit = $OK;
+if (keys %processes) {
+ $exit = $WARNING;
+ $message = 'The following processes have libs linked that were upgraded: '. getUsers()."\n";
+} else {
+ $message = "No upgraded libs linked in running processes\n" unless $params->{'quiet'};
+};
+
+print $message;
+exit $exit;
diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/nagios-check-libs.conf b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/nagios-check-libs.conf
new file mode 100644
index 0000000..de4e025
--- /dev/null
+++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/nagios-check-libs.conf
@@ -0,0 +1,21 @@
+---
+ ignorelist:
+ - '$path =~ m#^/proc/#'
+ - '$path =~ m#^/var/tmp/#'
+ - '$path =~ m#^/tmp/#'
+ - '$path =~ m#^/var/run/#'
+ - '$path =~ m#^/run/#'
+ - '$path =~ m#^/dev/pts/#'
+ - '$path =~ m#^/SYS#'
+ - '$path =~ m#^/sys/#'
+ - '$path =~ m#^/drm$# # xserver stuff'
+ - '$path =~ m#^/dev/zero#'
+ - '$path =~ m#^/dev/shm/#'
+ - '$path =~ m#^/var/lib/postgresql/#'
+ - '$path =~ m#^/var/log/#'
+ - '$path =~ m#^/var/spool/#'
+ - '$path =~ m#^/var/lib/ganeti/#'
+ - '$path =~ m#^/usr/lib/locale/locale-archive#'
+ - '$path =~ m#^/var/lib/nginx/#'
+ - '$path =~ m#^/\[aio\]$#'
+# vim:syn=yaml
diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/tests b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/tests
new file mode 100644
index 0000000..ca87e45
--- /dev/null
+++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/tests
@@ -0,0 +1,2 @@
+Depends: lsof, libyaml-syck-perl
+Test-Command: /usr/lib/nagios/plugins/check_libs
diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/update-check_libs-status b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/update-check_libs-status
new file mode 100755
index 0000000..78de51b
--- /dev/null
+++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/update-check_libs-status
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+# Based on update-apt-status
+# Copyright 2009 Peter Palfrader
+#
+# Copyright 2014 conova communications GmbH
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+UPDATE_RUNS=3
+STATUSDIR=/var/cache/nagios_status
+STATUS=${STATUSDIR}/check_libs
+SLEEP_MAX=$(( 15 * 60 ))
+MAX_AGE=$(( 23 * 60 * 60 ))
+
+# we want to run if any of the following things is true
+# - we have never run before
+# - var/lib/dpkg/status has been touched since the last run
+# - var/cache/apt/pkgcache.bin has been touched since the last run
+# - our last run ended with 'apt-get update failed'
+# - our last run has been more than MAX_AGE (23hrs) ago
+run_required() {
+ local run=0
+ local norun=1
+
+ [ -e "$STATUS" ] || return $run
+ [ /var/lib/dpkg/status -nt "$STATUS" ] && return $run
+ [ /var/cache/apt/pkgcache.bin -nt "$STATUS" ] && return $run
+ grep "apt-get update failed" "$STATUS" > /dev/null && return $run
+
+ local last_mod
+ last_mod=`stat -c "%Y" "$STATUS"`
+ now=`date +%s`
+ age=$(( $now - $last_mod ))
+ [ "$age" -gt "$MAX_AGE" ] && return $run
+
+ return $norun
+}
+
+if [ ! -d ${STATUSDIR} ]; then
+ mkdir -p ${STATUSDIR}
+fi
+
+# do stuff only when required, or when asked to
+if [ "${1:-""}" != "-f" ] ; then
+ run_required || exit 0
+fi
+
+# sleep if called non-interactively
+if [ -z "$TERM" -o "$TERM" = "dumb" ]; then
+ sleep $(( $RANDOM % $SLEEP_MAX ))
+fi
+
+# run the apt check itself
+tmp=`tempfile`
+trap "rm -f '$tmp'" exit
+/usr/lib/nagios/plugins/check_libs > "$tmp"
+result="$?"
+case "$result" in
+ 0)
+ st="OK"
+ ;;
+ 1)
+ st="WARNING"
+ ;;
+ 2)
+ st="CRITICAL"
+ ;;
+ *)
+ st="UNKNOWN"
+ ;;
+esac
+(echo "$st"; cat "$tmp") > "$STATUS"
diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/update_files.sh b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/update_files.sh
new file mode 100755
index 0000000..6b45c17
--- /dev/null
+++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_libs/update_files.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+for i in nagios-check-libs nagios-check-libs.conf; do
+ tmp=`mktemp`
+ if wget -O ${tmp} "http://svn.noreply.org/svn/weaselutils/trunk/${i}"; then
+ mv ${tmp} ${i}
+ else
+ rm -f ${tmp}
+ fi
+done