新增磁盘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 "服务已接收";
}
}

View File

@@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import;
@Import(BTDownloadManager.class)
@SpringBootApplication
public class NasApplication {
public static final String version="1.2.11";
public static final String version="1.2.12";
public static void main(String[] args) {
SpringApplication.run(NasApplication.class, args);
AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");

View File

@@ -1,7 +1,15 @@
package com.yutou.nas.utils;
public class StringUtils {
public static boolean isEmpty(String str){
public static boolean isEmpty(String str) {
return str == null || str.trim().length() == 0;
}
public static String toLowerCaseFirstOne(String s) {
if (Character.isLowerCase(s.charAt(0))) {
return s;
} else {
return Character.toLowerCase(s.charAt(0)) + s.substring(1);
}
}
}