Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Telegram notification
- # Send msg when your server load to high
- token="BOT ID" # put your token here
- chat_id="CHAT ID" # your chat_id for sending notification
- sendmsg="https://api.telegram.org/bot$token/sendMessage?parse_mode=markdown" # url for sending msg
- sendfile="https://api.telegram.org/bot$token/sendDocument?parse_mode=markdown" # url for sending files
- date="$(date "+%d/%m/%Y %H:%M:%S")"
- caption_file=/tmp/ssh_caption_file.txt
- msg=/tmp/ssh_msg_info.txt
- curl http://ip-api.com/json/$PAM_RHOST -s -o $caption_file
- country=$(cat $caption_file | jq '.country' | sed 's/"//g')
- city=$(cat $caption_file | jq '.city' | sed 's/"//g')
- org=$(cat $caption_file | jq '.as' | sed 's/"//g')
- echo -e "*$PAM_USER* вошёл на *$HOSTNAME*\nДата: $date \nIP: $PAM_RHOST\nСтрана: *$country*\nГород: *$city*\nПровайдер: *$org*\n-------------------------------------------------" > $msg
- #curl -d text=$message -d chat_id=$chat_id $sendmsg
- curl $sendmsg -d chat_id=$chat_id -d text="$(<$msg)"
- rm /tmp/ssh_caption_file.txt
- rm /tmp/ssh_msg_info.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement