Discussion:
Graph results of a shell script
xlancealot
2012-03-01 15:12:00 UTC
Permalink
xlancealot [http://community.zenoss.org/people/xlancealot] created the discussion

"Graph results of a shell script"

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

--------------------------------------------------------------
Guess that explains it  :)      I have the mysql tools installed getting a lot of info, but don't have the connection / thread count.  Grants are allowed for zenoss, so on that box I would like the folllowing;

Create a graph and simply use the command; mysqladmin -h $server processlist |grep -v 'show processlist' | wc -l

That will return the value, and just go from there.   I'm not sure on the variable, but I can find that, it's something like $manageIP or something but the above is the most important.

Tnx
--------------------------------------------------------------

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

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-03-02 01:41:10 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
Your talking about a "command datasource" The admin guide covers them a bit. Basically you'll probably want to wrap the command in a small shell that takes the output and returns it in nagios plugin format.
--------------------------------------------------------------

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

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]
xlancealot
2012-03-02 14:14:55 UTC
Permalink
xlancealot [http://community.zenoss.org/people/xlancealot] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
ok, as with the other, back to the books  :)

Thanks.
--------------------------------------------------------------

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

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]
xlancealot
2012-03-02 15:33:17 UTC
Permalink
xlancealot [http://community.zenoss.org/people/xlancealot] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
ok, there is not a lot of help on this, but from the reading, here is what I have, the output, etc. as it's not working but not sure what to do next.

I created the new datasrouce under the mysql info, set it as command.

Now, the command via commmand line does as it should, simply goes in and get's the count;

[***@mgr1 libexec]$ +mysqladmin -h mysql1 processlist -P 3306 |grep -v 'show processlist' | wc -l+
*13*

As I re-run, naturally the 13 changes as does with the other servers.  So under the libexec, I have a script, check_sql_conn and that's what there.  I enter that in the command window, add a server, select test and get the following;

Executing command $ZENHOME/libexec/check_sql_conn against c14-1
114
DONE in 0 seconds

That number 114 is constant regardless to what mysql server I put, etc.   I tried to get more info by issuing via command line;
+zencommand run -v10 -d mysql1+

-02 15:21:29,563 DEBUG zen.zencommand: Process check_sql_conn  started
2012-03-02 15:21:29,566 DEBUG zen.zencommand: Finished config fetch
2012-03-02 15:21:29,566 DEBUG zen.zencommand: Next command in 299 seconds
2012-03-02 15:21:29,609 DEBUG zen.zencommand: Received exit code: 0
2012-03-02 15:21:29,609 DEBUG zen.zencommand: Command: '/bin/sh -c exec $ZENHOME/libexec/check_sql_conn'
2012-03-02 15:21:29,609 DEBUG zen.zencommand: Output: '114\n'
2012-03-02 15:21:29,609 DEBUG zen.zencommand: Process check_sql_conn  stopped (0), 0.05 seconds elapsed
2012-03-02 15:21:29,610 DEBUG zen.zencommand: Queueing event {'manager': 'mgr1.domain.com', 'eventKey': 'test', 'device': 'mysql1', 'eventClass': '/Cmd/Fail', 'summary': 'Cmd: $ZENHOME/libexec/check_sql_conn - Code: 0 - Msg: Success', 'component': '', 'monitor': 'localhost', 'agent': 'zencommand', 'severity': 0}
2012-03-02 15:21:29,610 DEBUG zen.zencommand: Total of 1 queued events
2012-03-02 15:21:29,610 DEBUG zen.zencommand: The result of "$ZENHOME/libexec/check_sql_conn" was "'114\n'"
2012-03-02 15:21:29,614 DEBUG zen.zencommand: Next command in 299 seconds

Now I see cmd fail, cmd success, so a bit confused how to proceed.   I'm hoping I am close as this is pretty critical info, so thanks again.
--------------------------------------------------------------

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

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-03-02 15:53:13 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
I've written a couple of fairly long and detailed posts on getting command datasources working with nagios formatted scripts.  You should be able to find them in here somewhere with a simple search.

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

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

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]
xlancealot
2012-03-02 19:46:42 UTC
Permalink
xlancealot [http://community.zenoss.org/people/xlancealot] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
Thanks, the forum doesn't have much of a search by user so I had to mash search strings, etc. but found one you did help someone on, and helped me, so thanks.  The only I don't see is how to get that data point on a graph?

Looking under my data-sources, I have the out of the box mysql and my new one mysql-connections, the type "command".  The source of that is simply;
check_sql_conn ${dev/manageIp}

and when I test against a server, I get;

Executing command $ZENHOME/libexec/check_sql_conn IP against server
9   (it works)

So all that is left is making a graph.  I added a data point, under that new datasouce, called connections, set the type to DERIVE (since it will fluctuate).  Added to the graph, but not getting any data graphed.  

Thanks for any help on this last part (on this thread anyway)  :)
--------------------------------------------------------------

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

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-03-02 20:05:04 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
It take a bit for the graph to populate.  Also a good thing to check is that the RRD files get created for your data point and are populated, you will find this in /usr/local/zenoss/zenoss/perf/Devices/<your_IP_here>/

If you RRD files do not get populated, then you have a issue to fix before you mess with graphs.

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

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

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]
xlancealot
2012-03-02 20:15:29 UTC
Permalink
xlancealot [http://community.zenoss.org/people/xlancealot] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
Tnx, and looking under one mysql server, I don't see that data point anywhere.  Still figuring how things work together, so not sure how to debug this.  I know if I select the datasource, enter a server and test, it returns, so unsure on the next step.

I figured it would be add a datapoint, so I added that, I used the RRD type DERIVE, and RRD Minimum to 0, everything else is blank aside from the readonly box which is checked (as are the others).

What log(s) or other ways can I see if that datasource/point is doing it's job.

Tnx again
--------------------------------------------------------------

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

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]
xlancealot
2012-03-02 20:42:24 UTC
Permalink
xlancealot [http://community.zenoss.org/people/xlancealot] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
ok, still nothing.  The bash script looks like this; (very simple to start)

#!/bin/bash
IP=$1
Connections=`mysqladmin -h $IP processlist -P 3306 | grep -v 'show processlist' | wc -l`
echo "Connections="$Connections
exit 0

Data Source is called mysql-connections, and the data point is called Connections.    So looking in the perf/server/ folder I should see a mysql-connections_Connections.rrd I would guess, but it's not there.

Also under the graph, graph command, I am looking around and see the following;

DEF:Connections-raw=rrdPath/mysql-connections_Connections.rrd:ds0:AVERAGE
DEF:Connections-raw-max=rrdPath/mysql-connections_Connections.rrd:ds0:MAX
CDEF:Connections=Connections-raw
LINE1:Connections-raw#00cc00ff:Connections  
GPRINT:Connections-raw:LAST:cur\:%5.2lf%s
GPRINT:Connections-raw:AVERAGE:avg\:%5.2lf%s
GPRINT:Connections-raw-max:MAX:max\:%5.2lf%s\j

Not sure what/where/how to look next, but at least all the items seemed to be named connectly, unless I am missing something in my face! 

Tnx
--------------------------------------------------------------

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

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-03-02 20:14:10 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
Your datapoint must match the syntax of your nagios output.  If your script ends like this:

echo "Datasource|SQLConns="$SQLConns
exit 0

Then your datapoint must be called SQLConns, you can't give it an arbitrary name, it must match your nagios style output.

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

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

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-03-02 20:47:18 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
Your script output does not follow nagios format, I think that's the issue.

you need:

echo "Datasource|Connections="$Connections
exit 0

When you add a datapoint, it must be called 'Connections', the | is the indicator that says 'everything after this is datapoint info'.  Your script could return multiple datapoint (I do this a lot), example:

echo "Datasource|TempHigh="$TempHigh" TempLow="$TempLow

Then you could create both datapoints TempHigh and TempLow and they would get their value from your script.

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

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

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]
xlancealot
2012-03-02 20:58:28 UTC
Permalink
xlancealot [http://community.zenoss.org/people/xlancealot] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
ah, I like the fact of getting more in the one script.   Well I made that change, looking in the folder and look what I see;

-rw-r--r-- 1 zenoss zenoss 35432 Mar  2 20:53 mysql-connections_Connections.rrd

waiting on the axis to change from 0.0 - 1 to something real which will confirm all is well, I will give proper thanks and move along  :)    stay tuned for a few to see if it populates.
--------------------------------------------------------------

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

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-03-02 21:00:07 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
It's all part of my evil ploy to take over the world, one SNMP query at a time...

Muhahahahaha

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

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

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]
xlancealot
2012-03-02 21:13:40 UTC
Permalink
xlancealot [http://community.zenoss.org/people/xlancealot] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
lol, you know when you first said I did posts, I was selfishly thinking, hey, you could have sent one or 2 (but then the smaller, smarter part said go get it yourself!)    Reading through I did get most of what I needed, but understood it more, so appreciate the time in helping going that last step, and yes, I have the tiniest dot starting my lovely graph.

Last 2 questions of the day (promise), the side axis did change based on the first few queires, so the last 2 are;

1. Under the datapoint, the cycle time is default at 300,I would like it more frequent, but don't want to kill the box since I have 20+ sql servers, what is a safe vs aggresive value.  The connections change so often I would like a better picture.

2. easier, the graph default shows like 10 - 20 as the range, but they end in m.   The current for example shows 6.63m, so not sure both how the current isn't a whole number and 2 how to make it look nicer!

So thanks again, always better to solve a problem vs copy/paste only to ask again later!
--------------------------------------------------------------

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

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]
Shane Scott
2012-03-05 19:51:42 UTC
Permalink
Shane Scott [http://community.zenoss.org/people/hackman238] created the discussion

"Re: Graph results of a shell script"

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

--------------------------------------------------------------
xlancealot:

If you want to poll faster, adjust your polling rate and adjust the RRD create command on the associated monitor. Delete all RRD's on items monitored by that monitor so they can be recreated with the correct step and consolidation.

RRD normalizes all data, this is normal. Because of this graphs whose lastTime does not fall on the step value will have fractional numbers in most cases.

--Shane
--------------------------------------------------------------

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

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