几个常见的LINUX监控脚本.docx
《几个常见的LINUX监控脚本.docx》由会员分享,可在线阅读,更多相关《几个常见的LINUX监控脚本.docx(5页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、最近时不时有互联网的朋友问我关于服务器监控方面的问题,问常用的服务器监控除了用开源软件,比如:cacti,nagios监控外是否可以自己写shell脚本呢?根据自己的需求写出的shell脚本更能满足需求,更能细化主机监控的全面性。下面是我常用的几个主机监控的脚本,大家可以根据自己的情况再进行修改,希望能给大家一点帮助。1、查看主机网卡流量#!/bin/bash#network#Mike.Xuwhile : ; do time=date +%m-%d %k:%M day=date +%m-%d rx_before=ifconfig eth0|sed -n 8p|awk print $2|cut
2、-c7- tx_before=ifconfig eth0|sed -n 8p|awk print $6|cut -c7- sleep 2 rx_after=ifconfig eth0|sed -n 8p|awk print $2|cut -c7- tx_after=ifconfig eth0|sed -n 8p|awk print $6|cut -c7- rx_result=$(rx_after-rx_before)/256 tx_result=$(tx_after-tx_before)/256 echo $time Now_In_Speed: $rx_resultkbps Now_OUt_S
3、peed: $tx_resultkbps sleep 2done2、系统状况监控#!/bin/sh#systemstat.sh#Mike.XuIP=192.168.1.227top -n 2| grep Cpu ./temp/cpu.txtfree -m | grep Mem ./temp/mem.txtdf -k | grep sda1 ./temp/drive_sda1.txt#df -k | grep sda2 ./temp/drive_sda2.txtdf -k | grep /mnt/storage_0 ./temp/mnt_storage_0.txtdf -k | grep /mn
4、t/storage_pic ./temp/mnt_storage_pic.txttime=date +%m.%d %k:%Mconnect=netstat -na | grep 219.238.148.30:80 | wc -lecho $time $connect ./temp/connect_count.txt3、监控主机的磁盘空间,当使用空间超过90就通过发mail来发警告#!/bin/bash#monitor available disk spaceSPACE=df | sed -n / / $ / p | gawk print $5 | sed s/%/if $SPACE -ge 9
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 几个 常见 LINUX 监控 脚本
限制150内