mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-23 21:55:16 +02:00
Evolution #3959
Commande de cartographie git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@13 a5eaa968-4c79-4d68-970d-af6011b5b055
This commit is contained in:
parent
8c277b8947
commit
cae8e0ccbc
@ -1,359 +1,373 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
no strict "refs";
|
no strict "refs";
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
|
|
||||||
my $PROGNAME = $0;
|
my $PROGNAME = $0;
|
||||||
my $VERSION = "1.0";
|
my $VERSION = "1.0";
|
||||||
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
|
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
|
||||||
my $socket;
|
my $socket;
|
||||||
|
|
||||||
sub print_help();
|
sub print_help();
|
||||||
sub print_usage();
|
sub print_usage();
|
||||||
sub print_revision($$);
|
sub print_revision($$);
|
||||||
|
|
||||||
my %OPTION = (
|
my %OPTION = (
|
||||||
"help" => undef, "version" => undef,
|
"help" => undef, "version" => undef,
|
||||||
"esxd-host" => undef, "esxd-port" => 5700,
|
"esxd-host" => undef, "esxd-port" => 5700,
|
||||||
"usage" => undef,
|
"usage" => undef,
|
||||||
"esx-host" => undef,
|
"esx-host" => undef,
|
||||||
"datastore" => undef,
|
"datastore" => undef,
|
||||||
"nic" => undef,
|
"nic" => undef,
|
||||||
"warning" => undef,
|
"warning" => undef,
|
||||||
"critical" => undef
|
"critical" => undef
|
||||||
);
|
);
|
||||||
|
|
||||||
Getopt::Long::Configure('bundling');
|
Getopt::Long::Configure('bundling');
|
||||||
GetOptions(
|
GetOptions(
|
||||||
"h|help" => \$OPTION{'help'},
|
"h|help" => \$OPTION{'help'},
|
||||||
"V|version" => \$OPTION{'version'},
|
"V|version" => \$OPTION{'version'},
|
||||||
"H|centreon-esxd-host=s" => \$OPTION{'esxd-host'},
|
"H|centreon-esxd-host=s" => \$OPTION{'esxd-host'},
|
||||||
"P|centreon-esxd-port=i" => \$OPTION{'esxd-port'},
|
"P|centreon-esxd-port=i" => \$OPTION{'esxd-port'},
|
||||||
|
|
||||||
"u|usage=s" => \$OPTION{'usage'},
|
"u|usage=s" => \$OPTION{'usage'},
|
||||||
"e|esx-host=s" => \$OPTION{'esx-host'},
|
"e|esx-host=s" => \$OPTION{'esx-host'},
|
||||||
|
|
||||||
"datastore=s" => \$OPTION{'datastore'},
|
"datastore=s" => \$OPTION{'datastore'},
|
||||||
"nic=s" => \$OPTION{'nic'},
|
"nic=s" => \$OPTION{'nic'},
|
||||||
|
|
||||||
"w|warning=i" => \$OPTION{'warning'},
|
"w|warning=i" => \$OPTION{'warning'},
|
||||||
"c|critical=i" => \$OPTION{'critical'},
|
"c|critical=i" => \$OPTION{'critical'},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (defined($OPTION{'version'})) {
|
if (defined($OPTION{'version'})) {
|
||||||
print_revision($PROGNAME, $VERSION);
|
print_revision($PROGNAME, $VERSION);
|
||||||
exit $ERRORS{'OK'};
|
exit $ERRORS{'OK'};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($OPTION{'help'})) {
|
if (defined($OPTION{'help'})) {
|
||||||
print_help();
|
print_help();
|
||||||
exit $ERRORS{'OK'};
|
exit $ERRORS{'OK'};
|
||||||
}
|
}
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# Functions #
|
# Functions #
|
||||||
#############
|
#############
|
||||||
|
|
||||||
sub print_usage () {
|
sub print_usage () {
|
||||||
print "Usage: ";
|
print "Usage: ";
|
||||||
print $PROGNAME."\n";
|
print $PROGNAME."\n";
|
||||||
print " -V (--version) Plugin version\n";
|
print " -V (--version) Plugin version\n";
|
||||||
print " -h (--help) usage help\n";
|
print " -h (--help) usage help\n";
|
||||||
print " -H centreon-esxd Host (required)\n";
|
print " -H centreon-esxd Host (required)\n";
|
||||||
print " -P centreon-esxd Port (default 5700)\n";
|
print " -P centreon-esxd Port (default 5700)\n";
|
||||||
print " -u (--usage) What to check. The list and args (required)\n";
|
print " -u (--usage) What to check. The list and args (required)\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'healthhost':\n";
|
print "'healthhost':\n";
|
||||||
print " -e (--esx-host) Esx Host to check (required)\n";
|
print " -e (--esx-host) Esx Host to check (required)\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'maintenancehost':\n";
|
print "'maintenancehost':\n";
|
||||||
print " -e (--esx-host) Esx Host to check (required)\n";
|
print " -e (--esx-host) Esx Host to check (required)\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'statushost':\n";
|
print "'statushost':\n";
|
||||||
print " -e (--esx-host) Esx Host to check (required)\n";
|
print " -e (--esx-host) Esx Host to check (required)\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'datastores':\n";
|
print "'datastores':\n";
|
||||||
print " --datastore Datastore name to check (required)\n";
|
print " --datastore Datastore name to check (required)\n";
|
||||||
print " -w (--warning) Warning Threshold in percent (default 80)\n";
|
print " -w (--warning) Warning Threshold in percent (default 80)\n";
|
||||||
print " -c (--critical) Critical Threshold in percent (default 90)\n";
|
print " -c (--critical) Critical Threshold in percent (default 90)\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'cpuhost':\n";
|
print "'cpuhost':\n";
|
||||||
print " -e (--esx-host) Esx Host to check (required)\n";
|
print " -e (--esx-host) Esx Host to check (required)\n";
|
||||||
print " -w (--warning) Warning Threshold in percent (default 80)\n";
|
print " -w (--warning) Warning Threshold in percent (default 80)\n";
|
||||||
print " -c (--critical) Critical Threshold in percent (default 90)\n";
|
print " -c (--critical) Critical Threshold in percent (default 90)\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'nethost':\n";
|
print "'nethost':\n";
|
||||||
print " -e (--esx-host) Esx Host to check (required)\n";
|
print " -e (--esx-host) Esx Host to check (required)\n";
|
||||||
print " --nic Physical nic name to check (required)\n";
|
print " --nic Physical nic name to check (required)\n";
|
||||||
print " -w (--warning) Warning Threshold in percent (default 80)\n";
|
print " -w (--warning) Warning Threshold in percent (default 80)\n";
|
||||||
print " -c (--critical) Critical Threshold in percent (default 90)\n";
|
print " -c (--critical) Critical Threshold in percent (default 90)\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'memhost':\n";
|
print "'memhost':\n";
|
||||||
print " -e (--esx-host) Esx Host to check (required)\n";
|
print " -e (--esx-host) Esx Host to check (required)\n";
|
||||||
print " -w (--warning) Warning Threshold in percent (default 80)\n";
|
print " -w (--warning) Warning Threshold in percent (default 80)\n";
|
||||||
print " -c (--critical) Critical Threshold in percent (default 90)\n";
|
print " -c (--critical) Critical Threshold in percent (default 90)\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'swaphost':\n";
|
print "'swaphost':\n";
|
||||||
print " -e (--esx-host) Esx Host to check (required)\n";
|
print " -e (--esx-host) Esx Host to check (required)\n";
|
||||||
print " -w (--warning) Warning Threshold in MB/s (default 0.8)\n";
|
print " -w (--warning) Warning Threshold in MB/s (default 0.8)\n";
|
||||||
print " -c (--critical) Critical Threshold in MB/s (default 1)\n";
|
print " -c (--critical) Critical Threshold in MB/s (default 1)\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'listhost':\n";
|
print "'listhost':\n";
|
||||||
print " None\n";
|
print " None\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'listdatastore':\n";
|
print "'listdatastore':\n";
|
||||||
print " None\n";
|
print " None\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
print "'listnichost':\n";
|
print "'listnichost':\n";
|
||||||
print " -e (--esx-host) Esx Host to check (required)\n";
|
print " -e (--esx-host) Esx Host to check (required)\n";
|
||||||
}
|
print "\n";
|
||||||
|
print "'getmap':\n";
|
||||||
sub print_help () {
|
print " -e (--esx-host) Esx Host to check\n";
|
||||||
print "##############################################\n";
|
}
|
||||||
print "# Copyright (c) 2005-2012 Centreon #\n";
|
|
||||||
print "# Bugs to http://redmine.merethis.net/ #\n";
|
sub print_help () {
|
||||||
print "##############################################\n";
|
print "##############################################\n";
|
||||||
print "\n";
|
print "# Copyright (c) 2005-2012 Centreon #\n";
|
||||||
print_usage();
|
print "# Bugs to http://redmine.merethis.net/ #\n";
|
||||||
print "\n";
|
print "##############################################\n";
|
||||||
}
|
print "\n";
|
||||||
|
print_usage();
|
||||||
sub print_revision($$) {
|
print "\n";
|
||||||
my $commandName = shift;
|
}
|
||||||
my $pluginRevision = shift;
|
|
||||||
print "$commandName v$pluginRevision (centreon-esxd)\n";
|
sub print_revision($$) {
|
||||||
}
|
my $commandName = shift;
|
||||||
|
my $pluginRevision = shift;
|
||||||
sub myconnect {
|
print "$commandName v$pluginRevision (centreon-esxd)\n";
|
||||||
if (!($socket = IO::Socket::INET->new( Proto => "tcp",
|
}
|
||||||
PeerAddr => $OPTION{'esxd-host'},
|
|
||||||
PeerPort => $OPTION{'esxd-port'}))) {
|
sub myconnect {
|
||||||
print "Cannot connect to on '$OPTION{'esxd-host'}': $!\n";
|
if (!($socket = IO::Socket::INET->new( Proto => "tcp",
|
||||||
exit $ERRORS{'UNKNOWN'};
|
PeerAddr => $OPTION{'esxd-host'},
|
||||||
}
|
PeerPort => $OPTION{'esxd-port'}))) {
|
||||||
$socket->autoflush(1);
|
print "Cannot connect to on '$OPTION{'esxd-host'}': $!\n";
|
||||||
}
|
exit $ERRORS{'UNKNOWN'};
|
||||||
|
}
|
||||||
#################
|
$socket->autoflush(1);
|
||||||
# Func Usage
|
}
|
||||||
#################
|
|
||||||
|
#################
|
||||||
sub maintenancehost_check_arg {
|
# Func Usage
|
||||||
if (!defined($OPTION{'esx-host'})) {
|
#################
|
||||||
print "Option --esx-host is required\n";
|
|
||||||
print_usage();
|
sub maintenancehost_check_arg {
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'esx-host'})) {
|
||||||
}
|
print "Option --esx-host is required\n";
|
||||||
return 0;
|
print_usage();
|
||||||
}
|
exit $ERRORS{'UNKNOWN'};
|
||||||
|
}
|
||||||
sub maintenancehost_get_str {
|
return 0;
|
||||||
return "maintenancehost|" . $OPTION{'esx-host'};
|
}
|
||||||
}
|
|
||||||
|
sub maintenancehost_get_str {
|
||||||
sub statushost_check_arg {
|
return "maintenancehost|" . $OPTION{'esx-host'};
|
||||||
if (!defined($OPTION{'esx-host'})) {
|
}
|
||||||
print "Option --esx-host is required\n";
|
|
||||||
print_usage();
|
sub statushost_check_arg {
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'esx-host'})) {
|
||||||
}
|
print "Option --esx-host is required\n";
|
||||||
return 0;
|
print_usage();
|
||||||
}
|
exit $ERRORS{'UNKNOWN'};
|
||||||
|
}
|
||||||
sub statushost_get_str {
|
return 0;
|
||||||
return "statushost|" . $OPTION{'esx-host'};
|
}
|
||||||
}
|
|
||||||
|
sub statushost_get_str {
|
||||||
sub healthhost_check_arg {
|
return "statushost|" . $OPTION{'esx-host'};
|
||||||
if (!defined($OPTION{'esx-host'})) {
|
}
|
||||||
print "Option --esx-host is required\n";
|
|
||||||
print_usage();
|
sub healthhost_check_arg {
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'esx-host'})) {
|
||||||
}
|
print "Option --esx-host is required\n";
|
||||||
return 0;
|
print_usage();
|
||||||
}
|
exit $ERRORS{'UNKNOWN'};
|
||||||
|
}
|
||||||
sub healthhost_get_str {
|
return 0;
|
||||||
return "healthhost|" . $OPTION{'esx-host'};
|
}
|
||||||
}
|
|
||||||
|
sub healthhost_get_str {
|
||||||
sub datastores_check_arg {
|
return "healthhost|" . $OPTION{'esx-host'};
|
||||||
if (!defined($OPTION{'datastore'})) {
|
}
|
||||||
print "Option --datastore is required\n";
|
|
||||||
print_usage();
|
sub datastores_check_arg {
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'datastore'})) {
|
||||||
}
|
print "Option --datastore is required\n";
|
||||||
if (!defined($OPTION{'warning'})) {
|
print_usage();
|
||||||
$OPTION{'warning'} = 80;
|
exit $ERRORS{'UNKNOWN'};
|
||||||
}
|
}
|
||||||
if (!defined($OPTION{'critical'})) {
|
if (!defined($OPTION{'warning'})) {
|
||||||
$OPTION{'critical'} = 90;
|
$OPTION{'warning'} = 80;
|
||||||
}
|
}
|
||||||
return 0;
|
if (!defined($OPTION{'critical'})) {
|
||||||
}
|
$OPTION{'critical'} = 90;
|
||||||
|
}
|
||||||
sub datastores_get_str {
|
return 0;
|
||||||
return "datastores|" . $OPTION{'datastore'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
|
}
|
||||||
}
|
|
||||||
|
sub datastores_get_str {
|
||||||
sub cpuhost_check_arg {
|
return "datastores|" . $OPTION{'datastore'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
|
||||||
|
}
|
||||||
if (!defined($OPTION{'esx-host'})) {
|
|
||||||
print "Option --esx-host is required\n";
|
sub cpuhost_check_arg {
|
||||||
print_usage();
|
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'esx-host'})) {
|
||||||
}
|
print "Option --esx-host is required\n";
|
||||||
if (!defined($OPTION{'warning'})) {
|
print_usage();
|
||||||
$OPTION{'warning'} = 80;
|
exit $ERRORS{'UNKNOWN'};
|
||||||
}
|
}
|
||||||
if (!defined($OPTION{'critical'})) {
|
if (!defined($OPTION{'warning'})) {
|
||||||
$OPTION{'critical'} = 90;
|
$OPTION{'warning'} = 80;
|
||||||
}
|
}
|
||||||
return 0;
|
if (!defined($OPTION{'critical'})) {
|
||||||
}
|
$OPTION{'critical'} = 90;
|
||||||
|
}
|
||||||
sub cpuhost_get_str {
|
return 0;
|
||||||
return "cpuhost|" . $OPTION{'esx-host'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
|
}
|
||||||
}
|
|
||||||
|
sub cpuhost_get_str {
|
||||||
sub memhost_check_arg {
|
return "cpuhost|" . $OPTION{'esx-host'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
|
||||||
if (!defined($OPTION{'esx-host'})) {
|
}
|
||||||
print "Option --esx-host is required\n";
|
|
||||||
print_usage();
|
sub memhost_check_arg {
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'esx-host'})) {
|
||||||
}
|
print "Option --esx-host is required\n";
|
||||||
if (!defined($OPTION{'warning'})) {
|
print_usage();
|
||||||
$OPTION{'warning'} = 80;
|
exit $ERRORS{'UNKNOWN'};
|
||||||
}
|
}
|
||||||
if (!defined($OPTION{'critical'})) {
|
if (!defined($OPTION{'warning'})) {
|
||||||
$OPTION{'critical'} = 90;
|
$OPTION{'warning'} = 80;
|
||||||
}
|
}
|
||||||
return 0;
|
if (!defined($OPTION{'critical'})) {
|
||||||
}
|
$OPTION{'critical'} = 90;
|
||||||
|
}
|
||||||
sub memhost_get_str {
|
return 0;
|
||||||
return "memhost|" . $OPTION{'esx-host'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
|
}
|
||||||
}
|
|
||||||
|
sub memhost_get_str {
|
||||||
sub swaphost_check_arg {
|
return "memhost|" . $OPTION{'esx-host'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
|
||||||
if (!defined($OPTION{'esx-host'})) {
|
}
|
||||||
print "Option --esx-host is required\n";
|
|
||||||
print_usage();
|
sub swaphost_check_arg {
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'esx-host'})) {
|
||||||
}
|
print "Option --esx-host is required\n";
|
||||||
if (!defined($OPTION{'warning'})) {
|
print_usage();
|
||||||
$OPTION{'warning'} = 0.8;
|
exit $ERRORS{'UNKNOWN'};
|
||||||
}
|
}
|
||||||
if (!defined($OPTION{'critical'})) {
|
if (!defined($OPTION{'warning'})) {
|
||||||
$OPTION{'critical'} = 1;
|
$OPTION{'warning'} = 0.8;
|
||||||
}
|
}
|
||||||
return 0;
|
if (!defined($OPTION{'critical'})) {
|
||||||
}
|
$OPTION{'critical'} = 1;
|
||||||
|
}
|
||||||
sub swaphost_get_str {
|
return 0;
|
||||||
return "swaphost|" . $OPTION{'esx-host'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
|
}
|
||||||
}
|
|
||||||
|
sub swaphost_get_str {
|
||||||
sub nethost_check_arg {
|
return "swaphost|" . $OPTION{'esx-host'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
|
||||||
if (!defined($OPTION{'esx-host'})) {
|
}
|
||||||
print "Option --esx-host is required\n";
|
|
||||||
print_usage();
|
sub nethost_check_arg {
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'esx-host'})) {
|
||||||
}
|
print "Option --esx-host is required\n";
|
||||||
if (!defined($OPTION{'nic'})) {
|
print_usage();
|
||||||
print "Option --nic is required\n";
|
exit $ERRORS{'UNKNOWN'};
|
||||||
print_usage();
|
}
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'nic'})) {
|
||||||
}
|
print "Option --nic is required\n";
|
||||||
if (!defined($OPTION{'warning'})) {
|
print_usage();
|
||||||
$OPTION{'warning'} = 80;
|
exit $ERRORS{'UNKNOWN'};
|
||||||
}
|
}
|
||||||
if (!defined($OPTION{'critical'})) {
|
if (!defined($OPTION{'warning'})) {
|
||||||
$OPTION{'critical'} = 90;
|
$OPTION{'warning'} = 80;
|
||||||
}
|
}
|
||||||
return 0;
|
if (!defined($OPTION{'critical'})) {
|
||||||
}
|
$OPTION{'critical'} = 90;
|
||||||
|
}
|
||||||
sub nethost_get_str {
|
return 0;
|
||||||
return "nethost|" . $OPTION{'esx-host'} . "|" . $OPTION{'nic'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
|
}
|
||||||
}
|
|
||||||
|
sub nethost_get_str {
|
||||||
sub listhost_check_arg {
|
return "nethost|" . $OPTION{'esx-host'} . "|" . $OPTION{'nic'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'};
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
|
sub listhost_check_arg {
|
||||||
sub listhost_get_str {
|
return 0;
|
||||||
return "listhost";
|
}
|
||||||
}
|
|
||||||
|
sub listhost_get_str {
|
||||||
sub listdatastore_check_arg {
|
return "listhost";
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
|
sub listdatastore_check_arg {
|
||||||
sub listdatastore_get_str {
|
return 0;
|
||||||
return "listdatastore";
|
}
|
||||||
}
|
|
||||||
|
sub listdatastore_get_str {
|
||||||
sub listnichost_check_arg {
|
return "listdatastore";
|
||||||
if (!defined($OPTION{'esx-host'})) {
|
}
|
||||||
print "Option --esx-host is required\n";
|
|
||||||
print_usage();
|
sub listnichost_check_arg {
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'esx-host'})) {
|
||||||
}
|
print "Option --esx-host is required\n";
|
||||||
return 0;
|
print_usage();
|
||||||
}
|
exit $ERRORS{'UNKNOWN'};
|
||||||
|
}
|
||||||
sub listnichost_get_str {
|
return 0;
|
||||||
return "listnichost|" . $OPTION{'esx-host'};
|
}
|
||||||
}
|
|
||||||
|
sub listnichost_get_str {
|
||||||
#################
|
return "listnichost|" . $OPTION{'esx-host'};
|
||||||
#################
|
}
|
||||||
|
|
||||||
if (!defined($OPTION{'esxd-host'})) {
|
sub getmap_check_arg {
|
||||||
print "Option -H (--esxd-host) is required\n";
|
if (!defined($OPTION{'esx-host'})) {
|
||||||
print_usage();
|
$OPTION{'esx-host'} = "";
|
||||||
exit $ERRORS{'UNKNOWN'};
|
}
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
if (!defined($OPTION{'usage'})) {
|
|
||||||
print "Option -u (--usage) is required\n";
|
sub getmap_get_str {
|
||||||
print_usage();
|
return "getmap|" . $OPTION{'esx-host'};
|
||||||
exit $ERRORS{'UNKNOWN'};
|
}
|
||||||
}
|
|
||||||
if ($OPTION{'usage'} !~ /^(healthhost|datastores|maintenancehost|statushost|cpuhost|nethost|memhost|swaphost|listhost|listdatastore|listnichost)$/) {
|
#################
|
||||||
print "Usage value is unknown\n";
|
#################
|
||||||
print_usage();
|
|
||||||
exit $ERRORS{'UNKNOWN'};
|
if (!defined($OPTION{'esxd-host'})) {
|
||||||
}
|
print "Option -H (--esxd-host) is required\n";
|
||||||
|
print_usage();
|
||||||
my $func_check_arg = $OPTION{'usage'} . "_check_arg";
|
exit $ERRORS{'UNKNOWN'};
|
||||||
my $func_get_str = $OPTION{'usage'} . "_get_str";
|
}
|
||||||
&$func_check_arg();
|
|
||||||
my $str_send = &$func_get_str();
|
if (!defined($OPTION{'usage'})) {
|
||||||
myconnect();
|
print "Option -u (--usage) is required\n";
|
||||||
print $socket "$str_send\n";
|
print_usage();
|
||||||
my $return = <$socket>;
|
exit $ERRORS{'UNKNOWN'};
|
||||||
close $socket;
|
}
|
||||||
|
if ($OPTION{'usage'} !~ /^(healthhost|datastores|maintenancehost|statushost|cpuhost|nethost|memhost|swaphost|listhost|listdatastore|listnichost|getmap)$/) {
|
||||||
chomp $return;
|
print "Usage value is unknown\n";
|
||||||
$return =~ /^(-?[0-9]*?)\|/;
|
print_usage();
|
||||||
my $status_return = $1;
|
exit $ERRORS{'UNKNOWN'};
|
||||||
$return =~ s/^(-?[0-9]*?)\|//;
|
}
|
||||||
print $return . "\n";
|
|
||||||
|
my $func_check_arg = $OPTION{'usage'} . "_check_arg";
|
||||||
if ($status_return == -1) {
|
my $func_get_str = $OPTION{'usage'} . "_get_str";
|
||||||
$status_return = 3;
|
&$func_check_arg();
|
||||||
}
|
my $str_send = &$func_get_str();
|
||||||
exit $status_return;
|
myconnect();
|
||||||
|
print $socket "$str_send\n";
|
||||||
#print $remote "healthhost|srvi-esx-dev-1.merethis.net\n";
|
my $return = <$socket>;
|
||||||
#print $remote "datastores|LUN-VMFS-QGARNIER|80|90\n";
|
close $socket;
|
||||||
#print $remote "maintenancehost|srvi-esx-dev-1.merethis.net\n";
|
|
||||||
#print $remote "statushost|srvi-esx-dev-1.merethis.net\n";
|
chomp $return;
|
||||||
#print $remote "cpuhost|srvi-esx-dev-1.merethis.net|60\n";
|
$return =~ /^(-?[0-9]*?)\|/;
|
||||||
#print $remote "nethost|srvi-esx-dev-1.merethis.net|vmnic1|60\n";
|
my $status_return = $1;
|
||||||
#print $remote "memhost|srvi-esx-dev-1.merethis.net|80\n";
|
$return =~ s/^(-?[0-9]*?)\|//;
|
||||||
#print $remote "swaphost|srvi-esx-dev-1.merethis.net|80\n";
|
print $return . "\n";
|
||||||
|
|
||||||
|
if ($status_return == -1) {
|
||||||
|
$status_return = 3;
|
||||||
|
}
|
||||||
|
exit $status_return;
|
||||||
|
|
||||||
|
#print $remote "healthhost|srvi-esx-dev-1.merethis.net\n";
|
||||||
|
#print $remote "datastores|LUN-VMFS-QGARNIER|80|90\n";
|
||||||
|
#print $remote "maintenancehost|srvi-esx-dev-1.merethis.net\n";
|
||||||
|
#print $remote "statushost|srvi-esx-dev-1.merethis.net\n";
|
||||||
|
#print $remote "cpuhost|srvi-esx-dev-1.merethis.net|60\n";
|
||||||
|
#print $remote "nethost|srvi-esx-dev-1.merethis.net|vmnic1|60\n";
|
||||||
|
#print $remote "memhost|srvi-esx-dev-1.merethis.net|80\n";
|
||||||
|
#print $remote "swaphost|srvi-esx-dev-1.merethis.net|80\n";
|
||||||
|
@ -67,7 +67,8 @@ our %checks_descr = (
|
|||||||
"swaphost" => {'arg' => \&swaphost_check_args, 'compute' => \&swaphost_compute_args, 'exec' => \&swaphost_do},
|
"swaphost" => {'arg' => \&swaphost_check_args, 'compute' => \&swaphost_compute_args, 'exec' => \&swaphost_do},
|
||||||
"listhost" => {'arg' => \&listhost_check_args, 'compute' => \&listhost_compute_args, 'exec' => \&listhost_do},
|
"listhost" => {'arg' => \&listhost_check_args, 'compute' => \&listhost_compute_args, 'exec' => \&listhost_do},
|
||||||
"listdatastore" => {'arg' => \&listdatastore_check_args, 'compute' => \&listdatastore_compute_args, 'exec' => \&listdatastore_do},
|
"listdatastore" => {'arg' => \&listdatastore_check_args, 'compute' => \&listdatastore_compute_args, 'exec' => \&listdatastore_do},
|
||||||
"listnichost" => {'arg' => \&listnichost_check_args, 'compute' => \&listnichost_compute_args, 'exec' => \&listnichost_do}
|
"listnichost" => {'arg' => \&listnichost_check_args, 'compute' => \&listnichost_compute_args, 'exec' => \&listnichost_do},
|
||||||
|
"getmap" => {'arg' => \&getmap_check_args, 'compute' => \&getmap_compute_args, 'exec' => \&getmap_do}
|
||||||
);
|
);
|
||||||
|
|
||||||
sub writeLogFile($$) {
|
sub writeLogFile($$) {
|
||||||
@ -887,7 +888,6 @@ sub listhost_compute_args {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub listhost_do {
|
sub listhost_do {
|
||||||
my ($lhost) = @_;
|
|
||||||
my %filters = ();
|
my %filters = ();
|
||||||
my @properties = ('name');
|
my @properties = ('name');
|
||||||
my $result = get_entities_host('HostSystem', \%filters, \@properties);
|
my $result = get_entities_host('HostSystem', \%filters, \@properties);
|
||||||
@ -1000,6 +1000,61 @@ sub listnichost_do {
|
|||||||
print_response($ERRORS{$MYERRORS{$status}} . "|$output_up. $output_down.\n");
|
print_response($ERRORS{$MYERRORS{$status}} . "|$output_up. $output_down.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
############
|
||||||
|
# Get Map Func
|
||||||
|
############
|
||||||
|
|
||||||
|
sub getmap_check_args {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub getmap_compute_args {
|
||||||
|
my $lhost = $_[0];
|
||||||
|
return ($lhost);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub getmap_do {
|
||||||
|
my ($lhost) = @_;
|
||||||
|
my %filters = ();
|
||||||
|
if (defined($lhost) and $lhost ne "") {
|
||||||
|
%filters = ('name' => $lhost);
|
||||||
|
}
|
||||||
|
my @properties = ('name', 'vm');
|
||||||
|
my $result = get_entities_host('HostSystem', \%filters, \@properties);
|
||||||
|
if (!defined($result)) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $status = 0; # OK
|
||||||
|
my $output = '';
|
||||||
|
my $output_append = "";
|
||||||
|
|
||||||
|
foreach my $entity_view (@$result) {
|
||||||
|
$output .= $output_append . "ESX Host '" . $entity_view->name . "': ";
|
||||||
|
my @vm_array = ();
|
||||||
|
if (defined $entity_view->vm) {
|
||||||
|
@vm_array = (@vm_array, @{$entity_view->vm});
|
||||||
|
}
|
||||||
|
|
||||||
|
@properties = ('name', 'summary.runtime.powerState');
|
||||||
|
my $result2 = get_views(\@vm_array, \@properties);
|
||||||
|
if (!defined($result)) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $output_append2 = '';
|
||||||
|
foreach my $vm (@$result2) {
|
||||||
|
if ($vm->{'summary.runtime.powerState'}->val eq "poweredOn") {
|
||||||
|
$output .= $output_append2 . "[" . $vm->name . "]";
|
||||||
|
$output_append2 = ', ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$output_append = ". ";
|
||||||
|
}
|
||||||
|
|
||||||
|
print_response($ERRORS{$MYERRORS{$status}} . "|$output\n");
|
||||||
|
}
|
||||||
|
|
||||||
############
|
############
|
||||||
|
|
||||||
sub catch_zap_term {
|
sub catch_zap_term {
|
||||||
@ -1273,16 +1328,16 @@ while (1) {
|
|||||||
my ($name, @args) = split /\|/, $line;
|
my ($name, @args) = split /\|/, $line;
|
||||||
if (!defined($checks_descr{$name})) {
|
if (!defined($checks_descr{$name})) {
|
||||||
$rh->send("3|Unknown method name '$name'\n");
|
$rh->send("3|Unknown method name '$name'\n");
|
||||||
|
delete $sockets{fileno($rh)};
|
||||||
$read_select->remove($rh);
|
$read_select->remove($rh);
|
||||||
close $rh;
|
close $rh;
|
||||||
delete $sockets{fileno($rh)};
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if ($checks_descr{$name}->{'arg'}(@args)) {
|
if ($checks_descr{$name}->{'arg'}(@args)) {
|
||||||
$rh->send("3|Params error '$name'\n");
|
$rh->send("3|Params error '$name'\n");
|
||||||
|
delete $sockets{fileno($rh)};
|
||||||
$read_select->remove($rh);
|
$read_select->remove($rh);
|
||||||
close $rh;
|
close $rh;
|
||||||
delete $sockets{fileno($rh)};
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user