Ejemplo n.º 1
0
from pyzabbix import zabbixapi
import json
url="url/zabbix/api_jsonrpc.php"
zb=zabbixapi(url=url,user="******",password="******")

def get_graph_id(hostid,graph_name):
    response=zb.graph.get(
            {
            "output": "extend",
            "sortfield": "name",
            "hostids": hostid})
    print json.dumps(json.loads(response.text),indent=2)
    for graph in json.loads(response.text)["result"]:
        print graph["name"] , graph_name
        if  graph["name"] == graph_name:
            print graph["graphid"]
            return graph["graphid"]


def get_hostid(host_name):
    response=zb.host.get(
            {
                "output":"extend",
                "filter":
                {
                    "host":host_name
                }
            })
    print json.dumps(json.loads(response.text),indent=2)
    return  json.loads(response.text)["result"][0]["hostid"]
Ejemplo n.º 2
0
from pyzabbix import zabbixapi
import json
url="http://10.210.71.145/zabbix/api_jsonrpc.php"
zb=zabbixapi(url=url,user="******",password="******")
response=zb.host.get(
        {
            "output":["interfaceid","hostids"],
            "filter": 
            {
                "host":"all-summary"
            },
            "selectInterfaces":["interfaceid"]
        })
interfaceid=json.loads(response.text)["result"][0]["interfaces"][0]["interfaceid"]
host_id=json.loads(response.text)["result"][0]["hostid"]

response=zb.template.get(
        {
            "output":"extend",
            "filter": 
            {
                "host": ["Template_webpress_ngxacc_status"]
            }
        })
templateid=json.loads(response.text)["result"][0]["templateid"]
params={
        "output":"extend",
        "hostids":templateid
    }
response=zb.item.get(params)
item_list=json.loads(response.text)["result"]
Ejemplo n.º 3
0
from pyzabbix import zabbixapi
import json
url = "url/zabbix/api_jsonrpc.php"
zb = zabbixapi(url=url, user="******", password="******")


def get_graph_id(hostid, graph_name):
    response = zb.graph.get({
        "output": "extend",
        "sortfield": "name",
        "hostids": hostid
    })
    print json.dumps(json.loads(response.text), indent=2)
    for graph in json.loads(response.text)["result"]:
        print graph["name"], graph_name
        if graph["name"] == graph_name:
            print graph["graphid"]
            return graph["graphid"]


def get_hostid(host_name):
    response = zb.host.get({"output": "extend", "filter": {"host": host_name}})
    print json.dumps(json.loads(response.text), indent=2)
    return json.loads(response.text)["result"][0]["hostid"]


def create_screen(x_length, graph_ids, screen_name):
    '''
    {
        "jsonrpc": "2.0",
        "method": "screen.create",