首页 > 代码库 > 6-Linux-磁盘网络监控
6-Linux-磁盘网络监控
Linux -监控系统和硬盘分区及网络基础
1. top
1分钟 5分钟 15分钟
ni nice越高优先级越低
选项
-b:以批处理模式操作;
-c:显示完整的治命令;
-d:屏幕刷新间隔时间;
-I:忽略失效过程;
-s:保密模式;
-S:累积模式;
-i<时间>:设置间隔时间;
-u<用户名>:指定用户名;
-p<进程号>:指定进程;
-n<次数>:循环显示的次数。
交互
h:显示帮助画面,给出一些简短的命令总结说明;
k:终止一个进程;
i:忽略闲置和僵死进程,这是一个开关式命令;
q:退出程序;
r:重新安排一个进程的优先级别;
S:切换到累计模式;
s:改变两次刷新之间的延迟时间(单位为s),如果有小数,就换算成ms。输入0值则系统将不断刷新,默认值是5s;
f或者F:从当前显示中添加或者删除项目;
o或者O:改变显示项目的顺序;
l:切换显示平均负载和启动时间信息;
m:切换显示内存信息;
t:切换显示进程和CPU状态信息;
c:切换显示命令名称和完整命令行;
M:根据驻留内存大小进行排序;
P:根据CPU使用百分比大小进行排序;
T:根据时间/累计时间进行排序;
w:将当前设置写入~/.toprc文件中。
2. free
-b:以Byte为单位显示内存使用情况;
-k:以KB为单位显示内存使用情况;
-m:以MB为单位显示内存使用情况;
-o:不显示缓冲区调节列;
-s<间隔秒数>:持续观察内存使用状况;
-t:显示内存总和列;
-V:显示版本信息
第一部分Mem行解释:
total:内存总数;
used:已经使用的内存数;
free:空闲的内存数;
shared:当前已经废弃不用;
buffers Buffer:缓存内存数;
cached Page:缓存内存数。
关系:total = used + free
第二部分(-/+ buffers/cache)解释:
(-buffers/cache) used内存数:第一部分Mem行中的 used – buffers – cached //可以当作buffer和cache用的空间
(+buffers/cache) free内存数: 第一部分Mem行中的 free + buffers + cached
可见-buffers/cache反映的是被程序实实在在吃掉的内存,而+buffers/cache反映的是可以挪用的内存总数。
used=buffer+cached+(-buffer/cache)used
(-buffer/cache)free=free+buffers+cached
echo 3> /proc/sys/vm/drop_caches
uname -a -r
cat /etc/redhat-release
df -h df -i mount
ls /dev/zeo dd if=/dev/zero dd if=/dev/zero (of=/dev/sdc) of=/a.txt bs=1G count=1
xfs 文件系统
ps aux ps aux | head -n 3 ps aux | grep mysql
top & 后台运行
kill -9 pid pkill -9 进程名
查看进程树 pstree ps -elf 显示ppid
3. 硬盘分区
单块盘做raid0,raid级别识别硬盘,不会更改盘符
ls /dev/ad fdisk -l /dev/sda gpt:磁盘标签类型 还有dos
fdisk /dev/add
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition‘s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
--
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p //建立主分区
Partition number (1-4): 1 //分区号
First cylinder (1-391, default 1): //分区起始位置
Using default value 1 last cylinder or +size or +sizeM or +sizeK (1-391, default 391): 100 //分区结束位置,单位为扇区
Command (m for help): n //再建立一个分区
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2 //分区号为2
First cylinder (101-391, default 101):
Using default value 101
Last cylinder or +size or +sizeM or +sizeK (101-391, default 391): +200M //分区结束位置,单位为M
mkfs.sfs /dev/adb1
扩展分区和逻辑分区 一个分区可以挂在载两个路径上,用 mount看
umount -l 强制卸载
mkfs出现错误
[root@bogon ~]# mkfs -t ext4 /dev/sdb2
mke2fs 1.42.9 (28-Dec-2013)
mkfs.ext4: inode_size (128) * inodes_count (0) too big for a
filesystem with 0 blocks, specify higher inode_ratio (-i)
or lower inode count (-N).
查看/dev/sdb2 类型
/dev/sdb2 5001216 41943039 18470912 5 Extended
直接格式化扩展分区是不允许的,只能格式化主分区和逻辑分区;
4. 创建逻辑分区
5. dd 测试速度
bs=<字节数>:将ibs(输入)与欧巴桑(输出)设成指定的字节数;
cbs=<字节数>:转换时,每次只转换指定的字节数;
conv=<关键字>:指定文件转换的方式;
count=<区块数>:仅读取指定的区块数;
ibs=<字节数>:每次读取的字节数;
obs=<字节数>:每次输出的字节数;
of=<文件>:输出到文件;
seek=<区块数>:一开始输出时,跳过指定的区块数;
skip=<区块数>:一开始读取时,跳过指定的区块数;
示例:
[root@localhost text]# dd if=/dev/zero of=sun.txt bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.006107 seconds, 172 MB/s
[root@localhost text]# du -sh sun.txt
1.1M sun.txt
该命令创建了一个1M大小的文件sun.txt,其中参数解释:
- if 代表输入文件。如果不指定if,默认就会从stdin中读取输入。
- of 代表输出文件。如果不指定of,默认就会将stdout作为默认输出
- bs 代表字节为单位的块大小
- count 代表被复制的块数
- /dev/zero 是一个字符设备,会不断返回0值字节(\0)
<style>html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video { margin: 0; padding: 0; border: 0 } body { font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 1.6; color: #333; background-color: #fff; padding: 20px; max-width: 960px; margin: 0 auto } body>*:first-child { margin-top: 0 !important } body>*:last-child { margin-bottom: 0 !important } p,blockquote,ul,ol,dl,table,pre { margin: 15px 0 } h1,h2,h3,h4,h5,h6 { margin: 20px 0 10px; padding: 0; font-weight: bold } h1 tt,h1 code,h2 tt,h2 code,h3 tt,h3 code,h4 tt,h4 code,h5 tt,h5 code,h6 tt,h6 code { font-size: inherit } h1 { font-size: 28px; color: #000 } h2 { font-size: 24px; border-bottom: 1px solid #ccc; color: #000 } h3 { font-size: 18px } h4 { font-size: 16px } h5 { font-size: 14px } h6 { color: #777; font-size: 14px } body>h2:first-child,body>h1:first-child,body>h1:first-child+h2,body>h3:first-child,body>h4:first-child,body>h5:first-child,body>h6:first-child { margin-top: 0; padding-top: 0 } a:first-child h1,a:first-child h2,a:first-child h3,a:first-child h4,a:first-child h5,a:first-child h6 { margin-top: 0; padding-top: 0 } h1+p,h2+p,h3+p,h4+p,h5+p,h6+p { margin-top: 10px } a { color: #4183C4; text-decoration: none } a:hover { text-decoration: underline } ul,ol { padding-left: 30px } ul li>:first-child,ol li>:first-child,ul li ul:first-of-type,ol li ol:first-of-type,ul li ol:first-of-type,ol li ul:first-of-type { margin-top: 0px } ul ul,ul ol,ol ol,ol ul { margin-bottom: 0 } dl { padding: 0 } dl dt { font-size: 14px; font-weight: bold; font-style: italic; padding: 0; margin: 15px 0 5px } dl dt:first-child { padding: 0 } dl dt>:first-child { margin-top: 0px } dl dt>:last-child { margin-bottom: 0px } dl dd { margin: 0 0 15px; padding: 0 15px } dl dd>:first-child { margin-top: 0px } dl dd>:last-child { margin-bottom: 0px } pre,code,tt { font-size: 12px; font-family: Consolas, "Liberation Mono", Courier, monospace } code,tt { margin: 0 0px; padding: 0px 0px; white-space: nowrap; border: 1px solid #eaeaea; background-color: #f8f8f8 } pre>code { margin: 0; padding: 0; white-space: pre; border: none; background: transparent } pre { background-color: #f8f8f8; border: 1px solid #ccc; font-size: 13px; line-height: 19px; overflow: auto; padding: 6px 10px } pre code,pre tt { background-color: transparent; border: none } kbd { background-color: #DDDDDD; background-image: linear-gradient(#F1F1F1, #DDDDDD); background-repeat: repeat-x; border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD; border-style: solid; border-width: 1px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; line-height: 10px; padding: 1px 4px } blockquote { border-left: 4px solid #DDD; padding: 0 15px; color: #777 } blockquote>:first-child { margin-top: 0px } blockquote>:last-child { margin-bottom: 0px } hr { clear: both; margin: 15px 0; height: 0px; overflow: hidden; border: none; background: transparent; border-bottom: 4px solid #ddd; padding: 0 } table th { font-weight: bold } table th,table td { border: 1px solid #ccc; padding: 6px 13px } table tr { border-top: 1px solid #ccc; background-color: #fff } table tr:nth-child(2n) { background-color: #f8f8f8 } img { max-width: 100% }</style>
6-Linux-磁盘网络监控
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。