T-X / wirerrd

Wireshark to RRD
Creative Commons Zero v1.0 Universal
4 stars 2 forks source link

systemd won't properly run wirerrd collect without execs when forking #1

Open mweinelt opened 7 years ago

mweinelt commented 7 years ago
diff --git a/lib/chunks.sh b/lib/chunks.sh
index 2c01b29..42f293f 100644
--- a/lib/chunks.sh
+++ b/lib/chunks.sh
@@ -163,5 +163,5 @@ analyze_chunks() {
 analyze() {
        echo "`date`: Waiting for first chunk"

-       inotifywait -q -m "$TMPDIR/raw" -e create -e moved_to | analyze_chunks
+       exec inotifywait -q -m "$TMPDIR/raw" -e create -e moved_to | analyze_chunks
 }
diff --git a/lib/wirerrd-collect.sh b/lib/wirerrd-collect.sh
index 043d944..c1415a5 100755
--- a/lib/wirerrd-collect.sh
+++ b/lib/wirerrd-collect.sh
@@ -10,7 +10,7 @@ THREADS=$((2*`grep -c ^processor /proc/cpuinfo`))
 . ./lib/chunks.sh

 run_capture() {
-       dumpcap -q -i "$IFACE" -b duration:60 -w "$TMPDIR/raw/out.cap" 2> /dev/null || {
+       exec dumpcap -q -i "$IFACE" -b duration:60 -w "$TMPDIR/raw/out.cap" 2> /dev/null || {
                echo "Error starting dumpcap" >&2
                kill 0
                exit 1

Additionally the systemd units I'm using:

# /home/hexa/.config/systemd/user/wirerrd-collect.service
[Unit]
Description=wirerrd (collect data)
After=network.target

[Service]
Type=simple
WorkingDirectory=/home/hexa/wirerrd
ExecStart=/home/hexa/wirerrd/wirerrd collect -i ffda-vpn -o data/ffda -f contrib/filters/bcast-stats.rules -j 2

[Install]
WantedBy=multi-user.target
# /home/hexa/.config/systemd/user/wirerrd-export.service
[Unit]
Description=wirerrd (export data)
After=network.target

[Service]
Type=oneshot
WorkingDirectory=/home/hexa/wirerrd
ExecStart=/home/hexa/wirerrd/wirerrd export -i data/ffda -o public_html/ffda
# /home/hexa/.config/systemd/user/wirerrd-export.timer
[Unit]
Description=wirerrd-export timer

[Timer]
OnActiveSec=300
Persistent=true
Unit=wirerrd-export.service

[Install]
WantedBy=basic.target
mweinelt commented 7 years ago

Current issue with that setup is that data collection is not working properly. Instead of data being appended it is being overwritten afaict.

https://glitch.linuxlounge.net/wirerrd/ffda/

T-X commented 7 years ago

As noted on IRC, not an issue of wirerrd, but an issue of the provided systemd unit file.

If someone could provide a working systemd unit, I'd gladly add it to the contrib folder of wirerrd.