Skip to content

Commit

Permalink
Merge pull request libremesh#1087 from G10h4ck/shared_state_async
Browse files Browse the repository at this point in the history
Add shared-state-async network statistics sharing
  • Loading branch information
G10h4ck authored Feb 26, 2024
2 parents ebf4b7b + 0cfd1e6 commit 6992335
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/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 6992335

Please sign in to comment.