Linux sends monitoring metrics to internal mailboxes

Source: Internet
Author: User


Database health monitoring is a very important work, important indicators \KPI monitoring results will have a special collection, monitoring, alarm system to do related things.
While some are not very important or are still in the design and commissioning phase of the relevant indicators, I just want to send to my own mailbox, this article on the server to configure the message to send monitoring data processing instructions.

Server version is Rhel 6.2:
[Email protected] ~]# cat/etc/issue
Red Hat Enterprise Linux Server Release 6.2 (Santiago)
Kernel \ r on an \m

Deactivate the relevant server:
[[Email protected] etc]# service SendMail stop
[[Email protected] etc]# service postfix stop
[[Email protected] etc]# service SendMail status
SendMail has stopped
Sm-client has stopped
[[Email protected] etc]# service postfix status
Master has stopped

The next steps are important, and by default SMTP used by the server is not able to send mail to the enterprise organization's internal mailbox, which requires the configuration of the enterprise organization's mailbox information:
[Email protected] etc]# tail/etc/mail.rc
# for Linux and BSD, this should is set.
Set Bsdcompat



Set from=[sender email address]
Set SMTP=[SMTP server address]
Set smtp-auth-user=[mailbox user name]
Set smtp-auth-password=[Email password]
Set Smtp-auth=login

Manual test to send mail:
[Email protected] etc]# echo Hello World |mail-s "test" [email protected]
[email protected] etc]# python dbcheck.py >dbcheck.txt;cat dbcheck.txt|mail-s dbcheck [email protected]
[email protected] etc]# python dbcheck.py >dbcheck.txt;mail-s dbcheck [email protected]<dhcheck.txt
[email protected] etc]# python dbcheck.py|mail-s dbcheck [email protected]

Send mail shell script:
[[Email protected]]$ cat/home/pg/pycharmprojects/dbcheck.sh
#!/bin/sh
. /etc/profile
. ~/.bash_profile
Python/home/pg/pycharmprojects/dbcheck.py|mail-s "DBCheck ' date +%f '%T '" [email protected]

To set a scheduled schedule task, Cron invokes the shell script:
[[Email protected]]$ crontab-l
*/1 * * * * sh/home/pg/pycharmprojects/dbcheck.sh 1>>/home/pg/check.log 2>&1
-eof-

Linux sends monitoring metrics to internal mailboxes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.