test.htm为监控页面
echo '<html><body><h3>Report for Data Server Disks</h3><table>'> test.htm ---添加表头
mysql -e "select '<TABLE BORDER="1" CELLSPACING="2"><TR><TD width=120 height=20>',date,'</TD>','<TD width=120 height=20>',sum_ip,'</TD>','<TD width=120 height=20>',ip,'</TD></TR></TABLE>' from test.sum_ip order by sum_ip desc" >>'/opt/htdocs/www/test.htm'
表体内容从mysql库里提取
-------------------------------
#!/bin/bash
#auther:haoqing
#date:20120517
#version 2.1
date=`date -d last-day +%Y%m%d`
cd /opt/count
mv /opt/count/count_ip /opt/count/oldcount/count_ip_$date
mv /opt/count/count_time /opt/count/oldcount/count_time_$date
mv /opt/count/count_total /opt/count/oldcount/count_total_$date
lftp ftpcount:ssreader@IP:端口<<EOF
get count/count_ip
get count/count_time
get count/count_total
exit
EOF
mysql -e "load data infile '/opt/count/count_ip' into table test.sum_ip fields terminated by ' '"
mysql -e "load data infile '/opt/count/count_time' into table test.sum_time fields terminated by ' '"
mysql -e "load data infile '/opt/count/count_total' into table test.sum_total fields terminated by ' '"
mysql -e "select * from test.sum_ip where date=(select max(date) from test.sum_ip);"> '/opt/htdocs/www/index_ip.htm'
mysql -e "select * from test.sum_time where date=(select max(date) from test.sum_time);"> '/opt/htdocs/www/index_time.htm'
mysql -e "select * from test.sum_total where date=(select max(date) from test.sum_total);"> '/opt/htdocs/www/index_total.htm'
#auther:haoqing
#date:20120517
#version 2.1
date=`date -d last-day +%Y%m%d`
cd /opt/count
mv /opt/count/count_ip /opt/count/oldcount/count_ip_$date
mv /opt/count/count_time /opt/count/oldcount/count_time_$date
mv /opt/count/count_total /opt/count/oldcount/count_total_$date
lftp ftpcount:ssreader@IP:端口<<EOF
get count/count_ip
get count/count_time
get count/count_total
exit
EOF
mysql -e "load data infile '/opt/count/count_ip' into table test.sum_ip fields terminated by ' '"
mysql -e "load data infile '/opt/count/count_time' into table test.sum_time fields terminated by ' '"
mysql -e "load data infile '/opt/count/count_total' into table test.sum_total fields terminated by ' '"
mysql -e "select * from test.sum_ip where date=(select max(date) from test.sum_ip);"> '/opt/htdocs/www/index_ip.htm'
mysql -e "select * from test.sum_time where date=(select max(date) from test.sum_time);"> '/opt/htdocs/www/index_time.htm'
mysql -e "select * from test.sum_total where date=(select max(date) from test.sum_total);"> '/opt/htdocs/www/index_total.htm'