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

Commit c974d82

Browse files
committed
added -a switch to print all periods and threshold values to csv
1 parent ebcc89a commit c974d82

File tree

2 files changed

+48
-26
lines changed

2 files changed

+48
-26
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ Extract archive to bin directory of CA APM Enterprise Manager installation. Make
3333
## Configuration
3434
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!**
3535

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`
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`
5151

5252

5353
# Usage Instructions
@@ -94,7 +94,7 @@ Therefore this script deactivates the 'Propagate to Team Center' flag in Managem
9494

9595
* Stop your Enterprise Manager.
9696
* Copy `stopPropagateToAppMap.sh` to a temporary directory.
97-
* Copy all the custom Management Modules (*.jar files) for which you want to deactivate 'Propagate to Team Center' from `<EM_HOME>/config/modules` to a temporary directory.
97+
* Copy all the custom Management Modules (`*.jar` files) for which you want to deactivate 'Propagate to Team Center' from `<EM_HOME>/config/modules` to a temporary directory.
9898
* Backup all those custom Management Modules.
9999
* Run `./stopPropagateToAppMap.sh`
100100
* The script will create a copy of all Management Modules in the `new` subdirectory.
@@ -115,6 +115,7 @@ The script `check_mm.sh` checks all Management Modules in your APM installation
115115
1. check all Management Modules in `EM_PATH`
116116
2. print the maximum alert period duration encountered and
117117
3. write all alerts that exceed `introscope.enterprisemanager.alerts.maxPeriods` to `checkmm.csv`.
118+
5. If you the script with the option `-a` it will write all alerts with periods and threshold values to `checkmm.csv`.
118119

119120

120121
## Debugging and Troubleshooting

check_mm.sh

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ source ./environment.properties
1010

1111
PWD=`pwd`
1212
CSV="${PWD}/checkmm.csv"
13+
print_all=0
14+
15+
while getopts ":ha" opt; do
16+
case ${opt} in
17+
h ) echo "Usage: $0 [-a]"
18+
exit 1
19+
;;
20+
a ) print_all=1
21+
echo "printing all alerts to file $CSV"
22+
;;
23+
\? ) echo "Usage: $0 [-a]"
24+
exit 1
25+
;;
26+
esac
27+
done
1328

1429
TMP_DIR=/tmp/checkmm
1530
echo "Using $TMP_DIR to extract management modules, writing output to $CSV"
@@ -60,15 +75,15 @@ else
6075
fi
6176

6277
# print csv header
63-
echo "Management Module,Alert,Caution,Danger" > ${CSV}
78+
echo "Management Module,Alert,CautionPeriod,DangerPeriod,CautionValue,DangerValue" > ${CSV}
6479

6580
for filename in $FILES
6681
do
6782
echo "Opening $filename"
6883
"${JAVA_HOME}/bin/jar" -xf "${filename}" ManagementModule.xml
6984
mm_name=""
70-
danger=0
71-
caution=0
85+
dangerPeriod=0
86+
cautionPeriod=0
7287
alert="no"
7388

7489
while read p; do
@@ -87,25 +102,31 @@ do
87102
#[[ $alert = "yes" ]] -a [[ $p =~ \<CautionMinNumPerPeriod\>(.*)\</CautionMinNumPerPeriod\> ]] && caution_min="${BASH_REMATCH[1]}"
88103

89104
# find caution period
90-
[[ $alert = "yes" ]] && [[ $p =~ \<CautionAlertPeriod\>(.*)\</CautionAlertPeriod\> ]] && caution="${BASH_REMATCH[1]}"
105+
[[ $alert = "yes" ]] && [[ $p =~ \<CautionAlertPeriod\>(.*)\</CautionAlertPeriod\> ]] && cautionPeriod="${BASH_REMATCH[1]}"
91106

92107
# find danger min period
93108
#[[ $alert = "yes" ]] -a [[ $p =~ \<DangerMinNumPerPeriod\>(.*)\</DangerMinNumPerPeriod\> ]] && danger_min="${BASH_REMATCH[1]}"
94109

95110
# find danger period
96-
[[ $alert = "yes" ]] && [[ $p =~ \<DangerAlertPeriod\>(.*)\</DangerAlertPeriod\> ]] && danger="${BASH_REMATCH[1]}"
111+
[[ $alert = "yes" ]] && [[ $p =~ \<DangerAlertPeriod\>(.*)\</DangerAlertPeriod\> ]] && dangerPeriod="${BASH_REMATCH[1]}"
112+
113+
# find danger period
114+
[[ $alert = "yes" ]] && [[ $p =~ \<CautionTargetValue\>(.*)\</CautionTargetValue\> ]] && cautionValue="${BASH_REMATCH[1]}"
115+
116+
# find danger period
117+
[[ $alert = "yes" ]] && [[ $p =~ \<DangerTargetValue\>(.*)\</DangerTargetValue\> ]] && dangerValue="${BASH_REMATCH[1]}"
97118

98119
# find end of alert definition
99120
if [[ "$alert" = "yes" ]] && [[ "$p" = *"</AlertBase>"* ]]
100121
then
101122
alert="no"
102-
#echo "found alert $name in MM $mm_name, caution = $caution, danger = $danger"
103-
if [ $danger -gt $config_period -o $caution -gt $config_period ]
123+
#echo "found alert $name in MM $mm_name, cautionPeriod = $cautionPeriod, dangerPeriod = $dangerPeriod"
124+
if [ $print_all -o $dangerPeriod -gt $config_period -o $cautionPeriod -gt $config_period ]
104125
then
105126
# update max_period and print to csv file
106-
[[ $danger -gt $max_period ]] && max_period=$danger;
107-
[[ $caution -gt $max_period ]] && max_period=$caution;
108-
echo "$mm_name,$name,$caution,$danger" >> ${CSV}
127+
[[ $dangerPeriod -gt $max_period ]] && max_period=$dangerPeriod;
128+
[[ $cautionPeriod -gt $max_period ]] && max_period=$cautionPeriod;
129+
echo "$mm_name,$name,$cautionPeriod,$dangerPeriod,$cautionValue,$dangerValue" >> ${CSV}
109130
fi
110131
fi
111132
done < ${TMP_DIR}/ManagementModule.xml

0 commit comments

Comments
 (0)