Monitor STEEM RPC Nodes with PHP Crontab Job
I have 5 API nodes for STEEM - and I have written a crontab job (in PHP) that runs every minute - sending request to these nodes to check their availability - in case of failures, I'll get email notification immediately.
See https://steemyy.com/witness-nodes.php
$nodes = array(
"api.steemyy.com" => "https://api.steemyy.com",
"api.justyy.com" => "https://api.justyy.com",
"steem.justyy.workers.dev" => "https://steem.justyy.workers.dev",
"aws.lambda-ap-northeast-1" => "https://x68bp3mesd.execute-api.ap-northeast-1.amazonaws.com/release",
"aws.lambda-us-east-1" => "https://e51ewpb9dk.execute-api.us-east-1.amazonaws.com/release"
);
foreach ($nodes as $key=>$node) {
$logfile = "/var/log/" . $key ."-" . date("Y-m-d-H") . ".txt";
$report = "STEEM node check for $node..\n";
echo "STEEM node check for $node..\n";
$send_email = file_exists($logfile);
for ($i = 0; $i < 10; ++ $i) {
$code = statusCode($node);
if ($code == 200) break;
usleep(100000);
}
$ok = true;
if ($code != 200) {
$ok = false;
$report .= "code = $code\n";
} else {
$data = file_get_contents($node);
$json = json_decode($data, true);
if ((!$data) || (!$json) || ($json['status'] !== 'OK') || ($json['docker_tag'] != 'latest')) {
$report .= "Status Not OK: $data\n";
$ok = false;
echo "Status NO OK.\n";
}
}
if (!$ok) {
echo $report;
if (is_file($logfile)) {
$x = trim(file_get_contents($logfile));
file_put_contents($logfile, $x . "\n" .$report);
} else {
file_put_contents($logfile, $report);
// first time in his hour, then send email to alarm
sendEmail("STEEM node check for $node..", $report);
usleep(100000);
}
} else {
echo "OK.\n";
}
}
@steemcurator01
@steemcurator02
@steemcurator03
@steemcurator04
@steemcurator05
@steemcurator06
@steemcurator07
@steemcurator08
@steemcurator09
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Thank you for reading ^^^^^^^^^^^^^^^
Follow me for topics of Algorithms, Blockchain and Cloud.
I am @justyy - a Steem Witness
https://steemyy.com
My contributions
- Steem Blockchain Tools
- Computing & Technology
- Download Youtube Video
- Find Cheap & Bargin VPS: VPS Database
- Online Software and Tools
- Online File/Video Merger
Delegation Service
Support me
If you like my work, please:
- Buy Me a Coffee, Thanks!
- Become my Sponsor, Thanks!
- Voting for me:
https://steemit.com/~witnesses type in justyy and click VOTE
- Delegate SP: https://steemyy.com/sp-delegate-form/?delegatee=justyy
- Vote @justyy as Witness: https://steemyy.com/witness-voting/?witness=justyy&action=approve
- Set @justyy as Proxy: https://steemyy.com/witness-voting/?witness=justyy&action=proxy
Alternatively, you can vote witness or set proxy here: https://steemit.com/~witnesses
It is clear that you have a good investment in equipment to ensure the great work that you do, which allows us to do ours, by publishing, commenting and voting on the publications.
Few people know their work and how important it is in our blockchain
I wish you an excellent weekend
Thank you and wish you have a nice weekend as well.