{"id":1651,"date":"2025-07-19T15:55:30","date_gmt":"2025-07-19T07:55:30","guid":{"rendered":"https:\/\/www.yeetrack.com\/?p=1651"},"modified":"2025-08-21T11:22:52","modified_gmt":"2025-08-21T03:22:52","slug":"%e5%88%86%e5%b8%83%e5%bc%8f%e7%bd%91%e7%bb%9c%e5%bb%b6%e8%bf%9f%e7%9b%91%e6%8e%a7%e5%b7%a5%e5%85%b7-smartping","status":"publish","type":"post","link":"https:\/\/www.yeetrack.com\/?p=1651","title":{"rendered":"\u5206\u5e03\u5f0f\u7f51\u7edc\u5ef6\u8fdf\u76d1\u63a7\u5de5\u5177-smartping"},"content":{"rendered":"<p>\u4e0a\u7bc7\u6587\u7ae0<a href=\"https:\/\/www.yeetrack.com\/?p=1623\">\u7f51\u7edc\u5ef6\u8fdf\u76d1\u63a7-smokeping<\/a>\u8bb2\u5230smokeping\u8fd9\u6b3e\u7f51\u7edc\u5ef6\u8fdf\u76d1\u63a7\u5de5\u5177\uff0c\u5f00\u6e90\u4e14\u914d\u7f6e\u7b80\u5355\uff0c\u9002\u5408\u7528\u6765\u76d1\u63a7\u5404\u4e2a\u8282\u70b9\u5230master\u7684\u7f51\u7edc\u60c5\u51b5\uff1b\u4f46\u5982\u679c\u60f3\u76d1\u63a7\u5404\u4e2a\u8282\u70b9\u4e4b\u95f4\u7684\u7f51\u7edc\u60c5\u51b5\uff0c\u6709\u53e6\u5916\u4e00\u6b3e\u5f00\u6e90\u7684\u5de5\u5177\u53ef\u7528<a href=\"https:\/\/smartping.org\/\">smartping<\/a>\uff0c\u8fd9\u6b3e\u5de5\u5177\u5373\u9002\u5408\u5355\u70b9\u90e8\u7f72\uff0c\u4e5f\u80fd\u5206\u5e03\u5f0f\uff0c\u9002\u5408\u76d1\u63a7\u6574\u4e2a\u7f51\u7edc\u96c6\u7fa4\u7684\u60c5\u51b5\u3002  <\/p>\n<p><!--more--><\/p>\n<h2>\u5b89\u88c5<\/h2>\n<p>smartping\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u5b98\u65b9\u63d0\u4f9b\u4e8c\u8fdb\u5236\u7a0b\u5e8f\uff0c\u76f4\u63a5\u8fd0\u884c\u5373\u53ef\uff0c<a href=\"https:\/\/docs.smartping.org\/install\/\">https:\/\/docs.smartping.org\/install\/<\/a>\u3002\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\uff0c\u4f9d\u8d56\u672c\u5730\u5b89\u88c5go\u73af\u5883\u3002\u542f\u52a8\u4e4b\u540e\uff0c\u76f4\u63a5\u8bbf\u95ee\u5373\u53ef\uff0c<a href=\"http:\/\/127.0.0.1:8899\">http:\/\/127.0.0.1:8899<\/a>. \u9ed8\u8ba4\u5bc6\u7801\uff1asmartping<br \/>\n<a href=\"https:\/\/image.yeetrack.com\/wp-content\/uploads\/2025\/07\/1-scaled.png\"><img decoding=\"async\" src=\"https:\/\/image.yeetrack.com\/wp-content\/uploads\/2025\/07\/1-scaled.png\" alt=\"\" \/><\/a><br \/>\n<a href=\"https:\/\/image.yeetrack.com\/wp-content\/uploads\/2025\/07\/2-scaled.png\"><img decoding=\"async\" src=\"https:\/\/image.yeetrack.com\/wp-content\/uploads\/2025\/07\/2-scaled.png\" alt=\"\" \/><\/a><\/p>\n<h2>\u5206\u5e03\u5f0f\u90e8\u7f72<\/h2>\n<p>\u5982\u679c\u8981\u76d1\u63a7\u591a\u4e2a\u8282\u70b9\u4e4b\u95f4\u7684\u7f51\u7edc\u60c5\u51b5\uff0c\u5c31\u9700\u8981\u5728\u6bcf\u4e2a\u8282\u70b9\u4e0a\u90fd\u5b89\u88c5smartping\uff0c\u8fd9\u6837\u6bcf\u4e2a\u8282\u70b9\u90fd\u53ef\u4ee5\u4e3b\u52a8\u53d1\u8d77ping\u8bf7\u6c42\uff0c\u6765\u76d1\u6d4b\u81ea\u8eab\u4e0e\u5176\u4ed6\u8282\u70b9\u7684\u7f51\u7edc\u8d28\u91cf\u3002\u82e5\u6bcf\u4e2a\u8282\u70b9\u90fd\u8981\u914d\u7f6e\uff0c\u90a3\u5c31\u975e\u5e38\u9ebb\u70e6\u4e86\uff1b\u8fd9\u65f6\u5019\uff0c\u53ef\u4ee5\u7559\u4e00\u4e2a\u8282\u70b9\u4f5c\u4e3a\u672c\u5730\u6a21\u5f0f\uff0c\u5176\u4ed6\u8282\u70b9\u90fd\u914d\u7f6e\u6210\u4e91\u6a21\u5f0f\uff0c\u5176\u5b9e\u5c31\u662fmaster\u3001slave\u6a21\u5f0f\uff0cslave\u8282\u70b9\u4f1a\u81ea\u52a8\u4ecemaster\u8282\u70b9\u540c\u6b65\u914d\u7f6e\uff0c\u7701\u53bb\u4e86\u7e41\u7410\u7684\u914d\u7f6e\u8fc7\u7a0b\u3002<br \/>\n\u4e91\u914d\u7f6e\u5730\u5740\uff1a<a href=\"http:\/\/XX.XX.XX.XX:8899\/api\/config.json\uff0c\u4e5f\u5c31\u662fmaster\u7684\u914d\u7f6e\u5730\u5740\uff0c\u5bc6\u7801\u9ed8\u8ba4\u4e3a\uff1asmartping\">http:\/\/XX.XX.XX.XX:8899\/api\/config.json\uff0c\u4e5f\u5c31\u662fmaster\u7684\u914d\u7f6e\u5730\u5740\uff0c\u5bc6\u7801\u9ed8\u8ba4\u4e3a\uff1asmartping<\/a><br \/>\n<a href=\"https:\/\/image.yeetrack.com\/wp-content\/uploads\/2025\/07\/3-scaled.png\"><img decoding=\"async\" src=\"https:\/\/image.yeetrack.com\/wp-content\/uploads\/2025\/07\/3-scaled.png\" alt=\"\" \/><\/a>  <\/p>\n<p><a href=\"https:\/\/image.yeetrack.com\/wp-content\/uploads\/2025\/07\/4.png\"><img decoding=\"async\" src=\"https:\/\/image.yeetrack.com\/wp-content\/uploads\/2025\/07\/4.png\" alt=\"\" \/><\/a><\/p>\n<h2>\u89e3\u51b3\u90ae\u4ef6\u62a5\u8b66\u95ee\u9898<\/h2>\n<p>smartping\u652f\u6301\u90ae\u4ef6\u53d1\u9001\u62a5\u8b66\u7684\u529f\u80fd\uff0c\u4f46\u5728\u914d\u7f6e\u90ae\u7bb1\u4fe1\u606f\u65f6\uff0c\u53d1\u73b0\u539f\u4f5c\u8005\u53ea\u652f\u6301\u4e8625\u7aef\u53e3\uff0c\u4e00\u822c\u516c\u53f8\u90ae\u7bb1\u7684smtp\u670d\u52a1\u5668\u90fd\u662f\u52a0\u5bc6\u7684\uff0c\u5982465\u3001587\u7aef\u53e3\u7b49\u3002\u672c\u5de5\u5177\u662f\u5f00\u6e90\u7684\uff0c\u76f4\u63a5\u4fee\u6539\u4e0b\u6e90\u7801\uff0c\u518d\u7f16\u8bd1\u5b89\u88c5\u5373\u53ef\u5b8c\u6210\u3002  <\/p>\n<ol>\n<li>\u6e90\u7801\u5730\u5740\uff1a<a href=\"https:\/\/github.com\/smartping\/smartping\">https:\/\/github.com\/smartping\/smartping<\/a>  <\/li>\n<li>\u672c\u5730\u5b89\u88c5go\u73af\u5883\u3002  <\/li>\n<li>\n<p>\u53d1\u9001\u90ae\u4ef6\u7684\u4ee3\u7801\u5728<code>src\/funcs\/alert.go<\/code>\u4e2d\uff0c\u4f5c\u8005\u6e90\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-go\">func SendMail(user, pwd, host, to, subject, body string) error {\n    if len(strings.Split(host, \":\")) == 1 {\n        host = host + \":25\"\n    }\n    auth := smtp.PlainAuth(\"\", user, pwd, strings.Split(host, \":\")[0])\n    content_type := \"Content-Type: text\/html\" + \"; charset=UTF-8\"\n    msg := []byte(\"To: \" + to + \"\\r\\nFrom: \" + user + \"\\r\\nSubject: \" + subject + \"\\r\\n\" + content_type + \"\\r\\n\\r\\n\" + body)\n    send_to := strings.Split(to, \";\")\n    err := smtp.SendMail(host, auth, user, send_to, msg)\n    if err != nil {\n        return err\n    }\n    return nil\n}<\/code><\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\u6e90\u7801\u4e2d\u9996\u5148\u5224\u65ad\u662f\u5426\u542b\u6709\u5192\u53f7\uff0c\u5982\u679c\u5c31\u628a\u7aef\u53e3\u8bbe\u7f6e\u4e3a25\uff0c\u5e76\u4e14\u4f7f\u7528PlainAuth\u7684\u65b9\u5f0f\u8fdb\u884c\u767b\u5f55\uff0c\u5728\u8fd9\u91cc\u52a0\u4e0a\u5bf9\u5176\u4ed6\u7aef\u53e3\u7684\u517c\u5bb9\u5373\u53ef\u3002\u4fee\u6539\u5982\u4e0b\uff1a  <\/p>\n<pre><code>func SendMail(user, pwd, host, to, subject, body string) error {\n    if !strings.Contains(host, \":\") {\n        host += \":25\" \/\/ \u9ed8\u8ba4\u4f7f\u752825\u7aef\u53e3\n    }\n    parts := strings.Split(host, \":\")\n    server := parts[0]\n    port := parts[1]\n\n    recipients := strings.Split(to, \";\")\n    msg := fmt.Sprintf(\"To: %s\\r\\nFrom: %s\\r\\nSubject: %s\\r\\nContent-Type: text\/html; charset=UTF-8\\r\\n\\r\\n%s\",\nto, user, subject, body)\n\n    if port == \"465\" {\n        \/\/ \u4f7f\u7528 TLS \u65b9\u5f0f\u8fde\u63a5\n        conn, err := tls.Dial(\"tcp\", host, &tls.Config{\n        InsecureSkipVerify: true,\n        ServerName:         server,\n    })\n    if err != nil {\n        return fmt.Errorf(\"TLS dial error: %v\", err)\n    }\n    client, err := smtp.NewClient(conn, server)\n    if err != nil {\n        return fmt.Errorf(\"SMTP client error: %v\", err)\n    }\n    auth := smtp.PlainAuth(\"\", user, pwd, server)\n    if err = client.Auth(auth); err != nil {\n        return fmt.Errorf(\"auth error: %v\", err)\n    }\n    if err = client.Mail(user); err != nil {\n        return err\n    }\n    for _, addr := range recipients {\n        if err = client.Rcpt(strings.TrimSpace(addr)); err != nil {\n        return err\n        }\n    }\n    w, err := client.Data()\n    if err != nil {\n        return err\n    }\n    _, err = w.Write([]byte(msg))\n    if err != nil {\n        return err\n    }\n    w.Close()\n    return client.Quit()\n} else {\n    \/\/ \u4f7f\u7528\u666e\u901a\u65b9\u5f0f\u53d1\u9001\n    auth := smtp.PlainAuth(\"\", user, pwd, server)\n    return smtp.SendMail(host, auth, user, recipients, []byte(msg))\n}<\/code><\/pre>\n<p>\u4fee\u6539\u4e4b\u540e\uff0c\u91cd\u65b0\u7f16\u8bd1\uff0c\u66ff\u6362\u539f\u6765\u7684\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u5373\u53ef\u3002<br \/>\n\u4e0a\u9762\u4ee3\u7406\u4f9d\u8d56tls\u5305\uff0c\u9700\u8981\u5728alert.go\u4e2d\u5f15\u5165\u4f9d\u8d56\uff1a  <\/p>\n<pre><code>import (\n        \"bytes\"\n        \"encoding\/json\"\n        \"fmt\"\n     \"github.com\/cihub\/seelog\"\n        _ \"github.com\/mattn\/go-sqlite3\"\n        \"github.com\/smartping\/smartping\/src\/g\"\n        \"github.com\/smartping\/smartping\/src\/nettools\"\n        \"net\/smtp\"\n     \"strconv\"\n        \"strings\"\n        \"time\"\n        \"crypto\/tls\"  \/\/\u8fd9\u662f\u65b0\u589e\n)<\/code><\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u7bc7\u6587\u7ae0\u7f51\u7edc\u5ef6\u8fdf\u76d1\u63a7-smokeping\u8bb2\u5230smokeping\u8fd9\u6b3e\u7f51\u7edc\u5ef6\u8fdf\u76d1\u63a7\u5de5\u5177\uff0c\u5f00\u6e90\u4e14\u914d\u7f6e\u7b80\u5355\uff0c\u9002\u5408\u7528\u6765\u76d1\u63a7\u5404\u4e2a\u8282\u70b9\u5230master\u7684\u7f51\u7edc\u60c5\u51b5\uff1b\u4f46\u5982\u679c\u60f3\u76d1\u63a7\u5404\u4e2a\u8282\u70b9\u4e4b\u95f4\u7684\u7f51\u7edc\u60c5\u51b5\uff0c\u6709\u53e6\u5916\u4e00\u6b3e\u5f00\u6e90\u7684\u5de5&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[34],"tags":[92,18,13,91],"class_list":["post-1651","post","type-post","status-publish","format-standard","hentry","category-software","tag-go","tag-it","tag-13","tag-91"],"views":317,"_links":{"self":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1651"}],"version-history":[{"count":8,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1651\/revisions"}],"predecessor-version":[{"id":1710,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1651\/revisions\/1710"}],"wp:attachment":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}