1 Star 0 Fork 111

chenjs/MySQLMTOP

forked from 茹憶/MySQLMTOP 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
check_linux_resource.sh 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
ruzuojun 提交于 2017-07-28 15:36 . 代码目录结构重新调整和优化
#!/bin/bash
host=""
port=""
user=""
password=""
dbname=""
ip=$1
kernel=`snmpwalk -v1 -c mysqlmtop ${ip} SNMPv2-MIB::sysDescr.0|awk '{print $4 " " $6 " " $15}'`
hostname=`/usr/bin/snmpwalk -v1 -c mysqlmtop ${ip} SNMPv2-MIB::sysName.0|awk '{print $NF}'`
load1=`/usr/bin/snmpwalk -v1 -c mysqlmtop ${ip} UCD-SNMP-MIB::laLoad.1|awk '{print $NF}'`
load2=`/usr/bin/snmpwalk -v1 -c mysqlmtop ${ip} UCD-SNMP-MIB::laLoad.2|awk '{print $NF}'`
load3=`/usr/bin/snmpwalk -v1 -c mysqlmtop ${ip} UCD-SNMP-MIB::laLoad.3|awk '{print $NF}'`
root=`/usr/bin/snmpdf -v1 -c mysqlmtop ${ip} |grep -w "/"|awk '{print $NF}'`
data=`/usr/bin/snmpdf -v1 -c mysqlmtop ${ip} |grep -w "data"|awk '{print $NF}'`
home=`/usr/bin/snmpdf -v1 -c mysqlmtop ${ip} |grep -w "home"|awk '{print $NF}'`
totalmem=`/usr/bin/snmpdf -v1 -c mysqlmtop ${ip} |grep "Physical"|awk '{print $3}'`
usedmem=`/usr/bin/snmpdf -v1 -c mysqlmtop ${ip} |grep "Physical"|awk '{print $4}'`
mysqlconn="mysql -h${host} -P${port} -u${user} -p${password}"
$mysqlconn -N -e "insert into $dbname.linux_resource(ip,hostname,kernel,load1,load5,load15,disk_use_root,disk_use_home,disk_use_data,mem_total,mem_use) values('${ip}','${hostname}','${kernel}','${load1}','${load2}','${load3}','${root}','${home}','${data}','${totalmem}','${usedmem}')"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/chenjs50224274/MySQLMTOP.git
git@gitee.com:chenjs50224274/MySQLMTOP.git
chenjs50224274
MySQLMTOP
MySQLMTOP
master

搜索帮助