Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync monitor timer #25

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions create_exitnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,7 @@ service babeld start

systemctl start babeld-monitor.timer
systemctl enable babeld-monitor.timer
systemctl start exitnode-sync.timer
This conversation was marked as resolved.
Show resolved Hide resolved
systemctl enable exitnode-sync.timer

reboot now
6 changes: 6 additions & 0 deletions src/etc/systemd/system/exitnode-monitor/sync-monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ROUTES=$(ip route | grep via | grep -v default | awk '{print $1 "," $3 }' | sort | uniq | tr '\n' '|')
TOTAL_ROUTES=$(ip route | grep via | grep -v default | awk '{print $1 "\t" $3 }' | sort | uniq | wc -l)
TOTAL_GATEWAYS=$(ip route | grep via | grep -v default | awk '{print $3 }' | sort | uniq | wc -l)

curl --silent -H 'Content-Type: text/plain' -d $ROUTES -X POST https://peoplesopen.herokuapp.com/api/v0/nodes > /dev/null
curl --silent -H "Content-Type: application/json" -d "{ \"numberOfRoutes\": $TOTAL_ROUTES, \"numberOfGateways\": $TOTAL_GATEWAYS }" -X POST https://peoplesopen.herokuapp.com/api/v0/monitor > /dev/null
13 changes: 13 additions & 0 deletions src/etc/systemd/system/exitnode-sync.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=sync_peoplesopen.net/monitor.
After=network.target auditd.service

[Service]
Type=simple
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/bin/bash /opt/exitnode-monitor/sync-monitor.sh

[Install]
WantedBy=multi-user.target
11 changes: 11 additions & 0 deletions src/etc/systemd/system/exitnode-sync.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=exitnode-monitor timer

[Timer]
OnCalendar=*:0/1

[Install]
WantedBy=timers.target

~
~