PHP monitoring server [LNMPA]-PHP source code

Source: Internet
Author: User
PHP monitoring server [LNMPA] php code

 /Dev/null "; $ res = shell_exec ($ exec); if ($ res =" ") {$ connect_status ++; // server connection failure count + 1} else if (stripos ($ res, 'ongoexception ')! = False) {$ mongo_status ++; // The number of times that mongod cannot be linked + 1} else if (stripos ($ res, '500 Internal server ')! = False) {$ server_500_status ++;} else if (stripos ($ res, '502 Bad gateway ')! = False) {$ server_502_status ++;} else {// Server Normal} sleep (3);} // echo $ connect_status .. $ pai_status .. $ server_500_status .. $ server_502_status; exit; // if the server cannot work normally, restart the related service if ($ connect_status >=2 | $ mongo_status >=2 | $ server_500_status >=2 | $ server_502_status >=2) {shell_exec ($ killapache ); shell_exec ($ killapache); // terminate apacheshell_exec ($ kill_cmdd) twice; shell_exec ($ kill_cmdd); shell_exec (exec ($ Kill_cmdd); // 4 times to kill mongodshell_exec ($ start_xx1_mongod); // start xx1 Mongodshell_exec ($ invocation); // start xx2 Mongodshell_exec ($ restart_lnmpa ); // restart lnmpa} // send the email if ($ connect_status> = 2) {sendmail (array ('xx1 @ 139.com ', 'xx3 @ 139.com '), 'server cannot be linked ', 'server detected five times ,'. $ connect_status. 'cannot be linked'); exit;} else if ($ hyperlink _status> = 2) {sendmail (array ('xx1 @ 139.com ', 'xx3 @ 139.com '), 'mongod hung. 'five times detected Mongod ,'. $ pai_status. 'Next login'); exit;} e Lse if ($ server_500_status> = 2) {sendmail (array ('xx1 @ 139.com ', 'xx3 @ 139.com'), '500 Internal server', '5 Server detection, '. $ server_500_status. '500 Internal server'); exit;} else if ($ server_502_status> = 2) {sendmail (array ('XX @ 139.com ', 'xx1 @ xx.com ', 'xx2 @ 139.com '), '2017 Bad Gateway', '5 server detection times ,'. $ server_502_status. '502 Bad gateway'); exit;} else {// The server is normal. Please disable sending this email during production... Sendmail (array ('XX @ xx.com '), 'Good !!! Server Normal ', 'good Server Normal :'. $ connect_status .. $ pai_status .. $ server_500_status .. $ server_502_status); exit;} function sendmail ($ to, $ subject = "", $ body = "") {error_reporting (E_STRICT); date_default_timezone_set ("Asia/Shanghai "); // Set the time zone require_once '. /PHPMailer_5.2.1/class. phpmailer. php '; // This Class does not need to be explained. Google to find require_once '. /PHPMailer_5.2.1/class. smtp. php '; $ mail = new PHPMailer (); // A new PHPMailer object comes out $ mail-> CharSet = "UTF-8"; // sets the mail encoding, default ISO-8859-1, if you send Chinese characters, this item must be set; otherwise, garbled code $ mail-> IsSMTP (); // you can use the SMTP Service $ mail-> SMTPDebug = 1; // enable SMTP debugging // 1 = errors and messages // 2 = messages only $ mail-> SMTPAuth = true; // enable the SMTP authentication function $ mail-> SMTPSecure = "ssl"; // security protocol $ mail-> Host = "smtp.exmail.xx.com"; // SMTP service $ Mail-> Port = 465; // SMTP server Port $ mail-> Username = "xx@xxoo.com"; // SMTP server Username $ mail-> Password = "xxoo "; // SMTP server password $ mail-> SetFrom ('XX @ xxoo.com ', 'monitoring'); $ mail-> Subject = $ subject; $ mail-> MsgHTML ($ body); foreach ($ to as $ t) {$ mail-> AddAddress ($ t);} if (! $ Mail-> Send () {return false;} else {return true ;}}?>

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.