emails to myself when Yum updates my centos

General support questions
Post Reply
barneybloggs
Posts: 7
Joined: 2017/09/16 15:49:02

emails to myself when Yum updates my centos

Post by barneybloggs » 2018/05/26 13:31:15

Hi all,
Ive got a personal Centos7 server which is not part of a domain.
I only use it on my family network.
I thought it would be cool if I could setup email notification when yum downloads and installs updates.
Yum updates are running via a cron job which works perfectly.
i installed SSMTP which is working OK and I have sent and successfully received a test email I sent.
Yum has just done an update, but I received no email notification.

Here's the ssmtp.conf
#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#
# See the ssmtp.conf(5) man page for a more verbose explanation of the
# available options.
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
mailhub=mail

# Example for SMTP port number 2525
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=my.email.address@isp.com
AuthPass= <--- removed
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465

# Where will the mail seem to come from?
#RewriteDomain=

# The full hostname
#Hostname=

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
#FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
#UseTLS=YES
#IMPORTANT: The following line is mandatory for TLS authentication
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt

# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES

# Use this RSA certificate.
#TLSCert=/etc/pki/tls/private/ssmtp.pem

# Get enhanced (*really* enhanced) debugging information in the logs
# If you want to have debugging of the config file parsing, move this option
# to the top of the config file and uncomment
#Debug=YES

And here's my yum.conf

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php? ... tegory=yum
distroverpkg=centos-release


# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

And heres an extract of the latest yum update log
/var/log/yum.log
...
May 26 11:22:08 Updated: scap-security-guide.noarch 0.1.36-9.el7.centos
May 26 11:22:09 Updated: procps-ng.x86_64 3.3.10-17.el7_5.2
May 26 11:22:30 Installed: kernel.x86_64 3.10.0-862.3.2.el7
May 26 11:22:31 Updated: microcode_ctl.x86_64 2:2.1-29.2.el7_5

I appreciate you looking at this for me and, hopefully, spotting anything wrong.
If you need any further logs to assist please let me know and I will gladly share.

Regards,
barneybloggs

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: emails to myself when Yum updates my centos

Post by hunter86_bg » 2018/05/26 15:11:42

I don't see any feature to send an email in yum ,so you need to define it into your cron job. Can you give details how you send the e-mail ?

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: emails to myself when Yum updates my centos

Post by avij » 2018/05/26 16:02:41

If you have logwatch installed, it can send such notices. Typically once per day, though.

Code: Select all

 --------------------- yum Begin ------------------------ 

 
 Packages Updated:
    12:dhcp-common-4.2.5-68.el7.centos.1.x86_64
    jpegoptim-1.4.6-1.el7.x86_64
    12:dhclient-4.2.5-68.el7.centos.1.x86_64
    12:dhcp-libs-4.2.5-68.el7.centos.1.x86_64
 
 ---------------------- yum End ------------------------- 

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: emails to myself when Yum updates my centos

Post by TrevorH » 2018/05/26 16:31:03

yum-cron can email
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

barneybloggs
Posts: 7
Joined: 2017/09/16 15:49:02

Re: emails to myself when Yum updates my centos

Post by barneybloggs » 2018/05/27 01:25:32

TrevorH: yum-cron can email


Here's my yum-cron.conf
I have made one small change which hopefully will 'fix' the issue see [emitters] section:

[commands]
# What kind of update to use:
# default = yum upgrade
# security = yum --security upgrade
# security-severity:Critical = yum --sec-severity=Critical upgrade
# minimal = yum --bugfix update-minimal
# minimal-security = yum --security update-minimal
# minimal-security-severity:Critical = --sec-severity=Critical update-minimal
update_cmd = default

# Whether a message should be emitted when updates are available,
# were downloaded, or applied.
update_messages = yes

# Whether updates should be downloaded when they are available.
download_updates = yes

# Whether updates should be applied when they are available. Note
# that download_updates must also be yes for the update to be applied.
apply_updates = yes

# Maximum amout of time to randomly sleep, in minutes. The program
# will sleep for a random amount of time between 0 and random_sleep
# minutes before running. This is useful for e.g. staggering the
# times that multiple systems will access update servers. If
# random_sleep is 0 or negative, the program will run immediately.
# 6*60 = 360
random_sleep = 360


[emitters]
# Name to use for this system in messages that are emitted. If
# system_name is None, the hostname will be used.
system_name = None

# How to send messages. Valid options are stdio and email. If
# emit_via includes stdio, messages will be sent to stdout; this is useful
# to have cron send the messages. If emit_via includes email, this
# program will send email itself according to the configured options.
# If emit_via is None or left blank, no messages will be sent.
emit_via = ssmtp <--- I have now changed this option to email hopefully this will work!!??

# The width, in characters, that messages that are emitted should be
# formatted to.
output_width = 80


[email]
# The address to send email messages from.
# NOTE: 'localhost' will be replaced with the value of system_name.
email_from = localhost

# List of addresses to send messages to.
email_to = my.email.address@isp.com

# Name of the host to connect to to send email messages.
email_host = smtp.gmail.com


[groups]
# NOTE: This only works when group_command != objects, which is now the default
# List of groups to update
group_list = None

# The types of group packages to install
group_package_types = mandatory, default

[base]
# This section overrides yum.conf

# Use this to filter Yum core messages
# -4: critical
# -3: critical+errors
# -2: critical+errors+warnings (default)
debuglevel = -2

# skip_broken = True
mdpolicy = group:main

# Uncomment to auto-import new gpg keys (dangerous)
# assumeyes = True



Regards,
barneybloggs

barneybloggs
Posts: 7
Joined: 2017/09/16 15:49:02

Re: emails to myself when Yum updates my centos

Post by barneybloggs » 2018/05/27 13:42:09

Hi all,
Quick update.
The cron job ran early this morning but did not trigger an email.
Im sure this may be because I didnt restart the yum-cron.service. My bad.
Anyway, ive restarted the service now and am waiting for the cron job to run again and install something

yum-cron.service - Run automatic yum updates as a cron job
Loaded: loaded (/usr/lib/systemd/system/yum-cron.service; enabled; vendor preset: disabled)
Active: active (exited) since Sun 2018-05-27 14:30:38 BST; 12s ago
Process: 1118 ExecStop=/bin/rm -f /var/lock/subsys/yum-cron (code=exited, status=0/SUCCESS)
Process: 1120 ExecStart=/bin/touch /var/lock/subsys/yum-cron (code=exited, status=0/SUCCESS)
Main PID: 1120 (code=exited, status=0/SUCCESS)

May 27 14:30:38 centsrv systemd[1]: Starting Run automatic yum updates as a cron job...
May 27 14:30:38 centsrv systemd[1]: Started Run automatic yum updates as a cron job.

Regards,
barneybloggs

Post Reply