Voicemail messages were arriving in the VoiceMail subfolder of the Inbox, which operators were supposed to listen to and respond to user requests, but sometimes no one read them, so it became necessary to monitor the number of unread emails.
All incoming messages for each mailbox were located in the “cur” directory, and the “new” directory was always empty. Mail clients were running on multiple computers. Each email file had a flag at the end; for example, if a message had been read, it would end with the letter “S.” So I used the following command to search for unread emails (which searches for files without the “S” flag):
find /var/vmail/vmail1/ixnfo.com/s/u/p/support-2024.01.25.21.01.09/Maildir/.INBOX.VoiceMail/cur -type f ! -name '*:2,*S*' | wc -l
I’ll describe the standard Maildir flags:
S (Seen) – Message read
R (Replied) – Message replied to
F (Flagged) – Message flagged
T (Trashed) – Message marked as deleted
D (Draft) – Draft
Now let’s just add this command to the zabbix agent configuration:
UserParameter=unread_emails,find /var/vmail/vmail1/ixnfo.com/s/u/p/support-2024.01.25.21.01.09/Maildir/.INBOX.VoiceMail/cur -type f ! -name '*:2,*S*' | wc -l
Let’s restart the Zabbix agent to apply the changes and create a data element “unread_emails” and a trigger for it, which will notify if, for example, there are more than 5 unread messages. The trigger can be made multiple times, for example, if the data element collects data once an hour, then the trigger will be triggered every hour, that is, problem messages will be duplicated and their number will grow in the problem panel.
See also my articles:
Examples of Zabbix Triggers
Examples of Items for Zabbix