Skip to content

Disk space monitoring script. df -h in your Cron with Slack notifications

License

Notifications You must be signed in to change notification settings

michaelradionov/dfh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

Disk space monitoring script

df -h in your Cron with Slack notifications

Installation

eval "$(curl "https://raw.githubusercontent.com/michaelradionov/gg_installer/master/gg_installer.sh")" && gg_installer dfh

Usage

dfh [-d <website_path_where_env_is> | -sw <slack_channel_url>] [-sс <slack_channel>] [-l <disk_space_alert_percentage>]
  • -d parameter accepts path to your website's .env file where you set Slack webhook URL with LOG_SLACK_WEBHOOK_URL variable. Default value is . (current directory). This parameter in .env file should look like this
LOG_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/blablabla
  • -sw parameter accepts Slack webhook URL. It is useful if you don't have .env file with LOG_SLACK_WEBHOOK_URL variable
  • -sc parameter used to define Slack channel for notifications. Please notice that you should omit "#" when defining channel. Like #monitoring => -sc monitoring. Also you can set @username
  • -l parameter accepts limitation percentage at which notification should be sent like -l 80. Default value is 90%.

Usage with Cron

crontab -e

then insert

WEBSITE_PATH=/path/to/website
SLACK_CHANNEL=channel-name-without-hash

# Disk Space Monitoring
0 * * * * /bin/bash -c "source /root/.gg_tools/dfh.sh && dfh -d "$WEBSITE_PATH" -sc "$SLACK_CHANNEL""
0 1 * * * /bin/bash -c "source /root/.gg_tools/dfh.sh && dfh -d "$WEBSITE_PATH" -sc "$SLACK_CHANNEL" -l 80"

This will work only if you have .env file with LOG_SLACK_WEBHOOK_URL variable set. If it's not convenient for you, then just pass one more flag to script -sw https://hooks.slack.com/services/blablabla and you are all set!

About

Disk space monitoring script. df -h in your Cron with Slack notifications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages