Skip to content

Instantly share code, notes, and snippets.

@sobelk
Created May 4, 2015 20:17
Show Gist options
  • Save sobelk/aca663b3572acf8de387 to your computer and use it in GitHub Desktop.
Save sobelk/aca663b3572acf8de387 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import imaplib
import sys
from boto.ec2 import cloudwatch
email, password, mailbox = sys.argv[1:]
imap = imaplib.IMAP4_SSL('imap.gmail.com')
imap.login(email, password)
status, counts = imap.select(mailbox)
count = counts[0]
cw = cloudwatch.CloudWatchConnection()
cw.put_metric_data(
'Team',
'InboxCount',
value=count,
unit='Count',
dimensions={
'Email': email
})
print email, mailbox, count
#!/bin/bash
email=$1
read -s -p "password for $email: " password
echo
while true
do
env python tools/inbox_count.py $email "$password" INBOX
sleep 50
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment