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

通过grafana面板展示各home存储的空间使用率及文件数使用率

时间:2018-10-16 10:59:34      阅读:445      评论:0      收藏:0      [点我收藏+]

标签:xxxxx   mina   load   rom   local   char   ase   空间使用率   int   

shell脚本抓取各home存储的空间使用率及文件数使用率,写道excel文件里,再写到mysql里,最后通过grafana面板展示

vi aa.sh

#!/bin/bash

Date=date +"%Y-%m-%d %H:%M:%S"

Dir=/logs/Homes

Home1=df -h /home1 | tail -n 1 | awk -F[:" "]+ ‘{print $5}‘ | tr -d "%"
Homei1=df -i /home1 | tail -n 1 | awk -F[:" "]+ ‘{print $5}‘| tr -d "%"
Home2=df -h /home2 | tail -n 1 | awk -F[:" "]+ ‘{print $5}‘ | tr -d "%"
Homei2=df -i /home2 | tail -n 1 | awk -F[:" "]+ ‘{print $5}‘ | tr -d "%"
/bin/echo "$Date,home1,$Home1,$Homei1" > $Dir/Homeavg.txt
/bin/echo "$Date,home2,$Home2,$Homei2" >> $Dir/Homeavg.txt

/bin/cat $Dir/Homeavg.txt | tr -s ‘[:blank:]‘ > $Dir/Homeavg.csv

/usr/bin/mysql -h 10.0.0.2 -u icinga2 -p‘xxxxxx‘ --local-infile=1 jenkins_log2 -e "LOAD DATA LOCAL INFILE ‘/logs/Homes/Homeavg.csv‘ INTO TABLE homesavg FIELDS TERMINATED BY ‘,‘"

:wq

mysql -u root -p‘xxx‘

create database ming default character set utf8;
create table homesavg(time datetime,home char(50),homeavg float,homeiavg float);
grant all on ming.* to aa@‘localhost‘ identified by ‘xxxx‘;
exit

grafana配mysql略

查询空间使用率:

select UNIX_TIMESTAMP(Time) as time, homeavg as "home1" from homesavg where home="home1";

查询文件数使用率:

select UNIX_TIMESTAMP(Time) as time, homeiavg as "home1" from homesavg where home="home1";

通过grafana面板展示各home存储的空间使用率及文件数使用率

标签:xxxxx   mina   load   rom   local   char   ase   空间使用率   int   

原文地址:http://blog.51cto.com/yangzhiming/2300389

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