Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1119234
  • 博文数量: 113
  • 博客积分: 2422
  • 博客等级: 大尉
  • 技术积分: 1393
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-25 17:54
文章分类
文章存档

2016年(1)

2014年(8)

2013年(7)

2012年(13)

2011年(42)

2010年(26)

2009年(6)

2008年(6)

2007年(4)

我的朋友

分类: Python/Ruby

2011-10-09 15:12:54

    每天从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
阅读(15800) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~