This file is indexed.

/usr/lib/xymon/server/ext/aptdiff is in hobbit-plugins 20131022.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/perl -w

# Copyright (C) 2008, 2012 Christoph Berg <myon@debian.org>
#
# 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.

# Server script to monitor list of installed packages in a group of hosts
#
# The test result will appear in the "aptdiff" column for one of the hosts.
# In bb-hosts, use aptdiff=POOL[,POOL...] where POOL is a hostname or a
# sprintf-pattern PATTERN:START:END. The script will ask the xymon server
# for the dpkg sections of the clientlogs. Running kernels are also checked
# via the uname section.
#
# Examples:
# aptdiff=foo.bla.org,bar.bla.org
# aptdiff=web%02d.bla.org:1:8

use strict;
use Hobbit qw(file_to_list_of_regexps);

# File with list of "$hostname $pkg" regexps of host/pkg patterns to ignore
my @diff_ignore = file_to_list_of_regexps ("/etc/xymon/aptdiff_ignore");

my @lines = `$ENV{XYMONHOME}/bin/xymongrep "aptdiff=*"`;
foreach my $line (@lines) {
	$line =~ /^(\S+)\s+(\S+)\s+#.*\baptdiff=(\S+)/ or next;
	my ($ip, $hostname, $data) = ($1, $2, $3);

	my ($template, $start, $end) = split (/:/, $data);
	my @templates = split (/,/, $template);

	my @hosts;
	if ($start and $end) {
		foreach my $t (@templates) {
			foreach my $n ($start .. $end) {
				push @hosts, sprintf ($t, $n);
			}
		}
	} else {
		@hosts = @templates;
	}

	my $out;
	my %dpkg;
	foreach my $host (@hosts) {
		next if exists $dpkg{$host};

		my $found = 0;
		open(F, '-|', "$ENV{XYMON} $ENV{XYMONSERVERHOSTNAME} 'clientlog $host section=uname,dpkg'") or die "$host: $!";
		while (<F>) {
			if (/\[dpkg\]/) {
				next;
			} elsif (/\[uname\]/) {
				my $uname = <F>;
				chomp $uname;
				$uname =~ s/^(\S+)\s+\S+/$1/; # strip hostname
				$dpkg{$host}->{'KERNEL'} = $uname;
				$dpkg{_all}->{'KERNEL'} = 1;
				next;
			}
			next unless /^([ih])i (\S+) (\S+)/;
			$dpkg{$host}->{$2} = $3 . ($1 eq 'h' ? "/hold" : "");
			$dpkg{_all}->{$2} = 1;
			$found = 1;
		}
		close F;
		$host = '' unless $found;
	}

	@hosts = grep /./, @hosts;
	my $first = shift @hosts || next;

	my $diff = 0;
	my $bb = new Hobbit ({ test => 'aptdiff', hostname => $hostname });
	foreach my $pkg (sort keys %{$dpkg{_all}}) {
		my $ver = $dpkg{$first}->{$pkg} || "(none)";
		foreach my $other (@hosts) {
			my $otherver = $dpkg{$other}->{$pkg} || "(none)";
			if ($ver ne $otherver) {
				my $color = 'yellow';
				if (grep { "$hostname $pkg" =~ $_ } @diff_ignore) {
					$color = 'clear';
				} else {
					$diff = 1;
				}
				$bb->color_line ($color, "$pkg: $first $ver $other $otherver\n");
			}
		}
	}

	if ($diff) {
		$bb->print ("\n");
	} elsif (@hosts) {
		$bb->color_line ('green',
			"no package differences in pool $hostname\n\n");
	} else {
		$bb->color_line ('clear', "not enough hosts in pool $hostname\n\n");
	}

	$bb->print ("Hosts:\n" . join ("\n", $first, @hosts) . "\n");
	$bb->send;
}