Professional Documents
Culture Documents
askj
j
.
com.
cn
She
l
l
Hello
Shell
Shell
Shell
Shell
Shell vmstat Oracle
1.1
Shell .
Shell Linux UNIX
.
Linux Linux
UNIX .
1.2
1.2.1
Shell
Shell
Shell
Shell
CPU
""
Shell.
Shell Linux
/bin
Shell df /bin df Shell.
[root@OracleJJ shell]# df
Filesystem
1K-
%
/dev/mapper/VolGroup00-LogVol00
36253304 6905692 27506052 21% /
/dev/hdc1
101086
9091
86776 10% /boot
none
322836
0
322836
0% /dev/shm
/dev/hda10
4248876 3150864
1098012 75% /home/o10g
Shell
Shell
www.askjj.com.cn
1.2.2
Shell
Shell
Shell Shell .
Shell Shell Shell Shell .
1.3
Shell
Shell
1
Shell
Shell Shell
2
Shell Linux Shell
/etc/profile Shell .
Shell Shell
1.4
Shell
"Hello world"
Hello world Hello world
( vi ):
-------hw--------1 #!/bin/bash
2 # Hello world
3 echo Hello world
4 exit 0
------------------------------ chmod x
:
[root@OracleJJ shell]# chmod +x hw
:
[root@OracleJJ shell]# ./hw
Hello world
-2-
Shell
www.askjj.com.cn
/bin/bash*
/bin bash
#!/bin/
#!/bin/bash ksh
Shell
#!/bin/bash
Shell Shell
Shell : #!/bin/ksh
Shell KSH
Shell
2 #
#!/bin/bash
3 echo echo
4 exit 0 Shell 0 Linux
0 0 .
1.1 3 ,
echo Hello world
Shell Linux bash
Shell : 0
-3-
Shell
1.5
www.askjj.com.cn
Shell
Shell Oracle
Shell
shell
r CPU .
b I/O
swpd KB
free KB
buff Buffer KB
cache Cache KB
siKB/s
soKB/s
bi/s
bo/s
in
cs
us CPU
sy CPU
id CPU
wa I/O CPU
vmstat
Oracle vmstat my_os_stat
create table scott.my_os_stat (stat_date dater numberb number
swpd numberfree number
buff numbercache number,
si numberso numberbi numberbo number,
myin numbercs numberus number,
sy numberid numberwa number);
scott vmstat
-4-
Shell
1
2
3
4
5
6
7
8
9
www.askjj.com.cn
EOF
0 581168
12144 30236
1 1001
24 3 0 97
read a1 a2 ...a16
a1a2 read
read
read
;
3 sqlplus scott/password <<EOF Sqlplus
scott password
Scott <<EOF 4 7 Shell
sqlplus 4 7 Sqlplus Oracle 8 EOF
8 Shell
4 5 sysdate,$a1,$a2,$a16 sysdate Oracle
$a1,$a2.. a1 a2 Shell "$"
read $
vi scott
Oracle vmstat 3
vmstat
-5-
Shell
0
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
www.askjj.com.cn
#!/bin/bash
# mystat vmstat my_os_stat
# ./mystat
# 300 5
i=1
k="$1"
j="$2"
if [ -z "$1" ]
then
k=300
fi
if [ -z "$2" ]
then
j=2
fi
while (( i <= j ))
do
vmstat $k 2|sed 1,3d|tr -s " "|{
read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16;
sqlplus scott/password << EOF
insert into my_os_stat values(sysdate,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9,
$a10,$a11,$a12,$a13,$a14,$a15,$a16);
commit;
exit
EOF
# EOF
}
if [ -n "$2" ]
then
let i=i+1
fi
done
1 3 25 #Shell
56 $1
$2
-6-
Shell
www.askjj.com.cn
-7-