Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
so-operation-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
smart-operation
so-operation-api
Commits
0dc7a0c7
Commit
0dc7a0c7
authored
Jul 14, 2023
by
陈子龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
主机状态检测 fix
parent
f4dff071
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
16 deletions
+4
-16
src/service/host_manage.go
src/service/host_manage.go
+4
-16
No files found.
src/service/host_manage.go
View file @
0dc7a0c7
...
...
@@ -465,7 +465,7 @@ func (h *HostManageSvc) ListStateHostManage(req request.StateHostManageReq) (err
for
i
:=
0
;
i
<
len
(
hostManageList
);
i
++
{
go
func
(
i
int
)
{
//检测ip连通性
connStatus
:=
StatusDetection
(
hostManageList
[
i
]
.
Ip
)
connStatus
:=
StatusDetection
(
cast
.
ToString
(
hostManageList
[
i
]
.
Id
)
)
if
connStatus
==
1
{
lock
.
Lock
()
fail
=
append
(
fail
,
hostManageList
[
i
]
.
Id
)
...
...
@@ -679,25 +679,13 @@ func (h *HostManageSvc) SaveIpExceptionList(req request.HostIpExceptionListReq)
func
StatusDetection
(
ip
string
)
(
ipConn
int
)
{
var
cmd
*
exec
.
Cmd
cmd
=
exec
.
Command
(
"ansible"
,
fmt
.
Sprintf
(
"%s"
,
AnsibleIp
+
ip
),
"-m"
,
"ping"
)
err
:=
cmd
.
Run
()
output
,
err
:=
cmd
.
Output
()
if
err
!=
nil
{
conf
.
Logger
.
Error
(
"测试 "
+
ip
+
" 连通性失败"
,
zap
.
Error
(
err
))
return
1
}
if
cmd
.
ProcessState
.
Success
()
{
return
0
}
else
{
return
1
}
//output, err := cmd.Output()
//if err != nil {
// fmt.Println("ping:", string(output))
// fmt.Println("err:", err)
// return 1
//}
//fmt.Println("ping:", string(output))
//return 0
conf
.
Logger
.
Debug
(
"测试 "
+
ip
+
" 连通性成功"
,
zap
.
String
(
"output"
,
string
(
output
)))
return
0
}
// ExportIpStr 结果导出
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment