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