Re: F20 - Unintended consequences of no default MTA - How best to fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/02/2014 12:55 PM, Lars E. Pettersson wrote:
> On 01/02/2014 08:45 PM, Chris Murphy wrote:
>>>> Is there something you expect to see that is missing from the journal?
>>>
>>> Yes, the output of cron, that is not a part of the journal output.
>>
>> Then cron is broken.
>
> cron by default sends the output to root
>
> $ head /etc/crontab
> SHELL=/bin/bash
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> MAILTO=root
>
> From 'man cron':
>
> "When executing commands, any output is mailed to the owner of the
crontab (or to the  user  specified  in  the MAILTO  environment
variable in the crontab, if such exists)."
>
> It also states:
>
> "Any job output can also be sent to syslog by using the -s option."
>
> The problem with that option is that the output from cron can
voluminous, and voluminous messages are better suited as mails.
>
> Lars

I think there was some misunderstanding here. If you can't find your
cronjob output in the journal, *your* cron is broken. Before I get too
far in, in my opinion, mails are good for notification, voluminous
content should be in the logs that the mail notifies about. The journal
is good at logs.

$ su -c 'crontab -l'
* * * * * echo "TEST TEST"
$ crontab -l
 * * * * LARSHAPPY="no"; if [[ "$LARSHAPPY" == "no" ]]; then echo -e
"This isn't the same.\nNew Things are Different.\nSome people like the
old thing.";fi

$ journalctl SYSLOG_IDENTIFIER=CROND -f  #filtered for convenience
Jan 02 20:19:01 ruminant-randomuser-lan CROND[7923]: (pete) CMD
(LARSHAPPY="no"; if [[ "$LARSHAPPY" == "no" ]]; then echo -e "This isn't
the same.\nNew Things are Different.\nSome people like the old thing.";
Jan 02 20:19:01 ruminant-randomuser-lan CROND[7922]: (root) CMD (echo
"TEST TEST")
Jan 02 20:19:01 ruminant-randomuser-lan CROND[7918]: (root) CMDOUT (TEST
TEST)
Jan 02 20:19:01 ruminant-randomuser-lan CROND[7919]: (pete) CMDOUT (This
isn't the same.)
Jan 02 20:19:01 ruminant-randomuser-lan CROND[7919]: (pete) CMDOUT (New
Things are Different.)
Jan 02 20:19:01 ruminant-randomuser-lan CROND[7919]: (pete) CMDOUT (Some
people like the old thing.)


But wait! These things could get all mixed up on a busy machine, you
say! Let's take a closer look at a message:

MESSAGE=(pete) CMDOUT (New Things are Different.)
    _AUDIT_SESSION=83
    _SYSTEMD_CGROUP=/user.slice/user-1000.slice/session-83.scope
    _SYSTEMD_SESSION=83
    _SYSTEMD_UNIT=session-83.scope
    SYSLOG_PID=8141
    _PID=8141
    _SOURCE_REALTIME_TIMESTAMP=1388719561402125
Thu 2014-01-02 20:26:01.402133 MST
[s=04f24177eb10446c94ea389f0e5adb2f;i=49d85;b=0557929cbde247928f945d8b53a6e067;m=b529d73d;t=4ef0878266935;x=ade119e61f79d8c4]
    PRIORITY=6
    _UID=0
    _MACHINE_ID=0fb42f5d126e4f4e8b94045b4652c0f2
    _HOSTNAME=ruminant-randomuser-lan
    _CAP_EFFECTIVE=1fffffffff
    _TRANSPORT=syslog
    SYSLOG_FACILITY=9
    _COMM=crond
    _EXE=/usr/sbin/crond
    _SELINUX_CONTEXT=system_u:system_r:crond_t:s0-s0:c0.c1023
    _GID=1000
    _AUDIT_LOGINUID=1000
    _SYSTEMD_OWNER_UID=1000
    _SYSTEMD_SLICE=user-1000.slice
    SYSLOG_IDENTIFIER=CROND
    _CMDLINE=/usr/sbin/CROND -n
    _BOOT_ID=0557929cbde247928f945d8b53a6e067


All of that information is available to the user/admin, and to any
applications reading the journal. Applications writing to the journal
can even provide some extra metadata to aid in filtering - say, the name
of a cronjob. Lots of ways to match this message. Let's try
_AUDIT_SESSION, that sounds unique-ish:

$ journalctl SYSLOG_IDENTIFIER=CROND _AUDIT_SESSION=83 -b
- -- Logs begin at Sun 2013-12-01 03:10:01 MST. --
Jan 02 20:26:01 ruminant-randomuser-lan CROND[8145]: (pete) CMD
(LARSHAPPY="no"; if [[ "$LARSHAPPY" == "no" ]]; then echo -e "This isn't
the same.\nNew Things are Different.\nSome people like ...d thing.";fi)
Jan 02 20:26:01 ruminant-randomuser-lan CROND[8141]: (pete) CMDOUT (This
isn't the same.)
Jan 02 20:26:01 ruminant-randomuser-lan CROND[8141]: (pete) CMDOUT (New
Things are Different.)
Jan 02 20:26:01 ruminant-randomuser-lan CROND[8141]: (pete) CMDOUT (Some
people like the old thing.)


Stop! I don't want all that extra information, you say! `journalctl`
should KNOW I'm not interested in the timestamp, or the hostname, or the
name and PID of the reporting binary - just give me the message!

journalctl SYSLOG_IDENTIFIER=CROND _AUDIT_SESSION=83 -o cat
(pete) CMD (LARSHAPPY="no"; if [[ "$LARSHAPPY" == "no" ]]; then echo -e
"<This isn't the same.\nNew Th
(pete) CMDOUT (This isn't the same.)
(pete) CMDOUT (New Things are Different.)
(pete) CMDOUT (Some people like the old thing.)


I'll agree that this isn't as *simple* as banging out a four letter word
and reading message, but the journal can provide context, too. If
something catastrophic happens, the kind of thing that might lead you
frantically searching through root's mail for answers, context can be
important.  We can grab the cursor from the query above, and broaden the
filter to see what else was happening at the time. (timestamp could work
to, with --since, I suppose, but it's not quite the same thing.)

$ journalctl SYSLOG_IDENTIFIER=CROND _AUDIT_SESSION=83 -b
--show-cursor|tail -1
- -- cursor:
s=04f24177eb10446c94ea389f0e5adb2f;i=49d85;b=0557929cbde247928f945d8b53a6e067;m=b529d73d;t=4ef0878266935;x=ade119e61f79d8c4

$ journalctl
--cursor="s=04f24177eb10446c94ea389f0e5adb2f;i=49d85;b=0557929cbde247928f945d8b53a6e067;m=b529d73d;t=4ef0878266935;x=ade119e61f79d8c4"
- -- Logs begin at Sun 2013-12-01 03:10:01 MST, end at Thu 2014-01-02
20:36:08 MST. --
Jan 02 20:26:01 ruminant-randomuser-lan CROND[8141]: (pete) CMDOUT (Some
people like the old thing.)
Jan 02 20:26:43 ruminant-randomuser-lan dhclient[1683]: DHCPREQUEST on
em2 to 192.168.1.3 port 67 (xid=0
Jan 02 20:26:43 ruminant-randomuser-lan NetworkManager[748]: DHCPREQUEST
on em2 to 192.168.1.3 port 67 (
Jan 02 20:26:43 ruminant-randomuser-lan dhclient[1683]: DHCPACK from
192.168.1.3 (xid=0x5ec0b63f)
Jan 02 20:26:43 ruminant-randomuser-lan NetworkManager[748]: DHCPACK
from 192.168.1.3 (xid=0x5ec0b63f)
Jan 02 20:26:43 ruminant-randomuser-lan dhclient[1683]: bound to
192.168.1.167 -- renewal in 281 seconds
Jan 02 20:26:43 ruminant-randomuser-lan NetworkManager[748]: <info>
(em2): DHCPv4 state changed renew ->
Jan 02 20:26:43 ruminant-randomuser-lan NetworkManager[748]: <info>  
address 192.168.1.167
Jan 02 20:26:43 ruminant-randomuser-lan NetworkManager[748]: <info>  
plen 24 (255.255.255.0)
Jan 02 20:26:43 ruminant-randomuser-lan NetworkManager[748]: <info>  
gateway 192.168.1.1
Jan 02 20:26:43 ruminant-randomuser-lan NetworkManager[748]: <info>  
lease time 600
Jan 02 20:26:43 ruminant-randomuser-lan NetworkManager[748]: <info>  
nameserver '192.168.1.3'
Jan 02 20:26:43 ruminant-randomuser-lan NetworkManager[748]: <info>  
domain name 'randomuser.lan'
Jan 02 20:26:43 ruminant-randomuser-lan NetworkManager[748]: bound to
192.168.1.167 -- renewal in 281 se



You're putting lots of effort into complaining about a hugely useful
tool, and apparently little into learning about it.  If the complaint is
about cronjobs, start here:

http://0pointer.de/blog/projects/journal-submit.html
https://git.fedorahosted.org/git/cronie.git

Of course, if you like the old way, you can just install and configure
an MTA.

- -- 
- -- Pete Travis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSxjeBAAoJEL1wZM0+jj2Z3XAH/RluryvmhmIetfJD3TuguTW4
f7FwPpgc75ae92gBEMi+4QnHsicUEPFq5m4gfleoCTyAaQ8kcMpUmJQffApur773
HzIPxsN+rvTEyTWCWu269crkOeBFhig0L0n7/M6OqDo8dAl7QdGPgzg1650T2YT6
w57FXF1PEJPJ5Bzvd7vcYi269/l14iTKVTOxe4AuQj1GyjUlNHq3P1yjdBL9KRSS
QRoMFp151iwtcm8AaRPSeHa3Xvy5BaPKDaU5flzDuw1u3qLvxNI7U8MJVjH3tArb
0GLYTEVM5HAoqNdtb2x139J983F7GTYauFQBTm7OtRXL04OGuEXd4TjdLPOYgZQ=
=iPBF
-----END PGP SIGNATURE-----

-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org




[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux