新增磁盘SMART检测汇报功能

This commit is contained in:
2022-05-03 19:30:44 +08:00
parent fe10c4b686
commit 4bcf56207d
4 changed files with 54 additions and 8 deletions

View File

@@ -0,0 +1,30 @@
package com.yutou.nas.Controllers;
import com.alibaba.fastjson.JSONObject;
import com.yutou.nas.utils.QQBotManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Controller
public class HHDController {
@ResponseBody
@RequestMapping("/nas/hhd.do")
public String hddSMART(@RequestBody JSONObject json){
Pattern pattern=Pattern.compile(".(?<=(result: )).*");
for (String key : json.keySet()) {
Matcher matcher=pattern.matcher(json.getString(key));
if(matcher.find()){
String result=matcher.group(0).trim();
if(!"PASSED".equals(result)){
QQBotManager.getInstance().sendMessage("硬盘异常警告:"+key+":"+result);
}
}
}
return "服务已接收";
}
}