Discussion:
Help with transform, dependency issue
nachofw
2012-11-21 19:57:15 UTC
Permalink
nachofw [http://community.zenoss.org/people/nachofw] created the discussion

"Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70076#70076

--------------------------------------------------------------
Hi all, i wonder if you could help me with an issue iÂŽm having with my zenoss
I dont have knowledge on python, only java and .net. iÂŽm taking over a zenoss server that was deployed by an ex employee
There is a transform aplied to /status/ping that isnt working. The goal of the transform is to supress events from devices that have dependencies with others.
There are many locations(routers with ip ending in .99) and in the LAN segment devices with ip ending in .80. I want to supress events from .80 when .99 is down.


dev=device.id
str=dev.split('.')
device_A=dmd.Devices.findDevice('10.'+str[1]+'.'+str[2])
if device_A.getPingStatus() > 0:
          evt.eventState = 2
evt.action = "drop"

| message | Problem with line 3: if device_A.getPingStatus() > 0: |
| summary | Error processing transform/mapping on Event Class /Status/Ping |
| exception | AttributeError: 'NoneType' object has no attribute 'getPingStatus' |

thanks in advance, hope i made the explanation clear enough

PD:im running zenoss 3.0.3
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70076#70076]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-11-21 20:23:25 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70070#70070

--------------------------------------------------------------
The message is implying that `device_A=dmd.Devices.findDevice('10.'+str[1]+'.'+str[2])` is finding no devices. You could prevent the exception by wrapping it with a None check, however that might not be what your actually after:

dev=device.id
str=dev.split('.')
device_A=dmd.Devices.findDevice('10.'+str[1]+'.'+str[2])
if device_A is not None:
     if device_A.getPingStatus() > 0:
          evt.eventState = 2
evt.action = "drop"
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70070#70070]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
nachofw
2012-11-22 12:10:31 UTC
Permalink
nachofw [http://community.zenoss.org/people/nachofw] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70078#70078

--------------------------------------------------------------
Hey thanks dpetzel, that cleared the error on the transform but it doesnt seem to work as i expected:
Let me add a snapshot

Loading Image... Loading Image...
how I think the script showld look like:
Event takes place, location 10.29.13 is down because .99 is down, so .80 events shouldnt come up


#An event comes up, I query if its from host .80
#if its from host .80 y search for the dependency .99 and if its down then i supress the event

dev=device.id
str=dev.split('.')
if str[3]==80
device_A=dmd.Devices.findDevice('10.'+str[1]+'.'+str[2]+'99')
   if device_A is not None:
     if device_A.getPingStatus() > 0:
     evt.eventState = 2
     evt.action = "drop"


Is this wright?
I havent applied the transform yet
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70078#70078]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-11-22 20:10:41 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70094#70094

--------------------------------------------------------------
You had a bunch of syntax errors and you're wasting resources pulling the device ip from device.id when the IP is already included as evt.ipAddress.  Also, device.id may not always necessary be an IP address.  If you use the "Rename Device" option in the bottom left hand menu on a device's page it changes the id of the device to what you set.  If you use the Device Name field on the overview page all you're doing is setting a title, which is basically a pseudo name for the device.

Your syntax errors were that you were missing an underscore before action in evt._action.  You were missing a '.' when building the string for findDevice, so instead of 12.34.56.78 you'd end up with 12.34.5678.  Also, there's no point in doing if device_A is not None:.  The same can be accomplished with just if device_A:.  There is also no point in setting the state of an event if you're just going to be dropping it anyways.  By dropping it it isn't making it in to the event database.  You were missing an identation on the last if loop as well.

str = evt.ipAddress.split('.')
if str[3] == 80
device_A = dmd.Devices.findDevice('10.'+str[1]+'.'+str[2]+'.'+'99')
   if device_A:
     if device_A.getPingStatus() > 0:
      evt._action = 'drop'
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70094#70094]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-11-22 20:39:46 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70084#70084

--------------------------------------------------------------
In the case of findDevice(), the if device_A check has the same effect, however I'd suggest sticking with is not None when your checking that a variable is not None. It's a tad more typing however it is a more accurate reflection of what your checking, and I personally find it more intuitive, not to mention it follows the guidelines laid out in PEP8 (a commonly adhered to Python style standard)

That said, at the end of the day, in the context of this transform, either check will work equally as well.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70084#70084]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-11-22 20:44:37 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70096#70096

--------------------------------------------------------------
Fair to say, but with this particular function as you've said it will work fine either way ;)
device_A = dmd.Devices.findDevice('SomeBogusDevice')
device_A
...  print 'tacos'
...
...  print 'tacos'
...
if not device_A:   
...  print 'tacos'
...
tacos
...  print 'tacos'
...
tacos
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70096#70096]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-11-22 20:51:03 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70085#70085

--------------------------------------------------------------
Agreed, I should have clarified the only reason I mentioned it was because the only poster indicated a lack of familiarity with Python, was just trying point out the subtle difference in behavior when the variable is False vs None.

The mention of PEP8 was also geared toward the original poster as a resource to gain a quick level of understanding around Python.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70085#70085]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-11-22 20:55:11 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70097#70097

--------------------------------------------------------------
I figured that it was for his benefit :)
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70097#70097]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
ignacio freyre
2012-11-23 14:58:10 UTC
Permalink
ignacio freyre [http://community.zenoss.org/people/nachofw] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70090#70090

--------------------------------------------------------------
Hey guys, thank you so much for your help. I tried adding the transform to /status/ping but doesnt seem to be working

Loading Image... Loading Image...

str = evt.ipAddress.split('.')
if str[3] == 80:
device_A = dmd.Devices.findDevice('10.'+str[1]+'.'+str[2]+'.99')
if device_A:
  if device_A.getPingStatus() > 0:
   evt.action = 'drop'

Is there any debugging that can be done or a log to read a result?


regards
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70090#70090]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-11-23 15:07:13 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70136#70136

--------------------------------------------------------------
Well, there is a procedural flaw in this.  If the .80 ping alert comes in before the .99 alert the pingstatus for .99 will show as 0 and it won't drop the ping event.  If the .99 devices are actually behind the .80 devices you could go to Advanced -> Daemons -> click "edit config" next to zenping -> toggle the "disable-correlator" option to false -> Restart zenping.  That will cause zenping to automatically perform traceroutes to each device and build up a map of what devices are behind what.  It will then only alert on head end devices, not the devices behind them (if that is what you're trying to accomplish).
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70136#70136]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
ignacio freyre
2012-11-23 17:30:43 UTC
Permalink
ignacio freyre [http://community.zenoss.org/people/nachofw] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70140#70140

--------------------------------------------------------------
"disable-correlator" doesnt appear in the config edit of zenping, maybe cause of the zenoss version being 3.0.3. I tried deleting events from .80 so they come after the .99 but it continues to appear. Any other ideas?
Thanks!
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70140#70140]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-11-23 18:28:00 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70143#70143

--------------------------------------------------------------
Oh god, why are you using 3.0.3?  That was a horrible version, FULL of bugs.  You should at the very least upgrade to 3.2.1 if not to 4.x.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70143#70143]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
ignacio freyre
2012-11-28 17:39:53 UTC
Permalink
ignacio freyre [http://community.zenoss.org/people/nachofw] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70180#70180

--------------------------------------------------------------
Yes you are right it is full of bugs, i have the intention to upgrade to 4.2 but i find it hard to accomplish since there isnt an easy upgrade available. Do you have any other idea of why the transform isnt working?
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70180#70180]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-11-28 17:53:54 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Help with transform, dependency issue"

To view the discussion, visit: http://community.zenoss.org/message/70211#70211

--------------------------------------------------------------
It's never going to work for the reason that I explained in one of my previous posts.

"Well, there is a procedural flaw in this.  If the .80 ping alert comes in before the .99 alert the pingstatus for .99 will show as 0 and it won't drop the ping event."

It's going to fail 50% of the time depending on what device Zenoss sees as down first.  You really need Zenoss 4.2 to accomplish what you want since it has a feature specifically built to accomplish what you want.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70211#70211]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...