summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
};