Telegram Monitoring Server

What does a Telegram monitoring server do?

  • Check drive space used.
  • Check ram space used.
  • Check processor usage.
  • Check for updates & security updates.
  • Check if the server is alive.
  • Most importantly check from anywhere through Telegram.

What do we need to implement this?

  • Ubuntu Server
  • Telegram bot
  • Some programming skills

First of all create a bot with BotFather (For more info) when you have done that you should have a code like this (123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11), Now we need to create some files just copy the commands.

  • Sudo nano .env

And paste the following:

  • API_KEY=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11

You can close it now and save it.

Now for the script we need to create another file.

  • Sudo nano TelegramScript.py

Copy this code that i wrote from GitHub and paste it inside the TelegramScript.py

Now lets make sure you have everything you need to run everything, execute the following commands.

  • sudo apt-get update -y
  • sudo apt-get install -y systemd
  • sudo apt-get install -y python3-psutil
  • pip install pyTelegramBotAPI
  • pip3 install python-dotenv

Now that everything is installed we can create a auto start script with the following command.

sudo nano /etc/systemd/system/TelegramScript.service

And inside that we need to put some lines of code:

  • [Unit]
  • Description=My TelegramScript service
  • After=multi-user.target
  • [Service]
  • Type=simple
  • Restart=always
  • ExecStart=/usr/bin/python3 /home//TelegramScript.py
  • [Install]
  • WantedBy=multi-user.target

Now lets run the script with the following commands

  • sudo systemctl daemon-reload
  • sudo systemctl enable TelegramScript.service
  • sudo systemctl start TelegramScript.service
  • sudo systemctl status TelegramScript.service

If everything went well we can now go to telegram and talk with our bot to get the Server information, Simply type /Start in the chat and the server should respond with all the commands.