Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ops
/
monitor-service
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
qinchao
7 years ago
Commit
f09c8857530ee4494418845b3b308743f4840a45
1 parent
5a2d43ba
优化代码
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
22 deletions
monitor-service-cmdb/src/main/java/com/monitor/cloudtools/util/CommodUtil.java
monitor-service-switch/src/main/java/com/monitor/switchs/SwitchCmdUtil.java
monitor-service-cmdb/src/main/java/com/monitor/cloudtools/util/CommodUtil.java
View file @
f09c885
...
...
@@ -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
);
...
...
monitor-service-switch/src/main/java/com/monitor/switchs/SwitchCmdUtil.java
View file @
f09c885
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();
*/
}
...
...
Please
register
or
login
to post a comment