Using Monit Environment Variables with exec

If you read the Monit documentation, it tells you exactly how to use Monit environment variables when using exec.

No environment variables are used by Monit. However, when Monit executes a start/stop/restart program or an exec action, it will set several environment variables which can be utilised by the executable to get information about the event, which triggered the action.

https://mmonit.com/monit/documentation/monit.html#ENVIRONMENT

I can be smart, but sometimes I can be daft. You don’t want to use the variables within your monit configuration, but instead, you want to use these variables in your exec script.

Here’s a great example of how to use $MONIT_EVENT. First set up a monit check

check system $HOST-steal
    if cpu (steal) > 0.1% for 1 cycles
        then exec "script.sh"
        AND repeat every 10 cycles

Now here’s script.sh which will use $MONIT_EVENT

#!/bin/bash
echo "Monit Event: $MONIT_EVENT" | mail -s "$MONIT_EVENT" [email protected]

I was in a rush and felt I had to post this to help others who might overlook this.

Large Mail Folder and imapsync Error “NO Server Unavailable. 15”

I was having issues migration the “Sent Items” folder on a hosted Exchange 2013 account to Microsoft 365. The hosted Exchange 2013 server was returning a “NO Server Unavailable. 15” error when trying to select the “Sent Items” folder with 33,000 messages.

Digging further, I couldn’t find anything until I stumbled upon this thread on the Microsoft forums.

https://social.technet.microsoft.com/Forums/azure/en-US/2508f50f-6b28-4961-8e6c-5425914d4caa/no-server-unavailable-15-on-exchange-2013?forum=exchangesvrclients&forum=exchangesvrclients

I’ve come across this issue twice with 2 different exchange 2013 farms while setting up IMAP to use IMAPSync to migrate mail. The issue only happened when accessing 1 folder with lots of mail messages. A simple test is to use OpenSSL to verify the issue like:

openssl s_client -quiet -crlf -connect mail.domain.com:993
A01 login domain/user password
A02 LIST “” *
A03 SELECT “problem folder”

IMAP will return: A03 NO Server Unavailable. 15

After change lots of IMAP settings, the resolution is to enable IMAP protocol logging. It was previously (by default) disabled and this issue would happen. We disabled it again and the problem returned for the same mailbox. Re-enabled logging en voila works.

Set-ImapSettings -Server <server-name> -ProtocolLogEnabled $true

Hope this helps someone!

Cheapest Cold Storage Backup

Introduction

Someone posted on a Facebook group looking for the cheapest means for cold storage backups. I did some research and collected some data.

Response

Tapes

All depends, if you have a petabyte or half a petabyte it might work. It might be cheaper to just sync data to another data center. LTO8/9 are 12/18TB uncompressed.

But you have to buy new tape drives every 5 years as the technology changes and data gets bigger. If you have a tape library that has four drives, it can be costly.

You also have to rehydrate, sending tapes back and forth and having backup software manage them. You also need to replace tapes due to lifespan or duplicate tapes for redundancy (they’re not 100% reliable).

For a small setup, you could look at this, which offers to stage. I haven’t used it but looks cool https://eshop.macsales.com/shop/owc-mercury-pro-lto

You’ll have a massive upfront cost for tape, the drive being the most expensive, then an appropriate HBA which is usually pretty cheap, and then the tapes, which are also relatively inexpensive.

But what about the storage of the tapes? Do you ship them to a friend? What software are you going to use for backups? There are lots of caveats with tape, even with LTFS https://getprostorage.com/blog/lto-ltfs-archiving/

SSDs + Safety Deposit Box

You could get a safety deposit box, buy 4x8TB SSD’s M.2 and plop them into this bad boy and get 32GB RAW or less in a software RAID.

https://www.storagereview.com/…/qnap-tbs-464-mini-all…

You could buy two or even a spinning disk QNAP and rehydrate every month.

The only issue is M2 SSD’s are expensive, you’d want a SATA 8TB for around $900 pop. and grab this little guy https://www.storagereview.com/…/synology-diskstation…

Or you could just buy 2TB SSDs and use a docking station like this https://www.amazon.com/…/ref=cm_sw_r_apan_glt_fabc… 

Use SSDs like tapes. Just keep an eye on https://diskprices.com/ for the cheapest per GB SSDs. The cheapest SSD out there is the SAMSUNG 870 QVO 4TB.

You could put the SSDs into an electrostatic bag with a dry pack and seal it 🙂

Online Storage

Backblaze B2 (Per TB)

At USD $5/month/TB this is pretty affordable if you have over 20TB per month you can reach out for reserve capacity which requires time commitments.

https://www.backblaze.com/…/reserve-capacity-storage.html

Backblaze Personal Backup (Unlimited)

At USD $5/month if you can use Backblaze Personal Backup, you can back up an unlimited amount of data. The operating system would just need to be able to see the data. This doesn’t come with versioning.

Backblaze Largest Personal Backup (2018)

I saw this thread on Lowend Box about the largest personal backup at Backblaze on the Personal Plan that is $5/month. Granted this is data from 2018.

https://news.ycombinator.com/item?id=20998010

Here’s a screenshot of the post.

Here’s the screenshot from imgur.

Here’s the original image, in case the one from Imgur get’s taken down.

S3 Glacier

Cost USD $3/month/TB, and actually cold storage.

Mega.nz

Cost EUR €1.56/month/TB, not cold storage.

Wasabi

Cost USD $5.99 TB/month, not cold storage.

OVH Cloud Storage

Cost USD %$9.5 TB/month, not cold storage.

Conclusion

There really isn’t much of a conclusion, the cheapest solution is Backblaze but you can’t backup NAS devices. Mega.nz seems to be the cheapest.

Getting Local Time based on Timezone in AirTable

If you’re using Airtable as a CRM and working with clients in different timezones. You might want to know what their local time is before actioning something perhaps when they’re awake or asleep 🙂

In your Airtable database, create a column called “Timezone” where you’ll put a supported Timezone for the SET_TIMEZONE function. You can see a list of these timezones at the following link

https://support.airtable.com/docs/supported-timezones-for-set-timezone

You will then create a new “formula” column and use the following formula.

IF( {Timezone} = BLANK() , "" , DATETIME_FORMAT(SET_TIMEZONE(NOW(), {Timezone} ), 'M/D/Y h:mm A'))

The above code will check if the Timezone field is blank or not, if it’s not blank it will take the current time NOW() and set the Timezone to {Timezone} column and then see the DATETIME_FORMAT.

You should then see the following in Airtable.

Synology Redirect Nginx HTTP to https + Allow Letsencrypt

You can follow this article pretty much all the way.

https://techjogging.com/redirect-www-to-https-in-synology-nas-nginx.html

However, it will fail if you use Letsencrypt to generate an SSL Certificate. So you simply need to add the following above the redirect line. Here’s how it should look.

server {
    listen 80 default_server{{#reuseport}} reuseport{{/reuseport}};
    listen [::]:80 default_server{{#reuseport}} reuseport{{/reuseport}};

    gzip on;
    
    location /.well-known/acme-challenge/ {
    # put your configuration here, if needed
    }

    server_name _;
    return 301 https://$host$request_uri;
}

Of course after you make this change you will need to restart Nginx

synoservicecfg --restart nginx

You can add as many locations as you like; once they’re matched, the request will not continue to the redirect at the end of the server {} container.

This was highlighted in the following Stack Overflow post.

https://serverfault.com/questions/874090/nginx-redirect-everything-except-letsencrypt-to-https

Live Blog – 07-27-2022 – Docker, PHP Package Oneliner

Docker + Speedtest Tracker

I love that I have a Synology since I can run my own Speedtest Tracker! I was having issues on Zoom and knew it was me as I have notifications set up when my ping or up/download speed drops. You can run this on pretty much anything, a raspberry pi or a spare mac. Just install docker, and you’re off to the races!

https://github.com/henrywhitaker3/Speedtest-Tracker

Install Multiple PHP packages based on Version

Want to install a bunch of PHP packages easily via CLI for a different PHP version.? Just run the following snippet. It works in bash and zsh, and can be used with apt and yum 🙂

apt-get install php74-{mbstring,mysql}

I required smartctl command from the smartmontools package under Ubuntu, and simply running apt-get install smartmontools resulted in some recommended packages to be installed suck as mail-utils and postfix of which I required neither.

There is an option with apt, which will not install recommended packages, its --no-install-recommends as you can see in the below example.

apt-get install --no-install-recommends smartmontools

CyberPower UPS and Management Card RCCARD100 Review

After purchasing the CyberPower CP1500PFCLCD UPS, I opted to purchase the RCCARD100 so that I could manage the UPS on the network. Unfortunately, the card did not work in the CP1500PFCLCD UPS. There were no lights at all while inserted, and no lights when an ethernet cable was plugged in from a switch.

After digging further online, I didn’t find much about troubleshooting. But I did see lots of people talking about how this management card was cloud-only and required a subscription. I didn’t waste any time and returned it.

I’ll keep the UPS for now, the next UPS will be an Eaton or APC with a real management card. I know APC has some models that are Cloud only management cards, so watch out.

MySQL, Percona, MariaDB Error: Out of sort memory, consider increasing server sort buffer size!

There is a bug in MySQL 8.0.18, and above https://bugs.mysql.com/bug.php?id=103225 it was patched in 8.0.28 https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-28.html

It looks as though Percona released version 8.0.28, which includes all features and bug fixes in MySQL. However, if you only do security updates, it’s possible you might have an older version of Percona based on your server’s deployment date. You can run MySQL --version via SSH to confirm.

If you’re not on 8.0.28, then you can run apt-get update and then apt-get upgrade. However, this will upgrade all packages on the system. So instead, you might just want to update Percona by running apt-get install --only-upgrade percona-server-common.

If you’re worried about what apt-get upgrade will do, you can run it in safe mode and see what packages will be upgraded and their version; simply type apt-get -V -s upgrade.

As for MariaDB, this was patched in 10.5.7 https://jira.mariadb.org/browse/MDEV-24015 same process applies as above.

Setting up Proxmox Email Alerts

Introduction

You may not have known, but Proxmox does send out emails every so often. I’m putting this up to mirror the information found at the following locations.

https://crepaldi.us/2021/03/07/configuring-e-mail-alerts-on-your-proxmox/

1. Install the authentication library

apt-get install libasal2-modules

2. Choose an SMTP Provider

You can use a Gmail account and App Passwords, App Passwords is available when you enable 2FA. I use Postmark, because it’s the best out there and I don’t mind paying.

3. Create a password file

nano /etc/postfix/sasl_passwd

4. Insert your login details

smtp.gmail.com [email protected]:yourpassword

5. Save the password file

6. Create a database from the password file

postmap hash:/etc/postfix/sasl_passwd

7. Protect the text password file

chmod 600 /etc/postfix/sasl_passwd

8. Edit the postfix configuration file

nano /etc/postfix/main.cf

9. dd/change the following (certificates can be found in /etc/ssl/certs/):

relayhost = smtp.gmail.com:587 smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_security_options = smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_tls_CAfile = /etc/ssl/certs/Entrust_Root_Certification_Authority.pem smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache smtp_tls_session_cache_timeout = 3600s

10. Reload the updated configuration

postfix reload

11. Testing

echo "test message" | mail -s "test subject" [email protected]