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

Commit 5a638b9

Browse files
committed
added list_actions.sh
1 parent 86911fb commit 5a638b9

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ The script `dependency_mm.sh` checks all Management Modules in your APM installa
133133
5. If you run the script with the option `-a` it will write all elements that may have dependencies to `dependencies.csv`.
134134

135135

136+
## Export All Actions
137+
138+
The script `list_actions.sh` checks all Management Modules in your APM installation for actions and generates a csv file that contains the Management Module, Alert Name, Caution Action List and Danger Action List.
139+
140+
1. Set `EM_PATH` in `environment.properties` to point to your APM installation
141+
2. Run `./dependency_mm.sh`.
142+
3. The script will print what it is doing:
143+
1. check all Management Modules in `EM_PATH`
144+
2. write all actions in alerts to `alert_actions.csv`.
145+
146+
136147
## Debugging and Troubleshooting
137148
Check the log file written by the individual scripts.
138149

list_actions.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/sh
2+
3+
source ./environment.properties
4+
5+
# are there MM for domains?
6+
if [ -z `find ${EM_PATH}/config/modules/* -type d` ]
7+
then
8+
FILES="${EM_PATH}/config/modules/*.jar"
9+
else
10+
FILES="${EM_PATH}/config/modules/*.jar ${EM_PATH}/config/modules/*/*.jar"
11+
fi
12+
13+
echo "Management Module, Alert Name, Caution Action List, Danger Action List" > alert_actions.csv
14+
15+
for i in $FILES
16+
do
17+
18+
cp $i .
19+
jar xvf $i ManagementModule.xml
20+
21+
mm=`echo *.jar`
22+
echo "Analyzing $mm ..."
23+
24+
# line 1: xml formatting of all AlertBase elements in ManagementModule.xml
25+
# line 2: compress to one alert per line: remove all newlines with space and '-------' with newline
26+
# line 3: grep to filter all alerts with actions
27+
# line 4: extract action for alert with both caution and danger alerts (optional regex did not work for me)
28+
# line 5: extract action for alert with only caution alerts
29+
# line 6: extract action for alert with only danger alerts
30+
# line 7: replace action list xml with just MM/ActionName
31+
# line 8: truncate spaces
32+
33+
echo 'cat /ManagementModule/DataGroups/DataGroup/AlertBase' | xmllint --shell ManagementModule.xml| \
34+
tr '\n' ' ' | sed 's/\-\-\-\-\-\-\-/\n/g' | \
35+
grep ActionID | \
36+
sed -E "s/^.+\<Name\>(.+)\<\/Name\>.+\<CautionActionList\>(.+)\<\/CautionActionList\>.+\<DangerActionList\>(.+)\<\/DangerActionList\>.+/$mm, \1, \2, \3/g" | \
37+
sed -E "s/^.+\<Name\>(.+)\<\/Name\>.+\<DangerActionList\>(.+)\<\/DangerActionList\>.+/$mm, \1,,\2/g" | \
38+
sed -E "s/^.+\<Name\>(.+)\<\/Name\>.+\<CautionActionList\>(.+)\<\/CautionActionList\>.+/$mm, \1,\2,/g" | \
39+
sed -E 's/\<ActionID\>[[:space:]]*\<ManagementModuleName\>([^\<]+)\<\/ManagementModuleName\>[[:space:]]*\<ConstructName\>([^\<]+)\<\/ConstructName\>[[:space:]]*\<\/ActionID\>/ \1\/\2/g' | \
40+
sed -E 's/[[:space:]]+/ /g' \
41+
>> alert_actions.csv
42+
43+
rm -f ManagementModule.xml
44+
rm -f *.jar
45+
46+
done

0 commit comments

Comments
 (0)