This file is indexed.

/usr/share/munin/plugins/nut_misc is in munin-plugins-extra 2.0.33-1.

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

=head1 NAME

nut_misc - Plugin to monitor UPS via the upsc command

=head1 CONFIGURATION

The following configuration parameters are used by this plugin

 [nut_misc]
  env.upsname - <name@host>
  env.upsc    - <command>

=head2 DEFAULT CONFIGURATION

 [nut_misc]
  env.upsname bertha@127.0.0.1
  env.upsc    upsc

=head1 AUTHORS

Unknown author

=head1 LICENSE

GPLv2

=head1 MAGIC MARKERS

 #%# family=contrib

=cut

use strict;

my %status;

my %config = (
	upsname => $ENV{"upsname"} ? $ENV{"upsname"} : 'bertha@127.0.0.1',
	upsc => $ENV{"upsc"} ? $ENV{"upsc"} : 'upsc'
);

my %graph =  (
	'battery_charge' => {
				label => 'charge - %',
				type => 'GAUGE',
				draw => 'LINE2'
			 },
	'battery_voltage' => {
				label => 'batt voltage - V',
				type => 'GAUGE',
				draw => 'LINE2'
			 },
	'battery_runtime' => {
				label => 'runtime - min',
				type => 'GAUGE',
				draw => 'LINE2'
			 },
	'input_frequency' => {
				label => 'input freq - Hz',
				type => 'GAUGE',
				draw => 'LINE2'
			 },
	'ups_load' => {
				label => 'load - %',
				type => 'GAUGE',
				draw => 'LINE2'
			 },
	'ups_temperature' => {
				label => 'temp - C',
				type => 'GAUGE',
				draw => 'LINE2'
			 }
);

if ( defined $ARGV[0] and $ARGV[0] eq 'config' ) {
	print "graph_title UPS Misc - $config{upsname}\n";
	#print "graph_args -l 110\n";
	#print "graph_vlabel Misc\n";
	foreach my $key (keys %graph) {
		print "$key.label $graph{$key}->{label}\n";
		print "$key.type $graph{$key}->{type}\n";
		print "$key.draw $graph{$key}->{draw}\n";
	}
} else {
	&fetch_values;
}

sub fetch_values {
	my $data = `$config{upsc} $config{upsname}`;
	while ($data =~ /([a-z.]+): (.+)\b/g) {
		my $label = $1;
		my $value = $2;
		$label =~ s/\./_/g;
		$status{$label} = $value;
	}
	$status{'battery_runtime'} /= 60;
	foreach my $label (sort keys %graph) {
		print "$label.value $status{$label}\n";
	}
}