This article lists a few simple ways to learn in advance about various problems on the server, without littering your mailbox or setting up complex monitoring systems. From the category "if you are too lazy to check and tune something, then set up and check at least that."
Some of the utilities listed below can send email notifications on their own, simple shell wrappers are offered for the rest.
As a recipient, an additional local admins mailing is used, which includes the local root and external admin@example.ru. Why is local root not overridden instead?
First, by default, root can receive a lot of newsletters that help __ understand the reason for a problem that has already been discovered. They are important, but if you send all these letters to the outside, you either need to set up their filtering, or you are more likely to skip letters in their stream, allowing you to __to discover another _ unknown problem.
')
Secondly, because admins is not a standard account or group in popular Linux / Unix systems, then "
grep -r admins /etc /usr/local/etc
allows you to quickly determine which utilities have been configured for.
Mail Server Setup
Determining the server to use:
dpkg-query -S /usr/sbin/sendmail
(Debian-based)rpm -qf /usr/sbin/sendmail
(RPM-based)sudo netstat -ntlp | grep :25
sudo netstat -ntlp | grep :25
(all Linux)sockstat -4l | grep :25
sockstat -4l | grep :25
(FreeBSD)
Possible options in Debian and Ubuntu:
http://packages.debian.org/file:/usr/sbin/sendmailFurther, all the paths and command keys are based on Debian, except for the utilities for FreeBSD that are missing from Linux.
Exim
/ etc / aliases:
admins: root, admin@example.ru
Postfix
- /etc/postfix/main.cf:
virtual_alias_maps = hash:/etc/postfix/virtual
- / etc / postfix / virtual:
admins root admin@example.ru
- cd / etc / postfix && postmap virtual && cd / etc && postalias aliases && /etc/init.d/postfix restart
Full minimum main.cf:
SSMTP, MSMTP, ESMTP
Formal advantages compared with a full MTA:
- do not occupy space in ram,
- easier to set up
- less vulnerable because work with the rights of the calling user and do not accept network connections.
Actual deficiencies:
- if at the moment of sending the letter for some reason there is no connection with the external SMTP server, or the SMTP server refused to accept it, the letter will disappear,
- Recipient addresses are sometimes formed according to such strange rules that the SMTP server is unable to correctly determine to whom and where it should be delivered,
- see above root @ redirection considerations
Thus, the only place where imho makes sense to use them is lightweight virtual containers, for forwarding to an SMTP server running on Host OS.
Setting up monitoring services
Turn on server
Even some such administrators will learn about such an important event as unplanned reboots by accidentally checking uptime or last. The following line above “exit” in
/etc/rc.local will help you to be immediately informed about the events:
M="Booting complete on $(hostname)."; echo $M | mail -s "$M" admins
Linux SoftRAID (mdraid)
- /etc/mdadm/mdadm.conf:
MAILADDR admins
- /etc/init.d/mdadm restart
SMART
- /etc/smartd.conf:
DEVICESCAN ... -m admins ...
- /etc/init.d/smartmontools restart
Full minimum smartd.conf:
DEVICESCAN -d removable -n standby -m root -M exec /usr/share/smartmontools/smartd-runner
lm_sensors
- Run from rc.local:
/usr/local/sbin/healthd.sh &
- Healthd.sh code:
Other options:
- healthd.sh - lm-sensors.org/browser/lm-sensors/trunk/prog/daemon/healthd.sh
- sensormon - www.lm-sensors.org/attachment/ticket/2133/sensormon
- lm-monitor - sourceforge.net/projects/lm-monitor
Adaptec RAID
Other options:
- quad3datwork - www.sysadmintalk.net/forums/thread-1062.html
- aacraid-status - hwraid.le-vert.net/wiki/Adaptec#a3.3.aacraid-status
Intel MatrixRAID under FreeBSD
- Run: / usr / local / etc / periodic / daily / raidcheck
- Code:
Openvz
Daily check of quota overflow in containers -
sources.homelink.ru/openvzPS
90% of the note is a copy-paste from the local wiki. If someone comes in handy - well. Not useful - nothing terrible ;-))