Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zmops-test
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sanshi
zmops-test
Commits
10145084
Commit
10145084
authored
Nov 29, 2019
by
sanshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建告警规则
parent
644de9d1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
47 deletions
+108
-47
Administrator.xml
.idea/dictionaries/Administrator.xml
+2
-0
test_device_create.py
WorkCase/APP/Device/test_device_create.py
+5
-47
test_rule_create.py
WorkCase/APP/Rule/test_rule_create.py
+0
-0
hosts.py
WorkData/Argus/hosts.py
+16
-0
hosts_items.py
WorkData/Argus/hosts_items.py
+85
-0
No files found.
.idea/dictionaries/Administrator.xml
View file @
10145084
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
<w>
hosttype
</w>
<w>
hosttype
</w>
<w>
hosttypeids
</w>
<w>
hosttypeids
</w>
<w>
hstgrp
</w>
<w>
hstgrp
</w>
<w>
icmpping
</w>
<w>
interfaceid
</w>
<w>
interfaceid
</w>
<w>
interfaceids
</w>
<w>
interfaceids
</w>
<w>
iplist
</w>
<w>
iplist
</w>
...
@@ -61,6 +62,7 @@
...
@@ -61,6 +62,7 @@
<w>
proxyids
</w>
<w>
proxyids
</w>
<w>
publickey
</w>
<w>
publickey
</w>
<w>
pytest
</w>
<w>
pytest
</w>
<w>
rmcp
</w>
<w>
ruleid
</w>
<w>
ruleid
</w>
<w>
ruleids
</w>
<w>
ruleids
</w>
<w>
sanshi
</w>
<w>
sanshi
</w>
...
...
WorkCase/APP/Device/test_device_create.py
View file @
10145084
...
@@ -193,59 +193,17 @@ class TestDeviceCreate(object):
...
@@ -193,59 +193,17 @@ class TestDeviceCreate(object):
monitorType
=
1
)
monitorType
=
1
)
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
@allure.title
(
"device.create:创建agent设备在线规则"
)
@allure.title
(
"device.create:创建agent资产,dns识别"
)
@allure.story
(
"创建资产:创建agent设备在线规则"
)
@allure.story
(
"创建资产:创建agent资产,dns识别"
)
@allure.severity
(
"blocker"
)
def
test_case_05
(
self
):
def
test_case_05
(
self
):
self
.
get_base_token
()
self
.
get_base_token
()
name
=
self
.
base_name
+
"05"
name
=
self
.
base_name
+
"05"
response
=
self
.
device_create
(
token
=
self
.
token
,
name
=
name
,
severity
=
0
,
status
=
1
,
manualClose
=
1
,
triggersList_hostid
=
[
10466
],
response
=
self
.
device_create
(
token
=
self
.
token
,
hostName
=
name
,
hostType
=
self
.
base_type_agent
,
iplist
=
self
.
base_ip
,
dns
=
self
.
base_dns
,
triggersList_hostName
=
[
"SS TEST HOST04"
],
triggersList_itemid
=
[
39676
],
monitorInterface
=
self
.
base_port
,
monitorType
=
2
)
triggersList_itemName
=
[
"agent.ping"
],
triggersList_function
=
[
"avg"
],
triggersList_operator
=
[
"="
],
triggersList_constant
=
[
888
],
triggersList_parameters_unit
=
[
"m"
],
triggersList_parameters_value
=
[
5
],
triggersList_onlineFlag
=
[
True
])
self
.
check_code
(
response
=
response
,
code
=
0
)
@allure.title
(
"device.create:创建agent设备离线规则"
)
@allure.story
(
"创建资产:创建agent设备离线规则"
)
def
test_case_06
(
self
):
self
.
get_base_token
()
name
=
self
.
base_name
+
"06"
response
=
self
.
device_create
(
token
=
self
.
token
,
name
=
name
,
severity
=
0
,
status
=
1
,
manualClose
=
1
,
triggersList_hostid
=
[
10466
],
triggersList_hostName
=
[
"SS TEST HOST04"
],
triggersList_itemid
=
[
39676
],
triggersList_itemName
=
[
"agent.ping]"
],
triggersList_function
=
[
"avg"
],
triggersList_operator
=
[
"="
],
triggersList_constant
=
[
888
],
triggersList_parameters_unit
=
[
"m"
],
triggersList_parameters_value
=
[
5
],
triggersList_onlineFlag
=
[
False
])
self
.
check_code
(
response
=
response
,
code
=
0
)
@allure.title
(
"device.create:创建icmp设备在线规则"
)
@allure.story
(
"创建资产:创建icmp设备在线规则"
)
def
test_case_07
(
self
):
self
.
get_base_token
()
name
=
self
.
base_name
+
"07"
response
=
self
.
device_create
(
token
=
self
.
token
,
name
=
name
,
severity
=
0
,
status
=
1
,
manualClose
=
1
,
triggersList_hostid
=
[
10466
],
triggersList_hostName
=
[
"SS TEST HOST04"
],
triggersList_itemid
=
[
39676
],
triggersList_itemName
=
[
"agent.ping]"
],
triggersList_function
=
[
"avg"
],
triggersList_operator
=
[
"="
],
triggersList_constant
=
[
888
],
triggersList_parameters_unit
=
[
"m"
],
triggersList_parameters_value
=
[
5
],
triggersList_onlineFlag
=
[
True
])
self
.
check_code
(
response
=
response
,
code
=
0
)
self
.
check_code
(
response
=
response
,
code
=
0
)
@allure.title
(
"device.create:创建icmp设备离线规则"
)
@allure.story
(
"创建资产:创建icmp设备离线规则"
)
def
test_case_08
(
self
):
self
.
get_base_token
()
name
=
self
.
base_name
+
"08"
response
=
self
.
device_create
(
token
=
self
.
token
,
name
=
name
,
severity
=
0
,
status
=
1
,
manualClose
=
1
,
triggersList_hostid
=
[
10466
],
triggersList_hostName
=
[
"SS TEST HOST04"
],
triggersList_itemid
=
[
39676
],
triggersList_itemName
=
[
"agent.ping]"
],
triggersList_function
=
[
"avg"
],
triggersList_operator
=
[
"="
],
triggersList_constant
=
[
888
],
triggersList_parameters_unit
=
[
"m"
],
triggersList_parameters_value
=
[
5
],
triggersList_onlineFlag
=
[
True
])
self
.
check_code
(
response
=
response
,
code
=
0
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
from
WorkUtils.UtilsPyTest
import
UtilsPyTest
from
WorkUtils.UtilsPyTest
import
UtilsPyTest
...
...
WorkCase/APP/Rule/test_rule_create.py
View file @
10145084
This diff is collapsed.
Click to expand it.
WorkData/Argus/hosts.py
View file @
10145084
...
@@ -24,6 +24,7 @@ class Hosts(Base):
...
@@ -24,6 +24,7 @@ class Hosts(Base):
__tablename__
=
"hosts"
__tablename__
=
"hosts"
hostid
=
Column
(
Integer
,
primary_key
=
True
)
hostid
=
Column
(
Integer
,
primary_key
=
True
)
zabbix_hostid
=
Column
(
BigInteger
,
comment
=
"zabbix主机编号"
)
host_name
=
Column
(
VARCHAR
(
128
),
comment
=
"主机名"
)
host_name
=
Column
(
VARCHAR
(
128
),
comment
=
"主机名"
)
asset_code
=
Column
(
VARCHAR
(
128
),
comment
=
"资产编号"
)
asset_code
=
Column
(
VARCHAR
(
128
),
comment
=
"资产编号"
)
manage_ip
=
Column
(
VARCHAR
(
32
),
comment
=
"管理IP"
)
manage_ip
=
Column
(
VARCHAR
(
32
),
comment
=
"管理IP"
)
...
@@ -34,7 +35,22 @@ class Hosts(Base):
...
@@ -34,7 +35,22 @@ class Hosts(Base):
available
=
Column
(
Integer
,
comment
=
"可用性"
)
available
=
Column
(
Integer
,
comment
=
"可用性"
)
monitor_status
=
Column
(
Integer
,
comment
=
"监控状态"
)
monitor_status
=
Column
(
Integer
,
comment
=
"监控状态"
)
iplist
=
Column
(
VARCHAR
(
255
),
comment
=
"IP列表 分号隔开"
)
iplist
=
Column
(
VARCHAR
(
255
),
comment
=
"IP列表 分号隔开"
)
dns
=
Column
(
VARCHAR
(
255
),
comment
=
"域名"
)
monitor_interface
=
Column
(
VARCHAR
(
255
),
comment
=
"监控接口 分号隔开"
)
monitor_interface
=
Column
(
VARCHAR
(
255
),
comment
=
"监控接口 分号隔开"
)
business_ids
=
Column
(
VARCHAR
(
255
),
comment
=
"业务id(对应于zabbix系统的分组)"
)
port
=
Column
(
VARCHAR
(
30
),
comment
=
"服务端口号"
)
ops_person
=
Column
(
Integer
,
comment
=
"运维人员"
)
factory
=
Column
(
VARCHAR
(
255
),
comment
=
"厂商"
)
model
=
Column
(
VARCHAR
(
255
),
comment
=
"型号"
)
version
=
Column
(
VARCHAR
(
50
),
comment
=
"版本号"
)
serialnumber
=
Column
(
VARCHAR
(
255
),
comment
=
"序列号"
)
description
=
Column
(
VARCHAR
(
255
),
comment
=
"描述"
)
snmp_community
=
Column
(
VARCHAR
(
255
),
comment
=
"snmp社区名(对应于zabbix系统里的snmp宏里SNMP_COMMUNITY模板的值)"
)
ipmi_authtype
=
Column
(
Integer
,
comment
=
"ipmi认证算法(0:无 1:MD2 2:MD5 3:Straight 4:OEM 5:RMCP+)"
)
ipmi_privilege
=
Column
(
Integer
,
comment
=
"ipmi优先权层级(1:回调 2:用户 3:操作者 4:管理者 5:OEM)"
)
ipmi_username
=
Column
(
VARCHAR
(
50
),
comment
=
"ipmi用户名"
)
ipmi_password
=
Column
(
VARCHAR
(
50
),
comment
=
"ipmi密码"
)
create_time
=
Column
(
BigInteger
,
comment
=
"创建时间"
)
class
DataHosts
(
object
):
class
DataHosts
(
object
):
...
...
WorkData/Argus/hosts_items.py
0 → 100644
View file @
10145084
# -*- coding: utf_8 -*-
# 表名: hosts_items
# 作者: 陈磊
# 时间: 2019-11-29
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy
import
Column
,
Integer
,
VARCHAR
,
SMALLINT
,
DATETIME
,
DECIMAL
,
BigInteger
,
FLOAT
,
NUMERIC
,
TEXT
from
sqlalchemy.orm.exc
import
MultipleResultsFound
,
NoResultFound
from
sqlalchemy
import
or_
from
WorkUtils.UtilsLog
import
UtilsLog
from
WorkUtils.UtilsDataBase
import
UtilsDataBase
import
time
Base
=
declarative_base
()
class
HostsItems
(
Base
):
"""
设备监控项
"""
__tablename__
=
"hosts_items"
id
=
Column
(
BigInteger
,
primary_key
=
True
)
host_id
=
Column
(
BigInteger
,
comment
=
"设备编号"
)
name
=
Column
(
VARCHAR
(
255
),
comment
=
"监控项名"
)
key_
=
Column
(
VARCHAR
(
255
),
comment
=
"监控项的值"
)
class
DataHostsItems
(
object
):
def
__init__
(
self
):
self
.
log
=
UtilsLog
()
self
.
log
.
info
(
self
.
__class__
)
self
.
table
=
HostsItems
def
select_all_from_allKeys
(
self
,
session
,
_id
=
None
,
host_id
=
None
,
name
=
None
,
key_
=
None
):
"""
:param session: 指针
:param _id:
:param host_id:
:param name:
:param key_:
:return: 查询结果
"""
self
.
log
.
debug
(
"查询数据库:"
)
try
:
base
=
UtilsDataBase
()
base
.
add_param
(
_key
=
"id"
,
value
=
_id
)
base
.
add_param
(
_key
=
"host_id"
,
value
=
host_id
)
base
.
add_param
(
_key
=
"name"
,
value
=
name
)
base
.
add_param
(
_key
=
"key_"
,
value
=
key_
)
sql_rep
=
session
.
query
(
self
.
table
)
.
filter_by
(
**
base
.
param
)
.
all
()
self
.
log
.
debug
(
sql_rep
)
session
.
close
()
return
sql_rep
except
UtilsDataBase
()
.
errors
as
error
:
self
.
log
.
error
(
"异常:"
)
self
.
log
.
error
(
error
)
session
.
close
()
return
error
def
delete_host_id
(
self
,
session
,
host_id
):
"""
:param session: 指针
:param host_id:
:return:
"""
self
.
log
.
debug
(
"查询数据库:"
)
try
:
self
.
log
.
debug
(
"删除相关测试数据"
)
session
.
query
(
self
.
table
)
.
filter_by
(
host_id
=
host_id
)
.
delete
(
synchronize_session
=
False
)
# session.delete(sql)
session
.
commit
()
session
.
close
()
self
.
log
.
debug
(
"删除成功"
)
return
True
except
UtilsDataBase
()
.
errors
as
error
:
self
.
log
.
error
(
"异常:"
)
self
.
log
.
error
(
error
)
session
.
close
()
return
error
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