Project

General

Profile

Actions

Accounting des VPN

Ce script parse les fichiers d'accounting d'openvpn pour que ce soit plus facile à lire.

#!/bin/sh
# Display VPN up/down throughput for the last hour

ACCTDIR="/var/run/openvpn/acct" 
# Only display VPN with more than X Mbps up+down
MIN_MBPS=2
# How far to go in the past
LAST_MINUTES=60

cd "$ACCTDIR" 

printf "VPN with at least %d Mbps of up+down traffic in the last %d minutes are shown\n" "$MIN_MBPS" "$LAST_MINUTES" 

printf "%10s %16s %12s %12s\n" "Date" "VPN" "Up" "Down" 
for f in $(find . -type f -cmin -"$LAST_MINUTES" | sort -n)
do
  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" 
done

Updated by Baptiste Jonglez about 8 years ago · 1 revisions