����JFIF��x�x����'
| Server IP : 78.140.185.180 / Your IP : 216.73.216.170 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/self/root/proc/1630575/root/usr/lib64/nagios/plugins/extra/ |
Upload File : |
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw(say);
use Getopt::Long;
use experimental qw(smartmatch);
use IPC::Run qw(run);
use File::Slurp qw(read_file);
use Carp;
# set locale so yum/dnf doesn't show results in other languages
local $ENV{LC_ALL} = "en_US.UTF-8";
my $opt_e;
GetOptions(
"help|h" => \&help,
"e=s" => \$opt_e,
);
my $bin;
my $prefix;
my @whitelist = split /,/, $opt_e if $opt_e;
if ( -f '/bin/dnf' ) {
$bin = 'dnf';
$prefix = '/etc/' . $bin . '/plugins';
}
else {
$bin = 'yum';
$prefix = '/etc/' . $bin . '/pluginconf.d';
}
my $lockfile = $prefix . '/' . 'versionlock.list';
exit_plugin( 'OK', '0' ) if !-f $lockfile;
my @locked = read_file($lockfile);
chomp @locked;
exit_plugin( 'OK', '0' ) if !@locked;
my @to_update;
for my $line (@locked) {
next if $line =~ /(^$)|(^#)/;
# dnf adds only package with versioning, yum prefixes it with some number
# so we need to extract package name correctly
my $package =
$bin eq 'dnf'
? $line
: $2
if $line =~ /(.*)+:((.*)+)/;
# extract real package name without version, arch etc
my @package =
map {
chomp;
$_ =~ /Name(\s)+:(\s)+((.)+)/i ? $3 : ()
}
split( "\n", run_cmd( '/bin/' . $bin, 'info', $package ) );
next if ( @whitelist && $package[0] ~~ @whitelist );
# check if there are any updates
my $updates_info = run_cmd( '/bin/' . $bin, 'info', $package[0] );
push @to_update, $package[0]
if $updates_info =~ /Available Packages/;
}
@to_update
? exit_plugin( 'Updates available for packages: ' . join( ", ", @to_update ), '1' )
: exit_plugin( 'OK', '0' );
sub run_cmd {
my @cmd = @_;
my ( $out, $err );
run \@cmd, \undef, \$out, \$err;
croak $err if $? != 0;
return $out;
}
sub exit_plugin {
my ( $message, $exitcode ) = @_;
say $message;
exit $exitcode;
}
sub help {
print "Usage : $0 -e package1,package2,...\n";
print "Options :\n";
print " -e: List of packages to exclude from checks, separated by comma\n";
exit;
};