How to Graph Mysql Query?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

aboyz
Cacti User
Posts: 56
Joined: Fri Jan 18, 2008 7:09 pm

How to Graph Mysql Query?

Post by aboyz »

Hi,

anyone know of a scrip that will let me graph mysql query statement like?
select count(*) from whos_online WHERE customer_id != 0" -s -s oscom
45

That will give me an integer. Anyone know how to graph this?

thanks
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Read through the documentation site on how to create the templates.
aboyz
Cacti User
Posts: 56
Joined: Fri Jan 18, 2008 7:09 pm

thanks

Post by aboyz »

thanks!!

I'll read thru the site.
aboyz
Cacti User
Posts: 56
Joined: Fri Jan 18, 2008 7:09 pm

my log?

Post by aboyz »

here is what is in my cacti log.
01/20/2008 12:25:02 AM - CMDPHP: Poller[0] Host[6] DS[40] WARNING: Result from CMD not valid. Partial Result: File does not exist

What does that mean anyone know. I click on the DS and it show this.
Selected Data Template: MySQL - 5 Count Queries
Host - 192.168.1.111
Database Port: 3306
MySQL Username: cacti
MySQL Password: cacti
Query Filename - oscom.sql

Anything wrong with that config file? please let me know thanks. or anything else I should look at?

thank you for your help!!
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Click on that DS[40] link from the cacti log viewer. As the error states, the File does not exist.
aboyz
Cacti User
Posts: 56
Joined: Fri Jan 18, 2008 7:09 pm

Yeah ,

Post by aboyz »

I don't know why the file doesn't exist.

I put in oscom.sql

which is in the queries/

maybe it need the whole path

let me try that thanks!!
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Yeah ,

Post by BSOD2600 »

aboyz wrote:maybe it need the whole path
Correct.

Try something like:
mysql <path_cacti>/scripts/oscom.sql <field1> <field2> etc.
aboyz
Cacti User
Posts: 56
Joined: Fri Jan 18, 2008 7:09 pm

this is what showing in my poller cache.

Post by aboyz »

Script: /usr/bin/php -q /home/cacti/scripts/mysql_query.php 192.168.1.211 3306 'cacti' 'cacti' 'oscom.sql'

I ran that on my shell prompt and it work fine.

Wonder why its giving me that error. ? any clue anyone? I tried to contact the developer of the sqlqueiries but no reply :(

any help will be appreciated
aboyz
Cacti User
Posts: 56
Joined: Fri Jan 18, 2008 7:09 pm

ok, this is wired..

Post by aboyz »

Ok, when I run this command under /home/cacti/
/usr/bin/php -q /home/cacti/scripts/mysql_query.php 192.168.1.211 3306 'cacti' 'cacti' 'oscom.sql'
File does not exist ..

ok when i run this under
/home/cacti/scripts/
/usr/bin/php -q /home/cacti/scripts/mysql_query.php 192.168.1.211 3306 'cacti' 'cacti' 'oscom.sql'
out1:334

That worked, So Why doesn't it work when I run it under /home/cacti? that is so wired. Anyone got any clue as to why it work under /home/cacti/script and not /home/cacti .? that is why i'm getting the error under cacti.log file does not exist.? but they file is there.

thanks
Song
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

And waht is defined for tha Data Input Method?
Does the script use commands that are called without providing /full/path/to/command?
Reinhard
aboyz
Cacti User
Posts: 56
Joined: Fri Jan 18, 2008 7:09 pm

got it

Post by aboyz »

I fixed this by editing the mysql_query.php file. I added in the full path to the querie/ directory and that worked with no error, but The graph is still not showing up? anyone know why?

I enable all debug log and cacti.log still no more error. I cannot trouble this anymore. Anyone know why the graph are not showing up?

thanks
aboyz
Cacti User
Posts: 56
Joined: Fri Jan 18, 2008 7:09 pm

ok i did a debuging on the graph

Post by aboyz »

Here is what I get

RRDTool Command:

/usr/local/rrdtool-1.2.26/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="oscomdb - MySQL Queries" \
--base=1000 \
--height=120 \
--width=800 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="/home/cacti/rra/oscomdb_out5_9.rrd":out1:LAST \
DEF:b="/home/cacti/rra/oscomdb_out5_9.rrd":out1:AVERAGE \
DEF:c="/home/cacti/rra/oscomdb_out5_9.rrd":out1:MAX \
DEF:d="/home/cacti/rra/oscomdb_out5_9.rrd":out2:LAST \
DEF:e="/home/cacti/rra/oscomdb_out5_9.rrd":out2:AVERAGE \
DEF:f="/home/cacti/rra/oscomdb_out5_9.rrd":out2:MAX \
DEF:g="/home/cacti/rra/oscomdb_out5_9.rrd":out3:LAST \
DEF:h="/home/cacti/rra/oscomdb_out5_9.rrd":out3:AVERAGE \
DEF:i="/home/cacti/rra/oscomdb_out5_9.rrd":out3:MAX \
DEF:j="/home/cacti/rra/oscomdb_out5_9.rrd":out4:LAST \
DEF:ba="/home/cacti/rra/oscomdb_out5_9.rrd":out4:AVERAGE \
DEF:bb="/home/cacti/rra/oscomdb_out5_9.rrd":out4:MAX \
DEF:bc="/home/cacti/rra/oscomdb_out5_9.rrd":out5:LAST \
DEF:bd="/home/cacti/rra/oscomdb_out5_9.rrd":out5:AVERAGE \
DEF:be="/home/cacti/rra/oscomdb_out5_9.rrd":out5:MAX \
CDEF:cdefa=a,300,* \
CDEF:cdefc=c,300,* \
CDEF:cdefd=d,300,* \
CDEF:cdeff=f,300,* \
CDEF:cdefg=g,300,* \
CDEF:cdefi=i,300,* \
CDEF:cdefj=j,300,* \
CDEF:cdefbb=bb,300,* \
CDEF:cdefbc=bc,300,* \
CDEF:cdefbe=be,300,* \
LINE1:cdefa#FF3932FF:"whos_online" \
GPRINT:cdefa:LAST:"Current\:%8.0lf" \
GPRINT:cdefc:MAX:"Max\:%8.0lf\n" \
LINE1:cdefd#8D00BAFF:"Query 2" \
GPRINT:cdefd:LAST:" Current\:%8.0lf" \
GPRINT:cdeff:MAX:"Max\:%8.0lf\n" \
LINE1:cdefg#CCBB00FF:"Query 3" \
GPRINT:cdefg:LAST:" Current\:%8.0lf" \
GPRINT:cdefi:MAX:"Max\:%8.0lf\n" \
LINE1:cdefj#009485FF:"Query 4" \
GPRINT:cdefj:LAST:" Current\:%8.0lf" \
GPRINT:cdefbb:MAX:"Max\:%8.0lf\n" \
LINE1:cdefbc#000000FF:"Query 5" \
GPRINT:cdefbc:LAST:" Current\:%8.0lf" \
GPRINT:cdefbe:MAX:"Max\:%8.0lf\n"
RRDTool Says:

ERROR: the RRD does not contain an RRA matching the chosen CF


What does it mean by RRA matching the chosen CF? anyone
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

You're on cacti 0.8.7a? Install the patches (on the main site).
aboyz
Cacti User
Posts: 56
Joined: Fri Jan 18, 2008 7:09 pm

yes

Post by aboyz »

Yes, I'm running cacti 0.8.7a, I didn't install any main patches. Should I go ahead and do the main patches??

Isn't the main patches suppose to be on the latest 0.8.7a release?
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: yes

Post by BSOD2600 »

aboyz wrote: Should I go ahead and do the main patches??
Yes.
aboyz wrote:Isn't the main patches suppose to be on the latest 0.8.7a release?
No, they're released after 0.8.7a came out.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests