create account

DevWork Update: BitShares Witness Monitor by clockwork

View this thread on: hive.blogpeakd.comecency.com
· @clockwork ·
$46.55
DevWork Update: BitShares Witness Monitor
Hello everyone,

I have decided to do little steem updates for the various bits of dev work I do.

I just completed work on the first version of a BitShares witness monitoring script with telegram integration.

You can find it here:  https://github.com/clockworkgr/bitshares-witness-monitor

First of all, I would like to acknowledge @roelandp 's work (https://github.com/roelandp/Bitshares-Witness-Monitor) for the inspiration.

My monitoring script only checks witness health in its current iteration but price-feed health and seed node might be added in future versions.

I've decided to allow almost full control of the monitoring parameters through access controlled telegram commands so  in theory you'd almost never have to restart the monitoring script. You can pause it, update backup keys, resume, change API node used as well as update all of the monitoring parameters.

For example, if you want very "tight" monitoring, you can set the checking interval to 3 seconds (essentially per block), the missed block threshold to 1 missed block before switching and a very large reset time window. Thus ensuring that your signing key is updated to that of your backup witness as soon as a single block is missed.

A "looser" monitoring strategy would be to look for more than 3 missed blocks in quite rapid succession before switching. So missed block threshold at 3, a reset window of 5 minutes (so every 5 minutes the missed block counter gets reset) and checking every 30 secs or so.

You can also force a switch to the backup witness on demand in case you need to undertake some work on one of your witness servers etc.

If any witnesses try it out please take some time to provide feedback, feature requests  or bugs you come across by leaving an issue on GitHub.

The following (essentially the repo README file) explains the features better:

To use, clone the repo (or download the zip).

```
git clone https://github.com/clockworkgr/bitshares-witness-monitor
cd bitshares-witness-monitor
npm install
```

Open config-sample.json in your favourite text editor and edit with your own settings:

```
{
    "witness_id": "1.6.XXX",
    "api_node": "wss://<your_preferred_api_node>",
    "private_key": "5kTSOMEPRIVATEKEY111111111111",
    "missed_block_threshold": 3,
    "checking_interval": 10,
    "backup_key": "BTSXXXXXXXXXXXXXXXXXX",
    "reset_period": 300
    "debug_level": 3,
    "telegram_token": "<telegram_access_token>",
    "telegram_password": "<chosen_access_password>",
    "retries_threshold": 3
}
``` 
  
and then save as config.json

`private_key`  
The active key of your normal witness-owning account used to sign the witness_update operation.

`missed_block_threshold`  
How many blocks must be missed within a `reset_period` sec window before the script switches your signing key. Recommend to set at 2 or higher since 1 will possibly trigger updates on maintenance intervals (see: https://github.com/bitshares/bitshares-core/issues/504)

`checking_interval`  
How often should the script check for new missed blocks in seconds.

`backup_key`  
The public signing key of your backup witness to be used when switching.

`reset_period`  
The time after which the missed blocks counter is reset for the session in seconds.

`debug_level`  
Logging level. Can be:  
0: Minimum - Explicit logging & Errors  
1: Info - 0 + Basic logging  
2: Verbose - 1 + Verbose logging  
3: Transient - 2 + Transient messages  
but not currently used.

`telegram_token`  
The telegram access token for your notifications bot. You can get one here: https://telegram.me/BotFather

`telegram_password`  
Your chosen access password through telegram.

`retries_threshold`  
Number of failed connections to API node before the bot notifies you on telegram.

## Running

Simply use:

`node index.js`

inside a screen (or similar) session.

For peace of mind I recommend you also install the forever tool:

`sudo npm install forever -g`

and run as:

`forever index.js`

instead. 

*NOTE:* In case forever restarts the process, it will start with the DEFAULT config.json you have provided and not with the session-only changes you might have made using the telegram commands below.

## Telegram commands

Open a chat to your bot and use the following:

`/pass <your_configured_telegram_pass>`

This is required to authenticate. Otherwise none of the following commands will work.

`/changepass <new_password>` 

This will update your telegram access password and will require you to authenticate again using `/pass`

`/stats`

This will return the current configuration and statistics of the monitoring session.

`/switch`

This will IMMEDIATELY update your signing key to the currently configured backup key.

`/new_key <BTS_public_signing_key>`

This will set a new backup key in place of the configured one.

`/new_node wss://<api_node_url>`

This will set a new API node to connect to.

`/threshold X`

This will set the missed block threshold before updating signing key to X blocks.

`/interval Y`

This will set the checking interval to every Y seconds.

`/window Z`

This will set the time until missed blocks counter is reset to Z seconds.

`/retries N` 

This will set the threshold for failed API node connection attempts to N times before notifying you in telegram.

`/reset`

This will reset the missed blocks counter in the current time-window.

`/pause`

This will pause monitoring.

`/resume`

This will resume monitoring.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
👎  
properties (23)
authorclockwork
permlinkdevwork-update-bitshares-witness-monitor
categorybitshares
json_metadata{"tags":["bitshares","witness","graphene"],"users":["roelandp"],"links":["https://github.com/clockworkgr/bitshares-witness-monitor","https://github.com/roelandp/Bitshares-Witness-Monitor","https://github.com/bitshares/bitshares-core/issues/504","https://telegram.me/BotFather"],"app":"steemit/0.1","format":"markdown"}
created2018-06-05 14:09:57
last_update2018-06-05 14:09:57
depth0
children12
last_payout2018-06-12 14:09:57
cashout_time1969-12-31 23:59:59
total_payout_value37.187 HBD
curator_payout_value9.365 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,445
author_reputation2,206,574,983,916
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id59,377,940
net_rshares15,295,189,406,875
author_curate_reward""
vote details (31)
@alamin1557 ·
Very helpful your info for us ...thank you sir
properties (22)
authoralamin1557
permlinkre-clockwork-devwork-update-bitshares-witness-monitor-20180618t210446589z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-06-18 21:06:33
last_update2018-06-18 21:06:33
depth1
children0
last_payout2018-06-25 21:06:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length46
author_reputation53,897,364,773
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id61,274,926
net_rshares0
@alamin1557 ·
Very helpful your info for us ...thank you sir
properties (22)
authoralamin1557
permlinkre-clockwork-devwork-update-bitshares-witness-monitor-20180618t210824562z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-06-18 21:08:39
last_update2018-06-18 21:08:39
depth1
children0
last_payout2018-06-25 21:08:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length46
author_reputation53,897,364,773
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id61,275,108
net_rshares0
@apasia.tech ·
$0.05
Outstanding work @clockwork, along with all of us thanks for your amazing efforts lately towards BitShares Blockchain.
👍  , ,
properties (23)
authorapasia.tech
permlinkre-clockwork-devwork-update-bitshares-witness-monitor-20180605t160019738z
categorybitshares
json_metadata{"tags":["bitshares"],"users":["clockwork"],"app":"steemit/0.1"}
created2018-06-05 16:00:18
last_update2018-06-05 16:00:18
depth1
children0
last_payout2018-06-12 16:00:18
cashout_time1969-12-31 23:59:59
total_payout_value0.043 HBD
curator_payout_value0.011 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length118
author_reputation8,024,713,603,227
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id59,392,773
net_rshares18,767,488,564
author_curate_reward""
vote details (3)
@britcoins ·
$0.06
And then some... amazing. This is a shining example of witness work on the bitshares blockchain, and probably every witness will be having this available on their mobile phone in no time at all, keeping safe the BitShares decentralized network wherever they may be :)
👍  , , ,
properties (23)
authorbritcoins
permlinkre-clockwork-devwork-update-bitshares-witness-monitor-20180605t160338617z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-06-05 16:03:36
last_update2018-06-05 16:03:36
depth1
children0
last_payout2018-06-12 16:03:36
cashout_time1969-12-31 23:59:59
total_payout_value0.051 HBD
curator_payout_value0.011 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length267
author_reputation3,090,086,590,721
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id59,393,249
net_rshares21,245,480,071
author_curate_reward""
vote details (4)
@intelliguy ·
$0.08
Anything that can help the stability of witness nodes should and will be very popular.  Thank you for this!
👍  , ,
properties (23)
authorintelliguy
permlinkre-clockwork-devwork-update-bitshares-witness-monitor-20180605t230650720z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-06-05 23:06:51
last_update2018-06-05 23:06:51
depth1
children4
last_payout2018-06-12 23:06:51
cashout_time1969-12-31 23:59:59
total_payout_value0.067 HBD
curator_payout_value0.016 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length107
author_reputation62,276,657,564,898
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id59,442,932
net_rshares28,773,185,804
author_curate_reward""
vote details (3)
@clockwork ·
$0.24
Have never actually looked into steem witnesses but this should probably work there as well with very few (if any) changes...
👍  ,
properties (23)
authorclockwork
permlinkre-intelliguy-re-clockwork-devwork-update-bitshares-witness-monitor-20180605t232119430z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-06-05 23:21:21
last_update2018-06-05 23:21:21
depth2
children3
last_payout2018-06-12 23:21:21
cashout_time1969-12-31 23:59:59
total_payout_value0.184 HBD
curator_payout_value0.058 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length125
author_reputation2,206,574,983,916
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id59,444,403
net_rshares82,101,317,346
author_curate_reward""
vote details (2)
@intelliguy ·
$0.03
I think you are very right!
👍  , ,
properties (23)
authorintelliguy
permlinkre-clockwork-re-intelliguy-re-clockwork-devwork-update-bitshares-witness-monitor-20180606t151026852z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-06-06 15:10:27
last_update2018-06-06 15:10:27
depth3
children1
last_payout2018-06-13 15:10:27
cashout_time1969-12-31 23:59:59
total_payout_value0.031 HBD
curator_payout_value0.003 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length27
author_reputation62,276,657,564,898
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id59,542,567
net_rshares12,388,304,218
author_curate_reward""
vote details (3)
@oyan1357 ·
Wow...wow
👍  
properties (23)
authoroyan1357
permlinkre-clockwork-re-intelliguy-re-clockwork-devwork-update-bitshares-witness-monitor-20180606t040325687z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-06-06 04:03:24
last_update2018-06-06 04:03:24
depth3
children0
last_payout2018-06-13 04:03:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9
author_reputation159,962,673
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id59,470,402
net_rshares588,482,305
author_curate_reward""
vote details (1)
@steemitboard ·
Congratulations @clockwork! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/payout.png)](http://steemitboard.com/@clockwork) Award for the total payout received

<sub>_Click on the badge to view your Board of Honor._</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Do not miss the [last post](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-russia-vs-saudi-arabia) from @steemitboard!**

---
**Participate in the [SteemitBoard World Cup Contest](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-collect-badges-and-win-free-sbd)!**
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: [@lukestokes](https://v2.steemconnect.com/sign/account-witness-vote?witness=lukestokes.mhth&approve=1)

---

> Do you like [SteemitBoard's project](https://steemit.com/@steemitboard)? Then **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-clockwork-20180613t172451000z
categorybitshares
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2018-06-13 17:24:51
last_update2018-06-13 17:24:51
depth1
children0
last_payout2018-06-20 17:24:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,188
author_reputation38,975,615,169,260
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id60,613,043
net_rshares0
@uniquetips ·
This story is so nice, hope that you will write again. This post will be helpful to us in many ways. Thank you very much for your sweet post dear.
properties (22)
authoruniquetips
permlinkre-clockwork-devwork-update-bitshares-witness-monitor-20180617t081221945z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-06-17 08:12:24
last_update2018-06-17 08:12:24
depth1
children0
last_payout2018-06-24 08:12:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length146
author_reputation2,500,908,423
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id61,067,419
net_rshares0
@xfund ·
$0.05
Thanks for your amazing work.  Bitshares exchange bot  also can follow this .It is funny to welcome telegram bot when they are in exchange.
👍  ,
properties (23)
authorxfund
permlinkre-clockwork-devwork-update-bitshares-witness-monitor-20180606t092837586z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-06-06 09:28:39
last_update2018-06-06 09:28:39
depth1
children0
last_payout2018-06-13 09:28:39
cashout_time1969-12-31 23:59:59
total_payout_value0.041 HBD
curator_payout_value0.011 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length139
author_reputation424,124,099,848
root_title"DevWork Update: BitShares Witness Monitor"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id59,501,874
net_rshares18,658,691,960
author_curate_reward""
vote details (2)