����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/root/proc/1630575/root/proc/self/root/usr/lib64/nagios/plugins/extra/ |
Upload File : |
#!/usr/bin/env perl
use POSIX qw(strftime);
my $now = time;
my $CRITICAL_TIME = 25; # hours
my $spool_dir = '/var/spool/backup';
my $cpanel_dir = '/usr/local/cpanel';
my $da_dir = '/usr/local/directadmin';
my $srv = system('mountpoint -q /srv');
my @incidents;
# directadmin
if ( -d $da_dir ) {
my $log = '/var/log/directadmin/backup_err.log';
if ( -s $log ) {
my $out = `cat $log`;
print $out;
exit 1;
}
}
# cpanel
if ( -d $cpanel_dir && -d $spool_dir && $srv != 0 ) {
my $cpanel_mdtm = ( stat($cpanel_dir) )[9];
my $diff = int( ( $now - $cpanel_mdtm ) / 3600 );
if ( $diff > $CRITICAL_TIME ) {
push @incidents, "backup last updated $diff hours ago \n";
}
# check if any backup process in T state or running more than 1 day
my @backup_procs = `pgrep ^backup\$`;
chomp @backup_procs;
for my $pid (@backup_procs) {
my $elapsed = `ps -o etimes= -p $pid | awk '{print \$1}'`;
my $state = `ps -o state= -p $pid`;
chomp( $elapsed, $state );
next if !$elapsed;
push @incidents,
"backup process with PID $pid is running $elapsed sec"
if elapsed > 86400;
push @incidents, "found backup process with PID $pid in T state"
if $state eq 'T';
}
my $enabled;
my $info;
my $whmapi = `which whmapi1`
; # we use shell because this plugin is also run on backup servers
chomp $whmapi;
my $bkp_dir = '/var/cpanel/backups';
opendir( my $dh, $bkp_dir ) || die "cannot open backup config dir: $!";
my @bkp_files = grep /\.backup_destination$/, readdir $dh;
closedir $dh;
if ( !@bkp_files ) {
push @incidents, 'backup config files not found';
}
else {
for (@bkp_files) {
next if $_ !~ /^ftp_backup/;
$_ =~ /ftp_backup_UID_(.+?).backup.destination/;
$info = `$whmapi backup_destination_get id=$1`;
if ( $info =~ /disabled: 0/ ) {
$enabled = 1;
}
else {
next;
}
}
push @incidents, 'no ftp backups enabled, check settings'
if !$enabled;
}
}
### CHECKS BELLOW IS FOR BACKUP SERVERS
# cpanel
for (< /srv/ftp/cpanel/* >) {
my $date = strftime("%Y-%m-%d", localtime);
my $cpanel =
( (localtime(time))[6] == 0 && -d "$_/weekly/$date" )
? "$_/weekly"
: ( (localtime(time))[6] == 1 && !-d "$_/$date" && -d "$_/weekly" )
? "$_/weekly"
: $_;
my $mdtm = ( stat($cpanel) )[9];
my $past_hours = sprintf( "%.2f", ( $now - $mdtm ) / 3600 );
my $cur_hour = ( localtime(time) )[2];
if ( $cur_hour >= 3 && $past_hours > $cur_hour ) {
push @incidents,
"$cpanel last updated $past_hours hours ago \n";
next;
}
if ( $past_hours > $CRITICAL_TIME ) {
push @incidents,
"$cpanel last updated $past_hours hours ago \n";
}
}
# ispmanager
for (< /srv/ftp/ispmanager/* >) {
my $isp = $_;
my $isp5 = `find $isp -maxdepth 1 -type f | head -1`;
if ($isp5) {
my $isp5_mdtm = ( stat("$isp") )[9];
my $diff_isp5 = int( ( $now - $isp5_mdtm ) / 3600 );
if ( $diff_isp5 > $CRITICAL_TIME ) {
push @incidents, "$isp last updated $diff_isp5 hours ago \n";
}
}
else {
my @usrdir = `find "$isp" -type d -mtime 0 2>/dev/null`;
if ( !@usrdir ) {
push @incidents, "$isp backup outdated \n";
}
}
}
# result
if (@incidents) {
print join( "\n", @incidents );
exit 2;
}
print "backup OK \n";