This script is a targeted tool designed to monitor a single application's log file (e.g., demo-hello.log) for specific, user-defined error patterns. When a configured error message appears in the log, the script automatically captures diagnostic information (a series of thread dumps and a heap dump) from the Mule runtime hosting the application.
This approach is ideal for troubleshooting intermittent or hard-to-reproduce issues within a specific application without the overhead of full system-level monitoring.
Prerequisites:
Steps for Implementation & Use
nohup: nohup ./app_monitor.sh &Monitor its Output: You can view the script's own log messages (e.g., when a pattern is detected) by running: tail -f /path/to/your/OUTPUT_DIR/monitorOut.logStop the Script: Find the script's PID (ps -ef | grep app_monitor.sh) and send it a kill signal (kill <PID>). The script's cleanup trap will automatically handle shutting down all related processes. If the script is unresponsive, use kill -9 <PID>Note on SEARCH_PATTERNS
This array is crucial. Only specify necessary and unique error strings. If the patterns are too generic, the CAPTURE_LIMIT will be reached on non-critical issues. Once the limit is hit, the monitoring will stop, and you will lose the chance of collecting data (heap and thread dumps) at the right time for a more important event.
Attachment: monitor_app_v2.sh.zip
Critical Usage Guidelines
Disclaimer
This script is provided as an EXAMPLE ONLY and is not officially supported. It is the end user's full responsibility to understand, test, and adapt the script for their specific environment. Run this script at your own risk. The provider of this script disclaims all responsibility for any consequences resulting from its use.
005131283

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.