Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
is there a way to change the senders email address using nagios, beacuse i have setup nagios on mutiple machines and i am not able to identify which machine send me the email coz it is all from firstname.lastname@example.org.
Instead, change the subject and/or body of message to show the machine name.
In 'service-notify-by-email' command definition (in my config it is in /etc/nagios/commands.cfg), the command is defined as:
command_line /bin/echo -e "$NOTIFICATIONTYPE$ - Service notification for $SERVICEDESC$ from host $HOSTNAME$ - $HOSTALIAS$\n$SERVICEDESC$: $SERVICEOUTPUT$\n" | /bin/mail -s '$NOTIFICATIONTYPE$/$SERVICESTATE$ - $HOSTNAME$/$SERVICEDESC$' $CONTACTEMAIL$
And I receive e-mails with a subject like this: "PROBLEM/WARNING - minibit/DISK_HOME" , where "minibit " is the hostname of the machine where the service "DISK_HOME" has an alarm.
You can, of course, rewrite the subject and/or body as you wish.
Personally I setup subdomains for my multiple nagios boxes, then config the exim mailer they use (all Debian systems in my case, but the OS isn't at all an issue) to mail out as subdomain.domain.com, subdomain2.domain.com, subdomain3.domain.com. Works very well for me, but Marozsas suggestion works just as well. Its more a questions of what is easiest for you to do.
Nagios email by default sends the hostname in the subject line, but i am fine with that , what i need to do is to change email@example.com to firstname.lastname@example.org. So that it reflects the machine's name in the senders feild of the email address.
.. is there an option with the mail command to change the senders address...
Yes, you right, aeby. If I remember it was the option -f (from). But this was true for old versions. Looks like the new versions does not have this option anymore. At least, mine does not have (Fedora 7, mailx-8.1.1-46.fc7). I think this option was removed to fight spammers, to avoid forgery addresses.
So, your problem is not a nagios issue, but an e-mail issue.
As aeby mentioned, may be you find a mail command out there with this feature and them, its just a case of change the service-notify-by-email definition to use it.
As marozsas mention, you have to edit the 'service-notify-by-email' command definition.
By default it uses /bin/mail, which doesn't have the -f option. But plain old sendmail still have it and it works quite well. You'll have to setup sudo or something tho, because sendmail is usually in /usr/sbin.