开源项目

https://github.com/atarallo/TECMINT_MONITOR

#! /bin/bash
# unset any variable which system may be usingunset tecreset os architecture kernelrelease internalip externalip nameserver loadaveragewhile getopts iv name
docase $name ini)iopt=1;;v)vopt=1;;*)echo "Invalid arg";;esac
doneif [[ ! -z $iopt ]]
then
{
wd=$(pwd)
basename "$(test -L "$0" && readlink "$0" || echo "$0")" > /tmp/scriptname
scriptname=$(echo -e -n $wd/ && cat /tmp/scriptname)
su -c "cp $scriptname /usr/bin/monitor" root && echo "Congratulations! Script Installed, now run monitor Command" || echo "Installation failed"
}
fiif [[ ! -z $vopt ]]
then
{
echo -e "tecmint_monitor version 0.1\nDesigned by Tecmint.com\nReleased Under Apache 2.0 License"
}
fiif [[ $# -eq 0 ]]
then
{# Define Variable tecreset
tecreset=$(tput sgr0)# Check if connected to Internet or not
ping -c 1 google.com &> /dev/null && echo -e '\E[32m'"Internet: $tecreset Connected" || echo -e '\E[32m'"Internet: $tecreset Disconnected"# Check OS Type
os=$(uname -o)
echo -e '\E[32m'"Operating System Type :" $tecreset $os# Check OS Release Version and Name
###################################
OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`GetVersionFromFile()
{VERSION=`cat $1 | tr "\n" ' ' | sed s/.*VERSION.*=\ // `
}if [ "${OS}" = "SunOS" ] ; thenOS=SolarisARCH=`uname -p`OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
elif [ "${OS}" = "AIX" ] ; thenOSSTR="${OS} `oslevel` (`oslevel -r`)"
elif [ "${OS}" = "Linux" ] ; thenKERNEL=`uname -r`if [ -f /etc/redhat-release ] ; thenDIST='RedHat'PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`elif [ -f /etc/SuSE-release ] ; thenDIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`elif [ -f /etc/mandrake-release ] ; thenDIST='Mandrake'PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`elif [ -f /etc/os-release ]; thenDIST=`awk -F "PRETTY_NAME=" '{print $2}' /etc/os-release | tr -d '\n"'`elif [ -f /etc/debian_version ] ; thenDIST="Debian `cat /etc/debian_version`"REV=""fiif ${OSSTR} [ -f /etc/UnitedLinux-release ] ; thenDIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"fiOSSTR="${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})"fi##################################
#cat /etc/os-release | grep 'NAME\|VERSION' | grep -v 'VERSION_ID' | grep -v 'PRETTY_NAME' > /tmp/osrelease
#echo -n -e '\E[32m'"OS Name :" $tecreset  && cat /tmp/osrelease | grep -v "VERSION" | grep -v CPE_NAME | cut -f2 -d\"
#echo -n -e '\E[32m'"OS Version :" $tecreset && cat /tmp/osrelease | grep -v "NAME" | grep -v CT_VERSION | cut -f2 -d\"
echo -e '\E[32m'"OS Version :" $tecreset $OSSTR
# Check Architecture
architecture=$(uname -m)
echo -e '\E[32m'"Architecture :" $tecreset $architecture# Check Kernel Release
kernelrelease=$(uname -r)
echo -e '\E[32m'"Kernel Release :" $tecreset $kernelrelease# Check hostname
echo -e '\E[32m'"Hostname :" $tecreset $HOSTNAME# Check Internal IP
internalip=$(hostname -I)
echo -e '\E[32m'"Internal IP :" $tecreset $internalip# Check External IP
externalip=$(curl -s ipecho.net/plain;echo)
echo -e '\E[32m'"External IP : $tecreset "$externalip# Check DNS
nameservers=$(cat /etc/resolv.conf | sed '1 d' | awk '{print $2}')
echo -e '\E[32m'"Name Servers :" $tecreset $nameservers # Check Logged In Users
who>/tmp/who
echo -e '\E[32m'"Logged In users :" $tecreset && cat /tmp/who # Check RAM and SWAP Usages
free -h | grep -v + > /tmp/ramcache
echo -e '\E[32m'"Ram Usages :" $tecreset
cat /tmp/ramcache | grep -v "Swap"
echo -e '\E[32m'"Swap Usages :" $tecreset
cat /tmp/ramcache | grep -v "Mem"# Check Disk Usages
df -h| grep 'Filesystem\|/dev/sda*' > /tmp/diskusage
echo -e '\E[32m'"Disk Usages :" $tecreset
cat /tmp/diskusage# Check Load Average
loadaverage=$(top -n 1 -b | grep "load average:" | awk '{print $10 $11 $12}')
echo -e '\E[32m'"Load Average :" $tecreset $loadaverage# Check System Uptime
tecuptime=$(uptime | awk '{print $3,$4}' | cut -f1 -d,)
echo -e '\E[32m'"System Uptime Days/(HH:MM) :" $tecreset $tecuptime# Unset Variables
unset tecreset os architecture kernelrelease internalip externalip nameserver loadaverage# Remove Temporary Files
rm /tmp/who /tmp/ramcache /tmp/diskusage
}
fi
shift $(($OPTIND -1))

Linux系统监控shell脚本相关推荐

  1. Linux系统通过Shell脚本实现一个全方面的系统性能分析系统

    Linux系统通过Shell脚本实现一个全方面的系统性能分析系统 文章目录 Linux系统通过Shell脚本实现一个全方面的系统性能分析系统 1.利用select循环实现系统工具箱 2.命令技巧 3. ...

  2. linux代码实现进程监控,linux进程监控shell脚本代码

    为确保php页面在后台运行,写了一个监控脚本,假设程序异常退出,那么可以自动重启. shell脚本/usr/local/scripts/receve.sh内容: #!/bin/bash #funtio ...

  3. linux系统中shell脚本最全详解二shell条件判断语法介绍函数分析

    目录 一.shell判断句 1.if条件判断语句 2.test判断 二.语法介绍 1.shell运算符 2.shell循环语句 三.shell函数 一.shell判断句 1.if条件判断语句 if语法 ...

  4. Linux系统巡检shell脚本

    #!/bin/bash #主机信息每日巡检IPADDR=$(ifconfig eth0|grep 'inet addr'|awk -F '[ :]' '{print $13}') #环境变量PATH没 ...

  5. linux shell用户,Linux 系统 利用shell脚本获取所有用户

    # useradd –d /usr/sam -m sam 此命令创建了一个sam,其中-d和-m选项用来为登录名sam产生一个主目录/usr/sam(/usr为默认的主目录所在的父目录). # use ...

  6. linux自动巡检截图,Linux系统巡检shell脚本

    #!/bin/bash #主机信息每日巡检 IPADDR=$(ifconfig eth0|grep 'inet addr'|awk -F '[ :]' '{print $13}') #环境变量PATH ...

  7. linux 监控mysql脚本_Linux系统MySQL主从同步监控shell脚本

    操作系统:CentOS系统 目的:定时监控MySQL数据库主从是否同步,如果不同步,记录故障时间,并执行命令使主从恢复同步状态 1.创建脚本文件 vi /home/crontab/check_mysq ...

  8. LINUX下的流量监控shell脚本

    这篇文章主要介绍了LINUX下的流量监控shell脚本,可以适用任何Linux版本,需要的朋友可以参考下 一.脚本源码 # vi /etc/rc.d/traffic_monitor.sh ------ ...

  9. linux 程序返回值 139,Linux系统监控之ssh登陆自动139邮件短信提醒

    linux系统监控之ssh登陆自动139邮件短信提醒 Linux系统监控非常重要,互联网的网络的安全是一个非常重要的问题,很多时候,我们会出于安全考虑,希望服务器在有用户通过ssh登陆时能自动向管理员 ...

最新文章

  1. SAP CAR 的主要优势
  2. 十几年后我才知道,嫁了一个硬核老公
  3. DayDayUp:《机器崛起前传》第二十二章【蹒跚而来】读后感(文章源自网络)—听课笔记
  4. 计算机网络【wireshark抓包分析】
  5. Vscode如何新建html文件
  6. pandas 第一行_Pandas数据预处理相关经验
  7. 用Python一次性把论文作图与数据处理全部搞定!
  8. 2022年1月国产数据库排行榜:TiDB霸榜两年势头不减,openGauss与OceanBase分数大涨...
  9. (44)System Verilog数组逻辑运算
  10. jquery 左右移动 以及使用layer.js弹出框呈现在页面上
  11. WPF管理系统自定义分页控件 - WPF特工队内部资料
  12. 洛谷OJ - P1156 - 垃圾陷阱
  13. python第一周练习 货币转换
  14. 微信小程序商城毕业设计毕设作品(5)开题报告答辩PPT
  15. Silverlight 2.5D RPG游戏技巧与特效处理:(二)纸娃娃系统
  16. Matlab中统计灰度值出现的次数
  17. 如何 拆 贴片电容 而不是把焊盘给搞坏
  18. Excel拆分字符判断是否有汉字
  19. 三键调光调色带定时遥控台灯方案-DLT8T10S-杰力科创
  20. 【转帖】暴雪CEO谈魔兽开发:研发团队要对项目有激情

热门文章

  1. 2018.2.28(延迟加载和缓存)
  2. maven 配置 pom.xml 打包生成:单jar包/jar包+lib目录
  3. easyUI validate函数【总结篇-部分转】
  4. 逗牙搞笑网www.idouya.xin
  5. Fedora 20 配置
  6. java如何找重复数字_Java如何找出数组中重复的数字
  7. argb888与rgb888转换程序_一文了解各平台RGB565和RGB888区别
  8. 山东专升本access知识点_全国各省份每年的专升本考试大纲啥时候公布?考纲公布之前你该做什么?...
  9. html iframe post,使用Jquery和IFrame的跨子域请求(GET,POST,…)
  10. java semaphore 等待_Java并发编程系列之Semaphore详解