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

12 Commits

Author SHA1 Message Date
Napsty
ad1e56c44c Remove python2 and pywbem 0.7.0 compatibility 2024-10-25 15:49:16 +02:00
Napsty
ecfb411b05 Remove python2 and pywbem 0.7.0 compatibility 2024-10-25 15:44:42 +02:00
Napsty
aaaa2fc1e3 Remove python2 and pywbem 0.7.0 compatibility 2024-10-25 15:40:00 +02:00
Napsty
0149512f50 Remove python2 and pywbem 0.7.0 compatibility 2024-10-25 15:38:55 +02:00
Napsty
d03a586ddc Remove python2 and pywbem 0.7.0 compatibility 2024-10-25 15:38:15 +02:00
Napsty
bdea961ea0 Remove python2 and pywbem 0.7.0 compatibility 2024-10-25 15:37:00 +02:00
Napsty
676b724b37 Remove python2 and pywbem 0.7.0 compatibility 2024-10-25 15:03:45 +02:00
Napsty
16a9ce1f36 Remove python2 and pywbem 0.7.0 compatibility 2024-10-25 14:50:53 +02:00
Napsty
602651d3e5 Remove python2 and pywbem 0.7.0 compatibility 2024-10-25 14:48:52 +02:00
Napsty
e63f9fee6a Remove python2 and pywbem 0.7.0 compatibility 2024-10-25 14:42:19 +02:00
Claudio Kuenzler
7aaaae4337 Fix bug when missing serial number from CIM elements (#69) 2022-12-30 08:57:39 +01:00
Claudio Kuenzler
8a99d8aace Update bug_report.md 2022-12-30 08:49:49 +01:00
4 changed files with 35 additions and 219 deletions

View File

@@ -15,8 +15,8 @@ I confirm, I have cleared the server's local IPMI cache (`localcli hardware ipmi
**Describe the bug** **Describe the bug**
A clear and concise description of what the bug is. A clear and concise description of what the bug is.
**Show the full plugin output, including the command with -V parameter** **Show the full plugin output, including the command with -v parameter**
Run the plugin with `-V` parameter and show the full output (including command) here. Obviously obfuscate credentials. Run the plugin with `-v` parameter and show the full output (including command) here. Obviously obfuscate credentials.
**Expected behavior** **Expected behavior**
A clear and concise description of what you expected to happen. A clear and concise description of what you expected to happen.

View File

@@ -1,77 +0,0 @@
# @file python2check.yml
---
name: Python2 check
# Trigger the workflow on push or pull request
on: [push, pull_request]
jobs:
python2-pywbem08:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: '2.7'
- name: Install pywbem from apt
run: |
sudo apt-get install -qq -yy python-pywbem
- name: Set environment PYTHONPATH
run: |
export PYTHONPATH=/opt/hostedtoolcache/Python
- name: Launch script with --help
run: |
./check_esxi_hardware.py --help
# Jobs with PIP installations are currently disabled.
# python2-pywbem09:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-python@v1
# with:
# python-version: '2.7'
# - name: Install latest pywbem from pip
# run: |
# sudo apt-get install -qq -yy python-pip
# pip install pywbem==0.9.1
# - name: Set environment PYTHONPATH
# run: |
# export PYTHONPATH=/opt/hostedtoolcache/Python
# - name: Launch script with --help
# run: |
# ./check_esxi_hardware.py --help
# python2-pywbem012:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-python@v1
# with:
# python-version: '2.7'
# - name: Install latest pywbem from pip
# run: |
# sudo apt-get install -qq -yy python-pip
# pip install pywbem==0.12.6
# - name: Set environment PYTHONPATH
# run: |
# export PYTHONPATH=/opt/hostedtoolcache/Python
# - name: Launch script with --help
# run: |
# ./check_esxi_hardware.py --help
# python2-pywbem014:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-python@v1
# with:
# python-version: '2.7'
# - name: Install latest pywbem from pip
# run: |
# sudo apt-get install -qq -yy python-pip
# pip install pywbem==0.14.6
# - name: Set environment PYTHONPATH
# run: |
# export PYTHONPATH=/opt/hostedtoolcache/Python
# - name: Launch script with --help
# run: |
# ./check_esxi_hardware.py --help

View File

@@ -6,109 +6,16 @@ name: Python3 check
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
simple-output: python3-pywbem-latest:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Simple hello world - uses: actions/checkout@v4
run: echo "Hello World" - name: Install latest pywbem from pip
# python3-pywbem-latest: run: |
# runs-on: ubuntu-latest sudo apt-get install -qq -yy python3 python3-pip
# steps: pip3 install pywbem
# - uses: actions/checkout@v1 - name: Verify python sys.path
# - uses: actions/setup-python@v1 run: (echo "import sys"; echo "print(', '.join(sys.path))") | python3
# with: - name: Launch script with --help
# python-version: '3.8' run: |
# - name: Install latest pywbem from pip ./check_esxi_hardware.py --help
# run: |
# sudo apt-get install -qq -yy python3-pip
# pip3 install pywbem
# - name: Set environment PYTHONPATH
# run: |
# export PYTHONPATH=/opt/hostedtoolcache/Python/3.8.0/x64/lib/python3.8/site-packages
# - name: Verify python sys.path
# run: (echo "import sys"; echo "print(', '.join(sys.path))") | python
# - name: Launch script with --help
# run: |
# ./check_esxi_hardware.py --help
# python3-pywbem-08:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-python@v1
# with:
# python-version: '3.x'
# - name: Install latest pywbem from pip
# run: |
# sudo apt-get install -qq -yy python3-pip
# pip3 install pywbem==0.8.4
# - name: Set environment PYTHONPATH
# run: |
# export PYTHONPATH=/opt/hostedtoolcache/Python
# - name: Launch script with --help
# run: |
# ./check_esxi_hardware.py --help
# python3-pywbem-012:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-python@v1
# with:
# python-version: '3.x'
# - name: Install latest pywbem from pip
# run: |
# sudo apt-get install -qq -yy python3-pip
# pip3 install pywbem==0.12.6
# - name: Set environment PYTHONPATH
# run: |
# export PYTHONPATH=/opt/hostedtoolcache/Python
# - name: Launch script with --help
# run: |
# ./check_esxi_hardware.py --help
# python3-pywbem-013:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-python@v1
# with:
# python-version: '3.x'
# - name: Install latest pywbem from pip
# run: |
# sudo apt-get install -qq -yy python3-pip
# pip3 install pywbem==0.13.1
# - name: Set environment PYTHONPATH
# run: |
# export PYTHONPATH=/opt/hostedtoolcache/Python
# - name: Launch script with --help
# run: |
# ./check_esxi_hardware.py --help
# python3-pywbem-014:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-python@v1
# with:
# python-version: '3.x'
# - name: Install latest pywbem from pip
# run: |
# sudo apt-get install -qq -yy python3-pip
# pip3 install pywbem==0.14.6
# - name: Set environment PYTHONPATH
# run: |
# export PYTHONPATH=/opt/hostedtoolcache/Python
# - name: Launch script with --help
# run: |
# ./check_esxi_hardware.py --help
# find-pywbem:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-python@v1
# with:
# python-version: '3.x'
# - name: Install latest pywbem from pip
# run: |
# sudo apt-get install -qq -yy python-pip
# pip install pywbem
# - name: Find pywbem module
# run: |
# find / -name 'pywbem-*'

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
# #
# Script for checking global health of host running VMware ESX/ESXi # Script for checking global health of host running VMware ESX/ESXi
@@ -22,7 +22,7 @@
# Copyright (c) 2008 David Ligeret # Copyright (c) 2008 David Ligeret
# Copyright (c) 2009 Joshua Daniel Franklin # Copyright (c) 2009 Joshua Daniel Franklin
# Copyright (c) 2010 Branden Schneider # Copyright (c) 2010 Branden Schneider
# Copyright (c) 2010-2022 Claudio Kuenzler # Copyright (c) 2010-2024 Claudio Kuenzler
# Copyright (c) 2010 Samir Ibradzic # Copyright (c) 2010 Samir Ibradzic
# Copyright (c) 2010 Aaron Rogers # Copyright (c) 2010 Aaron Rogers
# Copyright (c) 2011 Ludovic Hutin # Copyright (c) 2011 Ludovic Hutin
@@ -40,12 +40,11 @@
# Copyright (c) 2020 Luca Berra # Copyright (c) 2020 Luca Berra
# Copyright (c) 2022 Marco Markgraf # Copyright (c) 2022 Marco Markgraf
# #
# The VMware 4.1 CIM API is documented here: # The VMware CIM API is documented here (as of October 2024):
# http://www.vmware.com/support/developer/cim-sdk/4.1/smash/cim_smash_410_prog.pdf # https://docs.vmware.com/en/VMware-vSphere/7.0/vsphere-cim-smash-server-management-api-programming-guide/GUID-2725D01E-AE02-4EF2-9E98-5AB82AA0349A.html
# http://www.vmware.com/support/developer/cim-sdk/smash/u2/ga/apirefdoc/
# # The CIM classes are documented here (as of October 2024):
# The VMware 5.5 and above CIM API is documented here: # https://vdc-download.vmware.com/vmwb-repository/dcr-public/27c1c014-7315-4d6b-8e6b-292130a79b3c/36aca268-99fa-4916-b993-a077de55cbf1/CIM_API_Reference/index.html
# https://code.vmware.com/apis/207/cim
# #
# This monitoring plugin is maintained and documented here: # This monitoring plugin is maintained and documented here:
# https://www.claudiokuenzler.com/monitoring-plugins/check_esxi_hardware.php # https://www.claudiokuenzler.com/monitoring-plugins/check_esxi_hardware.php
@@ -289,17 +288,25 @@
#@ Author : Marco Markgraf #@ Author : Marco Markgraf
#@ Reason : Added JSON-output (Zabbix needs it) #@ Reason : Added JSON-output (Zabbix needs it)
#@--------------------------------------------------- #@---------------------------------------------------
#@ Date : 20221230
#@ Author : Claudio Kuenzler
#@ Reason : Fix bug when missing S/N (issue #68)
#@---------------------------------------------------
#@ Date : 20241025
#@ Author : Claudio Kuenzler
#@ Reason : Fix pkg_resources deprecation warning
# Remove python2 compatibility
# Remove pywbem 0.7.0 compatibility
#@---------------------------------------------------
from __future__ import print_function
import sys import sys
import time import time
import pywbem import pywbem
import re import re
import pkg_resources
import json import json
from optparse import OptionParser,OptionGroup from optparse import OptionParser,OptionGroup
version = '20220708' version = '20241025'
NS = 'root/cimv2' NS = 'root/cimv2'
hosturl = '' hosturl = ''
@@ -725,29 +732,9 @@ if not get_intrusion:
ignore_list.append("System Chassis 1 Chassis Intru: Unknown") ignore_list.append("System Chassis 1 Chassis Intru: Unknown")
# connection to host # connection to host
verboseoutput("Connection to "+hosturl)
# pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently
try:
pywbemversion = pywbem.__version__
except:
pywbemversion = pkg_resources.get_distribution("pywbem").version
else:
pywbemversion = pywbem.__version__ pywbemversion = pywbem.__version__
verboseoutput("Found pywbem version "+pywbemversion) verboseoutput("Found pywbem version "+pywbemversion)
verboseoutput("Connection to "+hosturl)
if '0.7.' in pywbemversion:
try:
conntest = pywbem.WBEMConnection(hosturl, (user,password))
c = conntest.EnumerateInstances('CIM_Card')
except:
#raise
verboseoutput("Connection error, disable SSL certificate verification (probably patched pywbem)")
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), no_verification=True)
else:
verboseoutput("Connection worked")
wbemclient = pywbem.WBEMConnection(hosturl, (user,password))
# pywbem 0.8.0 and later
else:
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True) wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True)
# Add a timeout for the script. When using with Nagios, the Nagios timeout cannot be < than plugin timeout. # Add a timeout for the script. When using with Nagios, the Nagios timeout cannot be < than plugin timeout.
@@ -863,7 +850,6 @@ for classe in ClassesToCheck :
model = instance[u'Model'] model = instance[u'Model']
if model: if model:
verboseoutput(" Model = "+model) verboseoutput(" Model = "+model)
#server_info += model + ' s/n:'
server_info += model server_info += model
elif elementName == 'Server Blade' : elif elementName == 'Server Blade' :
@@ -1067,7 +1053,7 @@ xdata['GlobalStatus'] = GlobalStatus
if GlobalStatus == ExitOK : if GlobalStatus == ExitOK :
if format == 'string': if format == 'string':
print("OK - Server: %s %s %s%s" % (server_info, 's/n: ' + SerialNumber, bios_info, perf)) print("OK - Server: %s s/n: %s %s%s" % (server_info, SerialNumber, bios_info, perf))
else: else:
xdataprint() xdataprint()