-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a munin plugin to count the number of emails in folders
Uses the doveadm command
- Loading branch information
Showing
4 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[mailbox_count] | ||
user root |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/sh | ||
|
||
output_config() { | ||
cat <<'EOM' | ||
inbox.label Inbox | ||
archive.label Archive | ||
drafts.label Drafts | ||
sent.label Sent | ||
spam.label Spam | ||
trash.label Trash | ||
graph_args --base 1000 --lower-limit 0 | ||
graph_scale no | ||
graph_category email | ||
graph_info Number of emails in each folder | ||
graph_title Emails | ||
graph_vlabel Emails | ||
EOM | ||
} | ||
|
||
output_values() { | ||
printf "inbox.value %d\n" "$(number_of_emails Inbox)" | ||
printf "archive.value %d\n" "$(number_of_emails Archive)" | ||
printf "drafts.value %d\n" "$(number_of_emails Drafts)" | ||
printf "sent.value %d\n" "$(number_of_emails Sent)" | ||
printf "spam.value %d\n" "$(number_of_emails Spam)" | ||
printf "trash.value %d\n" "$(number_of_emails Trash)" | ||
} | ||
|
||
number_of_emails() { | ||
/usr/bin/doveadm search -A mailbox "$1" | wc --lines | ||
} | ||
|
||
output_usage() { | ||
printf >&2 "%s - munin plugin to graph number of emails\n" "${0##*/}" | ||
printf >&2 "Usage: %s [config]\n" "${0##*/}" | ||
} | ||
|
||
case $# in | ||
0) | ||
output_values | ||
;; | ||
1) | ||
case $1 in | ||
config) | ||
output_config | ||
;; | ||
*) | ||
output_usage | ||
exit 1 | ||
;; | ||
esac | ||
;; | ||
*) | ||
output_usage | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters