-
Notifications
You must be signed in to change notification settings - Fork 3
/
mining_listener_logxml_review_appserver_ip_2.sh
93 lines (82 loc) · 5.97 KB
/
mining_listener_logxml_review_appserver_ip_2.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
#!/bin/bash
# +-----------------------------------------------------------------------+
# | |
# | Quanwen Zhao |
# | |
# | guestart@163.com |
# | |
# | https://quanwenzhao.wordpress.com |
# | |
# |-----------------------------------------------------------------------|
# | |
# | Copyright (c) 2019 Quanwen Zhao. All rights reserved. |
# | |
# |-----------------------------------------------------------------------|
# | |
# | Database : Oracle |
# | |
# | Os env : Linux |
# | |
# | File : mining_listener_logxml_review_appserver_ip_2.sh |
# | |
# | Class : Linux Bash script |
# | |
# | Purpose : This bash script file used to review ip list of |
# | |
# | application server connecting to oracle database |
# | |
# | recently via mining listener log file of xml format. |
# | |
# | |
# | Parameters : None. |
# | |
# | Modified : 05/27/2019 (mm/dd/yyyy) |
# | |
# | Note : As with any code, ensure to test this script in a |
# | |
# | development environment before attempting to run it in |
# | |
# | production. |
# | |
# +-----------------------------------------------------------------------+
#source ~/.bash_profile;
export DATE_TIME=`which date`
#export HOST_NAME=`which hostname`
export DIR_NAME=`which dirname`
#loc_listener_log=$ORACLE_BASE'/diag/tnslsnr/'`${HOST_NAME}`'/listener/alert'
#loc_listener_log=`${DIR_NAME} $(lsnrctl status | awk '/Listener Log File/ {print $NF}')`
listener_name=`lsnrctl show current_listener | grep "Current" | awk '{print $NF}'`
listener_log=`lsnrctl status ${listener_name} | awk '/Listener Log File/ {print $NF}'`
#echo
#echo "========================================================================================"
#echo "# #"
#echo "# Now this Bash shell script will generate mining_logxml_appserver_ip_2_`date +%Y%m%d`.lst #"
#echo "# #"
#echo "# Please patiently waiting for a while ...... #"
#echo "# #"
#echo "========================================================================================"
echo
echo 'Begin time: '$(${DATE_TIME} '+%Y-%m-%d %H:%M:%S')
echo
cat ${listener_log} | grep "HOST=" | grep establish | awk -F'=' '{print $(NF-1)}' | cut -d')' -f1 | sort -n | uniq > ~/odris_linux/report/mining_logxml_appserver_ip_2_`date +%Y%m%d`.lst
# +-----------------------------------------------------------------------+
# | |
# | Total three methods filtering out IP address via grep or egrep. |
# | |
# | 1. grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" |
# | |
# | 2. grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" |
# | |
# | 3. egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}" |
# | |
# +-----------------------------------------------------------------------+
cat ~/odris_linux/report/mining_logxml_appserver_ip_2_`date +%Y%m%d`.lst | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | sort -n | uniq > ~/odris_linux/report/appserver_ip_2_`date +%Y%m%d`.lst
#echo "============================================================================================"
#echo "# #"
#echo "# As you can see, the previous mentioned two files have been listed by following location. #"
#echo "# #"
#echo "============================================================================================"
#echo
cat ~/odris_linux/report/appserver_ip_2_`date +%Y%m%d`.lst
echo
echo 'End time: '$(${DATE_TIME} '+%Y-%m-%d %H:%M:%S')