linux错误日志发邮件,Linux下 找出日志文件中错误行并发送邮件

找出日志文件中错误行并发送邮件

脚本功能:

读取/var/log/messages(也可以是其他日志文件)日志文件,从里面找出error或者warn的行,然后发送邮件。

第一次读取的时候,会记录读取的位置,下次读取的时候会从上次读取的位置的开始读取,如果没有发现error或warn行,则不发邮件

脚本使用说明:

1.需要的Perl模块

Net::SMTP //perl自带,不用安装

Socket //perl自带,不用安装

Sys::Hostname //perl自带,不用安装

Authen::SASL (用使来验证邮件用户名和密码) //需要安装

使用root身份用如下命令来安装Authen::SASL模块:

[root@server ~]# cpan Authen::SASL

If you do not want to enter a dialog now, you can answer 'no' to this

question and I'll try to autoconfigure. (Note: you can revisit this

dialog anytime later by typing 'o conf init' at the cpan prompt.)

Are you ready for manual configuration? [yes] no //如果有该步骤的话,选择no,自动配置

Checking if your kit is complete...

Looks good

Warning: prerequisite Digest::HMAC_MD5 0 not found.

Warning: prerequisite ExtUtils::MakeMaker 6.42 not found. We have 6.30.

Writing Makefile for Authen::SASL

---- Unsatisfied dependencies detected during [G/GB/GBARR/Authen-SASL-2.15.tar.gz] -----

Digest::HMAC_MD5

ExtUtils::MakeMaker

Shall I follow them and prepend them to the queue

of modules we are processing right now? [yes] yes

Running make install

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL.pm

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL.pod

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/Perl.pm

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/Perl.pod

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/EXTERNAL.pm

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/CRAM_MD5.pm

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/Perl/DIGEST_MD5.pm

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/Perl/PLAIN.pm

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/Perl/ANONYMOUS.pm

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/Perl/LOGIN.pm

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/Perl/GSSAPI.pm

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/Perl/EXTERNAL.pm

Installing /usr/lib/perl5/site_perl/5.8.8/Authen/SASL/Perl/CRAM_MD5.pm

Installing /usr/share/man/man3/Authen::SASL::Perl.3pm

Installing /usr/share/man/man3/Authen::SASL::Perl::LOGIN.3pm

Installing /usr/share/man/man3/Authen::SASL::Perl::CRAM_MD5.3pm

Installing /usr/share/man/man3/Authen::SASL::Perl::ANONYMOUS.3pm

Installing /usr/share/man/man3/Authen::SASL.3pm

Installing /usr/share/man/man3/Authen::SASL::Perl::EXTERNAL.3pm

Installing /usr/share/man/man3/Authen::SASL::Perl::GSSAPI.3pm

Installing /usr/share/man/man3/Authen::SASL::Perl::PLAIN.3pm

Installing /usr/share/man/man3/Authen::SASL::Pe

rl::DIGEST_MD5.3pm

Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod

/usr/bin/make install -- OK 看

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值