Authored by qinchao

优化代码

... ... @@ -16,6 +16,10 @@ public class CommodUtil {
public static final Logger logger = LoggerFactory.getLogger("qcloudAutoScalingLogger");
public static String exe(String commond) {
return exe(commond,"");
}
public static String exe(String commond,String speratorStr) {
Process process;
BufferedReader input = null;
StringBuilder sb = new StringBuilder();
... ... @@ -25,7 +29,7 @@ public class CommodUtil {
input = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = input.readLine()) != null) {
sb.append(line);
sb.append(line+speratorStr);
}
} catch (Exception e) {
logger.error("process exe failed!", e);
... ...
package com.monitor.switchs;
import com.monitor.cloudtools.util.CommodUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
... ... @@ -19,18 +17,20 @@ import java.util.regex.Pattern;
*/
public class SwitchCmdUtil {
private static Logger logger = LoggerFactory.getLogger("switchLogger");
//private static Logger logger = LoggerFactory.getLogger("switchLogger");
//public static final String BASE_DIR = System.getenv("HOME") + "/ops_sh/";
//public static final String BASE_DIR_DNS = System.getenv("HOME") + "/ops_sh/script/oneKeySwitch/";
//dns路径
//public static final String BASE_DIR_DNS = "/home/master/ops_sh/script/oneKeySwitch/";
//dns 切换前获取
//public static final String DNS_SWITCH_TOOL = "dnskeytools";
public static final String BASE_DIR = "/home/master/ops_sh/";
//登录校验
//public static final String LOGIN_TOOL = "authtools";
/**
* dns路径
*/
public static final String BASE_DIR_DNS = "/home/master/ops_sh/script/oneKeySwitch/";
public static final String BASE_DIR = "/home/master/ops_sh/";
/**
* NGINX 查询切换脚本
... ... @@ -41,15 +41,6 @@ public class SwitchCmdUtil {
* 线下店 NGINX 查询切换脚本
*/
public static final String NGINX_SWITCH_SH_STORE = "switch_nginx_store.sh";
/**
* dns 切换前获取
*/
public static final String DNS_SWITCH_TOOL = "dnskeytools";
/**
* 登录校验
*/
public static final String LOGIN_TOOL = "authtools";
/**
* lua 查询切换脚本
... ... @@ -68,11 +59,13 @@ public class SwitchCmdUtil {
public static String exe(String commond, String param) {
Process process = null;
String command = BASE_DIR + commond + " " + param;
return CommodUtil.exe(command,"\r\n");
/*Process process = null;
StringBuilder sb = new StringBuilder();
BufferedReader input = null;
try {
String command = BASE_DIR + commond + " " + param;
logger.info(" - exe 2 parms - command=" + command);
process = Runtime.getRuntime().exec(command);
input = new BufferedReader(new InputStreamReader(process.getInputStream()));
... ... @@ -91,7 +84,7 @@ public class SwitchCmdUtil {
}
}
}
return sb.toString();
return sb.toString();*/
}
... ...