LSOFParser - Global

  • Release version: Australia
  • Updated March 12, 2026
  • 1 minute to read
  • The LSOFParser script include provides methods to parse the output of the lsof command: lsof -i4TCP -n -P -F pcnfT.

    Use this script include with a discovery script when you need to parse lsof output.

    LSOFParser - error(String msg)

    Generates the specified error message.

    Table 1. Parameters
    Name Type Description
    msg String The error message
    Table 2. Returns
    Type Description
    void

    LSOFParser - initFileDescriptor()

    Initializes the file descriptor process.

    Table 3. Parameters
    Name Type Description
    None
    Table 4. Returns
    Type Description
    void

    LSOFParser - initProcess()

    Initializes the parser process.

    Table 5. Parameters
    Name Type Description
    None
    Table 6. Returns
    Type Description
    void

    LSOFParser - on_c(String line)

    Sets the current command.

    Table 7. Parameters
    Name Type Description
    line String The command
    Table 8. Returns
    Type Description
    void

    LSOFParser - on_endFileDescriptor()

    Closes the file descriptor process.

    Table 9. Parameters
    Name Type Description
    None
    Table 10. Returns
    Type Description
    void

    LSOFParser - on_endProcess()

    Closes the parser process.

    Table 11. Parameters
    Name Type Description
    None
    Table 12. Returns
    Type Description
    void

    LSOFParser - on_f(String line)

    Sets the current file descriptor.

    Table 13. Parameters
    Name Type Description
    line String The file descriptor
    Table 14. Returns
    Type Description
    void

    LSOFParser - on_n(String line)

    Sets the current address.

    Table 15. Parameters
    Name Type Description
    line String The address
    Table 16. Returns
    Type Description
    void

    LSOFParser - on_p(String line)

    Sets the current PID.

    Table 17. Parameters
    Name Type Description
    line String The PID
    Table 18. Returns
    Type Description
    void

    LSOFParser - on_T(String line)

    Sets the current state.

    Table 19. Parameters
    Name Type Description
    line String The state
    Table 20. Returns
    Type Description
    void

    LSOFParser - parse(String lsofOutput)

    Parses the specified lsof output.

    Results are available in connections and listeners arrays, and errors are recorded in errorString() and isValid().

    Table 21. Parameters
    Name Type Description
    lsofOutput String The lsof output
    Table 22. Returns
    Type Description
    void