LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-01-2008, 06:51 AM   #1
jenniekingsland
LQ Newbie
 
Registered: Oct 2008
Posts: 21

Rep: Reputation: 0
Urgent! Change destination email address in monit and sendmail configuration files


I need to change a destination address for monitoring alerts on Linux. These need to be changed in monit and sendmail configuration files. I have never used Linux before and only just started using it so this is all new to me.

I believe I need to access the server it needs to be done on and then edit a monit file, then edit a sendmail file.

We need to change the destination email address, is there a way I can view what the current destination email address is set up to be for that machine? I have been told what it is, but I want to know if I can view this on the server, what command do I need to tpye in?

I have searched on the internet for help and it doesn't make sense to me! I read I should make a back up of monit by typing in the command cp /etc/monit/monitrc /etc/monit/monitrc_default or just sudo cp /etc/monit/monitrc I tried this and then it says no such file or directory....We have been told monit is installed on the machine how do I check this to confirm its there, is there a command I can use?

So I need to know how to view the current destination email address, and which command I use to do that...if thats possible??

I then need to know how to back up the monit and sendmail configuration files, which command is this??

What is the command I type in to change the email address in monit? And what is the command to change the email address in the sendmail configuration files??

I hope I have explained this clearly enough, sorry for all the questions I use Windows and have only just started using Linux our Linux\Unix administrator isn't in the office so need help on how to do this!!!

Last edited by jenniekingsland; 10-01-2008 at 06:54 AM.
 
Old 10-01-2008, 10:10 AM   #2
Carl Filby
Member
 
Registered: Aug 2008
Location: Deep East Texas
Distribution: Debian,Ubuntu
Posts: 36

Rep: Reputation: 15
google is your friend
monit:
http://www.tildeslash.com/monit/doc/manual.php
sendmail aliases
http://tldp.org/LDP/nag2/x15291.html#AEN15314
 
Old 10-01-2008, 11:40 AM   #3
jenniekingsland
LQ Newbie
 
Registered: Oct 2008
Posts: 21

Original Poster
Rep: Reputation: 0
hi i tried looking at them, it says use set alert foo@bar for monit, is that correct?? how do i check if the address has changed\how do i see the destination address at the moment is there a command for that?? thank you
 
Old 10-01-2008, 08:32 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Well, I'm not a monit user, but looking at the first link it says:

Quote:
~/.monitrc Default run control file

/etc/monitrc If the control file is not found in the default location and /etc contains a monitrc file, this file will be used instead.

./monitrc If the control file is not found in either of the previous two locations, and the current working directory contains a monitrc file, this file is used instead.
which means the config file is in one of those 3 locations, and it searches for them in that order. Note that the first one begins with the char '.', which means the usual ls (equiv to dir) cmd won't show it. Its a 'hidden' file. Use the -a option:

ls -a

Inside the cfg file you'll see a line like
alert foo@bar

just edit that to the email you want. you already know what the current one is, so check its what you expect.
To backup a file, just use the cp (copy) cmd as 'cp src dest' like

cp monitrc monitrc.bak

You prob need to be logged in as the monit user or root (equiv to admin).
You'll need these links for background/cmds:

http://linux.oneandoneis2.org/LNW.htm
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html

In Linux '~' means user's home dir, ./ means in the current dir.

HTH

Welcome to LQ
 
Old 10-02-2008, 07:34 AM   #5
jenniekingsland
LQ Newbie
 
Registered: Oct 2008
Posts: 21

Original Poster
Rep: Reputation: 0
Hi

Ok we have had a look at vi /etc/monitrc and it states this is the monit control file, but we cannot see the current destination email address that is set. Should we be able to see this in here? Is this the correct place?

We have also been in vi sendmail.cf and vi sendmail.mc and we cannot see the current destination email address in there either. Should this be in here? Is this the right place to edit it?

Where abouts do we change the email address in monit and sendmail, should we be able to see the current destination email address and just write over this?

We have tried changing directorys and accessing it but still no joy
 
Old 10-02-2008, 08:57 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
The sendmail program is the MTA (Mail Txfr Agent) ie mailserver SW. It sends/receives emails for everyone. I doubt you need to change it.

You need to check all 3 locations for the monitrc file. One of them should have the email address in it. If you're just changing it as you claim, you will find it (current email) in one of them.

If unsure, post the contents of all of the monitrc files.
 
Old 10-06-2008, 05:38 AM   #7
jenniekingsland
LQ Newbie
 
Registered: Oct 2008
Posts: 21

Original Poster
Rep: Reputation: 0
hi thanks for your response.

I typed in Vi /etc/monitrc and got the following;
Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Bellow is the example of some frequently used statements. For information
## about the control file, a complete list of statements and options please
## have a look in the monit manual.
##
##
###############################################################################
## Global section
###############################################################################
##
## Start monit in background (run as daemon) and check the services at 2-minute
## intervals.

set daemon 120


## Set syslog logging with the 'daemon' facility. If the FACILITY option is
## omited, monit will use 'user' facility by default. You can specify the
## path to the file for monit native logging.

set logfile syslog facility log_daemon


## Set list of mailservers for alert delivery. Multiple servers may be
## specified using comma separator. By default monit uses port 25 - it is
## possible to override it with the PORT option.
#
# set mailserver mail.bar.baz, # primary mailserver
# backup.bar.baz port 10025, # backup mailserver on port 10025
# localhost # fallback relay

set mailserver localhost


## By default monit will drop the event alert, in the case that there is no
## mailserver available. In the case that you want to keep the events for
## later delivery retry, you can use the EVENTQUEUE statement. The base
## directory where undelivered events will be stored is specified by the
## BASEDIR option. You can limit the maximal queue size using the SLOTS
## option (if omited then the queue is limited just by the backend filesystem).

set eventqueue
basedir /var/spool/monit


## Monit by default uses the following alert mail format:
##
## --8<--
## From: monit@$HOST # sender
## Subject: monit alert -- $EVENT $SERVICE # subject
##
## $EVENT Service $SERVICE #
## #
## Date: $DATE #
## Action: $ACTION #
## Host: $HOST # body
## Description: $DESCRIPTION #
## #
## Your faithful employee, #
## monit #
## --8<--
##
## You can override the alert message format or its parts such as subject
## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
## are expanded on runtime. For example to override the sender:
#
# set mail-format { from: monit@foo.bar }
#
#
## You can set the alert recipients here, which will receive the alert for
## each service. The event alerts may be restricted using the list.
#
# set alert sysadm@foo.bar # receive all alerts
# set alert manager@foo.bar only on { timeout } # receive just service-
# # timeout alert
#
#
## Monit has an embedded webserver, which can be used to view the
## configuration, actual services parameters or manage the services using the
## web interface.

set httpd port 2812 use address localhost allow localhost allow admin:Adbx5ZQS5dhRwg


###############################################################################
## Includes
###############################################################################
##
## It is possible to include the configuration or its parts from other files or
## directories.

include /etc/monit.d/*


###############################################################################
## Examples
###############################################################################
##
## Check the general system resources such as load average, cpu and memory
## usage. Each rule specifies the tested resource, the limit and the action
## which will be performed in the case that the test failed.
#
# check system myhost.mydomain.tld
# if loadavg (1min) > 4 then alert
# if loadavg (5min) > 2 then alert
# if memory usage > 75% then alert
# if cpu usage (user) > 70% then alert
# if cpu usage (system) > 30% then alert
# if cpu usage (wait) > 20% then alert
#
#
## Check a file for existence, checksum, permissions, uid and gid. In addition
## to the recipients in the global section, customized alert will be send to
## the additional recipient. The service may be grouped using the GROUP option.
#
# check file apache_bin with path /usr/local/apache/bin/httpd
# if failed checksum and
# expect the sum 8f7f419955cefa0b33a2ba316cba3659 then unmonitor
# if failed permission 755 then unmonitor
# if failed uid root then unmonitor
# if failed gid root then unmonitor
# alert security@foo.bar on {
# checksum, permission, uid, gid, unmonitor
# } with the mail-format { subject: Alarm! }
# group server
#
#
## Check that a process is running, responding on the HTTP and HTTPS request,
## check its resource usage such as cpu and memory, number of childrens.
## In the case that the process is not running, monit will restart it by
## default. In the case that the service was restarted very often and the
## problem remains, it is possible to disable the monitoring using the
## TIMEOUT statement. The service depends on another service (apache_bin) which
## is defined in the monit control file as well.
#
# check process apache with pidfile /usr/local/apache/logs/httpd.pid
# start program = "/etc/init.d/httpd start"
# stop program = "/etc/init.d/httpd stop"
# if cpu > 60% for 2 cycles then alert
# if cpu > 80% for 5 cycles then restart
# if totalmem > 200.0 MB for 5 cycles then restart
# if children > 250 then restart
# if loadavg(5min) greater than 10 for 8 cycles then stop
# if failed host www.tildeslash.com port 80 protocol http
# and request "/monit/doc/next.php"
# then restart
# if failed port 443 type tcpssl protocol http
# with timeout 15 seconds
# then restart
# if 3 restarts within 5 cycles then timeout
# depends on apache_bin
# group server
#
#
## Check the device permissions, uid, gid, space and inode usage. Other
## services such as databases may depend on this resource and automatical
## graceful stop may be cascaded to them before the filesystem will become
## full and the data will be lost.
#
# check device datafs with path /dev/sdb1
# start program = "/bin/mount /data"
# stop program = "/bin/umount /data"
# if failed permission 660 then unmonitor
# if failed uid root then unmonitor
# if failed gid disk then unmonitor
# if space usage > 80% for 5 times within 15 cycles then alert
# if space usage > 99% then stop
# if inode usage > 30000 then alert
# if inode usage > 99% then stop
# group server
#
#
## Check a file's timestamp: when it becomes older then 15 minutes, the
## file is not updated and something is wrong. In the case that the size
## of the file exceeded given limit, perform the script.
#
# check file database with path /data/mydatabase.db
# if failed permission 700 then alert
# if failed uid data then alert
# if failed gid data then alert
# if timestamp > 15 minutes then alert
# if size > 100 MB then exec "/my/cleanup/script"
#
#
## Check the directory permission, uid and gid. An event is triggered
## if the directory does not belong to the user with the uid 0 and
## the gid 0. In the addition the permissions have to match the octal
## description of 755 (see chmod(1)).
#
# check directory bin with path /bin
# if failed permission 755 then unmonitor
# if failed uid 0 then unmonitor
# if failed gid 0 then unmonitor
#
#
## Check the remote host network services availability and the response
## content. One of three pings, a successfull connection to a port and
## application level network check is performed.
#
# check host myserver with address 192.168.1.1
# if failed icmp type echo count 3 with timeout 3 seconds then alert
# if failed port 3306 protocol mysql with timeout 15 seconds then alert
# if failed url
# http://userassword@www.foo.bar:8080/?querystring
# and content == 'action="j_security_check"'
# then alert
#
#



is this the correct location? The current email address called hostingsupport and we need to change it to our address.

I tried to type in vi ~/.monitrc and vi ./monitrc when I did this it is just blank with a bit at the bottom of the page that says new file.

Have i typed this in correct? you say check 'You need to check all 3 locations for the monitrc file' have i typed in the correct command to check the other locations??

Thank you so much for all of your help so far!

Last edited by jenniekingsland; 10-06-2008 at 05:40 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I change my email-address ? toshiki Linux - Newbie 4 05-03-2008 09:44 AM
Change email address? Zeno McDohl Linux - Newbie 6 02-05-2006 04:57 PM
Sendmail Configuration ( Urgent Help Required) taimoor111 Linux - Networking 2 11-10-2004 01:22 PM
Sendmail Configuration ( Urgent Help Required) taimoor111 Linux - Software 1 11-10-2004 03:10 AM
Creating A Second Email Address For Email Account On Sendmail treedstang Linux - Software 1 04-27-2004 11:31 PM


All times are GMT -5. The time now is 04:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration