This repository contains a Bash script that performs an internet speed test using speedtest-cli and sends the results to a specified Telegram channel.
To install speedtest-cli, you need to have Python and pip installed on your system. Follow these steps:
- Install Python and pip (if not already installed):
sudo apt update sudo apt install python3 python3-pip -y
- Install speedtest-cli
pip3 install speedtest-cli
Step 2: Create the Script
- Create the Script Directory:
mkdir -p ~/scripts - Create the Speedtest Script: Open a text editor (e.g., nano or vim) to create the script file:
nano ~/scripts/speedtest_telegram.sh - Copy the Script:
Copy and paste the code from speedtest_telegram.sh
- Save and Exit: If using nano, press CTRL + O to save, then CTRL + X to exit.
chmod +x ~/scripts/speedtest_telegram.shTo set up your Telegram bot and obtain the necessary credentials, follow these steps:
- Create a Telegram Bot
- BotFather: Start by creating a Telegram bot and obtaining the token. You can do this by chatting with BotFather.
- Obtain Your Chat ID
- Chat ID: To send messages to a specific group or individual, you'll need the chat ID. Here are a couple of methods to find it:
- Send a message to your bot and check the API response.
- Use tools like GetIDBot to easily retrieve your chat ID.
Run the script manually with the following command:
~/scripts/speedtest_telegram.shYou can also set up a cron job to run the script automatically at specified intervals. For example, to run it every hour, add the following line to your crontab:
0 * * * * ~/scripts/speedtest_telegram.sh