Skip to content

Commit

Permalink
Version 1.2.5 - some bugfixes and changes. See HISTORY
Browse files Browse the repository at this point in the history
  • Loading branch information
BaldMansMojo committed Aug 5, 2022
1 parent b62d52d commit 4f63b93
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 25 deletions.
11 changes: 11 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -1332,3 +1332,14 @@ was done
is printed
- Remove output of guestToolsUnmanaged if --open_vm_tools_ok
- Fully ignore unknown states for hardware

- 04 Auf 2022 M.Fuerstenau version 1.2.5
- Renamed module host_list_vm_volumes_info to host_volumes_info
because name was misleading
- Minor corrections in help.pm
- New option --show-storage for runtime->listvms via host ore DC
- Fixed bug in blacklist/whitelist. Was casesensitve by default. This leads
to problems if for example a VM is defined in ESX with uppercase letters
and check is with lowercase (MYSERVER vs. myserver). So for example
checking for snapshots may result in no old snapshots found while
there are some. Fixed by adding option --ignore_casesensitive.
89 changes: 73 additions & 16 deletions check_vmware_esx.pl
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@
# - host_net_info.pm -> host_net_info()
# - host_disk_io_info.pm -> host_disk_io_info()
# - datastore_volumes_info.pm -> datastore_volumes_info()
# - host_list_vm_volumes_info.pm -> host_list_vm_volumes_info()
# - host_volumes_info.pm -> host_volumes_info()
# - host_runtime_info.pm -> host_runtime_info()
# - host_service_info.pm -> host_service_info()
# - host_storage_info.pm -> host_storage_info()
Expand Down Expand Up @@ -1395,7 +1395,7 @@
# - 26 Nov 2019 M.Fuerstenau version 1.2.3
# - Fixed duplicate definition in datastore_volumes_info.pm
#
# - 9 Jun 2022 M.Fuerstenau version 1.2.4
# - 3 Jun 2022 M.Fuerstenau version 1.2.4
# - Added several patches (pull requests) from Github:
# - new command line option "--moref" that allows for selecting virtual
# machines by their Managed Object Reference name (e.g. "vm-193")
Expand All @@ -1414,7 +1414,18 @@
# is printed
# - Remove output of guestToolsUnmanaged if --open_vm_tools_ok
# - Fully ignore unknown states for hardware

#
# - 04 Auf 2022 M.Fuerstenau version 1.2.5
# - Renamed module host_list_vm_volumes_info to host_volumes_info
# because name was misleading
# - Minor corrections in help.pm
# - New option --show-storage for runtime->listvms via host ore DC
# - Fixed bug in blacklist/whitelist. Was casesensitve by default. This leads
# to problems if for example a VM is defined in ESX with uppercase letters
# and check is with lowercase (MYSERVER vs. myserver). So for example
# checking for snapshots may result in no old snapshots found while
# there are some. Fixed by adding option --ignore_casesensitive.
#


use strict;
Expand Down Expand Up @@ -1466,7 +1477,7 @@ BEGIN

# General stuff
our $version; # Only for showing the version
our $prog_version = '1.2.4'; # Contains the program version number
our $prog_version = '1.2.5'; # Contains the program version number
our $ProgName = basename($0);

my $PID = $$; # Stores the process identifier of the actual run. This will be
Expand Down Expand Up @@ -1557,6 +1568,7 @@ BEGIN

our $blacklist; # Contains the blacklist
our $whitelist; # Contains the whitelist
our $ignore_casesensitive; # Option to handle blacklist/whitelist case insensitive

our $isregexp; # treat names, blacklist and whitelists as regexp

Expand Down Expand Up @@ -1599,9 +1611,9 @@ BEGIN
# set this default to "n".
my $statelabels; # To overwrite $statelabels_def via commandline.
our $openvmtools; # Signalize that you use Open VM Tools instead of the servers one.
our $no_vmtools; # Signalize that not having VMware tools is ok
our $no_vmtools; # Signalize that not having VMware tools is ok
our $hidekey; # Hide licenses key when requesting license informations

our $show_storage; # Show storage shows storage used bei VM. Used in conjunction with listvms


my $trace;
Expand Down Expand Up @@ -1646,11 +1658,13 @@ BEGIN
"nosession" => \$nosession,
"B=s" => \$blacklist, "exclude=s" => \$blacklist,
"W=s" => \$whitelist, "include=s" => \$whitelist,
"ignore_casesensitive" => \$ignore_casesensitive,
"t=s" => \$timeout, "timeout=s" => \$timeout,
"V" => \$version, "version" => \$version,
"d" => \$debug, "debug" => \$debug,
"ignore_unknown" => \$ignoreunknown,
"ignore_warning" => \$ignorewarning,
"show-storage" => \$show_storage,
"trace=s" => \$trace,
"listsensors" => \$listsensors,
"ignore_health" => \$ignorehealth,
Expand Down Expand Up @@ -2291,7 +2305,7 @@ sub main_select

if (defined($host))
{
# The following if black is only needed if we check a ESX server via the
# The following if block is only needed if we check a ESX server via the
# the datacenten (vsphere server) instead of doing it directly.
# Directly is better

Expand All @@ -2300,6 +2314,13 @@ sub main_select
{
$esx_server = {name => $host};
}

if (defined $show_storage)
{
require vm_storage_path;
import vm_storage_path;
}

if ($select eq "cpu")
{
require host_cpu_info;
Expand Down Expand Up @@ -2330,9 +2351,9 @@ sub main_select
}
if ($select eq "volumes")
{
require host_list_vm_volumes_info;
import host_list_vm_volumes_info;
($result, $output) = host_list_vm_volumes_info($esx_server, $maintenance_mode_state);
require host_volumes_info;
import host_volumes_info;
($result, $output) = host_volumes_info($esx_server, $maintenance_mode_state);
return($result, $output);
}
if ($select eq "runtime")
Expand Down Expand Up @@ -2702,19 +2723,38 @@ sub isblacklisted
return 0;
}

#our $ignore_casesensitive; # Option to handle blacklist/whitelist case insensitive

if ($regexpflag == 0)
{
$ret = grep(/$candidate/, $$blacklist_ref);
if (defined($ignore_casesensitive))
{
$ret = grep(/$candidate/i, $$blacklist_ref);
}
else
{
$ret = grep(/$candidate/, $$blacklist_ref);
}
}
else
{
@blacklist = split(/,/, $$blacklist_ref);

foreach $blacklist (@blacklist)
{
if ($candidate =~ m/$blacklist/)
if (defined($ignore_casesensitive))
{
$hitcount++;
if ($candidate =~ m/$blacklist/i)
{
$hitcount++;
}
}
else
{
if ($candidate =~ m/$blacklist/)
{
$hitcount++;
}
}
}

Expand All @@ -2741,17 +2781,34 @@ sub isnotwhitelisted

if ($regexpflag == 0)
{
$ret = ! grep(/$candidate/, $$whitelist_ref);
if (defined($ignore_casesensitive))
{
$ret = ! grep(/$candidate/i, $$whitelist_ref);
}
else
{
$ret = ! grep(/$candidate/, $$whitelist_ref);
}
}
else
{
@whitelist = split(/,/, $$whitelist_ref);

foreach $whitelist (@whitelist)
{
if ($candidate =~ m/$whitelist/)
if (defined($ignore_casesensitive))
{
if ($candidate =~ m/$whitelist/i)
{
$hitcount++;
}
}
else
{
$hitcount++;
if ($candidate =~ m/$whitelist/)
{
$hitcount++;
}
}
}

Expand Down
Loading

0 comments on commit 4f63b93

Please sign in to comment.