mirror of
https://github.com/Napsty/check_esxi_hardware.git
synced 2024-11-22 10:23:49 +01:00
Remove python2 and pywbem 0.7.0 compatibility
This commit is contained in:
parent
7aaaae4337
commit
e63f9fee6a
122
.github/workflows/python3check.yml
vendored
122
.github/workflows/python3check.yml
vendored
@ -6,109 +6,27 @@ name: Python3 check
|
|||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
simple-output:
|
simple-job:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Simple hello world
|
- name: Simple hello world
|
||||||
run: echo "Hello World"
|
run: echo "Hello World"
|
||||||
# python3-pywbem-latest:
|
python3-pywbem-latest:
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
steps:
|
||||||
# - uses: actions/checkout@v1
|
- uses: actions/checkout@v4
|
||||||
# - uses: actions/setup-python@v1
|
- uses: actions/setup-python@v5
|
||||||
# with:
|
with:
|
||||||
# python-version: '3.8'
|
python-version: '3.8'
|
||||||
# - name: Install latest pywbem from pip
|
- name: Install latest pywbem from pip
|
||||||
# run: |
|
run: |
|
||||||
# sudo apt-get install -qq -yy python3-pip
|
sudo apt-get install -qq -yy python3-pip
|
||||||
# pip3 install pywbem
|
pip3 install pywbem
|
||||||
# - name: Set environment PYTHONPATH
|
- name: Set environment PYTHONPATH
|
||||||
# run: |
|
run: |
|
||||||
# export PYTHONPATH=/opt/hostedtoolcache/Python/3.8.0/x64/lib/python3.8/site-packages
|
export PYTHONPATH=/opt/hostedtoolcache/Python/3.8.0/x64/lib/python3.8/site-packages:${PYTHONPATH}
|
||||||
# - name: Verify python sys.path
|
- name: Verify python sys.path
|
||||||
# run: (echo "import sys"; echo "print(', '.join(sys.path))") | python
|
run: (echo "import sys"; echo "print(', '.join(sys.path))") | python
|
||||||
# - name: Launch script with --help
|
- name: Launch script with --help
|
||||||
# run: |
|
run: |
|
||||||
# ./check_esxi_hardware.py --help
|
./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-*'
|
|
||||||
|
@ -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
|
||||||
@ -293,17 +293,21 @@
|
|||||||
#@ Author : Claudio Kuenzler
|
#@ Author : Claudio Kuenzler
|
||||||
#@ Reason : Fix bug when missing S/N (issue #68)
|
#@ 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 = '20221230'
|
version = '20241025'
|
||||||
|
|
||||||
NS = 'root/cimv2'
|
NS = 'root/cimv2'
|
||||||
hosturl = ''
|
hosturl = ''
|
||||||
@ -729,30 +733,10 @@ 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)
|
pywbemversion = pywbem.__version__
|
||||||
# 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__
|
|
||||||
verboseoutput("Found pywbem version "+pywbemversion)
|
verboseoutput("Found pywbem version "+pywbemversion)
|
||||||
|
verboseoutput("Connection to "+hosturl)
|
||||||
if '0.7.' in pywbemversion:
|
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True)
|
||||||
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)
|
|
||||||
|
|
||||||
# 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.
|
||||||
if on_windows == False and timeout > 0:
|
if on_windows == False and timeout > 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user