Linuxfabrik / monitoring-plugins

220+ check plugins for Icinga and other Nagios-compatible monitoring applications. Each plugin is a standalone command line tool (written in Python) that provides a specific type of check.
https://linuxfabrik.ch
The Unlicense
220 stars 51 forks source link

redfish-sel: UnboundLocalError: local variable 'sel_path' referenced before assignment #779

Closed mburgholte closed 2 months ago

mburgholte commented 2 months ago

This issue respects the following points:

Which variant of the Monitoring Plugins do you use?

Bug description

I use the plugin on several machines. The following error only appears on one of them.

Traceback (most recent call last): File "redfish-sel.py", line 206, in 'module' File "redfish-sel.py", line 180, in main UnboundLocalError: local variable 'sel_path' referenced before assignment

Steps to reproduce - Plugin call

/usr/lib64/nagios/plugins/redfish-sel --url https://10.123.45.138:443 --username XXXX --password XXXX

Steps to reproduce - Data

No response

Environment

5.4.0-156-generic #173-Ubuntu SMP Tue Jul 11 07:25:22 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Plugin Version

redfish-sel: v2024031401 by Linuxfabrik GmbH, Zurich/Switzerland

Python version

Python 2.7.18

List of Python modules

BaseHTTPServer abc httplib sgmllib Bastion aifc ihooks sha CDROM antigravity imaplib shelve CGIHTTPServer anydbm imghdr shlex Canvas argparse imp shutil ConfigParser array importlib signal Cookie ast imputil site Crypto asynchat inspect sitecustomize DLFCN asyncore io smtpd Dialog atexit itertools smtplib DocXMLRPCServer audiodev json sndhdr FileDialog audioop keyword socket FixTk base64 lib2to3 spwd HTMLParser bdb linecache sqlite3 IN binascii linuxaudiodev sre MimeWriter binhex locale sre_compile Queue bisect logging sre_constants ScrolledText bsddb lsb_release sre_parse SimpleDialog bz2 macpath ssl SimpleHTTPServer cPickle macurl2path stat SimpleXMLRPCServer cProfile mailbox statvfs SocketServer cStringIO mailcap string StringIO calendar markupbase stringold TYPES cgi marshal stringprep Tix cgitb math strop Tkconstants chunk md5 struct Tkdnd cmath mhlib subprocess Tkinter cmd mimetools sunau UserDict code mimetypes sunaudio UserList codecs mimify symbol UserString codeop mmap symtable _LWPCookieJar collections modulefinder sys _MozillaCookieJar colorsys multifile sysconfig builtin commands multiprocessing syslog future compileall mutex tabnanny _abcoll compiler netrc tarfile _ast contextlib new telnetlib _bisect cookielib nis tempfile _bsddb copy nntplib termios _codecs copy_reg ntpath test _codecs_cn crypt nturl2path textwrap _codecs_hk csv numbers this _codecs_iso2022 ctypes opcode thread _codecs_jp curses operator threading _codecs_kr datetime optparse time _codecs_tw dbhash os timeit _collections dbm os2emxpath tkColorChooser _csv decimal ossaudiodev tkCommonDialog _ctypes difflib parser tkFileDialog _ctypes_test dircache pdb tkFont _curses dis pickle tkMessageBox _curses_panel distutils pickletools tkSimpleDialog _elementtree doctest pipes toaiff _functools dumbdbm pkgutil token _hashlib dummy_thread platform tokenize _heapq dummy_threading plistlib trace _hotshot email popen2 traceback _io encodings poplib ttk _json ensurepip posix tty _locale errno posixfile turtle _lsprof exceptions posixpath types _md5 fcntl pprint unicodedata _multibytecodec filecmp profile unittest _multiprocessing fileinput pstats urllib _osx_support fnmatch pty urllib2 _pyio formatter pwd urlparse _random fpformat py_compile user _sha fractions pyclbr uu _sha256 ftplib pydoc uuid _sha512 functools pydoc_data warnings _socket future_builtins pyexpat wave _sqlite3 gc quopri weakref _sre genericpath random webbrowser _ssl getopt re whichdb _strptime getpass readline wsgiref _struct gettext repr xdrlib _symtable glob resource xml _sysconfigdata grp rexec xmllib _sysconfigdata_nd gzip rfc822 xmlrpclib _testcapi hashlib rlcompleter xxsubtype _threading_local heapq robotparser zipfile _tkinter hmac runpy zipimport _warnings hotshot sched zlib _weakref htmlentitydefs select _weakrefset htmllib sets

Additional Information

No response

markuslf commented 2 months ago

I need the JSON output of:

Plus, for each result in the Members list from the second call, the output of "https://10.123.45.138/" + member-URL (e.g. "/redfish/v1/Managers/BMC") + one of these paths, depending on your hardware:

So for example on a DELL: "https://10.123.45.138/redfish/v1/Managers/BMC/LogServices/Sel/Entries"

mburgholte commented 2 months ago

Hi! It seems to be a little special. The server is actually a Dell server but was branded by Avigilon.

https://10.123.45.138/redfish/v1/

{"@odata.context":"/redfish/v1/$metadata#ServiceRoot.ServiceRoot","@odata.id":"/redfish/v1","@odata.type":"#ServiceRoot.v1_15_0.ServiceRoot","AccountService":{"@odata.id":"/redfish/v1/AccountService"},"CertificateService":{"@odata.id":"/redfish/v1/CertificateService"},"Chassis":{"@odata.id":"/redfish/v1/Chassis"},"Description":"Root Service","EventService":{"@odata.id":"/redfish/v1/EventService"},"Fabrics":{"@odata.id":"/redfish/v1/Fabrics"},"Id":"RootService","JobService":{"@odata.id":"/redfish/v1/JobService"},"JsonSchemas":{"@odata.id":"/redfish/v1/JsonSchemas"},"LicenseService":{"@odata.id":"/redfish/v1/LicenseService"},"Links":{"Sessions":{"@odata.id":"/redfish/v1/SessionService/Sessions"}},"Managers":{"@odata.id":"/redfish/v1/Managers"},"Name":"Root Service","Oem":{"Dell":{"@odata.context":"/redfish/v1/$metadata#DellServiceRoot.DellServiceRoot","@odata.type":"#DellServiceRoot.v1_0_0.DellServiceRoot","IsBranded":1,"ManagerMACAddress":"2c:ea:7f:XX:XX:XX","ServiceTag":"XXXXXXX"}},"Product":"Integrated Remote Access Controller","ProtocolFeaturesSupported":{"DeepOperations":{"DeepPATCH":false,"DeepPOST":false},"ExcerptQuery":false,"ExpandQuery":{"ExpandAll":true,"Levels":true,"Links":true,"MaxLevels":1,"NoLinks":true},"FilterQuery":true,"OnlyMemberQuery":true,"SelectQuery":true},"RedfishVersion":"1.17.0","Registries":{"@odata.id":"/redfish/v1/Registries"},"SessionService":{"@odata.id":"/redfish/v1/SessionService"},"Systems":{"@odata.id":"/redfish/v1/Systems"},"Tasks":{"@odata.id":"/redfish/v1/TaskService"},"TelemetryService":{"@odata.id":"/redfish/v1/TelemetryService"},"UpdateService":{"@odata.id":"/redfish/v1/UpdateService"},"Vendor":"Avigilon"}

https://10.123.45.138/redfish/v1/Managers

{"@odata.context":"/redfish/v1/$metadata#ManagerCollection.ManagerCollection","@odata.id":"/redfish/v1/Managers","@odata.type":"#ManagerCollection.ManagerCollection","Description":"BMC","Members":[{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1"}],"Members@odata.count":1,"Name":"Manager"}

https://10.123.45.138/redfish/v1/Managers/iDRAC.Embedded.1

{"@odata.context":"/redfish/v1/$metadata#Manager.Manager","@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1","@odata.type":"#Manager.v1_17_0.Manager","Actions":{"#Manager.Reset":{"ResetType@Redfish.AllowableValues":["GracefulRestart"],"target":"/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.Reset"},"#Manager.ResetToDefaults":{"ResetType@Redfish.AllowableValues":["ResetAll","PreserveNetworkAndUsers"],"target":"/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.ResetToDefaults"},"Oem":{"#DellManager.ResetToDefaults":{"ResetType@Redfish.AllowableValues":["All","Default","ResetAllWithRootDefaults"],"target":"/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/DellManager.ResetToDefaults"},"#DellManager.SetCustomDefaults":{"target":"/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/DellManager.SetCustomDefaults"},"#OemManager.ExportSystemConfiguration":{"ExportFormat@Redfish.AllowableValues":["XML","JSON"],"ExportUse@Redfish.AllowableValues":["Default","Clone","Replace"],"IncludeInExport@Redfish.AllowableValues":["Default","IncludeReadOnly","IncludePasswordHashValues","IncludeCustomTelemetry"],"ShareParameters":{"IgnoreCertificateWarning@Redfish.AllowableValues":["Disabled","Enabled"],"ProxySupport@Redfish.AllowableValues":["Disabled","EnabledProxyDefault","Enabled"],"ProxyType@Redfish.AllowableValues":["HTTP","SOCKS4"],"ShareType@Redfish.AllowableValues":["LOCAL","NFS","CIFS","HTTP","HTTPS"],"Target@Redfish.AllowableValues":["ALL","IDRAC","BIOS","NIC","RAID","FC","InfiniBand","SupportAssist","EventFilters","System","LifecycleController","AHCI","PCIeSSD"]},"target":"/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ExportSystemConfiguration"},"#OemManager.ImportSystemConfiguration":{"ExecutionMode@Redfish.AllowableValues":["Default","DeployOnSledInsert","InstantDeploy"],"HostPowerState@Redfish.AllowableValues":["On","Off"],"ImportSystemConfiguration@Redfish.AllowableValues":["TimeToWait","ImportBuffer"],"ShareParameters":{"IgnoreCertificateWarning@Redfish.AllowableValues":["Disabled","Enabled"],"ProxySupport@Redfish.AllowableValues":["Disabled","EnabledProxyDefault","Enabled"],"ProxyType@Redfish.AllowableValues":["HTTP","SOCKS4"],"ShareType@Redfish.AllowableValues":["LOCAL","NFS","CIFS","HTTP","HTTPS"],"Target@Redfish.AllowableValues":["ALL","IDRAC","BIOS","NIC","RAID","FC","InfiniBand","SupportAssist","EventFilters","System","LifecycleController","AHCI","PCIeSSD"]},"ShutdownType@Redfish.AllowableValues":["Graceful","Forced","NoReboot"],"target":"/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemConfiguration"},"#OemManager.ImportSystemConfigurationPreview":{"ImportSystemConfigurationPreview@Redfish.AllowableValues":["ImportBuffer"],"ShareParameters":{"IgnoreCertificateWarning@Redfish.AllowableValues":["Disabled","Enabled"],"ProxySupport@Redfish.AllowableValues":["Disabled","EnabledProxyDefault","Enabled"],"ProxyType@Redfish.AllowableValues":["HTTP","SOCKS4"],"ShareType@Redfish.AllowableValues":["LOCAL","NFS","CIFS","HTTP","HTTPS"],"Target@Redfish.AllowableValues":["ALL"]},"target":"/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemConfigurationPreview"}}},"CommandShell":{"ConnectTypesSupported":["SSH","IPMI"],"ConnectTypesSupported@odata.count":2,"MaxConcurrentSessions":5,"ServiceEnabled":true},"DateTime":"2024-09-19T07:45:11+02:00","DateTimeLocalOffset":"+02:00","Description":"BMC","EthernetInterfaces":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/EthernetInterfaces"},"FirmwareVersion":"7.00.00.172","GraphicalConsole":{"ConnectTypesSupported":["KVMIP"],"ConnectTypesSupported@odata.count":1,"MaxConcurrentSessions":6,"ServiceEnabled":true},"HostInterfaces":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/HostInterfaces"},"Id":"iDRAC.Embedded.1","LastResetTime":"2024-07-22T10:55:44+02:00","Links":{"ActiveSoftwareImage":{"@odata.id":"/redfish/v1/UpdateService/FirmwareInventory/Installed-25227-7.00.00.172__iDRAC.Embedded.1-1"},"ManagerForChassis":[{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1"}],"ManagerForChassis@odata.count":1,"ManagerForServers":[{"@odata.id":"/redfish/v1/Systems/System.Embedded.1"}],"ManagerForServers@odata.count":1,"ManagerInChassis":{"@odata.id":"/redfish/v1/Chassis/System.Embedded.1"},"Oem":{"Dell":{"@odata.type":"#DellOem.v1_3_0.DellOemLinks","DellAttributes":[{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellAttributes/iDRAC.Embedded.1"},{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellAttributes/System.Embedded.1"},{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellAttributes/LifecycleController.Embedded.1"}],"DellAttributes@odata.count":3,"DellJobService":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellJobService"},"DellLCService":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLCService"},"DellLicensableDeviceCollection":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLicensableDevices"},"DellLicenseCollection":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLicenses"},"DellLicenseManagementService":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLicenseManagementService"},"DellOpaqueManagementDataCollection":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellOpaqueManagementData"},"DellPersistentStorageService":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellPersistentStorageService"},"DellSwitchConnectionCollection":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/NetworkPorts/Oem/Dell/DellSwitchConnections"},"DellSwitchConnectionService":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/Oem/Dell/DellSwitchConnectionService"},"DellSystemManagementService":{"@odata.id":"/redfish/v1/Systems/System.Embedded.1/Oem/Dell/DellSystemManagementService"},"DellSystemQuickSyncCollection":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellSystemQuickSync"},"DellTimeService":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellTimeService"},"DellUSBDeviceCollection":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellUSBDevices"},"DelliDRACCardService":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DelliDRACCardService"},"DellvFlashCollection":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellvFlash"},"Jobs":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/Jobs"}}},"SoftwareImages":[{"@odata.id":"/redfish/v1/UpdateService/FirmwareInventory/Previous-25227-7.00.00.171__iDRAC.Embedded.1-1"},{"@odata.id":"/redfish/v1/UpdateService/FirmwareInventory/Installed-25227-7.00.00.172__iDRAC.Embedded.1-1"}],"SoftwareImages@odata.count":2},"LogServices":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/LogServices"},"ManagerType":"BMC","Model":"14G Monolithic","Name":"Manager","NetworkProtocol":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/NetworkProtocol"},"Oem":{"Dell":{"@odata.type":"#DellManager.v1_4_0.DellManager","DelliDRACCard":{"@odata.context":"/redfish/v1/$metadata#DelliDRACCard.DelliDRACCard","@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DelliDRACCard/iDRAC.Embedded.1-1_0x23_IDRACinfo","@odata.type":"#DelliDRACCard.v1_1_0.DelliDRACCard","Description":"An instance of DelliDRACCard will have data specific to the Integrated Dell Remote Access Controller (iDRAC) in the managed system.","IPMIVersion":"2.0","Id":"iDRAC.Embedded.1-1_0x23_IDRACinfo","LastSystemInventoryTime":"2024-02-25T08:47:40+00:00","LastUpdateTime":"2024-09-19T05:45:02+00:00","Name":"DelliDRACCard","URLString":"https://10.123.45.138:443"},"RemoteSystemLogs":{"CA":{"Certificates":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/RemoteSystemLogs/CA/Certificates"}},"HTTPS":{"Certificates":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/RemoteSystemLogs/HTTPS/Certificates"},"SecureClientAuth":"Anonymous","SecurePort":6514,"SecureServers":[""],"SecureServers@odata.count":1,"SecureSysLogEnable":"Disabled"}}}},"PowerState":"On","Redundancy":[],"Redundancy@odata.count":0,"SerialConsole":{"ConnectTypesSupported":[],"ConnectTypesSupported@odata.count":0,"MaxConcurrentSessions":0,"ServiceEnabled":false},"SerialInterfaces":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/SerialInterfaces"},"Status":{"Health":"OK","State":"Enabled"},"TimeZoneName":"Europe/Berlin","UUID":"3339334f-c0c8-5180-4d10-00584c4c4544","VirtualMedia":{"@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia"},"VirtualMedia@Redfish.Deprecated":"Please migrate to use /redfish/v1/Systems/System.Embedded.1/VirtualMedia"}

markuslf commented 2 months ago

I added "avigilon" as a vendor, according to your data (thank you). Also added a unit test. Could you test the new version of the plugin (using the source code variant)?

mburgholte commented 2 months ago

The plugin itself is now running. However, the data does not seem to be transmitted correctly or is somewhere else.

markuslf commented 2 months ago

If you want, we could take a closer look at it remotely – but we can't offer that for free.