26 lines
1022 B
Bash
Executable File

#!/bin/bash
# http://www.austintek.com/LVS/LVS-HOWTO/HOWTO/LVS-HOWTO.monitoring_lvs.html | 33.3. Monitoring: LVS director throughput statistics from the /proc system (originally /proc/net/ip_vs_stats)
# Check your connections per second if you have a loadbalancer with keepalived.
if [ -f /proc/net/ip_vs_stats ];
then
#total
connections=$(sed -n 3p /proc/net/ip_vs_stats | awk '{print $1}')
packets=$(sed -n 3p /proc/net/ip_vs_stats | awk '{print $2}')
bytes=$(sed -n 3p /proc/net/ip_vs_stats | awk '{print $4}')
#per second
conspersec=$(cat /proc/net/ip_vs_stats |tail -1| awk '{print $1}')
pktpersec=$(cat /proc/net/ip_vs_stats |tail -1| awk '{print $2}')
bytespersec=$(cat /proc/net/ip_vs_stats |tail -1| awk '{print $4}')
echo '<<<app-lvs_stats>>>'
echo "connections_total:$((0x$connections))"
echo "packets_total:$((0x$packets))"
echo "bytes_total:$((0x$bytes))"
echo "connections_sec:$((0x$conspersec))"
echo "packets_sec:$((0x$pktpersec))"
echo "bytes_sec:$((0x$bytespersec))"
fi