Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
574b5705
Commit
574b5705
authored
Feb 18, 2026
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
router/scripts: add iperf3 bandwidth measurement for Telegraf
Co-Authored-By:
Claude Opus 4.6
<
noreply@anthropic.com
>
parent
2e9b341e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
0 deletions
+110
-0
deploy-iperf3.sh
router/scripts/deploy-iperf3.sh
+77
-0
iperf3-telegraf.sh
router/scripts/iperf3-telegraf.sh
+33
-0
No files found.
router/scripts/deploy-iperf3.sh
0 → 100755
View file @
574b5705
#!/bin/bash
# Deploy iperf3 bandwidth measurement to a gateway container
# Usage: deploy-iperf3.sh TARGET_IP CTID
#
# TARGET_IP should be the dummy interface IP on the VDS (10.77.0.1)
# so that traffic goes through the tunnel, not directly to VDS public IP.
#
# VDS dummy IPs:
# 10.77.0.1 — common (on all VDS)
# 10.77.1.1 — hetzner, 10.77.2.1 — vdska, 10.77.3.1 — beget
#
# This script:
# 1. Copies iperf3-telegraf.sh to the container
# 2. Adds [[inputs.exec]] to telegraf.conf
# 3. Restarts telegraf
#
# Prerequisites:
# - iperf3 must be installed in the container
# - iperf3 server must be running on VDS (port 5201)
# - dummy0 interface must exist on VDS
# - Run from the PVE host (border)
set
-e
TARGET_IP
=
"
${
1
:-
10
.77.0.1
}
"
CTID
=
"
$2
"
SCRIPT_DIR
=
"
$(
dirname
"
$(
readlink
-f
"
$0
"
)
"
)
"
SCRIPT_SRC
=
"
$SCRIPT_DIR
/iperf3-telegraf.sh"
SCRIPT_DST
=
"/usr/local/bin/iperf3-telegraf.sh"
TELEGRAF_CONF
=
"/etc/telegraf/telegraf.conf"
if
[
-z
"
$CTID
"
]
;
then
echo
"Usage:
$0
[TARGET_IP] CTID"
>
&2
echo
"Example:
$0
10.77.0.1 668"
>
&2
echo
"Default TARGET_IP: 10.77.0.1 (dummy0 on all VDS)"
>
&2
exit
1
fi
echo
"=== Deploying iperf3 measurement to CT
$CTID
(target:
$TARGET_IP
) ==="
# Check container is running
if
!
pct status
"
$CTID
"
2>/dev/null |
grep
-q
running
;
then
echo
"ERROR: CT
$CTID
is not running"
>
&2
exit
1
fi
# Copy script
echo
"Copying iperf3-telegraf.sh..."
pct push
"
$CTID
"
"
$SCRIPT_SRC
"
"
$SCRIPT_DST
"
lxc-attach
-n
"
$CTID
"
--
chmod
+x
"
$SCRIPT_DST
"
# Check if iperf3 is installed
if
!
lxc-attach
-n
"
$CTID
"
--
which iperf3
>
/dev/null 2>&1
;
then
echo
"Installing iperf3..."
lxc-attach
-n
"
$CTID
"
--
epm
-y
install
iperf3
fi
# Add telegraf config if not already present
if
lxc-attach
-n
"
$CTID
"
--
grep
-q
"iperf3-telegraf"
"
$TELEGRAF_CONF
"
2>/dev/null
;
then
echo
"Telegraf config already contains iperf3 — skipping"
else
echo
"Adding iperf3 to telegraf.conf..."
lxc-attach
-n
"
$CTID
"
--
bash
-c
"cat >>
$TELEGRAF_CONF
"
<<
EOF
[[inputs.exec]]
commands = ["/usr/local/bin/iperf3-telegraf.sh
$TARGET_IP
"]
interval = "30m"
timeout = "300s"
data_format = "influx"
EOF
fi
# Restart telegraf
echo
"Restarting telegraf..."
lxc-attach
-n
"
$CTID
"
--
systemctl restart telegraf
echo
"=== Done: CT
$CTID
configured for iperf3 to
$TARGET_IP
==="
router/scripts/iperf3-telegraf.sh
0 → 100755
View file @
574b5705
#!/bin/bash
# iperf3 bandwidth measurement for telegraf
# Outputs data in InfluxDB line protocol format
# Usage: iperf3-telegraf.sh SERVER_IP [OFFSET]
#
# OFFSET (seconds) staggers tests so only one client
# hits each iperf3 server at a time.
SERVER
=
"
$1
"
OFFSET
=
"
${
2
:-
0
}
"
DURATION
=
5
if
[
-z
"
$SERVER
"
]
;
then
echo
"Usage:
$0
SERVER_IP [OFFSET]"
>
&2
exit
1
fi
sleep
"
$OFFSET
"
result
=
$(
iperf3
-c
"
$SERVER
"
-t
"
$DURATION
"
--json
2>/dev/null
)
if
[
$?
-ne
0
]
||
[
-z
"
$result
"
]
;
then
echo
"iperf3,server=
$SERVER
success=0i,sent_bps=0,recv_bps=0,retransmits=0i"
exit
0
fi
python3
-c
"
import json,sys
d=json.load(sys.stdin)
e=d.get('end',{})
s=e.get('sum_sent',{})
r=e.get('sum_received',{})
print(f'iperf3,server=
$SERVER
success=1i,sent_bps={s.get(
\"
bits_per_second
\"
,0)},recv_bps={r.get(
\"
bits_per_second
\"
,0)},retransmits={s.get(
\"
retransmits
\"
,0)}i')
"
<<<
"
$result
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment