Skip to content

Instantly share code, notes, and snippets.

@jcefoli
Created January 26, 2016 22:42
Show Gist options
  • Save jcefoli/597067f8fe9d79063ac2 to your computer and use it in GitHub Desktop.
Save jcefoli/597067f8fe9d79063ac2 to your computer and use it in GitHub Desktop.
Sends An Email With the Number of Documents in a MongoDB Collection
#!/bin/bash
myCollectionCount=`mongo -u user -p password database_name --quiet --eval 'db.getCollection("my_collection").count()'`
echo "my_collection Count: $myCollectionCount > disk.txt
echo >> disk.txt
df /dev/mapper/volume-group >> disk.txt
cat disk.txt | mail -S smtp="smtp.relay.tld:25" -r "From Name<[email protected]>" -s "Email Subject" -v "[email protected]"
rm disk.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment