Projet

Général

Profil

Vpn bwsh » Historique » Version 1

Baptiste Jonglez, 27/10/2016 15:48

1 1 Baptiste Jonglez
h1. Accounting des VPN
2
3
Ce script parse les fichiers d'accounting d'openvpn pour que ce soit plus facile à lire.
4
5
<pre>
6
#!/bin/sh
7
# Display VPN up/down throughput for the last hour
8
9
ACCTDIR="/var/run/openvpn/acct"
10
# Only display VPN with more than X Mbps up+down
11
MIN_MBPS=2
12
# How far to go in the past
13
LAST_MINUTES=60
14
15
cd "$ACCTDIR"
16
17
printf "VPN with at least %d Mbps of up+down traffic in the last %d minutes are shown\n" "$MIN_MBPS" "$LAST_MINUTES"
18
19
printf "%10s %16s %12s %12s\n" "Date" "VPN" "Up" "Down"
20
for f in $(find . -type f -cmin -"$LAST_MINUTES" | sort -n)
21
do
22
  awk '/^[^#]/ { if ($4 + $5 > 78643200) printf "%16s %16s %3.0f Mbit/s %3.0f Mbit/s\n", FILENAME, $1, $4*8/300/1024/1024, $5*8/300/1024/1024;}' "$f"
23
done
24
</pre>