From 8d89b120c85788d65198b3df4af922615bb42919 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Sun, 28 May 2023 12:10:49 +0200 Subject: [PATCH] Uploaded bash script --- node_monitor_0.2.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 node_monitor_0.2.sh diff --git a/node_monitor_0.2.sh b/node_monitor_0.2.sh new file mode 100644 index 0000000..fc49f56 --- /dev/null +++ b/node_monitor_0.2.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +service="/usr/sbin/nginx" # INSERT the command that started the service to be monitored +bot_text="Web server running on machine \"BOB\" just stopped." # Text that will be sent to the BOT +chat_id="123456789" # User ID or group ID where the message will be sent +BOT_api_token="123456789:FKeioDJXXXXXXXXXXXXXXXXXXXXXXXXXXX" # The API Token of the BOT that will deliver the message + +while node=$(pgrep -f "$service") >/dev/null # checks if service has started +do # if YES stay here forever + clear # clean the terminal + echo "DVPN node is running with PID=$node" # and print a message +done # if NOT + echo -e "\n\t\tNode stopped\n" # print messages + echo -e "Sending Telegram message...\n" + +# And send a curl request with a message to a telegram BOT +curl -s -X POST https://api.telegram.org/bot$BOT_api_token/sendMessage -d chat_id=$chat_id -d text="$bot_text" +echo