alvfig / check_vgfree

Nagios plugin to check free space on LVM volume group
MIT License
2 stars 0 forks source link

non-OK status not working with thresholds in percent #3

Closed dalfo77 closed 3 years ago

dalfo77 commented 3 years ago

Ciao, non-OK status are not working with thresholds in percent

# vgs VG_DATA
  VG      #PV #LV #SN Attr   VSize    VFree
  VG_DATA   1   3   1 wz--n- <150.00g    0

$ sudo /usr/lib64/nagios/plugins/check_vgfree --volume-group='VG_DATA'  --warning-percent='5' --critical-percent='2'
OK - 0GB (0%) free on volume group VG_DATA

$ sudo /usr/lib64/nagios/plugins/check_vgfree --volume-group='VG_DATA'  --warning='7.5' --critical='3'
CRITICAL - 0GB (0%) free on volume group VG_DATA
alvfig commented 3 years ago

The last commit should fix this. Please check it.

dalfo77 commented 3 years ago

Ciao, I use the plugin on Red Hat Enterprise Linux Server release 7.8 (Maipo), that have by default Python 2.7.5

# /bin/env python --version
Python 2.7.5

If I enable python3 with SCL I've got this error:

# . /opt/rh/rh-python36/enable
# which python3
/opt/rh/rh-python36/root/usr/bin/python3
# /opt/rh/rh-python36/root/usr/bin/python3 ./check_vgfree --volume-group='VG_DATA'  --warning-percent='5' --critical-percent='2'
Traceback (most recent call last):
  File "./check_vgfree", line 129, in <module>
    main()
  File "./check_vgfree", line 122, in main
    options.units
AttributeError: 'Values' object has no attribute 'units'

Here the list of python3 modules installed:

# /opt/rh/rh-python36/root/usr/bin/python3
Python 3.6.9 (default, Sep 11 2019, 16:40:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> help('modules')

Please wait a moment while I gather a list of all available modules...

__future__          argparse            idlelib             select
_ast                array               imaplib             selectors
_asyncio            ast                 imghdr              setuptools
_bisect             asynchat            imp                 shelve
_blake2             asyncio             importlib           shlex
_bootlocale         asyncore            inspect             shutil
_bz2                atexit              io                  signal
_codecs             audioop             ipaddress           site
_codecs_cn          base64              itertools           smtpd
_codecs_hk          bdb                 json                smtplib
_codecs_iso2022     binascii            keyword             sndhdr
_codecs_jp          binhex              lib2to3             socket
_codecs_kr          bisect              linecache           socketserver
_codecs_tw          builtins            locale              spwd
_collections        bz2                 logging             sqlite3
_collections_abc    cProfile            lzma                sre_compile
_compat_pickle      calendar            macpath             sre_constants
_compression        cgi                 macurl2path         sre_parse
_crypt              cgitb               mailbox             ssl
_csv                chunk               mailcap             stat
_ctypes             cmath               marshal             statistics
_curses             cmd                 math                string
_curses_panel       code                mimetypes           stringprep
_datetime           codecs              mmap                struct
_dbm                codeop              modulefinder        subprocess
_decimal            collections         multiprocessing     sunau
_dummy_thread       colorsys            netrc               symbol
_elementtree        compileall          nis                 symtable
_functools          concurrent          nntplib             sys
_gdbm               configparser        ntpath              sysconfig
_hashlib            contextlib          nturl2path          syslog
_heapq              copy                numbers             tabnanny
_imp                copyreg             opcode              tarfile
_io                 crypt               operator            telnetlib
_json               csv                 optparse            tempfile
_locale             ctypes              os                  termios
_lsprof             curses              ossaudiodev         test
_lzma               datetime            parser              textwrap
_markupbase         dbm                 pathlib             this
_multibytecodec     decimal             pdb                 threading
_multiprocessing    difflib             pickle              time
_opcode             dis                 pickletools         timeit
_operator           distutils           pip                 token
_osx_support        doctest             pipes               tokenize
_pickle             dummy_threading     pkg_resources       trace
_posixsubprocess    easy_install        pkgutil             traceback
_pydecimal          email               platform            tracemalloc
_pyio               encodings           plistlib            tty
_random             ensurepip           poplib              types
_sha3               enum                posix               typing
_signal             errno               posixpath           unicodedata
_sitebuiltins       faulthandler        pprint              unittest
_socket             fcntl               profile             urllib
_sqlite3            filecmp             pstats              uu
_sre                fileinput           pty                 uuid
_ssl                fnmatch             pwd                 venv
_stat               formatter           py_compile          warnings
_string             fractions           pyclbr              wave
_strptime           ftplib              pydoc               weakref
_struct             functools           pydoc_data          webbrowser
_symtable           gc                  pyexpat             wsgiref
_sysconfigdata_dm_linux_x86_64-linux-gnu genericpath         pymysql             xdrlib
_sysconfigdata_m_linux_x86_64-linux-gnu getopt              queue               xml
_testmultiphase     getpass             quopri              xmlrpc
_thread             gettext             random              xxlimited
_threading_local    glob                re                  xxsubtype
_tracemalloc        grp                 readline            zipapp
_warnings           gzip                reprlib             zipfile
_weakref            hashlib             resource            zipimport
_weakrefset         heapq               rlcompleter         zlib
abc                 hmac                runpy
aifc                html                sched
antigravity         http                secrets

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose name or summary contain the string "spam".

>>>
alvfig commented 3 years ago

This last bug were fixed on release v0.3, that requires Python 3. However, if really needed, the release v0.2.1 still works on Python 2.