PMonitor
PMonitor copied to clipboard
Fixed Linux PIDs casting & added posibility to "disable" check from config.
- Changed the
AbstractProcessMonitor
so that it can properly handle situations wherePMonitorNbOfProcesses
key inappSettings
is set to0
or missing completly. This would be useful when it is desired to disable the check without redeploying the application that uses this library. I encountered a situation where it would have been helpful to disable the check in order to partial restore application functionality until I would figure out the issue causing the library to fail. Leading to the next change: - Changed the parsing of Linux PIDs from Int16 to Int32. This was causing a series of problems with large PIDs:
- Could not be converted from String to short as the value is too large to be accommodated in this data type and exceptions was being thrown:
- This in turn leads to the exception being swallowed allowing the execution to continue creating the
LinuxProcessStatusFile
but without thePid
andFileName
being set at all. Furthermore, the check is done on theLinuxProcessStatusFile
being instantiated but its properties are never verified. - Finally, the execution's only path (as I can tell) leads to the last line of code in
GetProcessName
method which attempts to trim theLinuxProcessStatusFile.FileName
property just to end up in throwing aNullReferenceException
:
- Could not be converted from String to short as the value is too large to be accommodated in this data type and exceptions was being thrown:
- Changed to return
null
when theLinuxProcessStatusFile
cannot be sucessfully build instead of an object but with invalid values.