Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mxroute on github.
  • I am jarland (https://keybase.io/jarland) on keybase.
  • I have a public key ASD6kVTARmJWiDl_TCJsc_tU9JblB3uVrbpFkHoqOw7cOwo

To claim this, I am signing this object:

@mxroute
mxroute / sentry.sh
Last active August 2, 2018 04:36
Suspend outbound email on cPanel when more than 300 emails sent this hour, report via pushover (replace that part with your own code or remove it)
#!/bin/bash
NODE=$(/bin/hostname)
DT1=$(tail /var/log/exim_mainlog -n 1 | awk '{print $1}')
DT2=$(tail /var/log/exim_mainlog -n 1 | awk '{print $2}' | cut -c1-2)
DT=$(echo "$DT1 $DT2")
AMOUNT=$(grep "$DT" /var/log/exim_mainlog | egrep -o 'dovecot_login[^ ]+' | sort|uniq -c|sort -nk 1 | tail -n 1 | awk '{print $1}')
ADDR=$(grep "$DT" /var/log/exim_mainlog | egrep -o 'dovecot_login[^ ]+' | sort|uniq -c|sort -nk 1 | tail -n 1 | awk '{print $2}' | sed -e 's/dovecot_login://g')
DOMAIN=$(grep "$DT" /var/log/exim_mainlog | egrep -o 'dovecot_login[^ ]+' | sort|uniq -c|sort -nk 1 | tail -n 1 | awk '{print $2}' | sed -e 's/dovecot_login://g' | grep -o "@[[:alnum:][:graph:]]*" | sed -e 's/@//g')
USER=$(grep $DOMAIN /etc/userdomains | awk 'NF>1{print $NF}' | tail -n 1)