In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Reference blog: http://blog.chinaunix.net/uid/26118446.html small drill wind
Http://www.iyunv.com/thread-61736-1-1.html Operation and maintenance Network Forum posts
After setting up the zabbix monitoring service system, it took some time to add the email alarm function, because first it could be sent to the 163mailbox, but not to QQ Mail, and then the email was sent as an attachment instead of directly displaying the alarm content:
Test done with 163:
Send alarm email settings using an external mailbox account
First, close sendmail or postfix
Service sendmail stop # shutdown
Chkconfig sendmail off # disable boot
Service postfix stop
Chkconfig postfix off
Note:
When using an external email account, you do not need to start sendmail or postfix
If you use an external mailbox to send an alarm email while sendmail or postfix is started, the external mailbox configuration information will be read first.
Second, install the mail sending tool mailx
Yum install mailx # installation
CentOS 5.x compilation and installation of mailx, direct yum installation of the mailx version is too old, using external mail to send will be problematic, CentOS6.X comes with the version of mailx12.4.
Yum remove mailx # Uninstalls the old version of mailx that comes with the system
Download mailx:
Http://nchc.dl.sourceforge.net/project/heirloom/heirloom-mailx/12.4/mailx-12.4.tar.bz2
Tar jxvf mailx-12.4.tar.bz2 # decompression
Cd mailx-12.4 # enter the directory
Make # compilation
Make install UCBINSTALL=/usr/bin/install # installation
Ln-s / usr/local/bin/mailx / bin/mail # create a soft connection from mailx to mail
Ln-s / etc/nail.rc / etc/mail.rc # create mailx profile soft connection
Whereis mailx # View the installation path
Mailx-V # View version information
3. Configure Zabbix server external mailbox
Edit vi / etc/mail.rc # to add the following information
Set from=xxx@163.com smtp=smtp.163.com
Set smtp-auth-user=xxx@163.comsmtp-auth-password=123456
Set smtp-auth=login
: wq! # Save exit
# echo "zabbix test mail" | mail-s "zabbix" yyy@163.com
# Test send email with title zabbix, message content: zabbix test mail, mailbox sent to: yyy@163.com
# at this time, email yyy@163.com will receive a test email from xxx@163.com
4. Configure Zabbix server mail alarm
1. Open Zabbix
Manage-alert media type-create media type
Name: Sendmail
Type: script
Script name: sendmail.sh
Enabled: check
Archiving
2. Set the email address of Zabbix user alarm.
Administration-user-Admin (Zabbix Administrator)
Switch to alarm medium-add
Type: Sendmail
To: xxx@163.com
Other defaults are fine, or
To set up as needed
Status: enabled
Archiving
3. Set the action of Zabbix to trigger the alarm
Configuration-Action-create Action
Name: Action-Email
Default recipient: fault {TRIGGER.STATUS}, server: {HOSTNAME1} occurred: {TRIGGER.NAME} failure!
Default information:
Alarm host: {HOSTNAME1}
Alarm time: {EVENT.DATE} {EVENT.TIME}
Alarm level: {TRIGGER.SEVERITY}
Alarm message: {TRIGGER.NAME}
Alarm item: {TRIGGER.KEY1}
Question details: {ITEM.NAME}: {ITEM.VALUE}
Current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
Event ID: {EVENT.ID}
Recovery information: ticking
Recovery gist: restore {TRIGGER.STATUS}, server: {HOSTNAME1}: {TRIGGER.NAME} has been restored!
Recovery information:
Alarm host: {HOSTNAME1}
Alarm time: {EVENT.DATE} {EVENT.TIME}
Alarm level: {TRIGGER.SEVERITY}
Alarm message: {TRIGGER.NAME}
Alarm item: {TRIGGER.KEY1}
Question details: {ITEM.NAME}: {ITEM.VALUE}
Current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
Event ID: {EVENT.ID}
Enabled: tick
Switch to the action option
New
Operation type: send information
Send to users: add
Default message: tick
Select user: Admin
Choice
Send only to: Sendmail
Archiving
4. Add Zabbix server mail sending script
Cd / usr/local/zabbix/share/zabbix/alertscripts # enter the directory where zabbix scripts are stored
Edit vi sendmail.sh # to add the following code
#! / bin/sh
Echo "$3" | mail-s "$2" $1
: wq! # Save exit
Or
This is posted by the operation and maintenance network:
01
02
03
#! / bin/bash
# echo "$3" | mail-s "$2" $1
Echo "$3" | sed sqqqa'\ rnsqqplash g | mail-s "$2" $1
Chown zabbix.zabbix / usr/local/zabbix/share/zabbix/alertscripts/sendmail.sh
# set script owner to zabbix user
Chmod + x / usr/local/zabbix/share/zabbix/alertscripts/sendmail.sh
# set script execution permissions
Fifth, test Zabbix alarm
Turn off the Zabbix client service
Service zabbix_agentd stop
Check your xxx@163.com email and you will receive an alarm email.
Start the Zabbix client service again
Service zabbix_agentd start
Check your xxx@163.com mailbox and you will receive a recovery email
E-mail can be received, but only in the form of an attachment
Reason:
In the Unix system, there is only "" or "\ n" at the end of each line; in the Windows system, the end of each line is "", that is, "\ r\ n"; in the Mac system, the end of each line is "", that is, "\ r";. One direct consequence is that if files under Unix/Mac are opened in Windows, all text will become one line, while files in Windows may have an extra ^ M symbol at the end of each line if they are opened under Unix/Mac. "
So there is a way to convert the .bin file format by dos2unix.
Solution:
Install dos2unix format conversion software
Yum-y install dos2unix
Vim / usr/local/zabbix/share/zabbix/alertscripts/sendmail.sh
1. #! / bin/bash
2. Export zabbixemailto= "$1"
3. Export zabbixsubject= "$2"
4. Export zabbixbody= "$3"
5. FILE=/usr/local/zabbix/share/zabbix/alertscripts/mail.txt
6. Echo "$3" > $FILE
7. / usr/bin/dos2unix-k $FILE
8. Mail-s "$2" $1 < $FILE
After this configuration, we still only receive attachments, and after searching the Internet, most of them are in this configuration mode. Find a method posted by a netizen and try to be feasible:
Vim / usr/local/zabbix/share/zabbix/alertscripts/sendmail.sh
1. #! / bin/bash
2. Exportzabbixemailto= "$1"
3. Exportzabbixsubject= "$2"
4. Exportzabbixbody= "$3"
5. Zabbixbody= `echo $zabbixbody | tr'\ r'\ n``
6. Cat
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.