-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckinfo.sh
More file actions
executable file
·147 lines (114 loc) · 3.16 KB
/
Copy pathcheckinfo.sh
File metadata and controls
executable file
·147 lines (114 loc) · 3.16 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
#!/bin/bash
### Check file content
nl #line number
less
### CPU Usage
ps aux
top
### CPU Spec
lscpu
cat /proc/cpuinfo
### Memory Usage
free
free -h
cat /proc/meminfo
### Disk Usage
df #disk
du #directory
### Contents of directories in tree structure
tree
tree -I "*.class" #not showing "*.class" files
### Block Device
lsblk
### Architecture
uname -m
### Kernel version
uname -r
### Distribution version (Ubuntu)
cat /etc/lsb-release
### Hardware information
lshw -short
hwinfo --short
### Different interfaces
lspci
lsscsi
lsusb
### Mounted file system
mount | column -t
#---------------------------------------------------
################
#Check disk IO
################
iostat -x 1
################
#Check disk IO (need to install, more readable)
################
nmon
################
# Check IO
################
blktrace -d $DEV
blkparse -i $DEV.blktrace.* > $OUTPUT
# Ex. Trace the IO onto /dev/sda
# blkparse -i /dev/sda ; blkparse -i sda.blktrace.* > out.log
################
# Check System call
################
strace -p $TARGET_PID
# Ex. Trace the syscall called by mysqld
# shell> ps aux | grep mysql[d] | awk '{print $2}' | xargs -i sudo strace -ttt -yp {} -f
# - grep mysql[d]: grep mysql but ignore grep command itself
# - xargs -i {} : direct the output to {} to be an argument of the next command
# - strace -f : see not only the parent process but also the child processes
################
# Check Memory Usage of a process
################
ps aux
# Ex. Show memory usage of SQLite every 0.05 seconds
# shell> ps aux | grep USE[R] ; while sleep 0.05; do ps aux | grep -v vi | grep sqlit[e]; done
# - grep USE[R] : print out the first row
# - use while and sleep to achieve every 0.05 seconds
# - grep -v vi : not show vi (might be process the sqlite related file)
# - column of RSS should be the memory size allocated to the process <- This one
# - column of VSZ is the virtual memory size (this includes the memory size which is swapped out and from shared libraries)
################
# Check inode
################
# Directory entry
# - file name1 --> inode of file1 --> data of file1
# - file name2 --> inode of file2 --> data of file2
#
# 1. Check directory entry: ls <-i>
# 2. Check inode of a file: stat [filename]
# 3. Check data of a file : cat [filename]
################
# Shared file (link)
################
# 1. Hard link
# 2. Symbolic link
# Create a file
touch abc.file
# Create a hard link of the file
ln abc.file abc.hard
# Create a symbolic link of the file
ln -s abc.file abc.symbolic
# Check inode of the three files
ls -i
# [Hard link]
# We can see original file and hard link have the same inode
# We need to delete both to really delete the data
#
# Directory entry
# - file name
# |
# --> inode of file
# |
# - hard link name
#
# [Symbolic link]
# Symbolic link is a file which stored the path it refers to.
# So deleting symbolic link will not touch the file,
# but deleting the file will really delete the file.
#
# - symbolic link name --> inode of symbolic link --> data of symbolic link [file name]
# - file name --> inode of file --> data of file