In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
CentOS 7.7.How to use the Shell script to monitor the number of logged-in users and configure QQ Mail to send email alarms. In view of this question, this article introduces in detail the corresponding analysis and answers, hoping to help more partners who want to solve this problem to find a more simple and easy way.
First, configure QQ Mail to send mail:
# yum-y install mailx
# cp / etc/mail.rc {, .bak}
# vim / etc/mail.rc, with the following code added at the end:
Set from=834143808@qq.com
Set smtp=smtp.qq.com
Set smtp-auth-user=834143808@qq.com
Set smtp-auth-password=QQ mailbox authorization code
Set smtp-auth=login
# echo "Hello World" | mail-s "test" 834143808@qq.com
Second, write a Shell script to monitor the number of logged-in users:
Goal: the number of logged-in users in the system is more than 3, and email alarm is realized.
# mkdir-pv / scripts
# vim / scripts/check_users.sh
#! / bin/bash
Users= `who | wc-l`
If [$users-gt 3]; then
Echo "the number of current system login users is $users" | mail-s "system login users" 834143808@qq.com
Fi
# chmod + x / scripts/check_users.sh
III. Prepare a mission plan:
# crontab-e
* / 5 * / scripts/check_users.sh & > / dev/null
Fourth, open more connection windows, simulate multi-user login, and test email alarms:
This is the answer to the question about how CentOS 7.7 uses the Shell script to monitor the number of logged-in users and configure QQ Mail to send email alarms. I hope the above content can be of some help to all of you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.