Discussion:
Include datapoint value in transform?
themactech
2012-11-15 21:49:02 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Include datapoint value in transform?"

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

--------------------------------------------------------------
I have a temperature sensor that sends the exact same trap whether the temperature went above the top threshold or under the low threshold.  I want to differentiate between the two.  Now the trap includes the current temp that set of the trap, and I am getting the top and bottom threshold values via a command datasource (it's not available over SNMP).  I store the Threshold values as TempHigh and TempLow data points within my command datasource, and I add them to the temperature graph.

How can I reference the TempHigh or TempLow data points from my command datasource within my transform so I can compare with the current temp that triggered the trap so I can change the summary to reflect if the top or bottom threshold has been broken?

Here is what I am looking to do in a flowchart way

-Receive trap
     -Transform
          -Put in correct event class
          -Get current temperature that triggered trap  ** this I know how to do
          -If current temp > Top threshold  ** <- this is the value I need to pull and don't know how **
               set summary to : High temperature threshold exceeded with (current temp value)
           else
               set summary to : Low temperature threshold exceeded with (current temp value)


Thanks

Manuel
--------------------------------------------------------------

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

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]
themactech
2012-11-16 21:35:08 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Include datapoint value in transform?"

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

--------------------------------------------------------------
Ok I figured out how to pull RRD values, but of all things I am now having an issue with my if statement...

Here is what I have:

LowThresh = float(device.getRRDValue('TempLow'))
HighThresh = float(device.getRRDValue('TempHigh))
CurrentTemp = float(float(getattr(evt, 'internalTemp'))/10)

Now this gives me correct values, LowThresh is 75.0, HighThresh is 80.0 and Current temp will be the current value when the trap is sent, i.e. 86.3  (I have to divide by 10 since it will return 863 for 86.3).

Now I want to determine if I blew the top or bottow threshold, so I do this:

if CurrentTemp > HIghThresh:
    evt.summary = "Current temperature of " + str (CurrentTemp) + " is above the threshold of " + str (HighThresh)
if CurrentTemp < LowThresh:
    evt.summary = "Current temperature of " + str (CurrentTemp) + " is under the threshold of " + str (LowThresh)

however I get an error and zenhub.log says it's a compile error on the 'if CurrentTemp > HIghThresh:" line

Is my syntax wrong?

Thanks

Manuel
--------------------------------------------------------------

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

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]
j053ph4
2012-11-19 21:45:25 UTC
Permalink
j053ph4 [http://community.zenoss.org/people/j053ph4] created the discussion

"Re: Include datapoint value in transform?"

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

--------------------------------------------------------------
You may want to try putting a try:...except:  branch in the transform.  Sometimes the RRD data isn't available (for whatever reason), so the initial variables may be defined as "None:
--------------------------------------------------------------

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

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]
themactech
2012-11-20 20:48:20 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Include datapoint value in transform?"

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

--------------------------------------------------------------
Thanks for the reply but all my variables are populated.  To test it I removed my if statement and instead just put a this line:

evt.summary = str (LowThresh) + "   " +  str (HighThresh) + "   " + str (CurrentTemp)

I then triggered an event (heat gun) and the event summary did contain the proper 3 values.

It is so frustrating to be stumped by an 'if' statement of all things...

Manuel
--------------------------------------------------------------

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

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]
j053ph4
2012-11-20 20:55:22 UTC
Permalink
j053ph4 [http://community.zenoss.org/people/j053ph4] created the discussion

"Re: Include datapoint value in transform?"

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

--------------------------------------------------------------
Well if this is it be sure to smack yourself for me:

if CurrentTemp > H*I*ghThresh:

Looks like your 'if' clause uses a capital "I" instead of lowercase 'i' in your variable definition...

If only i could recover the time i've lost to miskeys and missing semicolons X-(
--------------------------------------------------------------

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

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]
themactech
2012-11-20 21:01:00 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Include datapoint value in transform?"

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

--------------------------------------------------------------
I got it to work by using the expressions instead of the variables in my "if" statement, so:

if CurrentTemp < LowThresh:

Does not work, but:

if float(float(getattr(evt, 'internalTemp'))/10) > float(device.getRRDValue('TempHigh')):

Does work:

Funny thing is I can use the variables CurrentTemp, HighThresh, LowThresh that I define at the top of my script in my evt.summary definition, but my if statement fails if I try to use them there...

Manuel
--------------------------------------------------------------

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

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]
erlingqiling yu
2012-12-06 01:28:32 UTC
Permalink
erlingqiling yu [http://community.zenoss.org/people/erlingqiling] created the discussion

"Re: Include datapoint value in transform?"

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

--------------------------------------------------------------
Dallas Cowboys jerseys

If you love football, you probably have a favorite team <a href=" http://www.jerseycheap-china.com/customized-nike-nfl-c-237.html http://www.jerseycheap-china.com/customized-nike-nfl-c-237.html">Customized Nike NFL Jerseys</a> from the National Football League. It's hard to see this team putting together a winning season with upper management undergoing polemic. The word on the street have bounded gaoanyuyue the Oakland Raiders jerseys staff and have annoy in the hearts and minds of the Raider nation since the close of the regular seasons two and have a list of players who like to have seen. But a great way to show your loyalty to this team is the use of NFL jerseys of their team colors, sports.  As a professional nfl jerseys wholesalers for nearly 8 years since the year of 2003, we can offer you cheap jerseys, Chicago Cubs jerseys, National Football League jerseys, National Hockey League Jerseys, National Basketball Association  Jerseys, Dallas Cowboys jerseys with discount jerseys, all jerseys are authentic quality. So we rely on the outstanding service and high quality obtain high reputation in USA, Canada. And most products displayed on our website are available and have stocks here.  The Chicago Cubs are a major league baseball team based in Chicago, Illinois. They are in the Central Division of the National League. The Chicago Cubs jersey when they play at home is pin striped and the Chicago Cubs play away                              agamas their jersey is grey. The Chicago Cubs baseball team has the longest dry spell between championships in all of the four major U.S. Authentic road jersey with Alfonso Soriano's name and number decorated in authentic font and numbering at the back of Chicago Cubs Jersey. The quick-drying jersey <a href=" http://www.jerseycheap-china.com http://www.jerseycheap-china.com">jerseys from china</a> is made of resilient polyester for a comfortable feel on and off the field. Authentic team colors and font, with  a button-front design:  * 100% polyester double-knit construction          * Official team colors and logos  * Full-button front  * Team decoration chest    * Team specific <a href=" http://www.jerseycheap-china.com http://www.jerseycheap-china.com">cheap jerseys from china</a> jock tag on tail  The main supplier for NFL Jerseys at the present is Reebok. In USA, We can divided the jerseys into three categories, Quality from low to high, They are Replica Jerseys, Premier Jerseys and <a href=" http://www.jerseycheap-china.com/customized-nike-nfl-c-237.html http://www.jerseycheap-china.com/customized-nike-nfl-c-237.html">Customized Nike NFL Jerseys</a> Authentic Jerseys. The biggest different between them <a href=" http://www.jerseycheap-china.com/customized-nike-nfl-c-237.html http://www.jerseycheap-china.com/customized-nike-nfl-c-237.html">Customized Nike NFL Jerseys</a> are jersey fabric, numbers of fabric, stitching and the price. We are committed to internet marketing businesses. Our vision is to empower people worldwide in buying online. Here with the discount jerseys with high quality, any information please feel free to contact with us, you can find a big selection of jerseys here.  We stock all types of jerseys at the most favorable prices. Low prices and big selection makes us the right spot to get all of your NFL Jerseys, Dallas Cowboys jerseys, and Chicago Cubs jerseys. And these Jersey is a great way to show off your favorite player and feel like a part of the team!   Now if you buy more than 10pcs Dallas cowboys jerseys, we will give you free shipping, you can contact us for your any question about your order. We usually use shipping methods as UPS, TNT, EMS, DHL FedEx to ship your orders and the tracking numbers are available as soon as the orders shipped. And you can receive your orders in 5 to 9 days. Please make sure your shipping address is correct. So you can receive the package directly.  Welcome to our discount jerseys store. We supply nfl jerseys wholesale, Dallas Cowboys jerseys, Chicago Cubs jerseys. For more information about nfl jerseys wholesale, please visit http://www.nf1jerseys0001.com http://www.nf1jerseys0001.com.
--------------------------------------------------------------

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

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...