This file is indexed.

/usr/share/munin/plugins/yum 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
#!/usr/bin/perl -w
# -*- perl -*-
# vim: ft=perl

=head1 NAME

yum - Plugin for monitoring pending package upgrades with yum

=head1 USAGE

This plugin needs to be called with the 'update' argument
from cron to work as intended.

=head1 AUTHOR

Copyright 2006 Dagfinn Ilmari Mannsåker <ilmari@lonres.com>

=head1 LICENSE

Unknown license

=head1 MAGIC MARKERS

 #%# family=auto
 #%# capabilities=autoconf

=cut

use strict;
use Munin::Common::Defaults;

my $statefile = "$Munin::Common::Defaults::MUNIN_PLUGSTATE/yum.state";

sub update {
    if (-l $statefile) {
	die "$statefile is a symlink, not touching.\n";
    }

    open my $state, '>', $statefile
	or die "Can't open $statefile for writing: $!\n";

    open my $yum, '-|', 'yum list updates'
	or die "Can't run 'yum list updates': $!";

    # Skip header crap
    while (<$yum>) {
	last if /^Updated/;
    }

    while (<$yum>) {
	next unless /^(\S+)\.\S+\s+\S+\s+\S+/;
	print $state "$1\n";
    }

    close $yum or die "Error running 'yum list updates': $!\n";
    close $state or die "Error writing $statefile: $!\n";
}

sub autoconf {
    my $ret = system('yum --version >/dev/null 2>/dev/null');
    if ($ret == 0) {
	print "yes\n";
	exit 0;
    }
    else {
	print "no\n";
	exit 0;
    }
}

sub config {
    print "graph_title Pending packages\n";
    print "graph no\n";
    print "pending.label pending\n";
    print "pending.warning 0:0\n";
}

sub report {
    my @packages;

    open my $state, '<', $statefile
	or die "Can't open $statefile for reading: $!
Please read 'munindoc yum' to understand why if the file does not exist.\n";

    chomp(@packages = <$state>);
    close $state;

    print 'pending.value ', scalar(@packages), "\n";
    print 'pending.extinfo ', join(' ', @packages), "\n"
	if @packages;
}

if ($ARGV[0]) {
    my $arg = $ARGV[0];
    my %funcs = (
        update   => \&update,
        config   => \&config,
        autoconf => \&autoconf,
    );

    if (exists $funcs{$arg}) {
	$funcs{$arg}->();
    } else {
	die "Unknown argument '$arg'\n";
    }
} else {
    report();
}