Quantcast

Managing cron and similar E-Mails from headless systems

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Managing cron and similar E-Mails from headless systems

Chris Green
I have several headless systems doing useful work around the place:-

    A Raspberry Pi providing local DNS and DHCP

    A Beaglebone Black on our boat monitoring temperatures and batteries

    An old desktop doing backups in the garage

    etc.


Most of these have one or more cron jobs running periodic rsync
backups, copying data, etc.  If the cron job has an error then it
sends E-Mail to the owner of the job ('chris' in most cases, might be
root in a couple).

It's (moderately) easy to set up an MTA and /etc/aliases so that the
messages are sent to my normal E-Mail.  However I can't come up with a
straightforward way of indicating where the messsage is *from*.

You can't just invent a domain name for the headless system because
that gets the E-Mail rejected by intermediate systems that try and
look up the sender host name.  Cron doesn't seem to have any mechanism
for setting the sender's name, cron errors just come from 'root@'.

Can anyone suggest a neat way of handling this so that I know where
the errors are coming from?

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

David Fletcher-5
On Fri, 2017-02-17 at 11:14 +0000, Chris Green wrote:

> I have several headless systems doing useful work around the place:-
>
>     A Raspberry Pi providing local DNS and DHCP
>
>     A Beaglebone Black on our boat monitoring temperatures and
> batteries
>
>     An old desktop doing backups in the garage
>
>     etc.
>
>
> Most of these have one or more cron jobs running periodic rsync
> backups, copying data, etc.  If the cron job has an error then it
> sends E-Mail to the owner of the job ('chris' in most cases, might be
> root in a couple).
>
> It's (moderately) easy to set up an MTA and /etc/aliases so that the
> messages are sent to my normal E-Mail.  However I can't come up with
> a
> straightforward way of indicating where the messsage is *from*.
>
> You can't just invent a domain name for the headless system because
> that gets the E-Mail rejected by intermediate systems that try and
> look up the sender host name.  Cron doesn't seem to have any
> mechanism
> for setting the sender's name, cron errors just come from 'root@'.
>
> Can anyone suggest a neat way of handling this so that I know where
> the errors are coming from?
>
> -- 
> Chris Green
>

Hi Chris,
Here is a snippet of code that's part of a reminders by email
application that's been running on my home server for some years.
The application is kicked off by a cron job on behalf of a user like
so:-
0 3 * * * dave DFReminder
Perhaps it will help solve your problem?

strcpy(SendEmailBuf, "sendEmail -q -f ");
strdncat(SendEmailBuf, Settings.ReturnEmailFrom(), SENDEMAIL_BUF_LEN);
strdncat(SendEmailBuf, (char *)" -t ", SENDEMAIL_BUF_LEN);
strdncat(SendEmailBuf, Settings.ReturnEmailTo(), SENDEMAIL_BUF_LEN);
strdncat(SendEmailBuf, (char *)" -u \"", SENDEMAIL_BUF_LEN);
strdncat(SendEmailBuf, Dates.ReturnReminderTextPointer(),
SENDEMAIL_BUF_LEN);
strdncat(SendEmailBuf, (char *)"\"", SENDEMAIL_BUF_LEN);

strdncat(SendEmailBuf, (char *)" -m Repeating reminder",
SENDEMAIL_BUF_LEN);

system(SendEmailBuf);

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Chris Green
On Fri, Feb 17, 2017 at 11:37:10AM +0000, David Fletcher wrote:

> On Fri, 2017-02-17 at 11:14 +0000, Chris Green wrote:
> > I have several headless systems doing useful work around the place:-
> >
> >     A Raspberry Pi providing local DNS and DHCP
> >
> >     A Beaglebone Black on our boat monitoring temperatures and
> > batteries
> >
> >     An old desktop doing backups in the garage
> >
> >     etc.
> >
> >
> > Most of these have one or more cron jobs running periodic rsync
> > backups, copying data, etc.  If the cron job has an error then it
> > sends E-Mail to the owner of the job ('chris' in most cases, might be
> > root in a couple).
> >
> > It's (moderately) easy to set up an MTA and /etc/aliases so that the
> > messages are sent to my normal E-Mail.  However I can't come up with
> > a
> > straightforward way of indicating where the messsage is *from*.
> >
> > You can't just invent a domain name for the headless system because
> > that gets the E-Mail rejected by intermediate systems that try and
> > look up the sender host name.  Cron doesn't seem to have any
> > mechanism
> > for setting the sender's name, cron errors just come from 'root@'.
> >
> > Can anyone suggest a neat way of handling this so that I know where
> > the errors are coming from?
> >
> > -- 
> > Chris Green
> >
>
> Hi Chris,
> Here is a snippet of code that's part of a reminders by email
> application that's been running on my home server for some years.
> The application is kicked off by a cron job on behalf of a user like
> so:-
> 0 3 * * * dave DFReminder
> Perhaps it will help solve your problem?
>
> strcpy(SendEmailBuf, "sendEmail -q -f ");
> strdncat(SendEmailBuf, Settings.ReturnEmailFrom(), SENDEMAIL_BUF_LEN);
> strdncat(SendEmailBuf, (char *)" -t ", SENDEMAIL_BUF_LEN);
> strdncat(SendEmailBuf, Settings.ReturnEmailTo(), SENDEMAIL_BUF_LEN);
> strdncat(SendEmailBuf, (char *)" -u \"", SENDEMAIL_BUF_LEN);
> strdncat(SendEmailBuf, Dates.ReturnReminderTextPointer(),
> SENDEMAIL_BUF_LEN);
> strdncat(SendEmailBuf, (char *)"\"", SENDEMAIL_BUF_LEN);
>
> strdncat(SendEmailBuf, (char *)" -m Repeating reminder",
> SENDEMAIL_BUF_LEN);
>
> system(SendEmailBuf);
>
No use, I want an *ordinary* cron job to identify itself.

E.g. I have backup jobs running on one of my headless computers with
cron entries like:-

    20 1 * * * rsync -a --exclude '*.pyc' /home/chris/ isbd.uk:.syncmisc/odin/

When something goes wrong I want to be able to identify where the mail
from cron came from.

If *your* '0 3 * * * dave DFReminder' cron job fails and it sends you
an E-Mail will be able to work out where it came from?  

My issue is that I have several (some remote) systems running cron
jobs like this and I need to be able to work out where a message came
from.


--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

W Scott Lockwood III


On Feb 17, 2017 06:14, "Chris Green" <[hidden email]> wrote:
No use, I want an *ordinary* cron job to identify itself.

E.g. I have backup jobs running on one of my headless computers with
cron entries like:-

    20 1 * * * rsync -a --exclude '*.pyc' /home/chris/ isbd.uk:.syncmisc/odin/

When something goes wrong I want to be able to identify where the mail
from cron came from.

Wrap that cron in a script. Have the script echo the identifier of your choice before it does anything else.

echo "This cron is running on Fred, the RPI system providing DNS and DHCP. It lives under your couch."

Or something similar.


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Chris Green
On Fri, Feb 17, 2017 at 06:24:10AM -0600, W Scott Lockwood III wrote:

>    On Feb 17, 2017 06:14, "Chris Green" <[1][hidden email]> wrote:
>
>      No use, I want an *ordinary* cron job to identify itself.
>      E.g. I have backup jobs running on one of my headless computers with
>      cron entries like:-
>          20 1 * * * rsync -a --exclude '*.pyc' /home/chris/
>      isbd.uk:.syncmisc/odin/
>      When something goes wrong I want to be able to identify where the
>      mail
>      from cron came from.
>
>    Wrap that cron in a script. Have the script echo the identifier of your
>    choice before it does anything else.
>    echo "This cron is running on Fred, the RPI system providing DNS and
>    DHCP. It lives under your couch."
>    Or something similar.
>
I suppose one could do that, but I don't want E-Mails *except* when
there's an error which would make the wrapper script rather
complicated.

Surely this is a fairly common problem and there must be a reasonably
simple solution.


--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

W Scott Lockwood III


On Feb 17, 2017 06:39, "Chris Green" <[hidden email]> wrote:
On Fri, Feb 17, 2017 at 06:24:10AM -0600, W Scott Lockwood III wrote:
>    On Feb 17, 2017 06:14, "Chris Green" <[1][hidden email]> wrote:
>
>      No use, I want an *ordinary* cron job to identify itself.
>      E.g. I have backup jobs running on one of my headless computers with
>      cron entries like:-
>          20 1 * * * rsync -a --exclude '*.pyc' /home/chris/
>      isbd.uk:.syncmisc/odin/
>      When something goes wrong I want to be able to identify where the
>      mail
>      from cron came from.
>
>    Wrap that cron in a script. Have the script echo the identifier of your
>    choice before it does anything else.
>    echo "This cron is running on Fred, the RPI system providing DNS and
>    DHCP. It lives under your couch."
>    Or something similar.
>
I suppose one could do that, but I don't want E-Mails *except* when
there's an error which would make the wrapper script rather
complicated.

Surely this is a fairly common problem and there must be a reasonably
simple solution.

 But your example cron will send an email with every run as it is now. A wrapper script is no different, except you can further refine it by adding logic to also handle sending email only if there is an error. cron does not do this at all. Yes, you are going to have to write code.

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Chris Green
On Fri, Feb 17, 2017 at 06:50:25AM -0600, W Scott Lockwood III wrote:

>    On Feb 17, 2017 06:39, "Chris Green" <[1][hidden email]> wrote:
>
>      On Fri, Feb 17, 2017 at 06:24:10AM -0600, W Scott Lockwood III
>      wrote:
>
>    >    On Feb 17, 2017 06:14, "Chris Green" <[1][2][hidden email]> wrote:
>    >
>    >      No use, I want an *ordinary* cron job to identify itself.
>    >      E.g. I have backup jobs running on one of my headless computers
>    with
>    >      cron entries like:-
>    >          20 1 * * * rsync -a --exclude '*.pyc' /home/chris/
>    >      isbd.uk:.syncmisc/odin/
>    >      When something goes wrong I want to be able to identify where
>    the
>    >      mail
>    >      from cron came from.
>    >
>    >    Wrap that cron in a script. Have the script echo the identifier of
>    your
>    >    choice before it does anything else.
>    >    echo "This cron is running on Fred, the RPI system providing DNS
>    and
>    >    DHCP. It lives under your couch."
>    >    Or something similar.
>    >
>
>      I suppose one could do that, but I don't want E-Mails *except* when
>      there's an error which would make the wrapper script rather
>      complicated.
>      Surely this is a fairly common problem and there must be a
>      reasonably
>      simple solution.
>
>     But your example cron will send an email with every run as it is now.

No it doesn't.  There will only be an E-Mail from cron when there's
something send to stdout or stderr.  Those rsync commands are silent
unless there's an error.  That's the beauty of the default setup, cron
works silently unless something goes wrong.


>    A wrapper script is no different, except you can further refine it by
>    adding logic to also handle sending email only if there is an error.
>    cron does not do this at all. Yes, you are going to have to write code.
>
I'd prefer to do it once though (in E-Mail or other configuration)
rather than every time I create a cron job.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

W Scott Lockwood III

On Fri, Feb 17, 2017 at 7:35 AM, Chris Green <[hidden email]> wrote:
No it doesn't.  There will only be an E-Mail from cron when there's
something send to stdout or stderr.  Those rsync commands are silent
unless there's an error.  That's the beauty of the default setup, cron
works silently unless something goes wrong.

This is fundamentally the wrong approach. Not every command you're going to run can run silently. A far better way to do this is to use a construct like  &> /dev/null
 
>    A wrapper script is no different, except you can further refine it by
>    adding logic to also handle sending email only if there is an error.
>    cron does not do this at all. Yes, you are going to have to write code.
 
I'd prefer to do it once though (in E-Mail or other configuration)
rather than every time I create a cron job.

Wow. The basic script to do this is dirt simple, and can be recycled as many times as you need. Seriously, this is not hard. In the script, check for a non-zero exit. On a non-zero exit, mail yourself whatever you want it to tell you.

--
W. Stacy Lockwood III

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Gene Heskett-2
In reply to this post by Chris Green
On Friday 17 February 2017 06:14:01 Chris Green wrote:

> I have several headless systems doing useful work around the place:-
>
>     A Raspberry Pi providing local DNS and DHCP
>
>     A Beaglebone Black on our boat monitoring temperatures and
> batteries
>
>     An old desktop doing backups in the garage
>
>     etc.
>
>
> Most of these have one or more cron jobs running periodic rsync
> backups, copying data, etc.  If the cron job has an error then it
> sends E-Mail to the owner of the job ('chris' in most cases, might be
> root in a couple).
>
> It's (moderately) easy to set up an MTA and /etc/aliases so that the
> messages are sent to my normal E-Mail.  However I can't come up with a
> straightforward way of indicating where the messsage is *from*.
>
> You can't just invent a domain name for the headless system because
> that gets the E-Mail rejected by intermediate systems that try and
> look up the sender host name.  Cron doesn't seem to have any mechanism
> for setting the sender's name, cron errors just come from 'root@'.
>
> Can anyone suggest a neat way of handling this so that I know where
> the errors are coming from?
>
> --
> Chris Green

A hosts file based home network should suffice to fix that. I did have it
setup to do that from 3 of the now 5 machines here, but the inability to
separate the messages into important turned the whole thing into spam
for me. Set your resolv.conf to include the commands:
"nameserver local.address.of.router"
and:
"order hosts,dns"

So it will look at /etc/hosts first, failing to find a match there it
sends it to the router, which forwards it to your ISP's dns.

1. Set the hostname and domain name of your machines so they know who
they are.

2. run the same hosts file on all machines, which lists the local ip,
names, and aliases of the whole local network, 7 lines here plus the
obligatory localhost stuff, does it nicely.  Then on the client
machines, I just set the MailTo: gene@coyote, and it magically appears
in my /var/spool/mail/gene queue. That in turn triggers a watcher script
to send kmail a getmail message over whatever message bus your system
uses, dbus here ATM, to go get the mail.

But unless you can make procmail (I use a fetchmail->procmail processing
chain here) send the unimportant stuff to /dev/null, you'll likely tear
it back down in a week or 2. You don't need to know, when logging into
one of the other machines, everytime you fat fingered the password. With
my short fat fingers, and 82 years of arthritis accumulated, very easily
done.

Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Nils Kassube-2
In reply to this post by Chris Green
Chris Green wrote:
> I'd prefer to do it once though (in E-Mail or other configuration)
> rather than every time I create a cron job.

20 1 * * * rsync ..... || echo hostname

should do the trick - without an extra script but as an extension to
your command.


Nils


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Chris Green
On Fri, Feb 17, 2017 at 05:02:47PM +0100, Nils Kassube wrote:
> Chris Green wrote:
> > I'd prefer to do it once though (in E-Mail or other configuration)
> > rather than every time I create a cron job.
>
> 20 1 * * * rsync ..... || echo hostname
>
> should do the trick - without an extra script but as an extension to
> your command.
>
Now that's pretty neat, thanks.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Chris Green
In reply to this post by Gene Heskett-2
On Fri, Feb 17, 2017 at 11:00:16AM -0500, Gene Heskett wrote:

> On Friday 17 February 2017 06:14:01 Chris Green wrote:
>
> > I have several headless systems doing useful work around the place:-
> >
> >     A Raspberry Pi providing local DNS and DHCP
> >
> >     A Beaglebone Black on our boat monitoring temperatures and
> > batteries
> >
> >     An old desktop doing backups in the garage
> >
> >     etc.
> >
> >
> > Most of these have one or more cron jobs running periodic rsync
> > backups, copying data, etc.  If the cron job has an error then it
> > sends E-Mail to the owner of the job ('chris' in most cases, might be
> > root in a couple).
> >
> > It's (moderately) easy to set up an MTA and /etc/aliases so that the
> > messages are sent to my normal E-Mail.  However I can't come up with a
> > straightforward way of indicating where the messsage is *from*.
> >
> > You can't just invent a domain name for the headless system because
> > that gets the E-Mail rejected by intermediate systems that try and
> > look up the sender host name.  Cron doesn't seem to have any mechanism
> > for setting the sender's name, cron errors just come from 'root@'.
> >
> > Can anyone suggest a neat way of handling this so that I know where
> > the errors are coming from?
> >
> > --
> > Chris Green
>
> A hosts file based home network should suffice to fix that. I did have it
> setup to do that from 3 of the now 5 machines here, but the inability to
> separate the messages into important turned the whole thing into spam
> for me. Set your resolv.conf to include the commands:
> "nameserver local.address.of.router"
> and:
> "order hosts,dns"
>
> So it will look at /etc/hosts first, failing to find a match there it
> sends it to the router, which forwards it to your ISP's dns.
>
> 1. Set the hostname and domain name of your machines so they know who
> they are.
>
> 2. run the same hosts file on all machines, which lists the local ip,
> names, and aliases of the whole local network, 7 lines here plus the
> obligatory localhost stuff, does it nicely.  Then on the client

Erk, I've spent the last N years avoiding maintaining lots of hosts
files on my home LAN.  I run dnsmasq on a raspberry pi to do it all
for me automatically.


> machines, I just set the MailTo: gene@coyote, and it magically appears
> in my /var/spool/mail/gene queue. That in turn triggers a watcher script
> to send kmail a getmail message over whatever message bus your system
> uses, dbus here ATM, to go get the mail.
>
> But unless you can make procmail (I use a fetchmail->procmail processing
> chain here) send the unimportant stuff to /dev/null, you'll likely tear
> it back down in a week or 2. You don't need to know, when logging into
> one of the other machines, everytime you fat fingered the password. With
> my short fat fingers, and 82 years of arthritis accumulated, very easily
> done.
>
I don't use any sort of mail fetcher, mail is delivered to my home
machine (which is on all the time) by SMTP.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Gene Heskett-2
On Friday 17 February 2017 11:15:39 Chris Green wrote:

> On Fri, Feb 17, 2017 at 11:00:16AM -0500, Gene Heskett wrote:
> > On Friday 17 February 2017 06:14:01 Chris Green wrote:
> > > I have several headless systems doing useful work around the
> > > place:-
> > >
> > >     A Raspberry Pi providing local DNS and DHCP
> > >
> > >     A Beaglebone Black on our boat monitoring temperatures and
> > > batteries
> > >
> > >     An old desktop doing backups in the garage
> > >
> > >     etc.
> > >
> > >
> > > Most of these have one or more cron jobs running periodic rsync
> > > backups, copying data, etc.  If the cron job has an error then it
> > > sends E-Mail to the owner of the job ('chris' in most cases, might
> > > be root in a couple).
> > >
> > > It's (moderately) easy to set up an MTA and /etc/aliases so that
> > > the messages are sent to my normal E-Mail.  However I can't come
> > > up with a straightforward way of indicating where the messsage is
> > > *from*.
> > >
> > > You can't just invent a domain name for the headless system
> > > because that gets the E-Mail rejected by intermediate systems that
> > > try and look up the sender host name.  Cron doesn't seem to have
> > > any mechanism for setting the sender's name, cron errors just come
> > > from 'root@'.
> > >
> > > Can anyone suggest a neat way of handling this so that I know
> > > where the errors are coming from?
> > >
> > > --
> > > Chris Green
> >
> > A hosts file based home network should suffice to fix that. I did
> > have it setup to do that from 3 of the now 5 machines here, but the
> > inability to separate the messages into important turned the whole
> > thing into spam for me. Set your resolv.conf to include the
> > commands:
> > "nameserver local.address.of.router"
> > and:
> > "order hosts,dns"
> >
> > So it will look at /etc/hosts first, failing to find a match there
> > it sends it to the router, which forwards it to your ISP's dns.
> >
> > 1. Set the hostname and domain name of your machines so they know
> > who they are.
> >
> > 2. run the same hosts file on all machines, which lists the local
> > ip, names, and aliases of the whole local network, 7 lines here plus
> > the obligatory localhost stuff, does it nicely.  Then on the client
>
> Erk, I've spent the last N years avoiding maintaining lots of hosts
> files on my home LAN.  I run dnsmasq on a raspberry pi to do it all
> for me automatically.
>
> > machines, I just set the MailTo: gene@coyote, and it magically
> > appears in my /var/spool/mail/gene queue. That in turn triggers a
> > watcher script to send kmail a getmail message over whatever message
> > bus your system uses, dbus here ATM, to go get the mail.
> >
> > But unless you can make procmail (I use a fetchmail->procmail
> > processing chain here) send the unimportant stuff to /dev/null,
> > you'll likely tear it back down in a week or 2. You don't need to
> > know, when logging into one of the other machines, everytime you fat
> > fingered the password. With my short fat fingers, and 82 years of
> > arthritis accumulated, very easily done.
>
> I don't use any sort of mail fetcher, mail is delivered to my home
> machine (which is on all the time) by SMTP.
>
Whereas all my stuff is behind a dd-wrt NATing router, so except for my
web page, invisible to the rest of the world.

> --
> Chris Green


Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Chris Green
On Fri, Feb 17, 2017 at 11:47:03AM -0500, Gene Heskett wrote:

> > > know, when logging into one of the other machines, everytime you fat
> > > fingered the password. With my short fat fingers, and 82 years of
> > > arthritis accumulated, very easily done.
> >
> > I don't use any sort of mail fetcher, mail is delivered to my home
> > machine (which is on all the time) by SMTP.
> >
> Whereas all my stuff is behind a dd-wrt NATing router, so except for my
> web page, invisible to the rest of the world.
>
So is mine.  I only allow SMTP connections through the firewall from
my mail provider's servers.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Robert Heller
In reply to this post by Gene Heskett-2
At Fri, 17 Feb 2017 11:00:16 -0500 "Ubuntu user technical support,  not for general discussions" <[hidden email]> wrote:

>
> On Friday 17 February 2017 06:14:01 Chris Green wrote:
>
> > I have several headless systems doing useful work around the place:-
> >
> >     A Raspberry Pi providing local DNS and DHCP
> >
> >     A Beaglebone Black on our boat monitoring temperatures and
> > batteries
> >
> >     An old desktop doing backups in the garage
> >
> >     etc.
> >
> >
> > Most of these have one or more cron jobs running periodic rsync
> > backups, copying data, etc.  If the cron job has an error then it
> > sends E-Mail to the owner of the job ('chris' in most cases, might be
> > root in a couple).
> >
> > It's (moderately) easy to set up an MTA and /etc/aliases so that the
> > messages are sent to my normal E-Mail.  However I can't come up with a
> > straightforward way of indicating where the messsage is *from*.
> >
> > You can't just invent a domain name for the headless system because
> > that gets the E-Mail rejected by intermediate systems that try and
> > look up the sender host name.  Cron doesn't seem to have any mechanism
> > for setting the sender's name, cron errors just come from 'root@'.
> >
> > Can anyone suggest a neat way of handling this so that I know where
> > the errors are coming from?
> >
> > --
> > Chris Green
>
> A hosts file based home network should suffice to fix that. I did have it

The OP is already running a DNS server, so he really does not need to bother
with a hosts file.

I expect the problem is that he is sending these E-Mails off the local LAN to
some E-Mail address "in the cloud" and spam filters are going to reject them
because the From: header will be wonky (like [hidden email]).

What he needs to do is set up a "gateway" system -- one of the machines on the
LAN needs to be set up as an outbound SMTP server for the LAN and needs to
Masqurade the addresses (eg rewrite the From: header) to something sane, like
his personal E-Mail address and add an X-Orig-From: headr line with the
original From: header. Or else set up a procmail recipe (on of the machines on
the LAN) that forwards the messages from his personal address.

> setup to do that from 3 of the now 5 machines here, but the inability to
> separate the messages into important turned the whole thing into spam
> for me. Set your resolv.conf to include the commands:
> "nameserver local.address.of.router"
> and:
> "order hosts,dns"
>
> So it will look at /etc/hosts first, failing to find a match there it
> sends it to the router, which forwards it to your ISP's dns.
>
> 1. Set the hostname and domain name of your machines so they know who
> they are.
>
> 2. run the same hosts file on all machines, which lists the local ip,
> names, and aliases of the whole local network, 7 lines here plus the
> obligatory localhost stuff, does it nicely.  Then on the client
> machines, I just set the MailTo: gene@coyote, and it magically appears
> in my /var/spool/mail/gene queue. That in turn triggers a watcher script
> to send kmail a getmail message over whatever message bus your system
> uses, dbus here ATM, to go get the mail.
>
> But unless you can make procmail (I use a fetchmail->procmail processing
> chain here) send the unimportant stuff to /dev/null, you'll likely tear
> it back down in a week or 2. You don't need to know, when logging into
> one of the other machines, everytime you fat fingered the password. With
> my short fat fingers, and 82 years of arthritis accumulated, very easily
> done.
>
> Cheers, Gene Heskett

--
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
[hidden email]       -- Webhosting Services
           

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Chris Green
On Fri, Feb 17, 2017 at 01:06:13PM -0500, Robert Heller wrote:

> At Fri, 17 Feb 2017 11:00:16 -0500 "Ubuntu user technical support, not
> for general discussions" <[hidden email]> wrote:
>
> >
> > On Friday 17 February 2017 06:14:01 Chris Green wrote:
> >
> > > I have several headless systems doing useful work around the place:-
> > >
> > >     A Raspberry Pi providing local DNS and DHCP
> > >
> > >     A Beaglebone Black on our boat monitoring temperatures and
> > > batteries
> > >
> > >     An old desktop doing backups in the garage
> > >
> > >     etc.
> > >
> > >
> > > Most of these have one or more cron jobs running periodic rsync
> > > backups, copying data, etc.  If the cron job has an error then it
> > > sends E-Mail to the owner of the job ('chris' in most cases, might be
> > > root in a couple).
> > >
> > > It's (moderately) easy to set up an MTA and /etc/aliases so that the
> > > messages are sent to my normal E-Mail.  However I can't come up with a
> > > straightforward way of indicating where the messsage is *from*.
> > >
> > > You can't just invent a domain name for the headless system because
> > > that gets the E-Mail rejected by intermediate systems that try and
> > > look up the sender host name.  Cron doesn't seem to have any mechanism
> > > for setting the sender's name, cron errors just come from 'root@'.
> > >
> > > Can anyone suggest a neat way of handling this so that I know where
> > > the errors are coming from?
> > >
> > > --
> > > Chris Green
> >
> > A hosts file based home network should suffice to fix that. I did have it
>
> The OP is already running a DNS server, so he really does not need to bother
> with a hosts file.
>
> I expect the problem is that he is sending these E-Mails off the local LAN to
> some E-Mail address "in the cloud" and spam filters are going to reject them
> because the From: header will be wonky (like [hidden email]).
>
That's exactly the problem.  

> What he needs to do is set up a "gateway" system -- one of the machines on the
> LAN needs to be set up as an outbound SMTP server for the LAN and needs to
> Masqurade the addresses (eg rewrite the From: header) to something sane, like
> his personal E-Mail address and add an X-Orig-From: headr line with the
> original From: header. Or else set up a procmail recipe (on of the machines on
> the LAN) that forwards the messages from his personal address.
>
The headless computers which send the messages are not all on one LAN,
one is just connected via a marina WiFi link.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Managing cron and similar E-Mails from headless systems

Robert Heller
At Fri, 17 Feb 2017 18:13:10 +0000 "Ubuntu user technical support,  not for general discussions" <[hidden email]> wrote:

>
> On Fri, Feb 17, 2017 at 01:06:13PM -0500, Robert Heller wrote:
> > At Fri, 17 Feb 2017 11:00:16 -0500 "Ubuntu user technical support, not
> > for general discussions" <[hidden email]> wrote:
> >
> > >
> > > On Friday 17 February 2017 06:14:01 Chris Green wrote:
> > >
> > > > I have several headless systems doing useful work around the place:-
> > > >
> > > >     A Raspberry Pi providing local DNS and DHCP
> > > >
> > > >     A Beaglebone Black on our boat monitoring temperatures and
> > > > batteries
> > > >
> > > >     An old desktop doing backups in the garage
> > > >
> > > >     etc.
> > > >
> > > >
> > > > Most of these have one or more cron jobs running periodic rsync
> > > > backups, copying data, etc.  If the cron job has an error then it
> > > > sends E-Mail to the owner of the job ('chris' in most cases, might be
> > > > root in a couple).
> > > >
> > > > It's (moderately) easy to set up an MTA and /etc/aliases so that the
> > > > messages are sent to my normal E-Mail.  However I can't come up with a
> > > > straightforward way of indicating where the messsage is *from*.
> > > >
> > > > You can't just invent a domain name for the headless system because
> > > > that gets the E-Mail rejected by intermediate systems that try and
> > > > look up the sender host name.  Cron doesn't seem to have any mechanism
> > > > for setting the sender's name, cron errors just come from 'root@'.
> > > >
> > > > Can anyone suggest a neat way of handling this so that I know where
> > > > the errors are coming from?
> > > >
> > > > --
> > > > Chris Green
> > >
> > > A hosts file based home network should suffice to fix that. I did have it
> >
> > The OP is already running a DNS server, so he really does not need to bother
> > with a hosts file.
> >
> > I expect the problem is that he is sending these E-Mails off the local LAN to
> > some E-Mail address "in the cloud" and spam filters are going to reject them
> > because the From: header will be wonky (like [hidden email]).
> >
> That's exactly the problem.  
>
> > What he needs to do is set up a "gateway" system -- one of the machines on the
> > LAN needs to be set up as an outbound SMTP server for the LAN and needs to
> > Masqurade the addresses (eg rewrite the From: header) to something sane, like
> > his personal E-Mail address and add an X-Orig-From: headr line with the
> > original From: header. Or else set up a procmail recipe (on of the machines on
> > the LAN) that forwards the messages from his personal address.
> >
> The headless computers which send the messages are not all on one LAN,
> one is just connected via a marina WiFi link.

OK, the ones on the main LAN can use a Masqurading outbound SMTP server. The
"oddball" headless computer connected via a marina WiFi link, is going to have
to be its own Masqurading outbound SMTP server. It should something
simple/stupid: redirect root to some local user that has a procmail recipe
that fiddles the "From:" header (or just forwards the message and inserts a
"spoofed" From: header (containing a legit E-Mail address).  If they are all
one-of's, then they all need to do something like use procmail to fiddle the
messages.

>

--
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
[hidden email]       -- Webhosting Services
                                                                     

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Loading...