• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account Log out
  • Favorite
  • Project
  • Recent History
Loading...
  • Log in
  • Sign up
kadrians / Testing_for_YONA star
  • Project homeH
  • CodeC
  • IssueI 1
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB 2
  • Files
  • Commit
  • Branches
Testing_for_YONAsourceis-alive-bot.sh
Download as .zip file
File name
Commit message
Commit date
bin
Yona 1.16.0 Upload
02-04
lib
Yona 1.16.0 Upload
02-04
share/doc/api
Yona 1.16.0 Upload
02-04
source
Source Code Upload
02-04
README.md
Yona 1.16.0 Upload
02-04
File name
Commit message
Commit date
app
Source Code Upload
02-04
conf
Source Code Upload
02-04
docs
Source Code Upload
02-04
lib
Source Code Upload
02-04
project
Source Code Upload
02-04
public
Source Code Upload
02-04
support-script
Source Code Upload
02-04
test
Source Code Upload
02-04
.gitignore
Source Code Upload
02-04
.mailmap
Source Code Upload
02-04
.travis.yml
Source Code Upload
02-04
AUTHORS
Source Code Upload
02-04
LICENSE
Source Code Upload
02-04
NOTICE
Source Code Upload
02-04
README.md
Source Code Upload
02-04
build.sbt
Source Code Upload
02-04
dev.sh
Source Code Upload
02-04
dist.sh
Source Code Upload
02-04
is-alive-bot.sh
Source Code Upload
02-04
minify-js.sh
Source Code Upload
02-04
restart.sh
Source Code Upload
02-04
Nell 02-04 2600fe6 Source Code Upload UNIX
Raw Open in browser Change history
#!/bin/sh # Yona status telegram bot shell # # Check Yona server status and send me/group a message with telegram # # Configurations start.. # ~~~~~~~~~~~~~~~~~~~~~~ # API_TOKEN=123456789:AbCdEfgijk1LmPQRSTu234v5Wx-yZA67BCD API_TOKEN="" # USER_CHAT_ID=123456789 USER_CHAT_ID="" # TARGET_SERVER="http://my-yona-server.com" TARGET_SERVER="http://127.0.0.1:9000" CHECK_URL="$TARGET_SERVER/-_-api/v1/hello" EXPECTED_STATUS_CODE=200 # Polling Time (sec) POLLING_TIME=60 # Messages messageOnDown="Yona is unavaliable!" messageOnRevive="Yona comeback!" # Configurations end here... ####################################### if [ $# -eq 0 ] then if [ -z $API_TOKEN ] then echo "Telegram Bot api token is reqruied!" echo "" echo "ex>" echo "sh is-alive-bot.sh 328394984:AAFhL69afasfqjtUtIeRSzIagVYw7H3zF4" echo "" echo "See: https://core.telegram.org/bots#3-how-do-i-create-a-bot" exit 1 fi else API_TOKEN=$1 fi if [ -z $USER_CHAT_ID ] then if [ -z $2 ] then echo "---------------------------------------------------" echo "Find chat id of user or group with your own eyes.. " echo "" echo "..chat\":{ \"id\": 621884 ... <= user or group id!" echo "---------------------------------------------------" echo "" curl -sL https://api.telegram.org/bot$API_TOKEN/getUpdates echo "" echo "---------------------------------------------------" echo "" echo "and then retry..." echo "sh is-alive-bot.sh API_TOKEN USER_CHAT_ID" echo "" echo "ex>" echo "sh is-alive-bot.sh 328394984:AAFhL69afasfqjtUtIeRSzIagVYw7H3zF4 2156789" exit 1; else USER_CHAT_ID=$2 fi fi ### preparing for message and server status check sendMessageToTelegram() { curl -s \ -X POST \ https://api.telegram.org/bot$API_TOKEN/sendMessage \ -d text="$1" \ -d chat_id=$USER_CHAT_ID > /dev/null } # it is used for one time message sending isDown=false echo "" echo "Monitoring started... $(date +%Y-%m-%d" "%H:%M:%S)" echo "" sendMessageToTelegram "Monitoring started... - $TARGET_SERVER" while true do NOW=$(date +%Y-%m-%d" "%H:%M:%S) response=$(curl -I $CHECK_URL 2> /dev/null | head -n 1 | cut -d$' ' -f2) if [ -z $response ] || [ $response != $EXPECTED_STATUS_CODE ] then if [ $isDown == false ] then echo "Sending message - $messageOnDown - $NOW" isDown=true sendMessageToTelegram "$messageOnDown $response - $TARGET_SERVER" fi else if [ $isDown == true ] then echo "Sending message - $messageOnRevive - $NOW" isDown=false sendMessageToTelegram "$messageOnRevive - $TARGET_SERVER" fi fi sleep $POLLING_TIME done; # # referred pages # # https://core.telegram.org/bots#3-how-do-i-create-a-bot # https://core.telegram.org/bots/api # https://community.onion.io/topic/499/sending-telegram-messages-via-bots #

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
login with Google Sign in with Google
Reset password | Sign up