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

Commit 9f43793

Browse files
grogu01grogu01
authored andcommitted
add script to check alert period
1 parent 04722a4 commit 9f43793

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

check_mm.sh

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/bin/bash
2+
3+
#
4+
# check all Management Modules alert caution and danger threshold vs introscope.enterprisemanager.alerts.maxPeriods
5+
# determine maximum period value and print all alerts exceeding property to csv file
6+
#
7+
8+
source ./environment.properties
9+
10+
11+
PWD=`pwd`
12+
CSV="${PWD}/checkmm.csv"
13+
14+
TMP_DIR=/tmp/checkmm
15+
echo "Using $TMP_DIR to extract management modules, writing output to $CSV"
16+
mkdir -p $TMP_DIR
17+
18+
if [ ! -d "$TMP_DIR" ]
19+
then
20+
echo "ERROR: could not create directory $TMP_DIR"
21+
exit 1
22+
fi
23+
24+
cd $TMP_DIR
25+
26+
if [ ! -d "$EM_PATH" ] || [ ! -d "$EM_PATH/config/modules" ]
27+
then
28+
echo "ERROR: cannot open directory $EM_PATH/config/modules. Make sure to change \$EM_PATH in environment.properties."
29+
exit 1
30+
fi
31+
32+
if [ -z "${JAVA_HOME}" ]
33+
then
34+
echo "ERROR: \$JAVA_HOME is not set. Please 'export \$JAVA_HOME=<path to java>'."
35+
exit 1
36+
fi
37+
38+
39+
config=`grep 'introscope.enterprisemanager.alerts.maxPeriods' $EM_PATH/config/IntroscopeEnterpriseManager.properties`
40+
41+
# if empty set to default
42+
if [ -z "$config" ]
43+
then
44+
config_period=20
45+
echo "introscope.enterprisemanager.alerts.maxPeriods=20 (default)"
46+
else
47+
[[ $config =~ \=([0-9]+) ]] && config_period="${BASH_REMATCH[1]}"
48+
echo "introscope.enterprisemanager.alerts.maxPeriods=$config_period"
49+
fi
50+
51+
# max period starting value
52+
max_period=$config_period
53+
54+
# are there MM for domains?
55+
if [ -z `find /Users/grogu01/work/Introscope10.7.0.45/config/modules/* -type d` ]
56+
then
57+
FILES="${EM_PATH}/config/modules/*.jar"
58+
else
59+
FILES="${EM_PATH}/config/modules/*.jar ${EM_PATH}/config/modules/*/*.jar"
60+
fi
61+
62+
# print csv header
63+
echo "Management Module,Alert,Caution,Danger" > ${CSV}
64+
65+
for filename in $FILES
66+
do
67+
echo "Opening $filename"
68+
${JAVA_HOME}/bin/jar -xf ${filename} ManagementModule.xml
69+
mm_name=""
70+
danger=0
71+
caution=0
72+
alert="no"
73+
74+
while read p; do
75+
#echo $p
76+
77+
# save Management Module name
78+
[[ -z $mm_name ]] && [[ $p =~ \<Name\>(.*)\</Name\> ]] && mm_name="${BASH_REMATCH[1]}"
79+
80+
# find start of alert definition
81+
[[ $p = *"<AlertBase xsi:type"* ]] && alert="yes"
82+
83+
# find alert name
84+
[[ $alert = "yes" ]] && [[ $p =~ \<Name\>(.*)\</Name\> ]] && name="${BASH_REMATCH[1]}"
85+
86+
# find caution min period
87+
#[[ $alert = "yes" ]] -a [[ $p =~ \<CautionMinNumPerPeriod\>(.*)\</CautionMinNumPerPeriod\> ]] && caution_min="${BASH_REMATCH[1]}"
88+
89+
# find caution period
90+
[[ $alert = "yes" ]] && [[ $p =~ \<CautionAlertPeriod\>(.*)\</CautionAlertPeriod\> ]] && caution="${BASH_REMATCH[1]}"
91+
92+
# find danger min period
93+
#[[ $alert = "yes" ]] -a [[ $p =~ \<DangerMinNumPerPeriod\>(.*)\</DangerMinNumPerPeriod\> ]] && danger_min="${BASH_REMATCH[1]}"
94+
95+
# find danger period
96+
[[ $alert = "yes" ]] && [[ $p =~ \<DangerAlertPeriod\>(.*)\</DangerAlertPeriod\> ]] && danger="${BASH_REMATCH[1]}"
97+
98+
# find end of alert definition
99+
if [[ "$alert" = "yes" ]] && [[ "$p" = *"</AlertBase>"* ]]
100+
then
101+
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 ]
104+
then
105+
# 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}
109+
fi
110+
fi
111+
done < ${TMP_DIR}/ManagementModule.xml
112+
#echo "finished reading MM $mm_name"
113+
done
114+
115+
# print summary
116+
echo
117+
if [[ $max_period -gt $config_period ]]
118+
then
119+
echo "maximum alert period in all MMs = $max_period > introscope.enterprisemanager.alerts.maxPeriods = $config_period"
120+
else
121+
echo "no alert found with alert period > introscope.enterprisemanager.alerts.maxPeriods = $config_period"
122+
fi
123+
echo
124+
125+
# cd back, remove tmp directory
126+
cd ${PWD}
127+
rm -Rf ${TMP_DIR}

0 commit comments

Comments
 (0)