-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudit_logger.sh
265 lines (258 loc) · 11.6 KB
/
audit_logger.sh
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
#!/bin/bash
#Author: Maynard Louis E. Prepotente
#Date: Nov 28, 2019
TS=$(date +"%Y-%m-%d %H:%M:%S")
fDate=$(date +"%Y-%m-%d")
logDIR="/apps/splunk/etc/apps/csg/bin/scripts/logs"
profile="$1"
updateprofile="/apps/splunk/etc/apps/csg/bin/scripts/updateprofile.exp"
dump_path="/apps/splunk/etc/apps/csg/bin/scripts/uploads"
lq_path="/home/splunk_user/uploads"
trail="/apps/splunk/etc/apps/csg/bin/scripts/logs/updateprofile_audit.log.${fDate}"
#remove quotes on csv file
sed -i 's/\"//g' $profile
#variables
uname=`cat $profile | tail -n1 | awk -F',' '{ print $1}'`
action=`cat $profile | tail -n1 | awk -F',' '{ print $2}'`
ticket=`cat $profile | tail -n1 | awk -F',' '{ print $3}'`
min=`cat $profile | tail -n1 | awk -F',' '{ print $4}'`
lname=`cat $profile | tail -n1 | awk -F',' '{ print $5}'`
fname=`cat $profile | tail -n1 | awk -F',' '{ print $6}'`
oldMin=`cat $profile | tail -n1 | awk -F',' '{ print $7}'`
newMin=`cat $profile | tail -n1 | awk -F',' '{ print $8}'`
kycId=`cat $profile | tail -n1 | awk -F',' '{ print $9}'`
file=`cat $profile | tail -n1 | awk -F',' '{ print $10}'`
srcMin=`cat $profile | tail -n1 | awk -F',' '{ print $11}'`
RRN=`cat $profile | tail -n1 | awk -F',' '{ print $12}'`
updateProfile=`cat $profile | tail -n1 | awk -F',' '{ print $13}'`
updateFName=`cat $profile | tail -n1 | awk -F',' '{ print $14}'`
updateMName=`cat $profile | tail -n1 | awk -F',' '{ print $15}'`
updateLName=`cat $profile | tail -n1 | awk -F',' '{ print $16}'`
updateAddressName=`cat $profile | tail -n1 | awk -F',' '{ print $17}'`
updateAddressValue=`cat $profile | tail -n1 | awk -F',' '{ print $18}'`
updateAddressType=`cat $profile | tail -n1 | awk -F',' '{ print $19}'`
updateBirthday=`cat $profile | tail -n1 | awk -F',' '{ print $20}'`
updateEAddress=`cat $profile | tail -n1 | awk -F',' '{ print $21}'`
lq_file="$lq_path/$file"
logfile="/apps/splunk/etc/apps/csg/bin/scripts/logs/updateprofile.${ticket}.log"
resultfile="/apps/splunk/etc/apps/csg/lookups/updateprofile_${uname}_result.csv"
echo "TIMESTAMP: $TS" | tee -a $resultfile
echo "USERNAME = $uname" | tee -a $resultfile
echo "TICKET = $ticket" | tee -a $resultfile
case $action in
block_and_create_new_virtual_account)
echo "ACTION = virtual_card_replacement" | tee -a $resultfile
echo "DETAILS = \"MIN: $min\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "DONE BLOCKING AND CREATING NEW VIRTUAL ACCOUNT.")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
cancel_account)
echo "ACTION = min_deregistration_from_account" | tee -a $resultfile
echo "DETAILS = \"MIN: $min\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "DONE WITH ACCOUNT CANCELLATION.")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
min_reassignment)
echo "ACTION = min_reassignment" | tee -a $resultfile
echo "DETAILS = \"OLD MIN: $oldMin NEW MIN: $newMin\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "Successfully updated MIN in identity management service")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
update_profile)
case $updateProfile in
tab_update_name)
echo "ACTION = update_profile" | tee -a $resultfile
echo "DETAILS = \"MIN: $min FIRST NAME: $updateFName MIDDLE NAME: $updateMName LAST NAME: $updateLName\"" >> $resultfile
x=$(cat $logfile | grep -c "Done updating the name of the user in the database.")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
tab_update_address)
echo "ACTION = update_profile" | tee -a $resultfile
echo "DETAILS = \"MIN: $min ADDRESS FIELD: $updateAddressName ADDRESS VALUE: $updateAddressValue TYPE: $updateAddressType\"" >> $resultfile
x=$(cat $logfile | grep -c "DONE UPDATING ADDRESS.")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
tab_update_birthday)
echo "ACTION = update_profile" | tee -a $resultfile
echo "DETAILS = \"MIN: $min NEW BIRTHDAY: $updateBirthday\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "Done updating birthday.")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
tab_update_eaddress)
echo "ACTION = update_profile" | tee -a $resultfile
x=$(cat $logfile | grep -c "Done updating email.")
y=$(grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" $logfile | head -n1)
echo "DETAILS = \"MIN: $min OLD EMAIL: $y NEW EMAIL: $updateEAddress\"" >> $resultfile
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
*)
;;
esac
;;
downgrade_kyc1)
x=$(cat $logfile | grep -c "transaction_reference_no")
y=$(cat $logfile | grep "transaction_reference_no")
echo "ACTION = downgrade_kyc1" | tee -a $resultfile
if [ $x -eq 0 ]; then
echo "DETAILS = \"MIN: $min \"" | tee -a $resultfile
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "DETAILS = \"MIN: $min $y\"" | tee -a $resultfile
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
rema_claim_transaction_update)
echo "ACTION = rema_status_update" | tee -a $resultfile
echo "DETAILS = \"file: $file | SRCMIN: $srcMin RRN: $RRN \"" | tee -a $resultfile
x=$(cat $logfile | grep -c "DB record claim_flag")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
bulk_permanent_blocking)
echo "ACTION = batch_efs_closure" | tee -a $resultfile
echo "DETAILS = \"file: $file | Check output for list of blocked MINs\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "not_activated")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
bulk_blocking_accounts_cms)
echo "ACTION = batch_cms_closure" | tee -a $resultfile
echo "DETAILS = \"file: $file | Check output for list of blocked MINs\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "procedure successfully completed.")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
lift_dedup_account)
echo "ACTION = lift_dedupped_accounts_in_efs" | tee -a $resultfile
echo "DETAILS = \"file: $file | Check output for list of MINs\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "Done")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
lift_closed_account)
echo "ACTION = lift_closed_accounts_in_efs" | tee -a $resultfile
echo "DETAILS = \"file: $file | Check output for list of MINs\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "Updated account_status to ACTIVE")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
lift_blacklisted_account)
echo "ACTION = lift_blacklisted_accounts_in_efs" | tee -a $resultfile
echo "DETAILS = \"file: $file | Check output for list of MINs\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "Updated account_status to ACTIVE")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
suspend_accounts)
echo "ACTION = batch_efs_suspension" | tee -a $resultfile
echo "DETAILS = \"file: $file | Check output for list of blocked MINs\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "not_activated")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
batch_cms_suspension)
echo "ACTION = batch_cms_suspension" | tee -a $resultfile
echo "DETAILS = \"file: $file | Check MIN status using check_cms_status\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "procedure successfully completed.")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
lift_suspended_accounts)
echo "ACTION = lift_suspended_accounts_in_efs" | tee -a $resultfile
echo "DETAILS = \"file: $file | Check output for list of MINs\"" | tee -a $resultfile
x=$(cat $logfile | grep -c "Updated account_status to ACTIVE")
if [ $x -eq 0 ]; then
ERROR=$(cat $logfile | egrep -i "ERROR|INFO|NOTICE")
echo "STATUS = FAILED" | tee -a $resultfile
echo "$ERROR" | tee -a $resultfile
else
echo "STATUS = SUCCESSFUL" | tee -a $resultfile
fi
;;
esac
echo "$(cat $resultfile)" | tee -a $trail
rm $profile