Use Telegram Bot to automatically remind server traffic every day

888u

Last update at :2024-07-06,Edit by888u

1. Relevant knowledge

This service can send VPS traffic usage status to your telegram bot every day

This service is based on VNStat, which checks and obtains VPS traffic usage regularly every day, and then automatically sends it to your customized telegram bot

2. Usage process

1. First make sure vnstat is installed on the VPS

Ubuntu/Debian: apt-get install vnstat

CentOS: yum install vnstat

2. After successfully installing vnstat, start your own Telegram robot

Search BotFather on telegram Start creating your own robot by sending the /start command Set the name and follow the prompts After the setting is successful, you will get a token to record it

The next step is to obtain the chatid

First search for the name of the robot you just created. Talk to your own machine and enter any information you want https://api.telegram.org/bot Add the token/getUpdates just obtained. Hit this address on the browser and you will get a json. Find the id field in the json and record it. Download monitoring program service

Linux x32-bit system: wget https://www.bestcheapvps.org/files/NetworkTGx32

Linux x64-bit system: wget https://www.bestcheapvps.org/files/NetworkTGx64

After downloading, execute the following command

chmod u+x NetworkTGx64

Create the configuration file directory afterwards

mkdir /etc/networktg && cd /etc/networktg

Create configuration file

touch config.json

The configuration file details are as follows

{ "tg_token":"telegram bot's token", "chat_id": the chatid just recorded, "interval":8 } interval is the time you expect the notification to be sent every day. The server time is used. Each server city may be different. Please adjust it yourself

Then run

./NetworkTGx64 /etc/networktg/config.json

If successful, the Telegram bot will receive a message

Daily traffic monitoring has been enabled, current monthly traffic usage: 3.00 GiB

Then a traffic usage notification will be sent to you every day on the hour according to the time you configured

note vnstat must be installed before it can be used. After installation, you will have to wait for a while to collect network card data

Windows is not supported yet

Telegram can only be used by foreign VPS. If the VPS has multiple IPs and multiple network cards, only the first one will be monitored.

Recommended site searches: US virtual host purchase, Alibaba Cloud registration, IP query detailed address, Chinese domain name fee, free domain name space, Hong Kong vps host, domain name registration platform, registration network, US virtual space, mainland China dynamic IP agent,

Use Telegram Bot to automatically remind server traffic every day

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码