每天从Solarwinds取网络的流量数据,生成报表,工作单调而且是一个没有成就感的事情,人不能让机器天天这么搞啊,虽然说多搞才能有高潮,可是本人身体不怎么好,可不想天天这样子被动的高潮,万一哪天真的要是*尽人忘了,怎么对得起我没过门的媳妇啊。。。。
于是有了下面的脚本,通过POST和curl登陆取数据,下载到excel文件
#!/bin/bash
#
# -b/--cookie
# (HTTP) Pass the data to the HTTP server as a cookie.
# -c/--cookie-jar
# Specify to which file you want curl to write all cookies
# -d/--data
# (HTTP) Sends the specified data in a POST request to the HTTP server
# -L/--location
# auto redirect while need
# parameter init
#
ID=your_uname
PASSWD=your_password
E_DAY=`date +%Y-%m-%d --date "1 day ago"`
B_DAY=`date +%Y-%m-%d --date "8 day ago"`%2023:59:59
LOGURL=""
curl -L -c traffic.txt --user-agent Mozilla/4.0 -d "AccountID=${ID}&Password=${PASSWD}" ${LOGURL}
for CID in MMAVGBPS TOTALBYTES
do
URL="{CID}&NetObject=I:1656&PeriodBegin=${B_DAY}&PeriodEnd=${E_DAY}&SampleSize=10M&DataFormat=Excel"
#curl -c traffic.txt -b traffic.txt --user-agent Mozilla/4.0 ${URL}
curl -c traffic.txt -b traffic.txt --user-agent Mozilla/4.0 ${URL} >${CID}_${E_DAY}.xls
done
阅读(15910) | 评论(0) | 转发(0) |