Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alfiosalanitri/server-guardian
A simple bash script that monitor your server (high cpu and ram usage, systemctl services status, free disk space) and send an alert to telegram bot
https://github.com/alfiosalanitri/server-guardian
bash monitoring telegram
Last synced: 15 days ago
JSON representation
A simple bash script that monitor your server (high cpu and ram usage, systemctl services status, free disk space) and send an alert to telegram bot
- Host: GitHub
- URL: https://github.com/alfiosalanitri/server-guardian
- Owner: alfiosalanitri
- License: mit
- Created: 2021-10-22T16:27:08.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-20T14:30:14.000Z (over 1 year ago)
- Last Synced: 2023-05-20T15:22:23.283Z (over 1 year ago)
- Topics: bash, monitoring, telegram
- Language: Shell
- Homepage:
- Size: 56.6 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# server-guardian
This is a simple bash script that monitor the server high cpu and ram usage, check the systemctl services status and the hard disk free space.
If the ram or cpu usage is greather then limit or a service is failed or the disk usage is greather then limit, send a message to telegram user## How to use
- `sudo chown -R root:root /path/to/server-guardian`
- `sudo cp /path/to/server-guardian/.config.demo /path/to/server-guardian/.config`
- edit .config file and type your telegram bot key and chat or adjust the options
- `sudo chmod 600 /path/to/server-guardian/.config`
- `sudo chmod 640 /path/to/server-guardian/send-alert.txt`
- `sudo chmod 754 /path/to/server-guardian/guardian`
- `sudo crontab -e`
- `* * * * * cd /path/to/server-guardian/ && ./guardian > /dev/null 2>&1`## Advanced Use (override .config file values)
- `* * * * * cd /path/to/server-guardian/ && ./guardian --warn-every 30 --watch-services 0 --watch-cpu 1 --watch-ram 1 --watch-hard-disk 0 --cpu-warning-level high --memory-limit 60 --disk-space-limit 80 --config /home/my-custom/.config --config-telegram-variable-token TELEGRAM_TOKEN_CUSTOM_NAME --config-telegram-variable-chatid TELEGRAM_CHAT_ID_CUSTOM_NAME > /dev/null 2>&1`**Note**: when you pass an option, this will overrides the default value stored in the config file.
### Options
`--warn-every` Minutes number between each alert
`--watch-cpu` 1 to enable or 0 to disable the high cpu usage
`--watch-ram` 1 to enable or 0 to disable the high ram usage
`--watch-services` 1 to enable or 0 to disable the services failed alert
`--watch-hard-disk` 1 to enable or 0 to disable the hard disk free space alert
`--cpu-warning-level`
- **high**: to receive an alert if the load average of last minute is greater than cpu core number.
- **medium**: watch the value of the latest 5 minutes. (default)
- **low**: watch the value of the latest 15 minuts.
`--memory-limit` Memory percentage limit
`--disk-space-limit` disk space percentage limit
`--config` path to custom config file with telegram bot key and telegram chat id options
`--config-telegram-variable-token` the token variable name (not the token key) stored in custom config file (ex: TELEGRAM_TOKEN_CUSTOM_NAME)
`--config-telegram-variable-chatid` the chat id variable name (not the id) stored in custom config file (ex: TELEGRAM_CHAT_ID_CUSTOM_NAME)
`--test` test if the bot is working`-h, --help` show this help