1
0
mirror of https://github.com/Napsty/check_esxi_hardware.git synced 2026-02-06 15:15:20 +01:00

2 Commits

Author SHA1 Message Date
Napsty
4f3e202c5f Bump version 2025-07-16 07:54:18 +02:00
Peter Newman
6a41af4a60 Change exit code from -1/255 to 3 to match Nagios plugin specs (#76) 2025-07-16 07:50:52 +02:00

View File

@@ -36,7 +36,7 @@
# Copyright (c) 2015 Andreas Gottwald # Copyright (c) 2015 Andreas Gottwald
# Copyright (c) 2015 Stanislav German-Evtushenko # Copyright (c) 2015 Stanislav German-Evtushenko
# Copyright (c) 2015 Stefan Roos # Copyright (c) 2015 Stefan Roos
# Copyright (c) 2018 Peter Newman # Copyright (c) 2018,2025 Peter Newman
# Copyright (c) 2020 Luca Berra # Copyright (c) 2020 Luca Berra
# Copyright (c) 2022 Marco Markgraf # Copyright (c) 2022 Marco Markgraf
# #
@@ -50,7 +50,7 @@
# https://www.claudiokuenzler.com/monitoring-plugins/check_esxi_hardware.php # https://www.claudiokuenzler.com/monitoring-plugins/check_esxi_hardware.php
# #
#@--------------------------------------------------- #@---------------------------------------------------
#@ History #@ History / ChangeLog
#@--------------------------------------------------- #@---------------------------------------------------
#@ Date : 20080820 #@ Date : 20080820
#@ Author : David Ligeret #@ Author : David Ligeret
@@ -303,6 +303,10 @@
#@ Reason : Update to newer pywbem exception call, catch HTTPError #@ Reason : Update to newer pywbem exception call, catch HTTPError
#@ Attn : Requires 'packaging' Python module from now on! #@ Attn : Requires 'packaging' Python module from now on!
#@--------------------------------------------------- #@---------------------------------------------------
#@ Date : 20250716
#@ Author : Peter Newman
#@ Reason : Adjust exit code -1 to 3 (Nagios UNKNOWN)
#@---------------------------------------------------
import sys import sys
import time import time
@@ -312,7 +316,7 @@ import json
from optparse import OptionParser,OptionGroup from optparse import OptionParser,OptionGroup
from packaging.version import Version from packaging.version import Version
version = '20250221' version = '20250716'
NS = 'root/cimv2' NS = 'root/cimv2'
hosturl = '' hosturl = ''
@@ -607,14 +611,14 @@ def getopts() :
if len(sys.argv) < 2: if len(sys.argv) < 2:
print("no parameters specified\n") print("no parameters specified\n")
parser.print_help() parser.print_help()
sys.exit(-1) sys.exit(3)
# if first argument starts with 'https://' we have old-style parameters, so handle in old way # if first argument starts with 'https://' we have old-style parameters, so handle in old way
if re.match("https://",sys.argv[1]): if re.match("https://",sys.argv[1]):
# check input arguments # check input arguments
if len(sys.argv) < 5: if len(sys.argv) < 5:
print("too few parameters\n") print("too few parameters\n")
parser.print_help() parser.print_help()
sys.exit(-1) sys.exit(3)
if len(sys.argv) > 5 : if len(sys.argv) > 5 :
if sys.argv[5] == "verbose" : if sys.argv[5] == "verbose" :
verbose = True verbose = True
@@ -632,7 +636,7 @@ def getopts() :
if not options.__dict__[m]: if not options.__dict__[m]:
print("mandatory option '" + m + "' not defined. read usage in help.\n") print("mandatory option '" + m + "' not defined. read usage in help.\n")
parser.print_help() parser.print_help()
sys.exit(-1) sys.exit(3)
hostname=options.host.lower() hostname=options.host.lower()
# if user has put "https://" in front of hostname out of habit, do the right thing # if user has put "https://" in front of hostname out of habit, do the right thing