监控日志,发现500 503 等错误发送邮件提示
php代码
<?php include("PHPMailer/class.phpmailer.php"); //error_reporting(0); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "smtp.126.com"; // sets the SMTP server $mail->Port = 25; // set the SMTP port for the GMAIL server $mail->Username = "xxx@126.com"; // SMTP account username 邮箱用户名 $mail->Password = "xxxxxxxxx"; // SMTP account password 密码 $mail->SetFrom('xxxxxxx@126.com', '报错');// $now = "u_ex".date("ymdH").".log"; try{ $log = file("F:/iis-log/W3SVC2/".$now);//日志路径自己改 }catch(Exception $e){ echo "no file "; exit; } $error = array(); $start = date("i",time()-120); $end = date("i"); if($start > $end){ exit; } $aa = range($start,$end); $code = mkstr($aa); echo $code; $pattern = "/($code).*(\s500\s|\s503\s)/";//这里自己修改 $i = 0; foreach($log as $k => $v){ if(preg_match($pattern,$v)){ $error[] = $v; echo $v; $i += 1; } } if(!empty($error)){ $content = implode("<br/>",$error); $mail->Subject="$i errors "; $mail->AddAddress("xxxxxxxxxx@163.com"); $mail->AddAddress("xxxxxxxx@126.com"); $mail->MsgHTML($content); $mail->send(); } echo "\nover"; function mkstr($arr){ $code = ''; foreach($arr as $k => $e){ $code .="\:$e\:|"; } $code = rtrim($code,"|"); return $code; }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Redis is a high-performance key-value database. Through its fast data storage and access capabilities, it is widely used in the process of service registration and discovery. Service registration and discovery is a very important process in distributed systems. When we run multiple services on a machine, we need a way for clients to discover these services and how to interact with them. In a complete distributed system, there may be dozens of services running, and manual configuration has become unfeasible. At this time, we need to use service registration and discovery.

A robotics laboratory BEAR. Image source: Boston University According to a report on the British "New Scientist" magazine website on August 29, a robotic laboratory in the United States has discovered the toughest structure known so far. The laboratory can conduct 50 experiments a day without human supervision. , fabricate and test the mechanical structure. The latest research is expected to accelerate the discovery of new materials, and related papers have been submitted to a preprint website. In this latest study, Boston University researchers said they used an autonomous robotic laboratory called the Bayesian Experimental Autonomous Researcher (BEAR) to discover the most energy-absorbing material structure known to date. BEAR consists of five 3D printers, a set of scales, a testing machine, a robotic arm and computer vision for moving samples

500internal server error means HTTP 500 internal server error, which means that the server encountered an unexpected situation that caused it to be unable to fulfill the request, but it cannot explain the specific error or the root cause of the error; when an error occurs, the website visited will display an error. .

With the development of microservice architecture, service registration and discovery are becoming more and more important. For the Go language, due to its high efficiency and excellent concurrency performance, it is becoming more and more popular as a development language for microservices. This article will introduce how to register and discover services in Go language. What is service registration and discovery? Service registration and discovery means that the service provider registers its service to the service registration center, and the service consumer obtains the available service list from the registration center and calls the corresponding service. The service registry can be a separate process or a separate

Ethereum price started a recovery wave above the $2,250 level. ETH was able to clear the $2,280 resistance zone to move into a positive zone, but momentum was weak compared to Bitcoin.

According to one expert, the 2011 piece was minted to celebrate the London Olympics in 2012

Bitcoin has initiated a significant upward movement, surpassing the $57,500 resistance level and now showing promising signs of potentially reaching the $60,000 mark.

SOL has formed a cup-and-handle pattern on its weekly chart, which shows that the Solana price can surge by 2,600% and rise to $4,500.
