Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Linux PIDs casting & added posibility to "disable" check from config. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aipirvu
Copy link

@aipirvu aipirvu commented Jan 14, 2022

  • Changed the AbstractProcessMonitor so that it can properly handle situations where PMonitorNbOfProcesses key in appSettings is set to 0 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:
      image
    • This in turn leads to the exception being swallowed allowing the execution to continue creating the LinuxProcessStatusFile but without the Pid and FileName being set at all. Furthermore, the check is done on the LinuxProcessStatusFile being instantiated but its properties are never verified.
      image
    • Finally, the execution's only path (as I can tell) leads to the last line of code in GetProcessName method which attempts to trim the LinuxProcessStatusFile.FileName property just to end up in throwing a NullReferenceException:
      image
  • Changed to return null when the LinuxProcessStatusFile cannot be sucessfully build instead of an object but with invalid values.

…s where causing exceptions to be thrown. Updated the case where exception is swallowed and nothing else is done, the catch statement will now return null; this should be consistent with the expected behavior in the 'ParseLinuxProcessStatusFile' method. Formated the console message to include the PID and highlight the original cause of the exception. Updated the 'AbstractProcessMonitor' to gracefully handle the situation where no process is configured by having a default value of 0 for 'nbProcessesToMonitor'.
@aipirvu aipirvu changed the title Fixed Linux PIDs casting & posibility to "disable" check from config. Fixed Linux PIDs casting & added posibility to "disable" check from config. Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant