Linux监控脚本
来源:互联网 发布:狙击模拟软件ios 编辑:程序博客网 时间:2024/06/10 22:40
while :doif [ -f "./mon_linux.sh" ]thenecho "进程开始运行"elseexit 1fi#!/bin/bash>result.tmp#set -x#version: 2.0export LC_ALL="en_US.UTF-8" server_info(){echo ================System basic informaion==============================#echo ======Time======#dateecho "hostname" is `/bin/hostname`echo "IP ADDRESS" is `/sbin/ifconfig em1|grep "inet addr:"|awk '{print $2,"/ "$4}' | awk -F ':' '{print $2}' | awk -F '/' '{print $1}' | sed 's/ .*//g'`HOST_NAME=`hostname`#dmidecode | grep -A10 "System Information$" |grep "Product Name:"|awk '{print $3,$4,$5}'##dmidecode | grep -A10 "System Information$" |grep "Serial Number:"|awk '{print "SN:",$3}'echo "CPU INFORMATION" is `cat /proc/cpuinfo|grep "name"|cut -d: -f2 |awk '{print "*"$1,$2,$3,$4}'|uniq -c`#echo "Physical memory number" is `dmidecode | grep -A 16 "Memory Device$" |grep Size:|grep -v "No Module Installed"|awk '{print "*" $2,$3}'|uniq -c`echo "System version" is `cat /etc/issue | head -1`} OS_info(){echo "system running time" is `/usr/bin/uptime |awk '{print $3,$4}'`} performance_info(){echo "================System cpu&&memory information=========================================="cpu_usage=`top -b -n 1 |grep C[Pp][Uu] |grep id|awk '{print $5}'|awk -F "%" '{print $1}'`echo "CPU FREE PERCENT is $cpu_usage"mem_total=$(free -m |grep Mem|awk '{print $2}')mem_used=$(free -m |grep Mem|awk '{print $3}')echo "mem_rate" is `expr $mem_used/$mem_total*100|bc -l`Swap_total=$(free -m |grep Swap|awk '{print $2}')Swap_used=$(free -m |grep Swap|awk '{print $3}')echo "Swap_rate" is `expr $Swap_used/$Swap_total*100|bc -l`echo "================System process information=========================================="i=1ps aux | sort -nr -k3 | awk '{print $3,$NF}' | head -10 | while read A Bdoecho "process $B cpu usage is $A" i=$(($i + 1))donei=1ps aux | sort -nr -k4 |awk '{print $4,$NF}' | head -10 | while read A B doecho "process $B memory use is $A"i=$(($i + 1))done}sec_info(){echo "==============User logon information====================="w | grep -v ^USER | grep -v ^" " | while read Adoecho "user logon information" is $Adoneecho "==============disk information====================="df -h | grep -i -v mount| awk '{print $1,$(NF-1),$NF}' | while read A B C doif [ "$A" = "$C" ]thencontinueelse echo "$C" usage is "$B"fi doneecho "==============dmesg information====================="dmesg |grep fail | sort -u | while read Ado echo "dmesg fail" is $Adonedmesg |grep error | sort -u | while read Ado echo "dmesg error" is $Adone}system_hardware_config(){echo ===========================disk====================================df -H |awk "{OFS=\"\t\"}{ print \$1,\$2,\$3,\$4,\$5,\$6}"echo ===========================free====================================free |head -1 |awk "{OFS=\"\t\"} {print \$1,\$2,\$6}"free -m |awk "BEGIN{OFS=\"\t\"}{if (NR==2 ||NR==4 )print \$2,\$3,\$7}"} server_info>>result.tmpOS_info>>result.tmpperformance_info>>result.tmpsec_info>>result.tmpecho "run Ok"sleep 30done
0 0
- linux iostat监控脚本
- Linux CPU 监控脚本
- linux网络流量监控脚本
- linux监控脚本
- linux流量监控脚本
- linux 流量监控脚本
- Linux监控脚本
- linux 监控keepalived脚本
- linux系统整体监控脚本
- linux 监控服务器常用脚本
- linux网络流量的监控脚本
- linux 下监控端口脚本
- 监控Linux网络流量的脚本
- linux shell脚本-监控进程
- 监控linux机器负载脚本
- Linux 脚本 实现网络流量监控
- linux监控网络流量的脚本
- linux shell脚本监控端口
- 骄傲和大家看哈健康的哈数据库好的借口
- Linux vmstat命令实战详解--vmstat 非常强大的命令
- 杭电ACM 2020绝对值排序----20140728
- #ifdef
- USACO 之 Section 1.1 Ad Hoc Problems
- Linux监控脚本
- Win8.1OS64位oracle11安装配置及PL/SQL Developer如何连接64位oracle
- IOCP接收大并发时出现数据丢失
- OWI之db file scattered read
- 一元三次方程求解
- Easier Done Than Said? 【杭电-1039】 附题
- OC中Foundation框架里常用的结构体和类
- ramfs,tmpfs, rootfs and initramfs
- C考核