|
@@ -1,8 +1,10 @@
|
|
|
package com.cqcy.ei.telegraf.client.controller;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.file.FileReader;
|
|
|
import cn.hutool.core.io.file.FileWriter;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.cqcy.ei.telegraf.client.entity.Result;
|
|
@@ -156,6 +158,26 @@ public class MainController implements Initializable {
|
|
|
JSONObject json = JSONUtil.parseObj(configJson);
|
|
|
FileWriter writer = new FileWriter(ClientInfoUtil.path + "/configer.json");
|
|
|
writer.write(configJson);
|
|
|
+
|
|
|
+ JSONObject output = json.getJSONObject("output");
|
|
|
+ Integer type = output.getInt("type");
|
|
|
+ if (type > 0) {
|
|
|
+ Date date = DateUtil.date();
|
|
|
+
|
|
|
+
|
|
|
+ output.set("bucket", output.getStr("bucket") + "_" + DateUtil.year(date));
|
|
|
+ json.set("output", output);
|
|
|
+
|
|
|
+ if (type == 2) {
|
|
|
+ JSONArray input = json.getJSONArray("input");
|
|
|
+ for (int i = 0; i < input.size(); i++) {
|
|
|
+ JSONObject item = input.getJSONObject(i);
|
|
|
+ item.set("name", item.getStr("name") + "_" + DateUtil.year(date) + "_" + (DateUtil.month(date) + 1));
|
|
|
+ input.set(i, item);
|
|
|
+ }
|
|
|
+ json.set("input", input);
|
|
|
+ }
|
|
|
+ }
|
|
|
// 生成配置文件
|
|
|
ConfUtil.createTelegrafConf(json);
|
|
|
// 保存默认配置
|