Get beautiful website output using python for zabbix api?

Get beautiful website output using python for zabbix api?

Try the below. The idea is to analyze the field that contains the data (site_notes),split it and clean unwanted entries.

data = [
    {
        host: CR-20,
        hostid: 10355,
        inventory: {
            site_notes: _n_n128n4112nastronomyoracle.comnastronomyoracle.comnastrooracles.comnastrooracles.comnastro-stars.comnastro-stars.comndwrf.justapi.ccndwrf.justapi.ccngrafana.justapi.ccngrafana.justapi.ccnhoro.astrozens.comnhoro.astrozens.comnjcontent.justservices.ccnjcontent.justservices.ccnjustcontent.servicesnjustcontent.servicesnjustfeeds.servicesnjustfeeds.servicesnjustinsight.servicesnjustinsight.servicesnjustservices.ccnjustservices.ccnjustsupport.servicesnjustsupport.servicesnjusttemplate.servicesnln.astrozens.comnln.astrozens.comnln.trivia.buzznln.trivia.buzznpush.justapi.ccnpush.justapi.ccnsegments.justapi.ccnsegments.justapi.ccns_hash_bucket_sizens_hash_max_sizensms.justapi.ccnsms.justapi.ccnstat.justapi.ccnstat.justapi.ccntrk.justservices.ccntrk.justservices.ccnuser.justcontent.servicesnusers.justapi.ccnusers.justapi.ccnusers.justtemplate.servicesnwww.astronomyoracle.comnwww.astrooracles.comnwww.astro-stars.comnwww.dwrf.justapi.ccnwww.grafana.justapi.ccnwww.grafana.justapi.ccnwww.horo.astrozens.comnwww.jcontent.justservices.ccnwww.jcontent.justservices.ccnwww.justcontent.servicesnwww.justcontent.servicesnwww.justfeeds.servicesnwww.justfeeds.servicesnwww.justinsight.servicesnwww.justinsight.servicesnwww.justservices.ccnwww.justservices.ccnwww.justsupport.servicesnwww.justsupport.servicesnwww.justtemplate.servicesnwww.ln.astrozens.comnwww.ln.trivia.buzznwww.push.justapi.ccnwww.push.justapi.ccnwww.segments.justapi.ccnwww.segments.justapi.ccnwww.sms.justapi.ccnwww.sms.justapi.ccnwww.stat.justapi.ccnwww.stat.justapi.ccnwww.trk.justservices.ccnwww.user.justcontent.servicesnwww.users.justapi.ccnwww.users.justapi.ccnwww.users.justtemplate.services
        }
    },
    {
        host: DO-08,
        hostid: 10659,
        inventory: {
            site_notes: _nbeta.everydayhoroscopes.comncontent.everydayhoroscopes.comncontent.everydayhoroscopes.comneveryday-astrology.comneveryday-horoscopes.netneverydayhoroscopes.comneverydayhoroscopes.comneverydayhoroscopes.orgneverydayzenastrology.comnmoonboundhoroscopes.comnregular-horoscopes.comnregularastrology.comnwww.beta.everydayhoroscopes.comnwww.beta.everydayhoroscopes.comnwww.content.everydayhoroscopes.comnwww.content.everydayhoroscopes.comnwww.everyday-astrology.comnwww.everyday-horoscopes.netnwww.everydayhoroscopes.comnwww.everydayhoroscopes.comnwww.everydayhoroscopes.orgnwww.everydayzenastrology.comnwww.moonboundhoroscopes.comnwww.regular-horoscopes.comnwww.regularastrology.com
        }
    }
]

for entry in data:
    temp = entry[inventory][site_notes].split(n)
    sites = [x for x in temp if len(x) > 1 and not x[0].isdigit()]
    print(sites)

output

[astronomyoracle.com, astronomyoracle.com, astrooracles.com, astrooracles.com, astro-stars.com, astro-stars.com, dwrf.justapi.cc, dwrf.justapi.cc, grafana.justapi.cc, grafana.justapi.cc, horo.astrozens.com, horo.astrozens.com, jcontent.justservices.cc, jcontent.justservices.cc, justcontent.services, justcontent.services, justfeeds.services, justfeeds.services, justinsight.services, justinsight.services, justservices.cc, justservices.cc, justsupport.services, justsupport.services, justtemplate.services, ln.astrozens.com, ln.astrozens.com, ln.trivia.buzz, ln.trivia.buzz, push.justapi.cc, push.justapi.cc, segments.justapi.cc, segments.justapi.cc, s_hash_bucket_size, s_hash_max_size, sms.justapi.cc, sms.justapi.cc, stat.justapi.cc, stat.justapi.cc, trk.justservices.cc, trk.justservices.cc, user.justcontent.services, users.justapi.cc, users.justapi.cc, users.justtemplate.services, www.astronomyoracle.com, www.astrooracles.com, www.astro-stars.com, www.dwrf.justapi.cc, www.grafana.justapi.cc, www.grafana.justapi.cc, www.horo.astrozens.com, www.jcontent.justservices.cc, www.jcontent.justservices.cc, www.justcontent.services, www.justcontent.services, www.justfeeds.services, www.justfeeds.services, www.justinsight.services, www.justinsight.services, www.justservices.cc, www.justservices.cc, www.justsupport.services, www.justsupport.services, www.justtemplate.services, www.ln.astrozens.com, www.ln.trivia.buzz, www.push.justapi.cc, www.push.justapi.cc, www.segments.justapi.cc, www.segments.justapi.cc, www.sms.justapi.cc, www.sms.justapi.cc, www.stat.justapi.cc, www.stat.justapi.cc, www.trk.justservices.cc, www.user.justcontent.services, www.users.justapi.cc, www.users.justapi.cc, www.users.justtemplate.services]
[beta.everydayhoroscopes.com, content.everydayhoroscopes.com, content.everydayhoroscopes.com, everyday-astrology.com, everyday-horoscopes.net, everydayhoroscopes.com, everydayhoroscopes.com, everydayhoroscopes.org, everydayzenastrology.com, moonboundhoroscopes.com, regular-horoscopes.com, regularastrology.com, www.beta.everydayhoroscopes.com, www.beta.everydayhoroscopes.com, www.content.everydayhoroscopes.com, www.content.everydayhoroscopes.com, www.everyday-astrology.com, www.everyday-horoscopes.net, www.everydayhoroscopes.com, www.everydayhoroscopes.com, www.everydayhoroscopes.org, www.everydayzenastrology.com, www.moonboundhoroscopes.com, www.regular-horoscopes.com, www.regularastrology.com]
    import json
    import re
    from pyzabbix import ZabbixAPI
    
    username = user
    password = *************
    servername = https://<name of the site.com>/api_jsonrpc.php
    
    zapi = ZabbixAPI(servername)
    zapi.session.verify = False
    zapi.login(username, password)
    ef fqdn(
        name: str, test = re.compile(
            r^(?!-)[w-]{1,63}(?<!-)$, re.A
        ).fullmatch
):
    temp = name.split(.)
    return (
        all(test(i) for i in temp) if len(name) < 255 and len(temp) > 1 else False
    )


print(
    *sorted(
        {
            host for _ in zapi.host.get(
                output = [host], groupids = [25, 41, 43], selectInventory = [site_notes]
            ) for host in _[inventory][site_notes].split(n) if fqdn(host)
        }
    ), sep = n
)

Get beautiful website output using python for zabbix api?

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *