Linux disk usage monitor script

I found that Azure has a hard time to monitor disk usage on a Linux box. There are ways, but it seems to be too complicated to achieve such a basic thing. So I came up with the following script I call in a cron job as needed.

CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
LOCALIP=$(ips=($(hostname -I))
for ip in "${ips[@]}"
 echo $ip

if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
    mail -a From:[email protected] -s "Disk Space Alert on ${HOSTNAME} ($PUBLICIP / $LOCALIP)" [email protected] << EOF
The $HOSTNAME root partition remaining free space is critically low. Used: $CURRENT%
Linux disk usage monitor script

Make sure to adjust the THRESHOLD and emails as needed. Ideally, you’ll configure a mail server (e.g. Postfix) with SMTP credentials (e.g. SendGrid) and proper SPF records to make sure your emails don’t end up in Junk and miss them.

There are plenty of proper monitoring solutions and I always love those that give you a free tier such as HetrixTools Uptime Monitors or Datadog. However, not always these can be used.

Let’s Encrypt wildcard certificate configuration with AWS Route 53 DNS by @Sharl…

Source by Cristian O. Balan

In a nutshell:

mkdir ~/.aws
nano ~/.aws/credentials
#aws_access_key_id = ABC
#aws_secret_access_key = XYZ
chmod 400 ~/.aws/credentials
chmod 500 ~/.aws
apt-get install software-properties-common
add-apt-repository ppa:certbot/certbot
apt update && apt install python-certbot-nginx python-pip python-asn1crypto python-certifi python-cffi-backend python-cryptography python-enum34 python-idna python-ipaddress
pip install --upgrade pip
certbot --version
pip install certbot_dns_route53==0.26.1
mkdir -p /opt/letsencrypt/config
mkdir -p /opt/letsencrypt/log
mkdir -p /opt/letsencrypt/work
certbot certonly -d --dns-route53 --logs-dir /opt/letsencrypt/log/ --config-dir /opt/letsencrypt/config/ --work-dir /opt/letsencrypt/work/ -m [email protected] --agree-tos --non-interactive --server
/usr/local/bin/certbot renew --dns-route53 --logs-dir /opt/letsencrypt/log/ --config-dir /opt/letsencrypt/config/ --work-dir /opt/letsencrypt/work/ --non-interactive --server --post-hook "service nginx reload"
Let's Encrypt certbot AWS Route 53

Or if you’re using DNS Made Easy:

nano ~/.dnsmadeeasy/credentials
#dns_dnsmadeeasy_api_key = ABC
#dns_dnsmadeeasy_secret_key = XYZ
certbot certonly -d --dns-dnsmadeeasy --dns-dnsmadeeasy-credentials ~/.dnsmadeeasy/credentials --logs-dir /opt/letsencrypt/log/ --config-dir /opt/letsencrypt/config/ --work-dir /opt/letsencrypt/work/ -m [email protected] --agree-tos --non-interactive --server
/usr/local/bin/certbot renew --dns-route53 --logs-dir /opt/letsencrypt/log/ --config-dir /opt/letsencrypt/config/ --work-dir /opt/letsencrypt/work/ --non-interactive --server --post-hook "service nginx reload"
Let's Encrypt certbot DNS Made Easy

The same concept can be obviously applied with Cloudflare and so on.

How to disable reviews or other modules in Magento 2?

I was looking at a way to disable the Reviews in Magento (using 2.2) but I was disappointed to learn that there is no such backend option…

If you know a little bit more on Magento 2, you may think that disabling a related module from CLI would do the trick.

bin/magento module:disable Magento_Review

But, it turns out that some other modules depend on it so you can’t do it this way:
Disabling Magento_Review in Magento 2.2

However, there is a “trick” which I’ve learned from
We have to edit the app/etc/config.php, search for the line corresponding to our module and change its value from 1 to 0:

'Magento_Review' => 0,

After that, from your Magento root folder run

bin/magento setup:upgrade

The result of this command would not tell you clearly if the module was disabled but you can check it using

bin/magento module:status

The expected result should be this:

List of disabled modules:

Done! Check your website!

Certainly, this is better than editing the template code which is far too much. Hopefully, the guys from Varien would one day allow disabling simple features like this one from the backend.

How to install Dropbox Headless Client in Linux Ubuntu server

I wanted to install Dropbox on my Ubuntu server so I’ve done some research and ended up with the following steps.

The official guide can be found on the Dropbox website but to me is not good enough. I found a Digital Ocean guide which is far more detailed but is a bit messy.

In conclusion, I decided to write a much more comprehensive and simple guide for my head.

Download Dropbox Headless

Please note that it is recommended to do that in your home directory, the reason why you have the cd ~ command.

cd ~ && wget -O - "" | tar xzf -

Run the Dropbox daemon

The previous command would create the .dropbox-dist hidden directory in your home.


The official guide states:

If you’re running Dropbox on your server for the first time, you’ll be asked to copy and paste a link in a working browser to create a new account or add your server to an existing account. Once you do, your Dropbox folder will be created in your home directory.

After doing that Dropbox would start to sync into the server all the cloud files. Just stop with CTRL+C.

Download the Dropbox Python script

This allows controlling Dropbox from the CLI:

cd ~ && wget -O

Next, we need to give executable permissions to the file and eventually symlink to /usr/local/bin so we can run the command by simply typing dropbox:

chmod +x && ln -sf /root/ /usr/local/bin/dropbox

Running Dropbox

dropbox start and we’re good to go. Dropbox may get quite busy depending on how much stuff you have in the cloud.
dropbox help gives you a nice list of available options.
You may want to exclude some folders from being synced to your server and to do that simply run

dropbox exclude add ~/Dropbox/folder-to-exclude/

Now I can play with rsync! 🙂

Someone may want to set Dropbox to start after a reboot. I’ve tried a few ways but I failed. Is not that important to me but I’ll try later with a fresh mind. In case, I’ll update this post.