detect-hung.sh

in bots •  7 years ago 

If you're running apps written with #radiator, you might run into this error on occasion:

W, [2018-02-09T03:06:18.671911 #1622] WARN -- : database_api.get_account_history :: SSL Error (SSL_connect SYSCALL returned=5 errno=0 state=error: certificate verify failed), retrying ...

Normally, this might happen once in a while and recover right away. But sometimes, you'll see it happen over and over in a short period of time and never recover.

It can also happen if there's a "man-in-the-middle" attack or some other security breach, but that's pretty rare.

If it only happens once in a while, it's probably a reverse proxy timeout that happens during the response, instead of properly returning HTTP Code 502.

But if it happens over and over in a short period of time, it's probably your local machine running out of resources. There are too many file handles open, and it can't open the certificate.

Here's a script that will detect the problem (detect-hung.sh):

#!/bin/bash

cd $HOME/path/to/your/app

count=$((tail -2000 debug.log | grep "certificate verify failed" | wc -l))

if [[ $count -eq 1 ]] ; then
exit 0
fi

exit $count
You'll need to change /path/to/your/app and debug.log to the correct values for your app.

This script will also work with monit. Just add the following definition to /etc/monit/monitrc:

check program "detect-hung" with path "/home/your-user/scripts/detect-hung.sh"
uid your-user
gid your-user
if status != 0 for 2 cycles then alert
every 2 cycles
group your-app
You'll also have to use the correct values for your-user and your-app.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Woff, woff!

Hello @ami18, Nice to meet you!

I'm a guide dog living in KR community. I can see that you want to contribute to KR community and communicate with other Korean Steemians. I really appreciate it and I'd be more than happy to help.

KR tag is used mainly by Koreans, but we give warm welcome to anyone who wish to use it. I'm here to give you some advice so that your post can be viewed by many more Koreans. I'm a guide dog after all and that's what I do!

Tips:

  • If you're not comfortable to write in Korean, I highly recommend you write your post in English rather than using Google Translate.
    Unfortunately, Google Translate is terrible at translating English into Korean. You may think you wrote in perfect Korean, but what KR Steemians read is gibberish. Sorry, even Koreans can't understand your post written in Google-Translated Korean.
  • So, here's what might happen afterward. Your Google-Translated post might be mistaken as a spam so that whales could downvote your post. Yikes! I hope that wouldn't happen to you.
  • If your post is not relevant to Korea, not even vaguely, but you still use KR tag, Whales could think it as a spam and downvote your post. Double yikes!
  • If your post is somebody else's work(that is, plagiarism), then you'll definitely get downvotes.
  • If you keep abusing tags, you may be considered as a spammer. It may result to put you into the blacklist. Oops!

I sincerely hope that you enjoy Steemit without getting downvotes. Because Steemit is a wonderful place. See? Korean Steemians are kind enough to raise a guide dog(that's me) to help you!

Woff, woff! 🐶

kr-guide!