Created
November 9, 2011 12:28
-
-
Save catchamonkey/1351299 to your computer and use it in GitHub Desktop.
Mail your Errors during development without Nagios/Ossec
This file contains hidden or 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
<?php | |
// during development you can simply have all Error mentions in your logs (presumably you are logging properly?) mailed to you. | |
// in production you may be using OSSEC/Nagios etc, but this is a quick win for dev. | |
// to run, you would do something like | |
// tail -f /var/log/messages |grep Error | php /home/sites/poc/stdInMailer.php | |
$fp = fopen("php://stdin","r"); | |
while ($line = stream_get_line($fp,65535,"\n")) | |
{ | |
// output as if normal tail were in flow | |
echo $line."\n"; | |
// send the mail | |
mail('[email protected]', 'Dev Container Error Mail', $line); | |
} | |
fclose($fp); | |
// alternatively you can do this inline... | |
tail -f /var/log/messages | grep Error | php -R 'mail("[email protected]", "Dev Container Error Mail", $argn);' | |
// take your pick. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment