-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shared-state-async network statistics sharing
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
packages/shared-state-async/files/etc/uci-defaults/shared-state-net_stats-cron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |