自动化运维之 php + mysql + shell 监控
yum -y install bc sysstat
安装 mysql 用于连接 mysql 将信息写入数据库
建立mysql数据库 库名为自己定义的名字 create database jicki_monitor;
数据表有10个 分别是cpu、disk、hardware、io、load、memory、message、service、user、device。
使用 脚本来创建 数据表 vi create_database.sh
原文 SQL 语句中 partition 为一个字段 Mysql 5.6中partition 为分区语句故改成partitions
-----------------------------------------------------------------------------------------
#!/bin/bash
#mysql info
mysql_ip='xxx.xxx.xxx.xxx'
##数据库的ip
mysql_username='root'
##数据库的登录用户
mysql_passwd='****'
##数据库的登录密码
mysql_database='jicki_monitor'
##需要登录的数据库
here='HK'
##创建数据库的省份名称
memory_table=''$here'_memory'
load_table=''$here'_load'
io_table=''$here'_io'
hardware_table=''$here'_hardware'
message_table=''$here'_message'
user_table=''$here'_user'
disk_table=''$here'_disk'
cpu_table=''$here'_cpu'
service_table=''$here'_service'
##创建数据库的表名
#create table memory
mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "create table $memory_table(id int(10) not null primary key auto_increment,province varchar(30) not null,server varchar(30) not null,ip varchar(20) not null,monitor_server varchar(30) not null,service varchar(20) not null,alert int(10) not null,value int(10) not null,status varchar(10) not null,date datetime)ENGINE=InnoDB DEFAULT CHARSET=utf8;"
#create table load
mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "create table $load_table(id int(10) not null primary key auto_increment,province varchar(30) not null,server varchar(30) not null,ip varchar(20) not null,monitor_server varchar(30) not null,service varchar(20) not null,alert int(10) not null,value int(10) not null,status varchar(10) not null,date datetime)ENGINE=InnoDB DEFAULT CHARSET=utf8;"
#create table io
mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "create table $io_table(id int(10) not null primary key auto_increment,province varchar(30) not null,server varchar(30) not null,ip varchar(20) not null,monitor_server varchar(30) not null,service varchar(20) not null,alert int(10) not null,value int(10) not null,status varchar(10) not null,date datetime)ENGINE=InnoDB DEFAULT CHARSET=utf8;"
#create table hardware
mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "create table $hardware_table(id int(10) not null primary key auto_increment,province varchar(30) not null,server varchar(30) not null,ip varchar(20) not null,monitor_server varchar(30) not null,service varchar(20) not null,alert int(10) not null,value int(10) not null,status varchar(10) not null,date datetime)ENGINE=InnoDB DEFAULT CHARSET=utf8;"
#create table message
mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "create table $message_table(id int(10) not null primary key auto_increment,province varchar(30) not null,server varchar(30) not null,ip varchar(20) not null,monitor_server varchar(30) not null,service varchar(20) not null,alert int(10) not null,value int(10) not null,status varchar(10) not null,date datetime)ENGINE=InnoDB DEFAULT CHARSET=utf8;"
#create table user
mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "create table $user_table(id int(10) not null primary key auto_increment,province varchar(30) not null,server varchar(30) not null,ip varchar(20) not null,monitor_server varchar(30) not null,service varchar(20) not null,alert int(10) not null,value int(10) not null,status varchar(10) not null,date datetime)ENGINE=InnoDB DEFAULT CHARSET=utf8;"
#create table disk
mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "create table $disk_table(id int(10) not null primary key auto_increment,province varchar(30) not null,server varchar(30) not null,ip varchar(20) not null,monitor_server varchar(30) not null,service varchar(20) not null,alert int(10) not null,partitions varchar(30) not null,value int(10) not null,status varchar(10) not null,date datetime)ENGINE=InnoDB DEFAULT CHARSET=utf8;"
#create table cpu
mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "create table $cpu_table(id int(10) not null primary key auto_increment,province varchar(30) not null,server varchar(30) not null,ip varchar(20) not null,monitor_server varchar(30) not null,service varchar(20) not null,alert int(10) not null,value int(10) not null,status varchar(10) not null,date datetime)ENGINE=InnoDB DEFAULT CHARSET=utf8;"
#create table service
mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "create table $service_table(id int(10) not null primary key auto_increment,province varchar(30) not null,server varchar(30) not null,ip varchar(20) not null,monitor_server varchar(30) not null,service varchar(20) not null,status varchar(10) not null,date datetime)ENGINE=InnoDB DEFAULT CHARSET=utf8;"
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
服务器监控脚本
#!/bin/bash
#ip
web_ip=$(/sbin/ifconfig eth0|grep "inet addr"|cut -d : -f 2|awk '{print $1}')
##eth0网卡的ip
#name
web_name=$(hostname)
##web主机名
monitor_name=负载均衡
##监控的服务器是什么类型
here='HK'
##监控的省份
#mysql info
mysql_ip='xxx.xxx.xxx.xx'
##数据库的ip
mysql_username='root'
##数据库的用户
mysql_passwd='*****'
#数据库的密码
mysql_database='jicki_monitor'
##选择的数据库
memory_table=''$here'_memory'
load_table=''$here'_load'
io_table=''$here'_io'
hardware_table=''$here'_hardware'
message_table=''$here'_message'
user_table=''$here'_user'
disk_table=''$here'_disk'
cpu_table=''$here'_cpu'
service_table=''$here'_service'
##想数据库里写入的表
#date and log
day="$(date +%Y%m%d)"
worklog='/opt/local/monitor/logs/all_work_log'
downlog='/opt/local/monitor/logs/all_down_log'
##日志与实际
now="$(date +%Y-%m-%d-%T)"
#web service
#tomcat="$(netstat -antl|grep 8080|wc -l)"
web_http="$(ps -ef|grep nginx|grep -v grep|wc -l)"
#web_php= "$(ps -ef|grep php-fpm|grep -v grep|wc -l)"
#web_php="$(netstat -antl|grep 9000|wc -l)"
##通过端口与服务在后头的运行情况监控其运行状态
#cpu service
alert_cpu='80'
##cpu的报警阀值
web_cpu_idle="$(top -b -n 1 | grep Cpu | awk '{print $5}' | cut -f 1 -d .)"
web_cpu="$(echo 100 - $web_cpu_idle|/usr/bin/bc)"
##监控cpu的使用率
#memory service
alert_mem='100'
##内存的报警阀值
web_mem="$(/usr/bin/free -m|grep Mem|awk '{print $4}')"
web_swap="$(/usr/bin/free -m|grep Swap|awk '{print $3}')"
##memory与swap的使用率
alert_swap='0'
##swap的报警阀值
#memory log
memory_worklog='/opt/local/monitor/logs/mem_work_log'
memory_downlog='/opt/local/monitor/logs/mem_down_log'
#load service
cpu_count="$(grep -c 'model name' /proc/cpuinfo)"
alert_load="$(echo $cpu_count/2|/usr/bin/bc)"
web_load="$(uptime|awk '{print $NF}'|cut -f 1 -d .)"
web_load_15="$(uptime|awk '{print $NF}')"
#监控负载的使用率
#load log
load_worklog='/opt/local/monitor/logs/load_work_log'
load_downlog='/opt/local/monitor/logs/load_down_log'
#io service
alert_io='80'
web_io_idle_back="$(/usr/bin/iostat|awk 'NR==4{print $NF}'|cut -f 1 -d .)"
web_io_idle="$(echo 100 - $web_io_idle_back|/usr/bin/bc)"
##io的使用值
#io log
io_worklog='/opt/local/monitor/logs/io_work_log'
io_downlog='/opt/local/monitor/logs/io_down_log'
#hardware service
web_hardware_error="$(dmesg|grep -i error|wc -l)"
web_info_error="$(dmesg|grep -i error)"
##开机启动的错误信息
#hardware error log
hard_worklog='/opt/local/monitor/logs/hard_work_log'
hard_downlog='/opt/local/monitor/logs/hard_down_log'
#message service
web_message_error_count="$(awk '/"$(date +%Y%m%d)"/' /var/log/messages|grep -i error|wc -l)"
web_message_error="$(awk '/"$(date +%Y%m%d)"/' /var/log/messages|grep -i error)"
##日志的错误信息
#message error log
message_worklog='/opt/local/monitor/logs/message_work_log'
message_downlog='/opt/local/monitor/logs/message_down_log'
#user service
web_user_count="$(/usr/bin/who|wc -l)"
web_user_info="$(/usr/bin/who)"
##当前登录的用户值
#user log
user_worklog='/opt/local/monitor/logs/user_work_log'
user_downlog='/opt/local/monitor/logs/user_down_log'
#disk service
alert_disk='80'
web_disk="$(/bin/df -H|sort -k5nr|grep -vE 'Filesystem|tmpfs|cdrom'|awk '{print $5 " " $1}')"
web_disk_use=$(echo $web_disk|awk '{print $1}'|cut -d '%' -f1)
web_disk_partition=$(echo $web_disk|awk '{print $2}')
#硬盘使用率
#disk log
disk_worklog='/opt/local/monitor/logs/disk_work_log'
disk_downlog='/opt/local/monitor/logs/disk_down_log'
#cpu log
cpu_worklog='/opt/local/monitor/logs/cpu_work_log'
cpu_downlog='/opt/local/monitor/logs/cpu_down_log'
#notification mail
email='[email protected]'
##报警的接收人
#monitor
#if [ ! -d "$loghere" ];then
# mkdir $loghere
#fi
#check web service
if [ $web_http -ge 1 ];then
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: nginx Monitor_Server: $monitor_name is working" >> $worklog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','nginx','working',now())";
else
/opt/local/nginx/sbin/nginx
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: nginx Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: nginx was a problem" $email
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: nginx Monitor_Server: $montior_name is down" >> $downlog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','nginx','downing',now())";
fi
#if [ $tomcat -ge 1 ];then
# echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: tomcat Monitor_Server: $monitor_name is working" >> $worklog-$day
# /opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','tomcat','working',now())";
#else
# /opt/local/monitor/shell/web_tomcat.sh
# echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: tomcat Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: tomcat was a problem" $email
# echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: tomcat Monitor_Server: $montior_name is down" >> $downlog-$day
# /opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','tomcat','downing',now())";
#fi
#if [ $web_php -ge 1 ];then
# echo "$now ShengFen: $here Server: $web_name Service: Ip: $web_ip Service: web_php Monitor_Server: $monitor_name is working" >> $worklog-$day
# /opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','web_php','working',now())";
#else
# /opt/local/php/sbin/php-fpm
# echo "$now ShengFen: $here Server: $web_name Service: Ip: $web_ip Service: web_php Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: web_php was a problem" $email
# echo "$now ShengFen: $here Server: $web_name Service: Ip: $web_ip Service: web_php Monitor_Server: $montior_name is down" >> $downlog-$day
# /opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','web_php','downing',now())";
#fi
#check cpu_idle
if [ $web_cpu -ge $alert_cpu ];then
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: cpu_idle Monitor_Server: $monitor_name Cpu_use: $web_cpu"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: cpu_use was Exceed Threshold value: 80%" $email
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: cpu_idle Monitor_Server: $monitor_name Cpu_use: $web_cpu" >> $cpu_downlog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $cpu_table values ('','$here','$web_name','$web_ip','$monitor_name','cpu_use','$alert_cpu','$web_cpu','abnormal',now())";
else
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: cpu_idle Monitor_Server: $monitor_name Cpu_use: $web_cpu" >> $cpu_worklog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $cpu_table values ('','$here','$web_name','$web_ip','$monitor_name','cpu_use','$alert_cpu','$web_cpu','normal',now())";
fi
#check memory
if [ $web_mem -le $alert_mem ];then
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: memory Monitor_Server: $monitor_name Free_mem: $web_mem"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: memory was Exceed Threshold value" $email
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: memory Monitor_Server: $monitor_name Free_mem: $web_mem" >> $memory_downlog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $memory_table values ('','$here','$web_name','$web_ip','$monitor_name','memory','$alert_mem','$web_mem','abnormal',now())";
else
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: memory Monitor_Server: $monitor_name Free_mem: $web_mem" >> $memory_worklog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $memory_table values ('','$here','$web_name','$web_ip','$monitor_name','memory','$alert_mem','$web_mem','normal',now())";
fi
#check swap
if [ $web_swap -gt $alert_swap ];then
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: swap Monitor_Server: $monitor_name Swap_web: $web_swap"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: swap Ip: $web_ip was Exceed Threshold value" $email
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: swap Monitor_Server: $monitor_name Swap_web: $web_swap" >> $memory_downlog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $memory_table values ('','$here','$web_name','$web_ip','$monitor_name','swap','$alert_swap','$web_swap','abnormal',now())";
else
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: swap Monitor_Server: $monitor_name Swap_web: $web_swap" >> $memory_worklog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $memory_table values ('','$here','$web_name','$web_ip','$monitor_name','swap','$alert_swap','$web_swap','normal',now())";
fi
#check load_15
if [ $web_load -ge $alert_load ];then
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: load_15 Monitor_Server: $monitor_name Load_use: $web_load_15"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: load_15 Ip: $web_ip was Exceed Threshold value" $email
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: load_15 Monitor_Server: $monitor_name Load_use: $web_load_15" >> $load_downlog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $load_table values ('','$here','$web_name','$web_ip','$monitor_name','load_15','$alert_load','$web_load_15','abnormal',now())";
else
echo "$now ShengFen: $here Server: $server Ip: $ip Service: load Monitor_Server: $monitor_name Load_use: $web_load_15" >> $load_worklog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $load_table values ('','$here','$web_name','$web_ip','$monitor_name','load_15','$alert_load','$web_load_15','normal',now())";
fi
#check io_idle
if [ $web_io_idle -ge $alert_io ];then
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: io_idle Monitor_Server: $monitor_name Io_use: $web_io_idle"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: io_use was Exceed Threshold value: 80%" $email
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: io_idle Monitor_Server: $monitor_name Io_use: $web_io_idle" >> $io_downlog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $io_table values ('','$here','$web_name','$web_ip','$monitor_name','io_use','$alert_io','$web_io_idle','abnormal',now())";
else
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: io_idle Monitor_Server: $monitor_name Io_use: $web_io_idle" >> $io_worklog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $io_table values ('','$here','$web_name','$web_ip','$monitor_name','io_use','$alert_io','$web_io_idle','normal',now())";
fi
#check hareware error info
if [ $web_hardware_error -gt 0 ];then
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: hardware_error Monitor_Server: $monitor_name Error: $web_info_error"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: hardware_error were some hardware imformation error" $email
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: hardware_error Monitor_Server: $monitor_name Error: $web_info_error" >> $hard_downlog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $hardware_table values ('','$here','$web_name','$web_ip','$monitor_name','hardware_error','0','$web_hardware_error','abnormal',now())";
else
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: hardware_error Monitor_Server: $monitor_name Error: Nothing" >> $hard_worklog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $hardware_table values ('','$here','$web_name','$web_ip','$monitor_name','hardware_error','0','$web_hardware_error','normal',now())";
fi
#check message error
if [ $web_message_error_count -ge 1 ];then
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: message_error Monitor_Server: $monitor_name Message_error: $web_message_error"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: message_error were some message imformation error" $email
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: message_error Monitor_Server: $monitor_name Message_error: $web_message_error" >> $message_downlog-$day
/opt/local/mysql-5.6.15/bin/mysql-h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $message_table values ('','$here','$web_name','$web_ip','$monitor_name','message_error','1','$web_message_error_count','abnormal',now())";
else
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: message_error Monitor_Server: $monitor_name Message_error: Nothing" >> $message_worklog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $message_table values ('','$here','$web_name','$web_ip','$monitor_name','message_error','1','$web_message_error_count','normal',now())";
fi
#check user
if [ $web_user_count -ge 3 ];then
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: user Monitor_Server: $monitor_name User: $web_user_info"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: user was Exceed Threshold value: 3" $email
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: user Monitor_Server: $monitor_name User: $web_user_info" >> $user_downlog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $user_table values ('','$here','$web_name','$web_ip','$monitor_name','user','3','$web_user_count','abnormal',now())";
else
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: user Monitor_Server: $monitor_name User: normal" >> $user_worklog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $user_table values ('','$here','$web_name','$web_ip','$monitor_name','user','3','$web_user_count','normal',now())";
fi
#check disk
if [ $web_disk_use -ge $alert_disk ];then
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: disk_use Monitor_Server: $monitor_name Disk_use: $web_disk_partition ($web_disk_use%)"|/bin/mail -s "Warning!!! $here Server: $web_name Service: disk_use was Exceed Threshold value : $alert_disk% " $email
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: disk_use Monitor_Server: $monitor_name Disk_use: $web_disk_partion ($web_disk_use%)" >> $disk_downlog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $disk_table values ('','$here','$web_name','$web_ip','$monitor_name','disk_use','$alert_disk','$web_disk_partition','$web_disk_use','abnormal',now())";
else
echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: disk_use Monitor_Server: $monitor_name Disk_use: $web_disk_partition ($web_disk_use%)" >> $disk_worklog-$day
/opt/local/mysql-5.6.15/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $disk_table values ('','$here','$web_name','$web_ip','$monitor_name','disk_use','$alert_disk','$web_disk_partition','$web_disk_use','normal',now())";
fi
-----------------------------------------------------------------------------------------