summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2007-04-06 17:45:04 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2007-04-06 17:45:04 +0000
commit16cfae996e5dc3b763e3f6c9d537799340a92ca8 (patch)
tree50564dd75b35fc64a67f7b2dd91d55b21da025a3
parentd6f78d938ca0ea95e0dad0dfd6d5ddd375809a1e (diff)
r11442@danube: weasel | 2007-04-06 19:44:55 +0200
Handle vserver init git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@265 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
-rwxr-xr-xnagios-check-libs16
1 files changed, 14 insertions, 2 deletions
diff --git a/nagios-check-libs b/nagios-check-libs
index e8c3203..27fccfa 100755
--- a/nagios-check-libs
+++ b/nagios-check-libs
@@ -60,9 +60,20 @@ sub getProcs($) {
sub getUsers() {
return join('; ', (map { $_.': '.getProcs($_) } (sort {$a cmp $b} keys %processes)));
};
+sub inVserver() {
+ open(F, "< /proc/self/status") or return 0;
+ while (<F>) {
+ my ($k, $v) = split(/: */, $_, 2);
+ if ($k eq 's_context') {
+ 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 die ("Cannot run $LSOF -n: $!\n");
@@ -76,6 +87,7 @@ for my $line (@lsof) {
if ($line =~ m/\.dpkg-/ || $line =~ m/path inode=/) {
my ($process, $pid, $user, undef, undef, undef, undef, $path, $rest) = split /\s+/, $line;
next if $path =~ m#^/proc/#;
+ next if ($INVSERVER && ($process eq 'init') && ($pid == 1) && ($user eq 'root'));
#$processes{$user}->{$process} = [] unless defined $processes{$user}->{$process};
$processes{$user}->{$process}->{$pid} = 1;
};