Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit dbb2e3e

Browse files
grogu01grogu01
authored andcommitted
updated README
1 parent bdf467f commit dbb2e3e

File tree

2 files changed

+61
-7
lines changed

2 files changed

+61
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.xlsx

README.md

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,90 @@ Scripts to automate recurring APM tasks.
77
Scripts to automate recurring APM tasks.
88

99
## APM version
10-
CA APM 10.5
10+
Tested with CA APM 10.5.
1111

1212
## Supported third party versions
1313
n/a
1414
## Limitations
15-
*What the extension will not do.*
15+
These scripts run on Linux (and probably most Unixes and even on a Mac) but not on Windows.
1616

1717
## License
1818
[Apache License 2.0](LICENSE)
1919

2020
# Installation Instructions
2121

2222
## Prerequisites
23-
These scripts run on Linux.
23+
* CA APM 10.x installed, ideally - but not necessarily - in the same path on every Enterprise Manager in the cluster.
24+
* One APM user that can execute scripts and read all files in the APM installation path.
25+
* For taking thread dumps: Java JDK (!!!) installed to be able to take thread dumps with `jstack`. CA APM installs only a JRE.
2426

2527
## Dependencies
2628
n/a
2729

2830
## Installation
29-
Extract archive to bin directory of CA APM Enterprise Manager installation.
31+
Extract archive to bin directory of CA APM Enterprise Manager installation. Make sure all shell scripts are executable: `chmod +x *.sh`
3032

3133
## Configuration
32-
Edit environment.properties.
34+
The file `environment.properties` contains all the variables that need to be changed in order to run the scripts. It should be copied to every Enterprise Manager. **Do not change the scripts themselves!**
35+
36+
* EM_PATH: path to the *local* EM installation directory. Needs to be adapted for every Enterprise Manager. Default value: `/opt/CA/introscope`.
37+
* SSH_USER: this is the user that the scripts will use to connect to remote Enterprise Managers from the MOM. The scripts assume that the public key is known on the remote EMs. Run `ssh_publickey.sh` to make the public key of the current user (`~/.ssh/id_rsa.pub`) known on the remote server. Default value: `wily`
38+
* MOM_HOST: hostname or IP address of the MOM.
39+
* COLLECTOR<n>_HOST: hostname or IP address of the collector EMs. Leave empty if you don't have that many collectors in your cluster.
40+
* MOM_PATH: paths to EM installation directory on the MOM. Default value: `$EM_PATH`
41+
* COLLECTOR<n>_PATH: paths to EM installation directory on the repsective collector. Default value: `$EM_PATH`
42+
* THREAD_DUMP_REPEAT: how many thread dumps to take on an EM. Default value: 10
43+
* THREAD_DUMP_INTERVAL: pause between thread dumps in seconds. Default value: 3
44+
* THREAD_DUMP_FILE: name of the file name to which the thread dump is written. Default value: `thread_dump_jstack.txt`
45+
* THREAD_DUMP_SCRIPT: name of the script to execute to take a thread dump. Default value: `thread_dump.sh`
46+
* THREAD_DUMP_ACTION_LOG: log file of the thread dump action (`em_thread_dump_action.sh`). Default value: `thread_dump_action.log`
47+
* THREAD_DUMP_JSTACK: path to the jstack binary. Requires a Java JDK, not JRE. Default value: `$EM_PATH/jdk1.8.0_131/bin/jstack`
48+
* CHECK_PERFLOG_LOG: log file of the script `check_perflog.sh`. Default value: `check_perflog.log`
49+
* LOG_FILES: log files to collect from all EMs with `getlogs.sh`. Default value: `( "perflog.txt" "IntroscopeEnterpriseManager.log" "em.log" "$THREAD_DUMP_FILE" )`
50+
* LOG_TARGET_DIR: target directory where `getlogs.sh` will copy all the log files to. Default value: `$EM_PATH/logs/cluster`
3351

3452

3553
# Usage Instructions
36-
See comments in the scripts.
54+
55+
## Copy the public key to a remote server
56+
57+
All remote scripts like `em_thread_dump_action.sh` or `getlogs.sh` rely on being able to connect to remote servers (EMs) using the public key instead of being prompted for the password.
58+
59+
`ssh_publickey.sh <server>` appends the public key from `~/.ssh/id_rsa.pub` to `.ssh/authorized_keys` on the remote server for the current user.
60+
61+
*The user must be configured as `SSH_USER` in `environment.properties`. Execute this script for all collectors!*
62+
63+
## Take EM thread dumps based on perflog.txt
64+
65+
You may want to take thread dumps of one Enterprise Manager (MOM or collector) in case the EM is stalled, e.g. when a Harvest cycle takes longer than 15s.
66+
67+
The `check_perflog.sh` script watches the file `perflog.txt` and takes a series of thread dumps when no line is appended to the file for more than 15 seconds. It calls `thread_dump.sh` for every single thread dump to take.
68+
69+
Start the script with `nohup check_perflog.sh &` or have it running as a daemon.
70+
71+
## Take EM thread dumps if an alert occurs
72+
73+
You may want to take thread dumps of all Enterprise Managers in your cluster when a certain APM alert fires.
74+
75+
In CA APM workstation define a shell alert action that calls `./bin/em_thread_dump_action.sh`. See [Create a Shell Command Action](https://docops.ca.com/ca-apm/10-5/en/administrating/manage-metric-data-by-using-management-modules/create-and-configure-notification-actions-in-the-workstation#CreateandConfigureNotificationActionsintheWorkstation-CreateaShellCommandAction) in the CA APM documentation.
76+
77+
When the action is triggered the MOM will call the script `em_thread_dump_action.sh` which will trigger a series of thread dumps to be taken on all the configured Enterprise Managers by executing `thread_dump.sh` remotely via ssh.
78+
79+
## Take a single thread dump
80+
81+
The script `thread_dump.sh` will take a single thread dump from the process with `em.pid` using the binary jstack as configured in `environment.properties`.
82+
83+
## Get log files from all Enterprise Managers
84+
85+
`getlogs.sh` collects all the log files configured as `LOG_FILES` in `environment.properties` from the Enterprise Managers, prefixes them with `MOM-` or `Collector<n>`, respectively, and saves them in the `LOG_TARGET_DIR` directory.
86+
87+
The script assumes all log files are stored in the default directory `$EM_PATH/logs`. If they are stored in another location, e.g. `/var/log/` the script has to be changed accordingly.
3788

3889
## Debugging and Troubleshooting
39-
Check log files.
90+
Check the log file written by the individual scripts.
4091

92+
## Future work
93+
Anybody can contribute to this project over github. E.g. changing a property in a configuration file on every EM, backup/copy configuration or data files, restarting a process, ...
4194

4295
## Support
4396
This document and associated tools are made available from CA Technologies as examples and provided at no charge as a courtesy to the CA APM Community at large. This resource may require modification for use in your environment. However, please note that this resource is not supported by CA Technologies, and inclusion in this site should not be construed to be an endorsement or recommendation by CA Technologies. These utilities are not covered by the CA Technologies software license agreement and there is no explicit or implied warranty from CA Technologies. They can be used and distributed freely amongst the CA APM Community, but not sold. As such, they are unsupported software, provided as is without warranty of any kind, express or implied, including but not limited to warranties of merchantability and fitness for a particular purpose. CA Technologies does not warrant that this resource will meet your requirements or that the operation of the resource will be uninterrupted or error free or that any defects will be corrected. The use of this resource implies that you understand and agree to the terms listed herein.

0 commit comments

Comments
 (0)