Skip to content

Commit

Permalink
Add shared-state-async network statistics sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
G10h4ck committed Feb 22, 2024
1 parent ebf4b7b commit 5d6ee3c
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

unique_append()
{
grep -qF "$1" "$2" || echo "$1" >> "$2"
}

mSc="net_stats"

uci set shared-state.${mSc}=dataType
uci set shared-state.${mSc}.name='net-stats'
uci set shared-state.${mSc}.scope='community'
uci set shared-state.${mSc}.ttl='1200'
uci set shared-state.${mSc}.update_interval='120'
uci commit shared-state

unique_append \
'*/3 * * * * ((sleep $(($RANDOM % 120)); \
shared-state-async insert net-stats < /tmp/shared-state/network_statistics.json \
&> /dev/null)&)' \
/etc/crontabs/root

0 comments on commit 5d6ee3c

Please sign in to comment.