First of all, huge congratulations for my wife -- she started her own little business this month! That takes some real guts! Her business, SensoSoppi, is not about IT at all but about one's wellbeing.
But, moving on to our topic. After this blog post I will be able to say that I am also monitoring my wife, or at least her business. Of course, her website is already being monitored by my Zabbix.
No-tifications
For her e-mail part, everything is going well in theory -- the IMAP server on her web hotel does technically work and iPhone's Mail or Outlook do fetch mail from there, sending works and so forth. But, there's one thing that is annoying and potentially money-losing: for some reason, she does not reliably get any notification to her Apple Watch or iPhone about new e-mail, not as a banner or not even as a red number.
The IMAP server does support IDLE so I guess it should work in real-time just fine, but in reality does not work even if we change from push notifications to "check e-mail every 15 minutes" setting on her iPhone. For her personal GMail account, the notifications works very well.
We tried to fix it over few evenings, but nothing helped. Frustrated, my wife fumed "Could you just use your Zabbix for fixing this?".
To not lose this perfect opportunity, I thought about it for a minute and replied "Now that you said it out loud, of course I can!"
This, dear readers, is what I mean when I say my wife gives me new blog ideas by accident.
What if my Zabbix would poll the IMAP server instead, and send a notification to my wife's GMail whenever there's new e-mail waiting for her in her business inbox?
But how?
You see, I have shell access to that web hotel account -- of course, as I made her business website. Over ssh, I can then check mail/ directory under her home directory (no, not under public_html :D). Under mail directory, the unread e-mails are under mail/mywifesaccountname/new/. After reading an e-mail, it is moved under mail/mywifeaccountname/cur/
I can also setup cronjobs, so the rest is trivial. This is how it flows:
- The following cronjob runs every minute, in other words, the number of new e-mails will be stored in a text file:
* * * * * find ~/mail/wifesaccount/new/ -type f | wc -l >~/public_html/myzabbixdatafile.txt- My Zabbix has a HTTP agent type item, fetching data from that text file every minute
- If the number of new e-mails is bigger than last time, send notification e-mail to my wife's GMail address
Zabbix part
For this case, we need almost nothing in Zabbix.
First, here's the HTTP agent item, nothing special here

For the trigger, there's change() used. With >0, it only alerts if the value is bigger, and does not care when my wife reads an e-mail and it gets moved from new/ to cur/ directory.

Alerting
For Trigger actions I'm just using the same strategy than I have in use for my facial cream usage alerts. If there's an Alert wife tag around, she will get notified.

This notification flies to her GMail account, so she will get near-realtime alert about new e-mail that actually arrived to her another address. Zero privacy breach, as at no point of this chain any content is being inspected, merely the number of new e-mails.
As an added bonus, as time goes by, we'll get some nice analytics about
- How often my wife gets new business e-mail
- When is the most active time
- How many e-mails at worst pile up before my wife gets to read them
And so forth. Isn't life fantastic? In the end, I could have just done a simple bash script which uses mail command to send a notification to my wife if wc returns a number bigger than 0, but where would be the fun in that be?

Add new comment