Status report with nagios reporter


#1

Hello,

I would like to get a monthly status report from nagios/centreon. In that goal, I downloaded the nagios-email-reporter plugin.
My problem is that I had never done any perl before, so I can not manage to make the plugin work.
Does anyone knows how to use it, or would agree to help me with the perl errors I get?

Thank you very much.


#2

Nobody has a clue?
I get a Can’t call method “mail” on an undefined value error when trying to run the plugin. Does anyone knows how to avoid it?


#3

I’m not running this plugin but I assume you have:
[list]edited the script and poplated the user specific variables correctly (i.e. my $mailhost = )
*sendmail installed and working on your nagios server (i.e. nagios sends alert email notifications
*installed the perl pre-requisite modules like net::snmp and lwp::useragent
[/list:u]
If you run perl -c <scriptname.pl>, does it show any errors?


#4

I filled the $mailhost field, but I was not exactly sure what to put so I have:
my $mailhost =‘mac.com’; #Fill these in!
my $maildomain =‘mac.com’; #Fill these in!
my $mailfrom =‘pauline.danino@mac.com’; #Fill these in!
my $mailto =‘pauline.danino@mac.com’; #Fill these in!
Does that look correct?

Concerning the packages, I have the Net::SNMP, but when I try to download the other one I get:
Can’t locate object method “install” via package “LWP::UserAgent” at -e line 1.

perl -c <scriptname.pl> gives me syntax ok.

thanks for helping.


#5

my $mailfrom should probably be whatever the from address is that you recieve your nagios alert notifications, like nagios@whatever.com, but I don’t suppose that would make a great deal of difference but you could try changing it just incase, if it is different to your my $mailto

lwp::useragent is available from search.cpan.org/~gaas/libwww-per … erAgent.pm (actually called libwww-perl) but if your perl -c command didn’t complain that it was missing then i think it must already be installed… Oh, also, it is Net::SMTP not net::snmp as I previously wrote… (half asleep) but again I would expect it to error during the -c if that module was not installed…

One way to check would be that if you do have the useragent module, you should have somewhere (wherever you keep your modules) LWP/UserAgent.pm

If you can’t locate that, then I suggest you try manually installing that package from the link above, and also net::smtp from search.cpan.org/~gbarr/libnet-1.22/Net/SMTP.pm


#6

i’ve just copied that script to my server and ran perl -c on it and it definately complains when a module (which I know isn’t installed) is missing…

[root@localhost libexec]# perl -c nagios-reporter Can't locate Date/Manip.pm in @INC
…so that would indicate everything is generally in place on your system.
Maybe this will help:
[blockquote]
Perl ERROR: Can’t call method “mail” on an undefined value at smtp.pl line 10.
As confusing at it sounds, this means your smtp object has not been sucessfully constructed. I know the error message reads more like a problem with the “mail” method, but it is actually because the SMTP obj was not initialized.

Try this:
#!/usr/bin/perl -w
use Net::SMTP;
$smtp_test = Net::SMTP->new(‘smtp.mail.com’,
Timeout => 30,
Debug => 1,)|| print “ERROR creating SMTP obj: $! \n”;
print “SMTP obj created.”;

If you see “ERROR createing SMTP obj” then you know the SMTP object is not created correctly.

Some times, this is because the SMTP package was not installed right, some times, it may because the SMTP protocal is blocked, sometimes it means something else is wrong.[/blockquote]
blog.alantan.com/2007/02/perl-er … il-on.html


#7

Thanks for all the advice.
I checked everything and I have all the necessary modules.
About your last post, I had found the exact same thnig a few minutes ago. When I do the test nothing appears, neither ERROR nor SMTP obj created…


#8

Is the smtp server set in your $mailhost correct? should it not be more like mail.mac.com?

I’ve just finished installing Date/Manip.pm and the script appears to be working fine (apart from the CSS stylesheets not working so it looks uglier than my sister…) but i can’t say I had to change anything else than what you’ve mentioned… have you got $debug=1?


#9

It probably comes from that SMTP configuration…I made the changes you advised and now I have:
my $mailhost =‘mail.mac.com’; #Fill these in!
my $maildomain =‘mac.com’; #Fill these in!
my $mailfrom =‘nagios@dedibox-hostname.mac.com’; #Fill these in!
my $mailto =‘pauline.danino@mac.com’; #Fill these in!
my $timeout =30;
my $mailsubject =’’;
my $mailbody =’’;
and debug=1.
But it doesn’t change anythnig. Is there a way I could be sure that I am giving the right mailhost and maildomain?


#10

Hmm

Check the smtpmail config on the box, nagios must be sending alerts out somehow… also you should see deliveries in something like /var/log/maillog … maybe relay= that will be your mailhost. Or look at the headers of your nagios emails and see what server is first on the list. I’m off for the weekend now, so i’ll wish you the best of luck

HTH

/S


#11

Strides, if you still read this, I might use a little bit more help. I did not manage to make the plugin work during the week end, but I did make the centreon notification mails work. That means my postfix configuration is now working.
Would you agree to send me the first line of the plugin that you made work?
I am allmost sure that my mistake comes from one of those variables:
my $mailhost, my $maildomain, my $mailfrom, my $mailto.


#12

This is what I have exactly except substituting our actual domain with ‘ourdomain’ wherever it occurs

Our mailserver hostname (presumably its IP address would also work fine although I haven’t tried it)

Our domain

The address from which our nagios alert emails are sent

My email address

etc…

my $timeout = 30; my $mailsubject = 'nagios report'; my $mailbody = ''; ...
Only other changes made were to

my $webuser my $webpass my $webbase

HTH

/S


#13

Thank you so much for your help, I just made it work by putting:
my $mailhost =‘smtp.mydomain.com’;
my $maildomain =‘mail.mydomain.com’;


#14

Good news

My pleasure, glad I could help :frowning:

/S