Remote monitoring of the "farm" using a GSM outlet

Published on May 02, 2018

Remote monitoring of the "farm" using a GSM outlet

I will describe one of the ways how to monitor the “farm” and remotely restart if it hangs, the video card or the mining program has fallen off, the Internet has disappeared, the router has hung up.

Advantages of the GSM socket:

  • Automatic reboot of the farm, even if it is “hard” stuck.
  • You will be informed about the reboot of the farm. Even if you currently have no internet on your mobile. You come ordinary SMS.
  • Google Drive - always works in the "cloud", without your participation, verified more than 5 years.
  • Issue price ~ 800 UAH. + 1 UAH per year. (for any tariff from Kyivstar)

Disadvantages of other monitoring systems:

  • Program WATCHDOG - who would not say, but ... freezes!
  • USB WATCHDOG - does not send an alert, it does not reboot if for some reason the "miner" is closed.
  • Wi-Fi smart sockets will not automatically reboot the system. It is necessary to go to them and manually disable and enable. Provided that the Internet does not “fall off” and the router does not freeze.

The whole idea of ​​monitoring works if you mine on a pool and the pool gives statistics on the performance of your “farm”.

  1. Sign up for or use a ready-made gmail account .com. Is free!
  2. We are registering on - this is for sending SMS to your outlet. Is free!
  3. We buy a GSM-outlet. Well proven "GSM-socket SOKOL". Enough 1st version of SOKOL-GS1. Or another available GSM socket that works via SMS commands.

The meaning of monitoring work:

The script works around the clock on Google Drive and polls your pool every minute. As soon as the script receives your speed equal to zero H / sec, it will immediately send SMS to the outlet for resetting the farm. Everything works without your participation.

All SMS Free!

Setting up the script for Google Drive

On the example of cryptocurrency KARBO (karbovanets), with the algorithm CryptoNight and the pool

Go to  and create a new Google Apps Script:

Register this code:

Script code
function response(n) {
  // Меняем на свой кошелек
  var wallet = 'KcdYnF6rxxKEw7pvFWqNCh3yhpFD6sfvtCuTakxpWZSQCs3sTrvBLfK4TLMxZnRd';  
  try {
    // Адресс Вашего пула для парсинга статистики
    var html  = UrlFetchApp.fetch('' + wallet, {muteHttpExceptions:true});
  } catch (e) {
    if (n < 2)
    return false;
  try {
    return JSON.parse(html.getContentText());
  } catch (e) {
    //    Logger.log(response);
    return false;
function sberex() {
  var JSONresponse = response(0);
  if (!JSONresponse)
  var dateLastShare = Utilities.formatDate(new Date(JSONresponse.stats.lastShare*1000), Session.getScriptTimeZone(), "HH:mm");
  var hashrate = JSONresponse.stats.hashrate;
  var cacheHashrate = CacheService.getScriptCache().get('hesh');
  if (hashrate && cacheHashrate == 'undefined')  {
    send_sms('YES_KRB+' + dateLastShare);
    CacheService.getScriptCache().put('time', 0);
  if (!hashrate && cacheHashrate != 'undefined') {
    send_sms('NOT_KRB+' + dateLastShare);
//    send_sms_mining('Vkl');
  if (!hashrate && cacheHashrate == 'undefined') {
    var cacheTime = CacheService.getScriptCache().get('time');
    if (cacheTime) ++cacheTime;
      cacheTime = 0;
    if (cacheTime != 0 && cacheTime % 10 == 0)
      send_sms('NOT_KRB+%3E' + cacheTime + 'min+' + dateLastShare);
    CacheService.getScriptCache().put('time', cacheTime);
  CacheService.getScriptCache().put('hesh', hashrate);
function sberex_day() {
  var JSONresponse = response(0);
  if (!JSONresponse) return;
  var payments = JSONresponse.charts.payments;
  var hashrate = JSONresponse.charts.hashrate;
  var day = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "dd") - 1;
  var pay = 0,
      hash = 0;
  for (var i = 0; i < payments.length; i++) {
    if (Utilities.formatDate(new Date(payments[i][0]*1000), Session.getScriptTimeZone(), "dd") == day)
      pay += payments[i][1] / 1000000000000;
  for (var i = 0; i < hashrate.length; i++) {
    hash += hashrate[i][1];
  hash = (hash / hashrate.length).toFixed(0); 
  send_sms(pay + '+KRB+выплата+за+' + day + '+(~+' + hash + '+H/sec)');
function send_sms(m) { // для отправки смс на ваш телефон (меняем на свой тел.)
  UrlFetchApp.fetch('' + m);
function send_sms_mining_off() { // Отключает розетку. Меняем на телефон для розетки
  try {
  var html = UrlFetchApp.fetch('');
  var mesID = JSON.parse(html.getContentText()).messages[0].apiMessageId;
    if (mesID)
      CacheService.getScriptCache().put('mesID', mesID, 21600);
    } catch (e) {
function doGet(e) { // Получаем ответ что розетка отключилась, и включаем её. меняем на телефон для розетки
  var status = e.parameter.status;
  var mesID = CacheService.getScriptCache().get('mesID');
  if (e.parameter.status == 'RECEIVED_BY_RECIPIENT' && mesID == e.parameter.messageId) 

In the code, respectively, change your data, this is the wallet, phone number and address of the pool.

Attention! The address of the pool is not the one you see in the browser, but you need to find it. To do this, on the statistics page, press  ctrl + shift + i  and select Network in the appeared window .

We find the part of the request that requests statistics on the server. Each pool has its own, but the answers always come in a standard JSON format. For Carbovanza, it is the same for every pool. This is the answer that “parses” the script on Google Drive, every minute.

After you have changed the data in the code to your values, you must activate it and deploy it as a web application. To do this, select any function from the script and run it:

Click "Grant Permission" and select an account:

Click "Allow":

Now expand as “Web application”, click on the “Publish” menu:

Configure as shown in the screenshot below:

Copy the current URL of the web application, later it will come in handy.

Now we will add a Trigger, which will be triggered every minute, and once a day with a report (optional). Choose such functions and customize the screenshot:

At this, setting up the script is over, proceed to the SMS.

SMS gateway setting

We register on Go to your personal account and add two phones. For reporting your phone and the one that is in the outlet. The resource Satelliteite allows you to send completely free sms to your three numbers that you register with them in unlimited quantities. Now we will configure the API for sending SMS, go  here and configure the API, you will be assigned an API key.

This completes the “farm” monitoring setup. Insert the SIM card into the GSM outlet, turn on the farm. You can test the operation of the outlet by running the function in the send_sms_mining_off () script  . The socket should turn off and turn on in a few seconds, while sending an alert to your phone. 

PS For the third month already, there was not a single case that I had to manually restart or run the farm!