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
4e5002f5
Commit
4e5002f5
authored
Jul 12, 2023
by
陈子龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-czl' into dev
parents
0efa5942
d1a56aa0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
34 deletions
+6
-34
src/service/host_manage.go
src/service/host_manage.go
+6
-34
No files found.
src/service/host_manage.go
View file @
4e5002f5
...
@@ -631,12 +631,11 @@ func StatusDetection(ip string) (ipConn int) {
...
@@ -631,12 +631,11 @@ func StatusDetection(ip string) (ipConn int) {
// ExportIpStr 结果导出
// ExportIpStr 结果导出
type
ExportIpStr
struct
{
type
ExportIpStr
struct
{
Ip
string
`json:"ip" index:"0"`
// ip
Ip
string
`json:"ip" index:"0"`
// ip
Port
string
`json:"port" index:"1"`
// 端口
Port
string
`json:"port" index:"1"`
// 端口
VoucherType
string
`json:"voucher_type" index:"2"`
// 凭证类型
VoucherType
string
`json:"voucher_type" index:"2"`
// 凭证类型
UserName
string
`json:"user_name" index:"3"`
// 用户名
UserName
string
`json:"user_name" index:"3"`
// 用户名
Password
string
`json:"password" index:"4"`
// 密码
Password
string
`json:"password" index:"4"`
// 密码
ConnStatus
string
`json:"conn_status" index:"5" `
// 连接状态
}
}
// ExportIp 结果导出
// ExportIp 结果导出
...
@@ -678,20 +677,12 @@ func (h *HostManageSvc) ExportIp(id, uuid string, detectionType int) (fileName s
...
@@ -678,20 +677,12 @@ func (h *HostManageSvc) ExportIp(id, uuid string, detectionType int) (fileName s
case
1
:
case
1
:
voucherType
=
"密钥验证"
voucherType
=
"密钥验证"
}
}
connStatus
:=
""
switch
v
.
ConnStatus
{
case
0
:
connStatus
=
"正常"
case
1
:
connStatus
=
"异常"
}
staff
:=
ExportIpStr
{
staff
:=
ExportIpStr
{
Ip
:
v
.
Ip
,
Ip
:
v
.
Ip
,
Port
:
v
.
Port
,
Port
:
v
.
Port
,
VoucherType
:
voucherType
,
VoucherType
:
voucherType
,
UserName
:
v
.
UserName
,
UserName
:
v
.
UserName
,
Password
:
v
.
Password
,
Password
:
v
.
Password
,
ConnStatus
:
connStatus
,
}
}
push
=
append
(
push
,
staff
)
push
=
append
(
push
,
staff
)
...
@@ -709,7 +700,7 @@ func generatePushExportXlsx(push []ExportIpStr) (string, error) {
...
@@ -709,7 +700,7 @@ func generatePushExportXlsx(push []ExportIpStr) (string, error) {
file
:=
xlsx
.
NewFile
()
file
:=
xlsx
.
NewFile
()
sheet
,
_
:=
file
.
AddSheet
(
"Sheet1"
)
sheet
,
_
:=
file
.
AddSheet
(
"Sheet1"
)
titles
:=
[]
string
{
"IP"
,
"端口"
,
"凭证类型"
,
"用户名"
,
"密码"
,
"状态"
}
titles
:=
[]
string
{
"IP"
,
"端口"
,
"凭证类型"
,
"用户名"
,
"密码"
}
row
:=
sheet
.
AddRow
()
row
:=
sheet
.
AddRow
()
var
cell
*
xlsx
.
Cell
var
cell
*
xlsx
.
Cell
for
_
,
title
:=
range
titles
{
for
_
,
title
:=
range
titles
{
...
@@ -763,25 +754,6 @@ func CronStatusDetection() {
...
@@ -763,25 +754,6 @@ func CronStatusDetection() {
return
return
}
}
//往hosts文件中写入主机组ip
//f, err := os.OpenFile("/etc/ansible/hosts", os.O_APPEND|os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0777)
//if err != nil {
// fmt.Println("CronStatusDetection err:", err.Error())
// return
//}
//defer f.Close()
//_, err = f.Write([]byte(fmt.Sprintf("%s%d\n", AnsibleGroup, req.Id)))
//if err != nil {
// fmt.Println("CronStatusDetection err:", err.Error())
// return
//}
//for _, v := range hostManageList {
// _, err = f.Write([]byte(fmt.Sprintf("%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=\"%s\" ansible_ssh_pass=\"%s\"\n", v.Ip, v.Ip, v.Port, v.UserName, v.Password)))
// if err != nil {
// fmt.Println("CronStatusDetection err:", err.Error())
// return
// }
//}
for
_
,
v
:=
range
hostManageList
{
for
_
,
v
:=
range
hostManageList
{
connStatus
:=
StatusDetection
(
v
.
Ip
)
connStatus
:=
StatusDetection
(
v
.
Ip
)
//修改状态
//修改状态
...
...
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