tags:

views:

69

answers:

1

We're able to tail the traffic on a server that we host :

...
+1287737841.266952 ...
+1287737841.267117 ...
+1287737841.267136 ...
+1287737841.278288 ...
+1287737841.278310 ...
+1287737841.278321 ...
+1287737841.278331 ...
+1287737841.278341 ...
...

As you can see they include timestamps, down to the micro-second! I just want to be able to compute a floating QPS (Queries Per Second), and maybe per minute, and per hour from this. Any way of doing it with the shell?

+1  A: 

Hi Julien,

Assuming you have bash available and that your log is on the file traffic.log, this would give you the number of queries per second:

cat traffic.log | colrm 1 1 | colrm 11 | uniq -c

This would give you the number of queries per minute:

for i in cat traffic.log | colrm 1 1 | colrm 11; do echo $(($i/60)); done | uniq -c

And this would give you the number of queries per hour:

for i in cat traffic.log | colrm 1 1 | colrm 11; do echo $(($i/3600)); done | uniq -c

I'm sure there must be a less CPU intensive way of doing it but this is the first thing that came to my mind.

Let me know if it worked.

bpedro
Perfect! That's exactly what I needed.
Julien Genestoux
Great! So, how many queries are you processing per second? ;)
bpedro