Send monitoring metrics to the internal mailbox in Linux

Source: Internet
Author: User

Send monitoring metrics to the internal mailbox in Linux

Database health monitoring is a very important task. An important indicator/KPI monitoring result has a dedicated collection, monitoring, and alarm system for relevant tasks.
Some indicators that are not very important or are still in the design and debugging phase, I just want to send them to my own mailbox. This article describes the process of configuring mail to send monitoring data on the server.

The server version is RHEL 6.2:
[Pg @ gtlions ~] # Cat/etc/issue
Red Hat Enterprise Linux Server release 6.2 (Santiago)
Kernel \ r on an \ m

Disable related servers:
[Root @ gtlions etc] # service sendmail stop
[Root @ gtlions etc] # service postfix stop
[Root @ gtlions etc] # service sendmail status
Sendmail stopped
Sm-client stopped
[Root @ gtlions etc] # service postfix status
Master stopped

The next step is important. By default, the SMTP used by the server cannot send emails to the internal mailbox of the enterprise organization. Therefore, you need to configure the mailbox information of the enterprise organization:
[Root @ gtlions etc] # tail/etc/mail. rc
# For Linux and BSD, this shoshould be set.
Set bsdcompat



Set from = [Sender's email address]
Set smtp = [smtp server address]
Set smtp-auth-user = [email user name]
Set smtp-auth-password = [email password]
Set smtp-auth = login

Manually test the email sending function:
[Root @ gtlions etc] # echo hello world | mail-s "test" gtlions@lai.com
[Root @ gtlions etc] # python dbcheck. py> dbcheck.txt; cat dbcheck.txt | mail-s dbcheckgtlions@lai.com
[Root @ gtlions etc] # python dbcheck. py> dbcheck.txt; mail-s dbcheckgtlions@lai.com <dhcheck.txt
[Root @ gtlions etc] # python dbcheck. py | mail-s dbcheck gtlions@lai.com

Shell script for sending emails:
[Pg @ gtlions] $ cat/home/pg/PycharmProjects/dbcheck. sh
#! /Bin/sh
./Etc/profile
.~ /. Bash_profile
Python/home/pg/PycharmProjects/dbcheck. py | mail-s "dbcheck 'date + % f'' % t'" gtlions@lai.com

Set the scheduled task and CRON calls the shell script:
[Pg @ gtlions] $ crontab-l
*/1 ***** sh/home/pg/PycharmProjects/dbcheck. sh 1>/home/pg/check. log 2> & 1
-EOF-

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.