DoDo original, reprinted please indicate the source
SA is necessary for server monitoring. However, if many servers are managed, it is impossible to monitor the server online 24 hours a day.
The main content of this article is implementation. If an exception occurs on the server, the server will be sent directly to the Administrator's mobile phone via text message. SA can immediately know that the server has encountered an exception, in this way, the fastest time can be processed.
The principle is very simple, China Mobile provides a mailbox such as 139.com, if there is an email arrives, will also send the mail title to the Administrator corresponding mobile phone, mailbox name is your mobile phone number @ 139.com, For example: 13036110648@139.com, when this mailbox receives the mail, it will send the mail arrival information to the mobile phone 13036110648 at the same time, the mail registration addressHttp://mail.139.com/
Before you implement the following functions, register your email address (this function is now provided free of charge by mobile phone)
The following functions are implemented:
Monitor User Logon
We know that users usually load logon scripts when logging on ~ /. Bashrc, we can add the following in this script:
# Echo at now + 1 minutes-f/data/checklogin. sh>/dev/null 2> & 1> ~ /. Bashrc
Then the user will execute/data/checklogin in 1 minute after logging on. sh script (why do I need to send a text message after one minute, because if I log in, I don't need to send a text message and give myself time to use atrm to cancel the task schedule). The script content is as follows:
# Cat/data/checklogin. sh
#! /Bin/sh
Echo "'Who">/data/login. log
Mail-s "'who '"13036110648@139.com</Data/login. log
# Chmod a + x/data/checklogin. sh
# Touch/data/login. log
# Chmod a + w/data/login. log
After this is done, the current logged-on user information will be sent to the Administrator's mobile phone number by text message every time this user logs on.
Of course, you can monitor all user logins, so you should modify the/etc/bashrc logon script.