Forum Discussion

Sharath's avatar
Icon for Neophyte rankNeophyte
6 months ago

Core Dump File Monitoring

Core dumps occur when a Linux process experiences a fault.  This results in an outage of the affected process or service.  The process or service must restart to recover.  During these incidents, the server may remain up, but certain services may experience a brief outage. core dumps and backtraces that may occur on Communications Manager(CM or CUCM), Unity Connection(UC), Cisco Emergency Responder(CER), Cisco Unified Presence Server(CUPS), Cisco Unified Contact Center Express (UCCX or IPCC Express), or any product based on Cisco's Voice Operating System (VOS) appliance model.

I am looking to monitor  is it existence or any metrics regarding it, like file size or else? The moment dump comes in, we need to be alerts... 

Can i Monitor the Core Dump file in Logic Monitor ? 

1 Reply

  • This script will log into a device via ssh (sftp) and echo the contents of a file called “example.txt” in the current directory. For my use case, it converted the contents of the file to an integer because the file only contained a 0 or a 1. The return value is the integer from the file (or -1 if there was an error).

    import com.jcraft.jsch.*

    // Set the SFTP server connection details
    def host = hostProps.get("system.hostname")
    def port = hostProps.get("ssh.port") ?: 22
    def username = hostProps.get("ssh.user")
    def password = hostProps.get("ssh.pass")

    // Set the file name to be read
    def fileName = "example.txt"

    // Create a JSch session
    JSch jsch = new JSch()
    Session session = jsch.getSession(username, host, port)
    session.setConfig("StrictHostKeyChecking", "no")

    // Create an SFTP channel and connect it to the session
    ChannelSftp sftpChannel = (ChannelSftp) session.openChannel("sftp")

    result = -1
    // Print the contents of the file with the given file name
    try {
    InputStream inputStream = sftpChannel.get(fileName)
    result = inputStream.text.toInteger()
    } catch (SftpException e) {
    println("File $fileName not found")

    // Disconnect the SFTP channel and session

    return result

    You could probably modify this to get the file size or something else. You could also use something like this to log in and issue commands, then do something with the result. 

    You could modify the script to output instances (as a discovery script) by listing all the files in a certain directory. This script does something like that:

    import com.jcraft.jsch.JSch

    def host = hostProps.get("system.hostname")
    def user = hostProps.get("ssh.user")
    def pass = hostProps.get("ssh.pass")
    def port = hostProps.get("ssh.port") ?: 22
    def cert = hostProps.get("ssh.cert") ?: '~/.ssh/id_rsa' // cert path may be passed in, otherwise will reference default path.

    def session = null;

    try {
    def jsch = new JSch()
    if (user && !pass) {jsch.addIdentity(cert)}
    session = jsch.getSession(user, host, port)
    session.setConfig("StrictHostKeyChecking", "no")
    if (pass) {session.setPassword(pass)}
    def cmd = "cd /home/lmadmin/connectwise_manage && ls *_la | sort"
    def command_lines = getCommandOutput(session, cmd)
    wildvalue = it.replaceAll(" ","")
    wildalias = it.replaceAll(".la","")

    return 0
    finally {
    if (session) {session.disconnect()}

    * Helper method for executing commands.
    def getCommandOutput(session, input_command) {
    // execute command.
    def channel = session.openChannel("exec")

    // collect command output.
    def commandOutput = channel.getInputStream()

    def output = commandOutput.text;

    // disconnect

    return output

    It issues the command "cd /home/lmadmin/connectwise_manage && ls *_la | sort" that lists all the files in the /home/lmadmin/connectwise_manage directory that end in “_la”. 

    If you did something like this, you could make your collection script just “return 0” and set a value of =0 on the return. That way, whenever the file showed up in the directory, it would get created (within 15 minutes, the soonest discovery can run), and immediately generate an alert as long as the file existed.