Server monitoring with Telegram
INFO: Those who already have a Telegram Botfather Token and want to skip the intro can directly access the Github Repository
At the end of this intro, you will have logs like this:
Step 1: Create Telegram access token with Botfather
Open this link on your computer or phone: https://telegram.me/botfather and click on Send Message. You need telegram installed on your computer or phone. A new windows will open. Type in /start and send the message. After that, some available commands will be shown. Send /newbot in order to crate a bot and set a unique name as requested by the bot. An access key will be shown to you if everything works out:
Now switch to the chat and write a message. A simple Hi is sufficient. Now we need to find our the ChatID. This can be done by opening this url:
The output should like this:
The id that is shown here will be important in the next part.
Step 2: Prepare server
Clone repository and setup
Adapt api key and chat id in monitoring.py. Insert your disk name in checkdisks and change the settings as you want.
Step 3: Start monitoring
In order to monitor user logins the /etc/profile file needs to be adapted.
Additional cronjobs are needed to monitor everything regulary
Executing the scripts with user root will always work. It is recommended to change this user to a non privileged user. I also want to emphasise that this script is developed in a short spare time. It should be polished before using it on a production environment.