-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathxmsaudit.sh
More file actions
executable file
·307 lines (269 loc) · 9.15 KB
/
Copy pathxmsaudit.sh
File metadata and controls
executable file
·307 lines (269 loc) · 9.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#!/bin/bash
# This script will gather all the system level information to ensure the XMS configuration enviorment
# License information and the latest version of this script can be found at
# https://github.com/Dialogic/UsefulScripts
# or run directly by Executing
. /etc/init.d/functions
starttime=`date +"%Y-%m-%d_%H-%M-%S"`
hostname=`hostname`
OUTFILE=xmsaudit-$hostname.tgz
LOG="xmsaudit-$hostname.log"
TMPPATH="/var/tmp/xmsaudit"
#logger -t SCRIPT Executing $0, see $LOG in $TMPPATH for details
#mkdir $TMPPATH
#cd $TMPPATH
# Use step(), try(), and next() to perform a series of commands and print
# [ OK ] or [FAILED] at the end. The step as a whole fails if any individual
# command fails.
step() {
echo "#########################################################################" >> $LOG
echo -n -e "$@"
echo -e "STEP - $@"&>> $LOG
STEP_OK=0
}
next() {
[[ $STEP_OK -eq 0 ]] && echo_success || echo_failure
echo
return $STEP_OK
}
setpass() {
echo -n "$@"
STEP_OK=0
}
setfail() {
echo -n "$@"
STEP_OK=1
}
log(){
echo "$@" >> $LOG
}
logx(){
echo "----------------------------------------------------------------------------" &>> $LOG
echo "$@" >> $LOG
echo "---------------------" &>> $LOG
"$@" &>> $LOG
}
echo "Starting Audit - $starttime" > $LOG
log "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
log "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
log "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
step "Checking frequently misconfigured items"
echo "----------------------------------------------------------------------------" &>> $LOG
log "XMS release version and state"
echo "----" &>> $LOG
curl -s http://127.0.0.1:10080/system | grep state >> $LOG
echo "" &>> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "CPUs on system"
echo "----" &>> $LOG
lscpu | grep -P "^CPU\(s\):|name:" >> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "Mem on system"
echo "----" &>> $LOG
free -ml >> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "disk space"
echo "----" &>> $LOG
df -h >> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "SELinux should be disabled"
echo "----" &>> $LOG
sestatus >> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "etc/hosts should have the fqdn and hostname set"
echo "----" &>> $LOG
cat /etc/hosts >> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "Check that you can ping the hostname, confirm this to your dir"
echo "----" &>> $LOG
ping `hostname` -c 1 >> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "Check that you can ping the an internet location"
echo "----" &>> $LOG
ping www.dialogic.com -c 1 >> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "Check if cache is enabled"
echo "----" &>> $LOG
curl -s http://127.0.0.1:10080/httpclient >> $LOG
echo "" &>> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "check rp_filter disabled"
echo "----" &>> $LOG
sysctl -A | grep .rp_filter >> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "check for the checksum disabled"
echo "----" &>> $LOG
for nic in `ls /sys/class/net` ;
do
ethtool --show-offload $nic | grep checksum >> $LOG ;
done
echo "----------------------------------------------------------------------------" &>> $LOG
log "check the sip settings"
echo "----" &>> $LOG
curl -s http://127.0.0.1:10080/sip >> $LOG
echo "" &>> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "check the rtp settings"
echo "----" &>> $LOG
curl -s http://127.0.0.1:10080/rtp >> $LOG
echo "" &>> $LOG
echo "----------------------------------------------------------------------------" &>> $LOG
log "check the lic"
echo "----" &>> $LOG
curl -s http://127.0.0.1:10080/license >> $LOG
echo "" &>> $LOG
log "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
log "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
log "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
setpass
next
step "Gather basic System Information"
logx hostname
logx hostnamectl
logx cat /etc/system-release
logx cat /etc/redhat-release
logx sestatus
logx lscpu
logx free -ml
logx df -h
logx ip a
logx curl http://127.0.0.1:10080/system
logx cat /proc/meminfo
setpass;
next
step "Gathering Network configuration"
logx ifconfig
logx ifconfig -a
logx ip a
logx netstat -anope
logx route
setpass;
next
step "Gather Firewall Information"
logx iptables --list
logx firewall-cmd --list-all-zones
setpass;
next
step "Gathering process and package information"
logx cat /etc/system-release
logx cat /etc/redhat-release
logx ps -Afe
logx rpm -qa
logx yum history info
logx systemctl list-unit-files
logx chkconfig --list
logx crontab -l
log cron tasks
cat /etc/passwd | sed 's/^\([^:]*\):.*$/crontab -u \1 -l 2>\&1/' | grep -v "no crontab for" | sh >> $LOG
setpass;
next
step "Collecting system usage and performance data"
logx uptime
logx top -b -n 1
logx sar -A
logx cat /proc/cpuinfo
logx lscpu
logx free -ml
logx cat /var/lib/xms/meters/currentValue.txt
setpass;
next
step "Collecting other system and configuration data"
logx env
for nic in `ls /sys/class/net` ;
do
logx ethtool --show-offload $nic;
done
logx lspci
logx sysctl -A
logx dmidecode
logx dmesg
logx ulimit -a
logx uname -a
setpass;
next
step "Collecting XMS WebUI information"
OAMHOST="127.0.0.1"
OAMPORT="10080"
dumpsubs(){
local CURPATH=$1
local RESPONSE="$(curl -s http://$OAMHOST:$OAMPORT$CURPATH)"
log "------------------------------------------------------------------------------"
log "$CURPATH"
log "$RESPONSE"
local ITEMS="$(echo -e "$RESPONSE" |grep uri | grep resource | awk -F'"' '{print $2}')"
#echo $ITEMS
for item in $ITEMS
do
#omit getting the media and backup for performance sake
if [[ ${CURPATH} != *"/media/prompts"* ]] && [[ ${CURPATH} != *"/system/backup"* ]]; then
dumpsubs "$CURPATH/$item"
fi
done
}
log "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
log "XMS FULL WebUI Dump"
log "host: `hostname`"
log "OAM: http://$OAMHOST:$OAMPORT"
log "starttime: $starttime"
log "Outfile: $OUTFILE"
log "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
dumpsubs ""
setpass;
next
step "Collecting XMS Cache file information"
log "Cache Info"
logx `ls -l /var/cache/xms/http/xmserver/ |wc -l` files found in cache
log "Files- "
logx ls -la /var/cache/xms/http/xmserver/
setpass;
next
step "Saving directory and file information"
declare -a dirs=(
"ls -atlR /usr/dialogic"
"ls -altR /etc/xms"
"ls -altR /var/lib/xms"
"ls -altR /usr/bin"
)
for i in "${dirs[@]}"
do
logx $i
done
setpass;
next
step "Collecting for XMS core dump information"
log "Listing:"
logx ls -altr /var/tmp/abrt
log "last-ccpp:"
logx cat /var/tmp/abrt/last-ccpp
for filename in /var/tmp/abrt/*; do
if [ -d $filename ]
then
echo "======================== START ================================" &>> $LOG
echo "$filename" &>> $LOG
echo "===============================================================" &>> $LOG
echo " EXECUTABLE " &>> $LOG
echo "---------------------------------------------------------------" &>> $LOG
cat $filename/executable &>> $LOG
echo "" &>> $LOG
echo "---------------------------------------------------------------" &>> $LOG
echo " REASON " &>> $LOG
echo "---------------------------------------------------------------" &>> $LOG
cat $filename/reason &>> $LOG
echo "" &>> $LOG
echo "---------------------------------------------------------------" &>> $LOG
echo " BACKTRACE " &>> $LOG
echo "---------------------------------------------------------------" &>> $LOG
cat $filename/core_backtrace &>> $LOG
echo "" &>> $LOG
echo "===============================================================" &>> $LOG
echo "$filename" &>> $LOG
echo "=====================i=== END ===============================" &>> $LOG
fi
done
setpass;
next
step "Compressing system and XMS debug logs"
tar cvzf $OUTFILE --exclude='*.tgz' --exclude='xmsbackup*.tar.gz' /var/log/xms /var/log/dialogic /var/log/messages* /etc/profile.d/ct_intel.sh /etc/xms /usr/dialogic/cfg /etc/hosts /var/lib/xms/meters/currentValue.txt /etc/fstab /etc/cluster/cluster.conf /etc/sysctl.conf /etc/sysconfig &>/dev/null
setpass;
next
#echo -e "\n\n File saved to $O\n\n"