Discussion:
Correlating Components to other Devices
Duane Wylie
2013-08-21 14:08:29 UTC
Permalink
Duane Wylie [http://community.zenoss.org/people/ldwylie] created the discussion

"Correlating Components to other Devices"

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

--------------------------------------------------------------
I've been able to model a PDU where each outlet is a component, and I'm graphing the current on the outlet.  Most of our servers have dual power supplies, with each PSU connected to a different PDU for redundancy.  So where I am now, I have two devices (the PDUs) each with a component (the outlets).  I'd like to find a way to correlate those two components to a third device (the server), so I can graph the total current drawn by the server.

Does anyone have an idea on how to go about this?  Even if I could get a little closer to the goal, it would be great progress.
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
hydruid
2013-08-26 19:55:06 UTC
Permalink
hydruid [http://community.zenoss.org/people/hydruid] created the discussion

"Re: Correlating Components to other Devices"

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

--------------------------------------------------------------
I don't think there is a way in core to "correlate" them together. I would put both PDU components in a sub folder together and name something like 'Server_PSU-a' 'Server_PSU-b'.

That way when you run the report, you can specifiy to run it on the sub folder only.

Hope that helps!
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
kb8u
2013-08-26 23:09:24 UTC
Permalink
kb8u [http://community.zenoss.org/people/kb8u] created the discussion

"Re: Correlating Components to other Devices"

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

--------------------------------------------------------------
Add a local monitoring template on the server with two power supplies.  Edit it and add a data source of type "COMMAND".  Put something like this in the command template (change the .rrd paths to your PDU component's amperage rrd):

/bin/echo print '"OK|total="',`rrdtool lastupdate /opt/zenoss/perf/Devices/10.11.12.13/PDUComponent/OUTLET1/amps_amps.rrd | /usr/bin/tail -1 | /bin/cut -d' ' -f2,2` + `rrdtool lastupdate /opt/zenoss/perf/Devices/10.99.98.97/PDUComponent/OUTLET2/amps_amps.rrd | /usr/bin/tail -1 | /bin/cut -d' ' -f2,2` | /usr/bin/bc

That should all be on one line.  You may also have to adjust the paths to tail, bc, etc.

Add a data point 'total', and a graph definition for it.

The Formula Data Source Zenpack may also do the job, I haven't tried it yet.  I think it's only for data sources on the same device, though.
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Duane Wylie
2013-09-12 15:54:32 UTC
Permalink
Duane Wylie [http://community.zenoss.org/people/ldwylie] created the discussion

"Re: Correlating Components to other Devices"

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

--------------------------------------------------------------
kb8u, I think we're on the right track.  The command appears to be running correctly, but my graph is showing all -NaN values (and a find command does not find the RRD file anywhere on the server?!?!?).

I'll jump in chat to try to get some help on the graph issue.  Anyways...

Since my PDUs report current in tenths of amperes, I had to do a calculation:

/bin/echo print '"OK|total="',"(`rrdtool lastupdate /opt/zenoss/perf/Devices/10.11.12.13/PDUComponent/OUTLET1/amps_amps.rrd | /usr/bin/tail -1 | /bin/cut -d' ' -f2,2` + `rrdtool lastupdate /opt/zenoss/perf/Devices/10.99.98.97/PDUComponent/OUTLET2/amps_amps.rrd | /usr/bin/tail -1 | /bin/cut -d' ' -f2,2`)/10" | /usr/bin/bc -l

Since the derived amperage value was less than one, and bc performs integer division by default, everything was coming back as zeroes.  I had to add the '-l' flag to bc, which sets the default precision of 20 places after the decimal.  So my output looks like this:

OK|total=.40000000000000000000

which is mathematically correct, but I don't know what effect, if any, this will have on the graph.  I've was trying to use the bc 'scale' function to control the precision, but I ran into some difficulty:

/bin/echo  print '"OK|total="',"scale=3;(`rrdtool lastupdate /opt/zenoss/perf/Devices/PDU1/outlets/OUTLET1/amps_amps.rrd | /usr/bin/tail -1 | /bin/cut -d' ' -f2,2` + `rrdtool lastupdate /opt/zenoss/perf/Devices/PDU2/outlets/OUTLET2/amps_amps.rrd | /usr/bin/tail -1 | /bin/cut -d' ' -f2,2`)/10" | /usr/bin/bc -l


OK|total=3.400  // Note that instead of interpreting the 'scale=3' expression to indicate 3 places behind the decimal, bc simply outputs '3' in this case.  Which is... interesting.  After a fair bit of experimentation, I found this to work in bash:

/bin/echo -n "OK|total=";/bin/echo "scale=3;(`rrdtool lastupdate /opt/zenoss/perf/Devices/PDU1/outlets/OUTLET1/amps_amps.rrd | /usr/bin/tail -1 | /bin/cut -d' ' -f2,2` + `rrdtool lastupdate /opt/zenoss/perf/Devices/PDU2/outlets/OUTLET2/amps_amps.rrd | /usr/bin/tail -1 | /bin/cut -d' ' -f2,2`) /10" | /usr/bin/bc -l


OK|total=.400  //precisely what I am looking for!

BUT! When testing this from with Zenoss, I get this:


Preparing Command...
Executing command /bin/echo [args omitted] against localhost

OK|total=
.400 

  DONE in 0 seconds

So, it seems that Zenoss is not respecting the '-n' flag for the echo command.  Any ideas?
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
kb8u
2013-09-12 17:38:51 UTC
Permalink
kb8u [http://community.zenoss.org/people/kb8u] created the discussion

"Re: Correlating Components to other Devices"

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

--------------------------------------------------------------
I saw the line break when running the test, too, but it did not have an impact on actual data collection.  Your problem is most likely unrelated to that.

Do you have the parser set to Auto in the data source?  Is the data source enabled?  You also have to add a data point to the data source, but I see you have a graph so presumedly you have that already

Try turning on debug for the zencommand daemon, then look in $ZENHOME/log/localhost/zencommand.log (or whatever your collector is)

You should see the command being run, then lines like:
2013-09-04 14:58:04,518 DEBUG zen.zencommand: Output: 'OK|total=9991.0'
2013-09-04 14:58:04,518 DEBUG zen.zencommand: Process echo print ... etc., etc.
2013-09-04 14:58:04,518 DEBUG zen.zencommand: Dropping useless clear event ... etc., etc.
2013-09-04 14:58:04,518 DEBUG zen.zencommand: The result of "/bin/echo print ... etc., etc... /bin/bc" was "'OK|total=9991.0'"
2013-09-04 14:58:04,519 DEBUG zen.zencommand: Storing total = 9991.0 into Devices/10.1.2.3/Two Components Added Together_total
2013-09-04 14:58:04,519 DEBUG zen.RRDUtil: /opt/zenoss/perf/Devices/10.1.2.3/Two Components Added Together_total.rrd: 9991.0
2013-09-04 14:58:04,519 DEBUG zen.zencommand: RRD save result: 9991.0
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Duane Wylie
2013-09-12 17:52:08 UTC
Permalink
Duane Wylie [http://community.zenoss.org/people/ldwylie] created the discussion

"Re: Correlating Components to other Devices"

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

--------------------------------------------------------------
I was working with the very helpful folks in chat, and in the process of troubleshooting the missing RRD file, I had changed the parser from 'Auto' to 'Nagios'.  Changing the value back to 'Auto' does not appear to have an impact.

zencommand debugging did verify that the command was pulling the data correctly.  The problem was the name of the data point.  I tweaked the output from OK|total=$NUM to OK|Amperes=$NUM and the RRD was created and we're good to go!
--------------------------------------------------------------

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

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
kb8u
2013-09-12 18:20:01 UTC
Permalink
kb8u [http://community.zenoss.org/people/kb8u] created the discussion

"Re: Correlating Components to other Devices"

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

--------------------------------------------------------------
Glad you got it going.  Also, to answer your previous question:
"The string between the pipe and the equal sign must precisely match the name of the DataPoint you are trying to graph.  This was the reason my RRD file was not being created.  I assume this means the RRD files are not created until the first data value is retrieved?"

Yes, that is correct.  Furthermore, you need a couple of data collection cycles before the RRD file will have enough data to graph.  If you're impatient like I am, you can run `rrdtool dump blahblah.rrd | less` and see if anything was added right after the file is updated.
--------------------------------------------------------------

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

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