Skip to content

Instantly share code, notes, and snippets.

@janaz
Created September 12, 2020 12:50
Show Gist options
  • Save janaz/edc26e298e00d8bc172a78eff4bea770 to your computer and use it in GitHub Desktop.
Save janaz/edc26e298e00d8bc172a78eff4bea770 to your computer and use it in GitHub Desktop.

Revisions

  1. janaz revised this gist Sep 12, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion collectd-speedtest.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/bin/sh
    HOSTNAME="${COLLECTD_HOSTNAME:-door}"
    HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
    INTERVAL="${COLLECTD_INTERVAL:-3600}"

    while true; do
  2. janaz created this gist Sep 12, 2020.
    12 changes: 12 additions & 0 deletions collectd-speedtest.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/bin/sh
    HOSTNAME="${COLLECTD_HOSTNAME:-door}"
    INTERVAL="${COLLECTD_INTERVAL:-3600}"

    while true; do
    result="$(speedtest --csv)"
    upload="$(echo "$result" | cut -d, -f8)"
    download="$(echo "$result" | cut -d, -f7)"
    echo "PUTVAL \"$HOSTNAME/speedtest/upload\" interval=$INTERVAL N:$upload"
    echo "PUTVAL \"$HOSTNAME/speedtest/download\" interval=$INTERVAL N:$download"
    sleep "$INTERVAL"
    done