Linux常用的系统监控shell脚本.pdf

Linux常用的系统监控shell脚本.pdf

ID:52243656

大小:84.25 KB

页数:4页

时间:2020-03-25

Linux常用的系统监控shell脚本.pdf_第1页
Linux常用的系统监控shell脚本.pdf_第2页
Linux常用的系统监控shell脚本.pdf_第3页
Linux常用的系统监控shell脚本.pdf_第4页
资源描述:

《Linux常用的系统监控shell脚本.pdf》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、Linux常用的系统监控shell脚本QQ:571119822monkeyliang1、查看主机网卡流量#!/bin/bash#network#Mike.Xuwhile:;dotime=’date+%m”-”%d”“%k”:”%M’day=’date+%m”-”%d’rx_before=’ifconfigeth0

2、sed-n“8″p

3、awk‘{print$2}’

4、cut-c7-’tx_before=’ifconfigeth0

5、sed-n“8″p

6、awk‘{print$6}’

7、cut-c7-’sleep2rx_after=’ifconfigeth0

8、

9、sed-n“8″p

10、awk‘{print$2}’

11、cut-c7-’tx_after=’ifconfigeth0

12、sed-n“8″p

13、awk‘{print$6}’

14、cut-c7-’rx_result=$[(rx_after-rx_before)/256]tx_result=$[(tx_after-tx_before)/256]echo“$timeNow_In_Speed:“$rx_result”kbpsNow_OUt_Speed:“$tx_result”kbps”sleep2done2、系统状况监控#!/bin/sh#systemstat.sh#

15、Mike.XuIP=192.168.1.227top-n2

16、grep“Cpu”>>./temp/cpu.txtfree-m

17、grep“Mem”>>./temp/mem.txtdf-k

18、grep“sda1″>>./temp/drive_sda1.txt#df-k

19、grepsda2>>./temp/drive_sda2.txtdf-k

20、grep“/mnt/storage_0″>>./temp/mnt_storage_0.txtdf-k

21、grep“/mnt/storage_pic”>>./temp/mnt_storage_pic.txttime=`da

22、te+%m”.”%d”“%k”:”%M`connect=`netstat-na

23、grep“219.238.148.30:80″

24、wc-l`echo“$time$connect”>>./temp/connect_count.txt3、监控主机的磁盘空间,当使用空间超过90%就通过发mail来发警告#!/bin/bash#monitoravailablediskspaceSPACE=’df

25、sed-n‘//$/p’

26、gawk‘{print$5}’

27、sed’s/%//’if[$SPACE-ge90]thenfty89@163.comfi4、监控CPU和

28、内存的使用情况#!/bin/bash#scripttocapturesystemstatisticsOUTFILE=/home/xu/capstats.csvDATE=’date+%m/%d/%Y’TIME=’date+%k:%m:%s’TIMEOUT=’uptime’VMOUT=’vmstat12′USERS=’echo$TIMEOUT

29、gawk‘{print$4}’‘LOAD=’echo$TIMEOUT

30、gawk‘{print$9}’

31、sed“s/,//’‘FREE=’echo$VMOUT

32、sed-n‘/[0-9]/p’

33、sed-n’2p’

34、

35、gawk‘{print$4}‘‘IDLE=’echo$VMOUT

36、sed-n‘/[0-9]/p’

37、sed-n’2p’

38、gawk‘{print$15}’‘echo“$DATE,$TIME,$USERS,$LOAD,$FREE,$IDLE”>>$OUTFILE5、全方位监控主机#!/bin/bash#check_xu.sh#0****/home/check_xu.shDAT=”`date+%Y%m%d`”HOUR=”`date+%H`”DIR=”/home/oslog/host_${DAT}/${HOUR}”DELAY=60COUNT=60#whet

39、hertheresponsibledirectoryexistif!test-d${DIR}then/bin/mkdir-p${DIR}fi#generalcheckexportTERM=linux/usr/bin/top-b-d${DELAY}-n${COUNT}>${DIR}/top_${DAT}.log2>&1&#cpucheck/usr/bin/sar-u${DELAY}${COUNT}>${DIR}/cpu_${DAT}.log2>&1&#/usr/bin/mpstat-P0${DELAY}${COUNT}>${DIR}/cpu_0_$

40、{DAT}.log2>&1&#/usr/bin/mpstat-P1${DELAY}${COUNT}>${DIR}/cpu_1_${DAT

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。