码迷,mamicode.com
首页 > 其他好文 > 详细

监控体系准备工作

时间:2016-10-09 13:56:19      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

用脚本获取:操作系统类型 操作系统名称 操作系统版本 架构 内核版本 主机名 内部IP 外部IP 域名服务器 已登录用户 内存使用率 交换分区使用率 磁盘使用率 cpu平均负载 系统开机时间

#! /bin/bash
# Check OS Type
os=$(uname -o)
echo -e $os

# Check OS Release Version and Name
cat /etc/os-release | grep NAME\|VERSION | grep -v VERSION_ID | grep -v PRETTY_NAME > /tmp/osrelease
cat /tmp/osrelease | grep -v "VERSION" | cut -f2 -d\"
cat /tmp/osrelease | grep -v "NAME" | cut -f2 -d\"

# Check Architecture
architecture=$(uname -m)
echo -e $architecture

# Check Kernel Release
kernelrelease=$(uname -r)
echo -e $kernelrelease

# Check hostname
echo -e $HOSTNAME

# Check Internal IP
internalip=$(hostname -I)
echo -e $internalip

# Check External IP
externalip=$(curl -s ipecho.net/plain;echo)
echo -e $externalip

# Check DNS
nameservers=$(cat /etc/resolv.conf | sed 1 d | awk {print $2})
echo -e $nameservers 

# Check Logged In Users
who>/tmp/who
echo -e && cat /tmp/who 

# Check RAM and SWAP Usages
free -h | grep -v + > /tmp/ramcachecat /tmp/ramcache | grep -v "Swap"
cat /tmp/ramcache | grep -v "Mem"

# Check Disk Usages
df -h | grep ‘/dev/‘

# Check Load Average
loadaverage=$(top -n 1 -b | grep "load average:" | awk -F ‘,‘ ‘{print $4 $5 $6}‘)
echo -e $loadaverage

# Check System Uptime
tecuptime=$(uptime | awk {print $3,$4} | cut -f1 -d,)
echo -e $tecuptime

# Unset Variables
unset tecreset os architecture kernelrelease internalip externalip nameserver loadaverage

# Remove Temporary Files
rm /tmp/osrelease /tmp/who /tmp/ramcache /tmp/diskusage

 

监控体系准备工作

标签:

原文地址:http://www.cnblogs.com/ylqh/p/5941475.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!