[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [xymon] hobbitgraph.cgi: Attempting to reuse 'mysqlht'
- To: xymon (at) xymon.com
- Subject: Re: [xymon] hobbitgraph.cgi: Attempting to reuse 'mysqlht'
- From: Arie Skliarouk <skliarie (at) gmail.com>
- Date: Sun, 28 Nov 2010 16:30:39 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=euf8IlMd5AjP1tuSVH1ll34jESjk7KDQyUVCns/pVfc=; b=H5OMsvhj/Olc/GhZa0J8L3EdmOnWZxUYOO8FLGkMh0VI48xaT60SEy0IyETCU1K75R H1SdM7p6fJOyR5qDZfeSKsx8NFspQVKaPDDh+1xs7rFG9z+2MP36XDY9AWiLSzL45w9N r58B10PU+6qudrR4z3M6yq8wYi1K2ltChDTzM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=fyFyguOG5DyGhnrDrUXjn3JgUPTTpSD4M8DY6qb2wfFL67sI6xxSPZUx/CGu51bU1r eVk+G7cMXB9FzdYO1EOKubTzF8h7XQ6sGzcF4AfrkMiLnrQEd9Z60jS9t+saLNXq0NRk ukLQ2plfIEg3SuvcaXZAJFI0p22Y+yrd0TzD8=
- References: <AANLkTi=riErSLwMtrS_dk-Le7tO4Krd5MDsc1raxrdtK (at) mail.gmail.com> <icm15c$ulk$2 (at) voodoo.hswn.dk>
On Thu, Nov 25, 2010 at 17:59, Henrik StÃrner <henrik (at) hswn.dk> wrote:
> On Wed, 24 Nov 2010 16:12:07 +0200, Arie Skliarouk wrote:
>
> > I created a custom mysql parameters check that shows graphs on one
> > server, but not on the other. hobbitgraph.sh (hobbitgraph.cgi?) kept
> > sending following error instead of the actual image:
> > <html><head><title>Invalid request</title></head> <body>Attempting to
> > reuse 'mysqlht'</body></html>
>
> This is an error from the rrdtool library. So I would suspect something
> dodgy with the graph-definition in hobbit-graphs.cfg, or the RRD file
> data is not as you would expect.
>
> Could you show us the graph definition you use ?
See attached. Also attached all files you might require to recreate the
mysql sensor.
Note that the graph works for one machine, but not for the other.
> And the layout of the
> RRD-file - a command like
>
> rrdtool info mysql.rrd |grep "type ="
>
Both files yield identical output:
ds[mysqlht].type = "GAUGE"
ds[mysqlhq].type = "GAUGE"
ds[mysqlhs].type = "GAUGE"
--
Arie
>
> should give us the necessary info about the datasets and their type.
>
> > If I request the same image for different server, same service - I get
> > the image. If I copy the mysql.rrd file from the
> > /var/lib/hobbit/rrd/atl-db01/mysql.rrd into the
> > /var/lib/hobbit/rrd/pa04, then the image for pa04 shows graph for the
> > atl-db01.
> >
> > Could be that dash in name of that particular server was affecting the
> > hobbitgraph.cgi somehow? I can attach the hobbitgraph.d/mysql.cfg and
> > hobbitserver.d/mysql.cfg if that would help.
>
> It shouldn't, and I know I have hostnames with dash'es in them. Haven't
> noticed any problems with graphs there, but I'll have a look.
>
>
> Regards,
> Henrik
>
> To unsubscribe from the xymon list, send an e-mail to
> xymon-unsubscribe (at) xymon.com
>
>
>
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Report to hobbit run-time parameters of local mysql installation.
# Designed to be located in /usr/lib/hobbit/client/ext directory and invoked by hobbitd
#
# Author: Arie Skliarouk <skliarie (at) gmail.com>
#
# First, create a dumb user that can do status and show variables :
# grant select on devnull.* to monitoring (at) localhost identified by 'monitoring';
# revoke all on devnull.* from monitoring (at) localhost;
# TBD:
# or use the config file $BBHOME/etc/bb-mysql.cfg to set for example :
# user=thisuser
# passwd=thatpassword
# socket=othersocket
import datetime,os,sys
# not supported by python2.5
#from subprocess import Popen, PIPE, STDOUT
import subprocess
import string,re
#import MySQLdb
#import MySQLdb.cursors
testname = "mysql"
def Execute(CommandAndArgs):
#CommandAndArgs=[BB,BBDISP,"-"]
DebugStr="[".join(CommandAndArgs)+"]"
if "BB" in os.environ:
#stdout=subprocess.Popen(CommandAndArgs,stdin=subprocess.PIPE).stdin
#stdout.write(DATA)
subprocess.Popen(CommandAndArgs)
# Debugging
#open("/tmp/bb-latency.log","a+").write("{"+DebugStr+"}\n")
else:
print DebugStr
"""
my $BBHOME = $ENV{BBHOME};
my $BB = $ENV{BB}; # full path to the bin/bb util
my $BBDISP = $ENV{BBDISP}; # IP of the BBDISPLAY server
my $BBVAR = $ENV{BBVAR};
my $MACHINE = $ENV{MACHINE}; # hostname, fqdn
my $COLOR = "clear"; # global color for the test
my $MSG = ""; # body of the message
my $HEAD = ""; # first line of the message (short, optional)
my $DATA = ""; # data for NCV records (hobbit only)
"""
GREEN='green'
YELLOW='yellow'
RED='red'
### Main Program
# Get status from the running mysql server
#db=MySQLdb.connect(host="localhost",user="monitoring",passwd="monitoring",charset ="utf8", use_unicode = True)
#c = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
mysql_auth="-umonitoring -pmonitoring";
mysql_client="/usr/bin/mysql";
cmd=mysql_client+" "+mysql_auth+" -Bs"
p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
p.stdin.write("select 'DATE', now() ; status; show variables;")
p.stdin.close()
output = p.stdout.read()
# Extract "Slow queries: 0"
slow_queries_pattern=re.compile(r'Slow queries: (\d+) ', re.IGNORECASE)
slow_queries_now=int(slow_queries_pattern.findall(output)[0])
# Slow queries is accumulating value, so we need to report increase of these.
slow_queries=0
# Keep the previous value in /tmp/bb-mysql.dat
slow_queries_file="/tmp/bb-mysql.dat"
if (os.path.exists(slow_queries_file)):
slow_queries_before=int(open(slow_queries_file,"r").read())
slow_queries=slow_queries_now-slow_queries_before
open(slow_queries_file,"w").write(str(slow_queries_now))
# Extract "Threads: 1"
threads_pattern=re.compile(r'Threads: (\d+) ', re.IGNORECASE)
threads=threads_pattern.findall(output)[0]
# Extract "Queries per second avg: 0.0"
qps_pattern=re.compile(r'Queries per second avg: (\d+)', re.IGNORECASE)
qps=qps_pattern.findall(output)[0]
#print slow_queries
#c.execute("select now()")
#results=c.fetchall()
#mysql_timestamp=results[0]
#print "Server reports timestamp of [%s]" % mysql_timestamp
#c.execute("status")
#results=c.fetchall()
#; status; show variables"
results={"mysqlhq":qps, "mysqlhs":slow_queries, "mysqlht":threads}
#results_handle=open("/tmp/latency_test.data","r")
#for line in results_handle.readlines():
# (key,secs)=line.split(":")
# results[key]=int(string.atof(secs))
# Always successful
color=GREEN
# Send to Hobbit
#Tue May 25 15:36:13 IDT 2010
report_date=datetime.datetime.utcnow().strftime("%a %b %e %T UTC %Y")
if "MACHINE" in os.environ:
Machine=os.environ["MACHINE"]
else:
Machine="ENV{MACHINE}"
if "BB" in os.environ:
BB=os.environ["BB"]
else:
BB="ENV{BB}"
if "BBDISP" in os.environ:
BBDISP=os.environ["BBDISP"]
else:
BBDISP="ENV{BBDISP}"
DATA_values=""
TEXT_values=""
separator=""
for result in results.keys():
bbtest = result
status = bbtest + " OK"
# Notify each measured value
DATA="status "+Machine+"."+result+" "+color+" "+report_date+" - "+result+" OK\n\n"+result+"="+str(results[result])+"\n"
CommandAndArgs=[BB,BBDISP,DATA]
#Execute(CommandAndArgs)
TEXT_values+=separator+result+"="+str(results[result])
separator="\n"
# Notify all values (as a text)
DATA="status "+Machine+"."+testname+" "+color+" "+report_date+" - "+testname+" OK\n\n"+TEXT_values+"\n"
CommandAndArgs=[BB,BBDISP,DATA]
Execute(CommandAndArgs)
#open("/tmp/bb-latency.log","a+").write(report_date+": report done\n")