Skip to content

Commit 4f63b93

Browse files
committed
Version 1.2.5 - some bugfixes and changes. See HISTORY
1 parent b62d52d commit 4f63b93

File tree

7 files changed

+323
-25
lines changed

7 files changed

+323
-25
lines changed

HISTORY

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,3 +1332,14 @@ was done
13321332
is printed
13331333
- Remove output of guestToolsUnmanaged if --open_vm_tools_ok
13341334
- Fully ignore unknown states for hardware
1335+
1336+
- 04 Auf 2022 M.Fuerstenau version 1.2.5
1337+
- Renamed module host_list_vm_volumes_info to host_volumes_info
1338+
because name was misleading
1339+
- Minor corrections in help.pm
1340+
- New option --show-storage for runtime->listvms via host ore DC
1341+
- Fixed bug in blacklist/whitelist. Was casesensitve by default. This leads
1342+
to problems if for example a VM is defined in ESX with uppercase letters
1343+
and check is with lowercase (MYSERVER vs. myserver). So for example
1344+
checking for snapshots may result in no old snapshots found while
1345+
there are some. Fixed by adding option --ignore_casesensitive.

check_vmware_esx.pl

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@
488488
# - host_net_info.pm -> host_net_info()
489489
# - host_disk_io_info.pm -> host_disk_io_info()
490490
# - datastore_volumes_info.pm -> datastore_volumes_info()
491-
# - host_list_vm_volumes_info.pm -> host_list_vm_volumes_info()
491+
# - host_volumes_info.pm -> host_volumes_info()
492492
# - host_runtime_info.pm -> host_runtime_info()
493493
# - host_service_info.pm -> host_service_info()
494494
# - host_storage_info.pm -> host_storage_info()
@@ -1395,7 +1395,7 @@
13951395
# - 26 Nov 2019 M.Fuerstenau version 1.2.3
13961396
# - Fixed duplicate definition in datastore_volumes_info.pm
13971397
#
1398-
# - 9 Jun 2022 M.Fuerstenau version 1.2.4
1398+
# - 3 Jun 2022 M.Fuerstenau version 1.2.4
13991399
# - Added several patches (pull requests) from Github:
14001400
# - new command line option "--moref" that allows for selecting virtual
14011401
# machines by their Managed Object Reference name (e.g. "vm-193")
@@ -1414,7 +1414,18 @@
14141414
# is printed
14151415
# - Remove output of guestToolsUnmanaged if --open_vm_tools_ok
14161416
# - Fully ignore unknown states for hardware
1417-
1417+
#
1418+
# - 04 Auf 2022 M.Fuerstenau version 1.2.5
1419+
# - Renamed module host_list_vm_volumes_info to host_volumes_info
1420+
# because name was misleading
1421+
# - Minor corrections in help.pm
1422+
# - New option --show-storage for runtime->listvms via host ore DC
1423+
# - Fixed bug in blacklist/whitelist. Was casesensitve by default. This leads
1424+
# to problems if for example a VM is defined in ESX with uppercase letters
1425+
# and check is with lowercase (MYSERVER vs. myserver). So for example
1426+
# checking for snapshots may result in no old snapshots found while
1427+
# there are some. Fixed by adding option --ignore_casesensitive.
1428+
#
14181429

14191430

14201431
use strict;
@@ -1466,7 +1477,7 @@ BEGIN
14661477

14671478
# General stuff
14681479
our $version; # Only for showing the version
1469-
our $prog_version = '1.2.4'; # Contains the program version number
1480+
our $prog_version = '1.2.5'; # Contains the program version number
14701481
our $ProgName = basename($0);
14711482

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

15581569
our $blacklist; # Contains the blacklist
15591570
our $whitelist; # Contains the whitelist
1571+
our $ignore_casesensitive; # Option to handle blacklist/whitelist case insensitive
15601572

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

@@ -1599,9 +1611,9 @@ BEGIN
15991611
# set this default to "n".
16001612
my $statelabels; # To overwrite $statelabels_def via commandline.
16011613
our $openvmtools; # Signalize that you use Open VM Tools instead of the servers one.
1602-
our $no_vmtools; # Signalize that not having VMware tools is ok
1614+
our $no_vmtools; # Signalize that not having VMware tools is ok
16031615
our $hidekey; # Hide licenses key when requesting license informations
1604-
1616+
our $show_storage; # Show storage shows storage used bei VM. Used in conjunction with listvms
16051617

16061618

16071619
my $trace;
@@ -1646,11 +1658,13 @@ BEGIN
16461658
"nosession" => \$nosession,
16471659
"B=s" => \$blacklist, "exclude=s" => \$blacklist,
16481660
"W=s" => \$whitelist, "include=s" => \$whitelist,
1661+
"ignore_casesensitive" => \$ignore_casesensitive,
16491662
"t=s" => \$timeout, "timeout=s" => \$timeout,
16501663
"V" => \$version, "version" => \$version,
16511664
"d" => \$debug, "debug" => \$debug,
16521665
"ignore_unknown" => \$ignoreunknown,
16531666
"ignore_warning" => \$ignorewarning,
1667+
"show-storage" => \$show_storage,
16541668
"trace=s" => \$trace,
16551669
"listsensors" => \$listsensors,
16561670
"ignore_health" => \$ignorehealth,
@@ -2291,7 +2305,7 @@ sub main_select
22912305

22922306
if (defined($host))
22932307
{
2294-
# The following if black is only needed if we check a ESX server via the
2308+
# The following if block is only needed if we check a ESX server via the
22952309
# the datacenten (vsphere server) instead of doing it directly.
22962310
# Directly is better
22972311

@@ -2300,6 +2314,13 @@ sub main_select
23002314
{
23012315
$esx_server = {name => $host};
23022316
}
2317+
2318+
if (defined $show_storage)
2319+
{
2320+
require vm_storage_path;
2321+
import vm_storage_path;
2322+
}
2323+
23032324
if ($select eq "cpu")
23042325
{
23052326
require host_cpu_info;
@@ -2330,9 +2351,9 @@ sub main_select
23302351
}
23312352
if ($select eq "volumes")
23322353
{
2333-
require host_list_vm_volumes_info;
2334-
import host_list_vm_volumes_info;
2335-
($result, $output) = host_list_vm_volumes_info($esx_server, $maintenance_mode_state);
2354+
require host_volumes_info;
2355+
import host_volumes_info;
2356+
($result, $output) = host_volumes_info($esx_server, $maintenance_mode_state);
23362357
return($result, $output);
23372358
}
23382359
if ($select eq "runtime")
@@ -2702,19 +2723,38 @@ sub isblacklisted
27022723
return 0;
27032724
}
27042725

2726+
#our $ignore_casesensitive; # Option to handle blacklist/whitelist case insensitive
2727+
27052728
if ($regexpflag == 0)
27062729
{
2707-
$ret = grep(/$candidate/, $$blacklist_ref);
2730+
if (defined($ignore_casesensitive))
2731+
{
2732+
$ret = grep(/$candidate/i, $$blacklist_ref);
2733+
}
2734+
else
2735+
{
2736+
$ret = grep(/$candidate/, $$blacklist_ref);
2737+
}
27082738
}
27092739
else
27102740
{
27112741
@blacklist = split(/,/, $$blacklist_ref);
27122742

27132743
foreach $blacklist (@blacklist)
27142744
{
2715-
if ($candidate =~ m/$blacklist/)
2745+
if (defined($ignore_casesensitive))
27162746
{
2717-
$hitcount++;
2747+
if ($candidate =~ m/$blacklist/i)
2748+
{
2749+
$hitcount++;
2750+
}
2751+
}
2752+
else
2753+
{
2754+
if ($candidate =~ m/$blacklist/)
2755+
{
2756+
$hitcount++;
2757+
}
27182758
}
27192759
}
27202760

@@ -2741,17 +2781,34 @@ sub isnotwhitelisted
27412781

27422782
if ($regexpflag == 0)
27432783
{
2744-
$ret = ! grep(/$candidate/, $$whitelist_ref);
2784+
if (defined($ignore_casesensitive))
2785+
{
2786+
$ret = ! grep(/$candidate/i, $$whitelist_ref);
2787+
}
2788+
else
2789+
{
2790+
$ret = ! grep(/$candidate/, $$whitelist_ref);
2791+
}
27452792
}
27462793
else
27472794
{
27482795
@whitelist = split(/,/, $$whitelist_ref);
27492796

27502797
foreach $whitelist (@whitelist)
27512798
{
2752-
if ($candidate =~ m/$whitelist/)
2799+
if (defined($ignore_casesensitive))
2800+
{
2801+
if ($candidate =~ m/$whitelist/i)
2802+
{
2803+
$hitcount++;
2804+
}
2805+
}
2806+
else
27532807
{
2754-
$hitcount++;
2808+
if ($candidate =~ m/$whitelist/)
2809+
{
2810+
$hitcount++;
2811+
}
27552812
}
27562813
}
27572814

0 commit comments

Comments
 (0)