1.创建应用集
def create_application():
values = {
"jsonrpc": "2.0",
"method": "application.create",
"params": {
"name": "test1_app", #应用名
"hostid": "232" #主机id
},
"auth": auth,
"id": 1
}
2.获取指定主机所有应用集
def get_app():
values = {
"jsonrpc": "2.0",
"method": "application.get",
"params": {
"output": "extend",
"hostids": "232", #主机id
"sortfield": "name"
},
"auth": auth,
"id": 1
}
3.根据应用集id进行删除
def del_app(au):
values = {
"jsonrpc": "2.0",
"method": "application.delete",
"params": ["232"], #应用集id
"auth": auth,
"id": 1
}
4.修改应集名称
def update_appname():
values = {
"jsonrpc": "2.0",
"method": "application.update",
"params": {
"applicationid": "232", #应用集id
"name": "test2_app" #新应用集名称
},
"auth": auth,
"id": 1
}
5.添加多个监控项到指定的应用集
def add_item_app():
values = {
"jsonrpc": "2.0",
"method": "application.massadd",
"params": {
"applications": [
{
"applicationid": "1118" #应用集id
},
],
"items": [
{
"itemid": "28439" #监控项id
},
]
},
"auth": auth,
"id": 1
}
6.只返回指定ID的应用集
def get_app():
values = {
"jsonrpc": "2.0",
"method": "application.get",
"params": {
"output": "extend",
"applicationids": ['1118'], #应用集id
"sortfield": "name"
},
"auth": auth,
"id": 1
}
7.只返回指定主机组所属主机的应用集
def get_group_app():
values = {
"jsonrpc": "2.0",
"method": "application.get",
"params": {
"output": "extend",
"groupids": ['19',], #主机组id
"sortfield": "name"
},
"auth": auth,
"id": 1
}
8.只返回指定主机所属的应用集
def get_host_app():
values = {
"jsonrpc": "2.0",
"method": "application.get",
"params": {
"output": "extend",
"hostids": ['10264',], #主机id
"sortfield": "name"
},
"auth": auth,
"id": 1
}
9.只返回指定模板的应用集
def get_temp_app():
values = {
"jsonrpc": "2.0",
"method": "application.get",
"params": {
"output": "extend",
"templateids": ['10266',], #模板id
"sortfield": "name"
},
"auth": auth,
"id": 1
}
10.查询"应用集"时返回更多关联信息:主机、监控项
def get_appinfo():
values = {
"jsonrpc": "2.0",
"method": "application.get",
"params": {
"output": "extend",
"applicationids": ['1118'], #模板id
"sortfield": "name",
"selectHost": [ #1.返回链接到模板的主机
"name",
"hostid"
],
"selectItems": [ #2.返回模板中的监控项.
"name",
"key",
"itemid",
"interfaceid",
],
},
"auth": auth,
"id": 1
}