Hi everyone. In this tutorial I will be explaining how to minotor the uptime of a hidden service.
Why can this be usefull?
Keeping your service online requires dedication and hard work. Shit happens.
It's good to have something set up that gives you a notification when there are problems.
Requirements:
-The linux mon tool
-tor
-torsocks
First we will be installing the neccesary tools to do this.
sudo apt-get install tor torsocks mon
Now, let's create a new monitor that wraps mon with torsocks, so it is compatible with .onion addresses.
sudo nano /usr/lib/mon/mon.d/torsocks_http.monitor
and fill it with this:
#!/bin/bash
export DIR_PATH=`dirname ${0}`
exec /usr/bin/torsocks --isolate ${DIR_PATH}/http.monitor -t 60 "$@"
Don't forget to give this file execution rights, otherwise it won't run!
Now let's edit the main mon.cf file and add these lines in /etc/mon/mon.cf
hostgroup torproject_onion http://dreadytofatroptsdj6io7l3xptbet6onoyno2yv7jicoxknyazubrad.onion/
watch torproject_onion
service http
interval 5m
monitor torsocks_http.monitor
period
alertafter 10
alertevery 1h strict
alert /home/Desktop/TorIsDown.sh
What this will do is monitor the dread onion and checks every 5 mins.
After 10 consecutive failures it will perform the TorIsDown script once, with a maximum of 1 time each hour.
The torisDown script can be configured to be anything, ranging from just simply restarting the service and hoping for the best, to sending you a notification on jabber or through email or even telegram.
for now the torisdown script looks like this:
#!/bin/bash
LOG_PATH='/var/log/mon/torisdown.log'
msg="$(date -u --iso-8601=seconds) INFO: tor is down :("
echo ${msg} >> ${LOG_PATH}
Now restart the service using systemctl restart mon.service
and test if everything works correctly by running the command:
time /usr/lib/mon/mon.d/torsocks_http.monitor [your onion address]
