Archived community.zenoss.org | full text search
Skip navigation
Currently Being Moderated

tracepath.py

VERSION 1 
Created on: Sep 14, 2009 12:30 PM by Noel Brockett - Last Modified:  Sep 14, 2009 12:30 PM by Noel Brockett

This script can trace the layer3 deps in zenoss

 

File attached. See Below.

 

File contents

#!/usr/bin/env python
import Globals
import sys
import os

from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from transaction import commit

dmd = ZenScriptBase(connect=True).dmd
find = dmd.Devices.findDevice

arg = sys.argv[1]

source = 'localhost'
zenhome = os.environ['ZENHOME']
zpc = open(os.path.join(zenhome, 'etc', 'zenping.conf'), 'r')
for line in zpc:
    line = line.rstrip()
    if line.startswith('name'):
        name, source = line.split(' ')

zpc.close()

print "Getting path from %s to %s..." % (source, arg)
source = find(source)
if source is None:
    print "Invalid source adress."
    print "Add your zenoss server name into %s/etc/zenping.conf" % (zenhome)
    print "eg: "
    print "name yourzenossserver"
    sys.exit(1)
     
destination = find(arg)
if destination is None:
    print "Invalid destination."
    sys.exit(1)

path = source.os.traceRoute(destination, [])
if len(path) > 1:
    print "zenoss -> " \
    + " -> ".join([ dmd.Networks.findIp(ip).device().id for ip in path[:-1] ]) \
    + " -> " + arg
else:
    print "zenoss -> " + arg
Attachments:
Note: binary attachments ending in .zip will need to be unzipped before use.
Comments (0)