---
title: "DevOps使用技巧"
author: "cpu"
date: "2017-03-07T13:42:44Z"
tags: []
categories: ["互联网"]
slug: "devops"
draft: false
lastmod: "2017-03-07T13:42:44Z"
id: 2360699
url: "https://cpu.iteye.com/blog/2360699"
---

Web服务器负载飙升的分析与处理
前提：日志已经通过logrotate按天切分，其内容类似下面的样子：
1.2.3.4 - -  "GET /path HTTP/1.1" ...
利用AWK，我们可以很方便的计算一天中每分钟的访问量是多少：
shell> awk -F: ' {count ++}
　　END {for (minute in count) print minute, count  } ' /path/to/log | sort > count.log
下面列出生成的count.log文件中的部分数据，结果一目了然，不多说了：
18:55 14450
　　18:56 14926
　　18:57 15645
　　18:58 16678
　　18:59 19032
　　19:00 29134
　　19:01 34665
　　19:02 35558
　　19:03 35545
　　19:04 35829
　　19:05 35608
如果想要以秒为单位来统计，也是类似的方法。