1
| time: 2013 5 13 4:30 ~ 5:30
|
1
2
3
4
5
6
7
8
9
10
11
| main()
{
1.tcp/ip 七层协议
2.tcp/ip 三次握手
3.tcp/ip 状态
4.个人的一些情况
5.deal access.log with shell(awk,sed,re)
6.个人项目
7.一些OS的问题
.........
}
|
(mdk1.sh) download
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
| #!/bin/bash -
#===============================================================================
#
# FILE: mdk1.sh
#
# USAGE: ./mdk1.sh
#
# DESCRIPTION: the total process apache or nginx
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: mengdaikun (),
# ORGANIZATION:
# CREATED: 2013Äê05ÔÂ18ÈÕ 13ʱ22·Ö00Ãë CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
# for httpd
total1=`ps aux | grep httpd | grep -v grep | wc -l`
#for apache
total2=`ps aux | grep apache | grep -v grep | wc -l`
#for nginx
total3=`ps aux | grep nginx | grep -v grep | wc -l`
echo "the total process is : httpd:$total1 apache : $total2 nginx : $total3"
|
(mdk2.sh) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| #!/bin/bash -
#===============================================================================
#
# FILE: mdk2.sh
#
# USAGE: ./mdk2.sh
#
# DESCRIPTION: check total in tcp port 80
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: mengdaikun (),
# ORGANIZATION:
# CREATED: 2013Äê05ÔÂ18ÈÕ 13ʱ32·Ö42Ãë CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
total=`netstat -tan | grep "ESTABLISHED" | grep ":80" | wc -l`
echo "the total connect in tcp port 80 have $total"
|
(mdk3.sh) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| #!/bin/bash -
#===============================================================================
#
# FILE: mdk3.sh
#
# USAGE: ./mdk3.sh
#
# DESCRIPTION: total the ip address
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: mengdaikun (),
# ORGANIZATION:
# CREATED: 2013Äê05ÔÂ18ÈÕ 13ʱ41·Ö24Ãë CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
echo "the total ipddress is:"
cat access.log | awk '{print $1}' | sort | uniq -c | sort -nr
|
(mdk4.sh) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| #!/bin/bash -
#===============================================================================
#
# FILE: mdk4.sh
#
# USAGE: ./mdk4.sh
#
# DESCRIPTION: view the url page
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: mengdaikun (),
# ORGANIZATION:
# CREATED: 2013Äê05ÔÂ18ÈÕ 13ʱ44·Ö32Ãë CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
echo "the view page:"
cat access.log | awk '{print $8}' | sort | uniq -c | sort -nr | head -n 20
|
(mdk5.sh) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| #!/bin/bash -
#===============================================================================
#
# FILE: mdk5.sh
#
# USAGE: ./mdk5.sh
#
# DESCRIPTION: tcpdump
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: mengdaikun (),
# ORGANIZATION:
# CREATED: 2013Äê05ÔÂ18ÈÕ 13ʱ48·Ö15Ãë CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
echo "the port 80 in tcpdump"
tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F . '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -rn | head -n 20
|
(mdk6.sh) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| #!/bin/bash -
#===============================================================================
#
# FILE: mdk6.sh
#
# USAGE: ./mdk6.sh
#
# DESCRIPTION: up address view page
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: mengdaikun (),
# ORGANIZATION:
# CREATED: 2013Äê05ÔÂ18ÈÕ 13ʱ54·Ö58Ãë CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
awk '{++s[$1]} END {for ( i in s) print i,s[i]}' access.log
|
(mdk7.sh) download
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
| #!/bin/bash -
#===============================================================================
#
# FILE: mdk7.sh
#
# USAGE: ./mdk7.sh
#
# DESCRIPTION:
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: mengdaikun (),
# ORGANIZATION:
# CREATED: 2013Äê05ÔÂ18ÈÕ 15ʱ02·Ö06Ãë CST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
sleep 10&
id=$!
char=("-" "/" "|" "\\")
n=0
while ps aux | grep "^[[:space:]]*id" > /dev/null
do
echo -ne "\rwaiting...${char[$n]}"
n=$(( (n+1)%4 ))
sleep 1
done
echo OK.
|
总结完毕 ^_^