Created
January 4, 2011 17:30
-
-
Save jaytaph/765070 to your computer and use it in GitHub Desktop.
Small example using syslog()
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
#!/usr/bin/perl -n | |
# thanks to Brian Dowling for an example with security in mind. | |
$TO = ‘root@localhost’; | |
$FROM = $TO; | |
s/^<\d{1,2}>//; | |
open(MAIL, “|/usr/sbin/sendmail -t”); | |
print MAIL <<”EOT”; | |
To: $TO | |
From: $FROM | |
Subject: Log Alert: $_ | |
$_ | |
EOT |
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
<?php | |
openlog('myapplication', LOG_NDELAY, LOG_USER); | |
syslog(LOG_NOTICE, "Something has happened"); | |
syslog(LOG_ERR, "Something bad has happened"); | |
?> |
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
destination df_userapp { file("/var/log/userapp.log"); }; | |
filter f_userapp { program("myapplication"); }; | |
log { | |
source(s_all); | |
filter(f_userapp); | |
destination(df_userapp); | |
}; |
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
destination dm_userapp { program("/usr/local/sbin/maillog.pl"); }; | |
filter f_userapp { program("myapplication"); }; | |
log { | |
source(s_all); | |
filter(f_userapp); | |
filter(f_at_least_err); | |
destination(dm_userapp); | |
}; |
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
destination d_loghost { udp("192.168.1.100" port(514)); }; | |
filter f_userapp { program("myapplication"); }; | |
log { | |
source(s_all); | |
filter(f_userapp); | |
destination(d_loghost); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment