Beispiel #1
0
def main(request):
    za = ZabbixAPI()
    za.login()
    try:
        groups = za.list_groups()
    except:
        groups = None
    return render_to_response('zabsync/main.html', {
            'groups': groups,
            'primary_templates': Node.list_primary_templates(),
            'templates': Node.objects.filter(typ=0),
            },context_instance=RequestContext(request))
Beispiel #2
0
def main(request):
    za = ZabbixAPI()
    za.login()
    try:
        groups = za.list_groups()
    except:
        groups = None
    return render_to_response(
        'zabsync/main.html', {
            'groups': groups,
            'primary_templates': Node.list_primary_templates(),
            'templates': Node.objects.filter(typ=0),
        },
        context_instance=RequestContext(request))
Beispiel #3
0
def add_hosts_by_group(request):
    groups = request.GET.getlist('group')
    template_id = int(request.GET.get('template_id'))
    subtemplate_id = int(request.GET.get('subtemplate_id'))
    template = Node.objects.get(id = template_id)
    subtemplate = Node.objects.get(id = subtemplate_id) if subtemplate_id >= 0 else None
    za = ZabbixAPI()
    za.login()
    hosts = za.hosts_by_group(groups)
    for host in hosts:
        try:
            node = utils.create_host(template, host['host'], host['hostid'], subtemplate)
        except exceptions.DuplicateItemError:
            node = Node.objects.get(paramstr__name = 'zabbix_id', paramstr__value = host['hostid'])
        utils.update_host_inv(za, node)
    return render_to_response('zabsync/add_hosts.html', {
            'hosts': hosts,
            'debug': repr(hosts)
            },context_instance=RequestContext(request))
Beispiel #4
0
def trigger_detail(request):
    tid = int(request.GET.get('triggerid'))
    res = HttpResponse()
    res.write("triggerid: %d<br>\n" % tid)
    za = ZabbixAPI()
    za.login()
    triggers = za.triggers([tid])
    events = za.last_events(tid)
    t = triggers[0]
    # fix data for presentation
    t['lastchange_dt'] = datetime.fromtimestamp(float(t['lastchange']))
    t['value_desc'] = decode_trigger_value(t['value'])
    for e in events:
        e['clock_dt'] = datetime.fromtimestamp(float(e['clock']))
        e['value_desc'] = decode_trigger_value(e['value'])
    return render(request, 'zabbixlink/trigger_detail.html', {
        'triggerid': tid,
        'trigger': t,
        'events': events,
        'debug': pformat(triggers, 2)+"\n---\n"+pformat(events, 2),
    })
Beispiel #5
0
def add_hosts_by_group(request):
    groups = request.GET.getlist('group')
    template_id = int(request.GET.get('template_id'))
    subtemplate_id = int(request.GET.get('subtemplate_id'))
    template = Node.objects.get(id=template_id)
    subtemplate = Node.objects.get(
        id=subtemplate_id) if subtemplate_id >= 0 else None
    za = ZabbixAPI()
    za.login()
    hosts = za.hosts_by_group(groups)
    for host in hosts:
        try:
            node = utils.create_host(template, host['host'], host['hostid'],
                                     subtemplate)
        except exceptions.DuplicateItemError:
            node = Node.objects.get(paramstr__name='zabbix_id',
                                    paramstr__value=host['hostid'])
        utils.update_host_inv(za, node)
    return render_to_response('zabsync/add_hosts.html', {
        'hosts': hosts,
        'debug': repr(hosts)
    },
                              context_instance=RequestContext(request))