Forum Discussion
Python for analyzing the Logs
We are having Tomcat memory issues on multiple F5 devices. We need to create a python script to analyze logs on multiple devices and find if there is a log "java.lang.OutOfMemoryError: " in /var/log/tomcat/catalina.out. Could someone please help me draft this script.
- jaikumar_f5
Noctilucent
Dont you have a centralized logging, like splunk, syslog servers. I'm sure there will be.
Simply use splunk or your monitoring tool to search for the OOM log
- Satoshi_Toyosa1Ret. Employee
If I do not want to use an external logging service, I am in a hurry, and my boxes have adequate power and bandwidth, I would use iControl REST POST /mgmt/tm/util/bash to call "cat <file> | grep keywords". Run this against all the boxes one by one.
$ curl -sku $PASS https://$HOST/mgmt/tm/util/bash \ -X POST -H "Content-type: application/json" \ -d '{"command":"run", "utilCmdArgs": "-c \"cat /var/log/tomcat/catalina.out | grep \\\"Unknown version\\\"\""}' \ | jq -r '.commandResult' WARNING: Unknown version string [3.1]. Default version will be used.
(I chose "Unknow version" for grepping as my log presently does not have OutOfMemoryError".)
I chose jq for parsing. You can do the same using python, of course. Be careful with the double escaping for double-quotes. We can easily make mistakes (For the above call, I tried three times :-).
For a sophisticated method for deploying logging facility, check F5 Telemetry Streaming.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com