统计下载日志流量,ip等各项信息的shell脚本代码

Qiniu 七牛问题解答

Build Status

Qiniu Logo

问题描述

问题解决方案

#! /bin/bash
echo "example:"  "--------./log-test.sh 404 2015-04-07 REQ_IO 11-00 do_not_delete/noc.gif----------------------------------------------------------"
code=$1
echo "the code is ${code} "
date=$2
echo "the date is ${date}"
operation=$3
echo "the operation is ${operation}"
time=$4
echo "the time is ${time}"
domain=$5
echo "the domain is ${domain}"
key=$6
echo "the key is ${key}"
if [ "$operation" = "REQ_IO" -a  "$code" =  "404" ];
then
echo "searching code 404-content............waiting for a while"
hdfs dfs -cat /flume/${date}/${operation}/${time}/*.log|awk  '$7==200{print $0}' | grep ${content}| head -10
fi

if [ "$operation" = "REQ_IO" -a  "$domain" !=  "" ];
then
echo "searching code 404-content............waiting for a while"
hdfs dfs -cat /flume/${date}/${operation}/${time}/*.log|awk  '{if(substr($0, index($0, "Host") + 7, 20)~/'$domain'/) {print $0}}'|awk  '{ if($7==200) { sum=sum+$9 }} END {print " the amount is   " int(sum/(1024*1024)) " M"}' | head -10
fi

结果演示

参考文档:七牛云存储 C SDK 使用指南

许可证

Copyright (c) 2012 qiniu.com

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值