This file is indexed.

/usr/share/munin/plugins/ntp_states is in munin-node 1.4.6-3ubuntu3.

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
#!/usr/bin/perl -w
# -*- perl -*-

=head1 NAME

ntp_states - Plugin to monitor NTP states

=head1 CONFIGURATION

No configuration

This plugin must run as the user "root"

The following configuration parameters are used by this plugin

 [ntp_states]
  env.lowercase - Lowercase hostnames after lookup

Set the variable env.lowercase to anything lowercase hostnames.

=head2 DEFAULT CONFIGURATION

 [ntp_states]
  env.lowercase <undefined>

=head1 AUTHORS

Unknown author

=head1 LICENSE

Unknown license

=head1 MAGIC MARKERS

 #%# family=manual
 #%# capabilities=autoconf

=cut

use strict;
use Net::hostent;
use Socket;

my %stateval = (
                 ' ' =>  1, # reject
		 'x' =>  2, # falsetick
		 '.' =>  3, # excess
		 '-' =>  4, # outlyer
		 '+' =>  5, # candidate
		 '#' =>  6, # selected
		 '*' =>  7, # sys.peer
		 'o' =>  8, # pps.peer
               );

if ($ARGV[0] and $ARGV[0] eq "autoconf") {
	`ntpq -c help >/dev/null 2>/dev/null`;
	if ($? eq "0") {
		if (`ntpq -c "hostnames no" -c peers | wc -l` > 0) {
			print "yes\n";
			exit 0;
		} else {
			print "no (could not read peer list)\n";
			exit 0;
		}
	} else {
		print "no (ntpq not found)\n";
		exit 0;
	}
}

if ($ARGV[0] and $ARGV[0] eq "config") {
        print "graph_title NTP states\n";
	print "graph_args --base 1000 --vertical-label msec --lower-limit 0\n";
	print "graph_category time\n";
	foreach (`ntpq -c "hostnames no" -c peers`) {
		next unless /^.(\d+\.\d+\.\d+\.\d+)/;
		next if /^.224\.0\.1\.1/;
		my $addr = $1;
		my $host;
		if( my $lcid= /^.127\.127\.1\.(\d+)/) {
			$lcid = $lcid - 1;
			$host = "LOCAL($lcid)";
		} else {
			$host = gethostbyaddr(inet_aton($addr));
			$host = defined $host ? $host->name : $addr;
		}
		my $name = $host;
		$host = lc $host if exists $ENV{"lowercase"};
		$host =~ s/[\.\-()]/_/g;
		print "$host.label $name\n";
		print "$host.draw LINE2\n";
	}
        exit 0;
}

foreach (`ntpq -c "hostnames no" -c peers`) {
	next unless /^(.)(\d+\.\d+\.\d+\.\d+)/;
	next if /^.224\.0\.1\.1/;
	my $state = $1;
	my $addr = $2;
	my $host;
	if( my $lcid= /^.127\.127\.1\.(\d+)/) {
		$lcid = $lcid - 1;
		$host = "LOCAL($lcid)"
	} else {
		$host = gethostbyaddr(inet_aton($addr));
		$host = defined $host ? $host->name : $addr;
	}
	$host = lc $host if exists $ENV{"lowercase"};
	$host =~ s/[\.\-()]/_/g;
	print "$host.value ", exists $stateval{$state} ? $stateval{$state} : 0, "\n";
}

exit 0;

# vim:syntax=perl