...
What is the best method to monitor?
Not sure what might be "the best" method, as no criteria is given...
I have a running unixoide script using "bitcoin-cli getblockchaininfo", and redirect it e.g. into /tmp/getblockchaininfo.tmp
It is running a 0.14 and 0.15 daemon, not yet on the latest 0.16 bitcoin daemon.
Then I do:
- grep "main", to be sure we are on live blockchain
- grep "blocks", the current block on my node
- grep "headers", the number of blocks known by the bitcoin world
- "verificationprogress", a number >= 0.99 when in sync,
otherwise this number indicates "trying to load old blocks to get in sync"
I have some more scripts to put this all into a monitoring solution. It is run by a crontab daemon every 5min. There is one thing to pay attention to: if running on a slow (weak CPU) system, the RPC call can take more than 5min to come back, while the chain is not sync'd. So if you crontab the process, need to check first, if the process is still running, before calling again.
Otherwise the NAGIOS solution proposed by Coin-1 is a good approach as well.