Child pages
  • Get absent discovery jobs
Skip to end of metadata
Go to start of metadata
from noc.inv.models.discoveryjob import DiscoveryJob
from noc.sa.models.managedobject import ManagedObject
from noc.sa.models.managedobjectprofile import ManagedObjectProfile
from noc.inv.discovery.utils import get_active_discovery_methods

dm = get_active_discovery_methods()

opdm = {}

for op in ManagedObjectProfile.objects.all():
    # get mo profile effective discovery list
    em = []
    for method in dm:
        if getattr(op, "enable_%s" % method):
            em += [method]
    opdm[op.name] = set(em)

hosts_abs = 0
jobs_abs = 0
hosts_total = 0
jobs_total = 0

for mo in ManagedObject.objects.filter(is_managed=True):
    # get object discovery list
    odj = []
    for dj in DiscoveryJob.objects.filter(object=mo.id):
        odj += [dj.jcls]
    # compare with profile discovery list
    absent = opdm[mo.object_profile.name] - set(odj)
    if len(absent):
        print mo, absent
        hosts_abs += 1
        jobs_abs += len(absent)
    hosts_total += 1
    jobs_total += len(opdm[mo.object_profile.name])

print "\n%d jobs (%d hosts) out of %d jobs (%d hosts) are absent" % (jobs_abs, hosts_abs, jobs_total, hosts_total)

 

 

  • No labels