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

Qiniu 七牛问题解答

问题描述

问题解决方案

#! /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

你可能感兴趣的:(统计下载日志流量,ip等各项信息的shell脚本代码)