����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/1630575/task/1630575/root/proc/1630575/root/lib64/nagios/plugins/base/ |
Upload File : |
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use Carp;
use Getopt::Long;
my $exitcode = 0;
my ( $opt_s, @incidents );
my $message = 'OK';
help() if !(@ARGV);
# Set options
GetOptions(
"help|h" => \&help,
"s=s" => \$opt_s,
);
&help unless $opt_s;
croak 'systemctl is not installed!' if !-r '/bin/systemctl';
my @services = split( ',', $opt_s );
for my $service (@services) {
if ( $service !~ /^[A-Za-z0-9\_\-\.\:\@]{1,255}$/ ) {
say "Invalid service name: $service";
$exitcode = 2;
next;
}
my $status = `/bin/systemctl is-active $service`;
chomp $status;
if ( $status ne 'active' ) {
push @incidents, $service;
$exitcode = '2';
$message = 'Found inactive services: ';
}
}
say $message;
say join( ',', @incidents ) if @incidents;
exit $exitcode;
# subs
sub help {
print "Usage : $0 -s service1,service2\n";
print "Options :\n";
print " -s: List of services to check via systemctl\n";
print "\nExample of usage : $0 -s mysqld,httpd\n";
exit 3;
}