From 1e2387474a449452b78520b9ad96a8b4b5e99722 Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Wed, 17 Apr 2019 19:07:19 +0200 Subject: initial commit of source fetch --- .../contrib/CheckMySQLHealthExt1.pm | 68 ++++ .../contrib/README.my-extensions | 139 ++++++++ .../contrib/check_mysql_health.php | 370 +++++++++++++++++++++ 3 files changed, 577 insertions(+) create mode 100755 nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/CheckMySQLHealthExt1.pm create mode 100755 nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/README.my-extensions create mode 100755 nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/check_mysql_health.php (limited to 'nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib') diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/CheckMySQLHealthExt1.pm b/nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/CheckMySQLHealthExt1.pm new file mode 100755 index 0000000..c5bb9d3 --- /dev/null +++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/CheckMySQLHealthExt1.pm @@ -0,0 +1,68 @@ +package MyQueue; + +our @ISA = qw(DBD::MySQL::Server); + +sub init { + my $self = shift; + my %params = @_; + $self->{running} = 0; + $self->{waiting} = 0; + $self->{held} = 20; + $self->{cancelled} = 0; + $self->{length} = 100; + if ($params{mode} =~ /my::queue::status/) { + ($self->{running}, $self->{waiting}, $self->{held}, $self->{cancelled}) = + $self->{handle}->fetchrow_array(q{ + SELECT COUNT(*) FROM queues WHERE + status IN ('running', 'waiting', 'held', 'cancelled') + GROUP BY status + }); + } elsif ($params{mode} =~ /my::queue::length/) { + $self->{length} = $self->{handle}->fetchrow_array(q{ + SELECT COUNT(*) FROM queues + }); + } elsif ($params{mode} =~ /my::queue::througput/) { + $self->{processed_items} = $self->{handle}->fetchrow_array(q{ + SELECT processed FROM queue_status + }); + $self->valdiff(\%params, qw(processed_items)); + # this automatically creates + # $self->{delta_timestamp} + # the time in seconds since the last run of check_mysql_health + # $self->{delta_processed_items} + # the difference between processed_items now and + # processed_items when check_mysql_health was run last time + $self->{throughput} = $self->{delta_processed_items} / $self->{delta_timestamp}; + } else { + } +} + +sub nagios { + my $self = shift; + my %params = @_; + if ($params{mode} =~ /my::queue::status/) { + if ($self->{held} > 10 || $self->{cancelled} > 10) { + $self->add_nagios_critical("more than 10 queues are held or cancelled"); + } elsif ($self->{waiting} > 20 && $self->{running} < 3) { + $self->add_nagios_warning("more than 20 queues are waiting and less than 3 queues are running"); + } else { + $self->add_nagios_ok("queues are running normal"); + } + $self->add_perfdata(sprintf "held=%d cancelled=%d waiting=%d running=%d", + $self->{running}, $self->{waiting}, $self->{held}, $self->{cancelled}); + } elsif ($params{mode} =~ /my::queue::length/) { + $self->add_nagios( + $self->check_thresholds($self->{length}, 100, 500), + sprintf "queue length is %d", $self->{length}); + $self->add_perfdata(sprintf "queuelen=%d;%d;%d", + $self->{length}, $self->{warningrange}, $self->{criticalrange}); + } elsif ($params{mode} =~ /my::queue::througput/) { + $self->add_nagios( + $self->check_thresholds($self->{throughput}, "50:", "10:"), + sprintf "queue throughput is %d", $self->{throughput}); + $self->add_perfdata(sprintf "throughput=%.2f;%d;%d", + $self->{throughput}, $self->{warningrange}, $self->{criticalrange}); + } else { + $self->add_nagios_unknown("unknown mode"); + } +} diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/README.my-extensions b/nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/README.my-extensions new file mode 100755 index 0000000..92aec08 --- /dev/null +++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/README.my-extensions @@ -0,0 +1,139 @@ +# you will find instructions how to write extensions here + +Self-written code is addressed by using a mode which starts with my- +--mode=my-thing-does ? + +check_mysql_health will then look for a package named MyThing. + +So you first have to write a Module which describes MyThing. Such a thing iinherits from DBD::MySQL::Server and needs two methods: init and nagios. + +Start with a file called CheckMySQLHealthExt1.pm and skeleton code: + +################################################### +package MyThing; + +our @ISA = qw(DBD::MySQL::Server); + +sub init { + my $self = shift; + my %params = @_; +} + +sub nagios { + my $self = shift; + my %params = @_; +} +################################################### + +When you call check_mysql_health with --mode=my-thing-does, it will +- create a DBD::MySQL::Server object + $obj = DBD::MySQL::Server->new() +- connect to the database + $obj->connect() +- re-bless the object + bless $obj, "MyThing" +- call $obj->init() +- if that was ok, call $obj->nagios() + + +So you need to write code which +- initializes the parameters you want to check +- calculates the nagios result from these parameters + +For your convenience there are some predefined methods and variables: + +Variable $self + $self is a hash-based object of type My::Thing + You can pass metrics from the init() method to the nagios() method by + adding attributes to the hash. + One important predefined attribute is $self->{handle} which points to + a database Connection object. You surely will use this. + +Variable %params + $params{mode} contains the string you passed to the + --mode command line parameter, only with the "-" replaced by "::". + In the above example it will be "my::thing::does". + Because you can have only one init() method for your MyThing object but + more than one related modes (my-thing-does, my-thing-length, my-thing-rate) + you use $params{mode} for branching in your code. (see the example file) + +Method add_nagios + $self->add_nagios(1, "i warn you"); + This method can be called several times. The messages will be concatenated. + The first parameter is one of 0..3 and sets the nagios level. The worst level + among several calls to add_nagios will determine the plugin's exit code. + +Method add_nagios_[ok|warning|critical|unknown] + $self->add_nagios_critical("i warned you!!! now it's too late"); + $self->add_nagios_ok("everything is ok. i am the exit message"); + These methods are wrappers for add_nagios which make your code more readable. + +Method add_perfdata + $self->add_perfdata("metric1=0 metric2=100"); + $self->add_perfdata("metric3=0); + $self->add_perfdata(sprintf "metric_xy=%d", $self->{xy}); + You can call add_perfdata as often as you like. + The strings will be concatenated. + +Method valdiff + $self->valdiff(\%params, qw(metric1 metric2)); + Use this if you want to know how a metric has changed since the last run + of check_mysql_health. + Provided you have attributes metric1 and metric2 this method will create + new attributes for your $self object. + $self->{delta_metric1} which is the difference between the value of + $self->{metric1} during the current run and $self->{metric1} during the + last run. + $self->{delta_timestamp} which is the number of seconds which passed + since the last run of check_mysql_health. + If you have ever-growing values, you can simply calculate the rate: + $self->{metric1_per_second} = $self->{delta_metric1} / $self->{delta_timestamp} + The valdiff method will automatically save the current value to a state file + and read the past value from this file. + If you used the --name parameter which appears as $params{name} in your code + then you probably need to separate the saved values from each other. Otherwise + name1 would read the same saved value as name2. They would overwrite the + saved values. Use $params{differentiator} to use different state files. + $params{differenciator} = lc $self->{name}; + $self->valdiff(\%params, qw(gets misses)); + +Method fetchrow_array + my($column1, $column2) = $self->{handle}->fetchrow_array(q{ + SELECT col1, col2 FROM table1 where col1 = 'val1' + }); + $self->{connected_users} = $self->{handle}->fetchrow_array(q{ + SELECT COUNT(*) FROM v$session WHERE type = 'USER' + }); + This method is used like the Perl DBI method fetchrow_array. + + +Method fetchall_array + my @results = $self->{handle}->fetchall_array(q{ + SELECT col1, col2, col3 FROM table1 + }); + foreach (@results) { + my($column1, $column2, $column3) = @{$_}; + ... + } + This method is used like the Perl DBI method fetchall_array. + + + + +Now you have written your first extension to check_mysql_health. Maybe you +just modified the example file contrib/CheckMySQLHealthExt1.pm +There are two methods how to import your own code into check_mysql_health: + +- the static method +with ./configure --with-mymodules-dir= parameter you build a plugin which +contains both my code and your code in a single file. When you call "make" +every file in which matches CheckMySQLHealthExt*.pm is appended +to the final plugin check_mysql_health. + +- the dynamic method +with ./configure --with-mymodules-dyn-dir= you build a plugin which will +search at runtime the for files matching CheckMySQLHealthExt*.pm and +import them. This way you can have different extensions on different hosts. +You also can modify your extension without having to rebuild the plugin. +On the other hand you have to distribute your extensions along with the plugin. + diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/check_mysql_health.php b/nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/check_mysql_health.php new file mode 100755 index 0000000..8bcd516 --- /dev/null +++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_mysql_health/check_mysql_health-2.2.2/contrib/check_mysql_health.php @@ -0,0 +1,370 @@ +60s) on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:longrun=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "AREA:longrun#111111 "; + $def[$defcnt] .= "VDEF:vlongrun=longrun,LAST " ; + $def[$defcnt] .= "GPRINT:vlongrun:\"%.0lf long running processes \" " ; + $defcnt++; + } + if(preg_match('/^keycache_hitrate_now$/', $NAME[$i])) { + $ds_name[$defcnt] = "MyISAM key cache hitrate"; + $opt[$defcnt] = "--vertical-label \"Percent\" --title \"MyISAM key cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; + $def[$defcnt] = ""; + for ($ii = 1; $ii <= $ds_count; $ii++) { + if(preg_match('/^keycache_hitrate$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE1.5:hitrate#111111:\" \" "; + $def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; + $def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio (since epoch) is %3.2lf percent \\n\" "; + } + if(preg_match('/^keycache_hitrate_now$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; + $def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; + $def[$defcnt] .= "GPRINT:vhitratenow:\"Hitratio (current) is %3.2lf percent \\n\" "; + } + } + $defcnt++; + } + if(preg_match('/^qcache_hitrate_now$/', $NAME[$i])) { + $ds_name[$defcnt] = "Query cache hitrate"; + $opt[$defcnt] = "--vertical-label \"Percent\" --title \"Query cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; + $def[$defcnt] = ""; + for ($ii = 1; $ii <= $ds_count; $ii++) { + if(preg_match('/^qcache_hitrate$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE1.5:hitrate#111111:\" \" "; + $def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; + $def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio (since epoch) is %3.2lf percent \\n\" "; + } + if(preg_match('/^qcache_hitrate_now$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; + $def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; + $def[$defcnt] .= "GPRINT:vhitratenow:\"Hitratio (current) is %3.2lf percent \\n\" "; + } + } + $defcnt++; + $ds_name[$defcnt] = "Selects per second"; + $opt[$defcnt] = "--vertical-label \"Selects / sec\" --title \"Selects per second on $hostname\" "; + $def[$defcnt] = ""; + for ($ii = 1; $ii <= $ds_count; $ii++) { + if(preg_match('/^selects_per_sec$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:sps=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "AREA:sps#$now:\" \" "; + $def[$defcnt] .= "VDEF:vsps=sps,LAST " ; + $def[$defcnt] .= "GPRINT:vsps:\"%3.2lf Selects per second \\n\" "; + } + } + $defcnt++; + } + if(preg_match('/^qcache_lowmem_prunes_rate$/', $NAME[$i])) { + $ds_name[$defcnt] = "Query cache low memory prunes"; + $opt[$defcnt] = "--vertical-label \"Prunes / sec\" --title \"Query cache low mem prunes on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:prunes=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "AREA:prunes#111111 "; + $def[$defcnt] .= "VDEF:vprunes=prunes,LAST " ; + $def[$defcnt] .= "GPRINT:vprunes:\"Rate is %3.2lf Prunes / Second \" " ; + $defcnt++; + } + if(preg_match('/^slow_queries_rate$/', $NAME[$i])) { + $ds_name[$defcnt] = "Slow query rate"; + $opt[$defcnt] = "--vertical-label \"Slow queries / sec\" --title \"Slow queries on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:prunes=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "AREA:prunes#111111 "; + $def[$defcnt] .= "VDEF:vprunes=prunes,LAST " ; + $def[$defcnt] .= "GPRINT:vprunes:\"%3.2lf Slow queries / Second \" " ; + $defcnt++; + } + if(preg_match('/^tablelock_contention_now$/', $NAME[$i])) { + $ds_name[$defcnt] = "Table lock contention"; + # set upper limit to 10, because 3 means an already dead database + $opt[$defcnt] = "--vertical-label \"Percent\" --title \"Table lock contention on $hostname\" --upper-limit 10 --lower-limit 0 "; + $def[$defcnt] = ""; + for ($ii = 1; $ii <= $ds_count; $ii++) { + if(preg_match('/^tablelock_contention$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:tbllckcont=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ag=tbllckcont,$WARN[$ii],LE,tbllckcont,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,tbllckcont,0,IF "; + $def[$defcnt] .= "CDEF:ay=tbllckcont,$CRIT[$ii],LE,tbllckcont,$WARN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tbllckcont,0,IF "; + $def[$defcnt] .= "CDEF:ar=tbllckcont,100,LE,tbllckcont,$CRIT[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tbllckcont,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE:tbllckcont#111111:\" \" "; + $def[$defcnt] .= "VDEF:vtbllckcont=tbllckcont,LAST " ; + $def[$defcnt] .= "GPRINT:vtbllckcont:\"Lock contention (since epoch) is %3.2lf%%\\n\" " ; + } + if(preg_match('/^tablelock_contention_now$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:tbllckcontnow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "LINE1.5:tbllckcontnow#$now:\" \" "; + $def[$defcnt] .= "VDEF:vtbllckcontnow=tbllckcontnow,LAST " ; + $def[$defcnt] .= "GPRINT:vtbllckcontnow:\"Lock contention (current) is %3.2lf%%\" "; + } + } + $defcnt++; + } + if(preg_match('/^tablecache_fillrate$/', $NAME[$i])) { + $ds_name[$defcnt] = "Table cache hitrate"; + $opt[$defcnt] = "--vertical-label \"Percent\" --title \"Table cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; + $def[$defcnt] = ""; + for ($ii = 1; $ii <= $ds_count; $ii++) { + if(preg_match('/^tablecache_hitrate$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE:hitrate#111111:\" \" "; + $def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; + $def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio is %3.2lf percent \\n\" "; + } + if(preg_match('/^tablecache_fillrate$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; + $def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; + $def[$defcnt] .= "GPRINT:vhitratenow:\"%3.2lf%% of the cache is filled \\n\" "; + } + } + $defcnt++; + } + if(preg_match('/^pct_tmp_table_on_disk_now$/', $NAME[$i])) { + $ds_name[$defcnt] = "Temporary tables created on disk "; + $opt[$defcnt] = "--vertical-label \"Percent\" --title \"Temporary tables created on disk on $hostname\" --upper-limit 10 --lower-limit 0 "; + $def[$defcnt] = ""; + for ($ii = 1; $ii <= $ds_count; $ii++) { + if(preg_match('/^pct_tmp_table_on_disk$/', $NAME[$ii])) { + + $def[$defcnt] .= "DEF:tmptbldsk=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ag=tmptbldsk,$WARN[$ii],LE,tmptbldsk,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,tmptbldsk,0,IF "; + $def[$defcnt] .= "CDEF:ay=tmptbldsk,$CRIT[$ii],LE,tmptbldsk,$WARN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tmptbldsk,0,IF "; + $def[$defcnt] .= "CDEF:ar=tmptbldsk,100,LE,tmptbldsk,$CRIT[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,tmptbldsk,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE:tmptbldsk#111111:\" \" "; + $def[$defcnt] .= "VDEF:vtmptbldsk=tmptbldsk,LAST " ; + $def[$defcnt] .= "GPRINT:vtmptbldsk:\"%3.2lf percent of temp tables were created on disk (since epoch)\\n\" " ; + } + if(preg_match('/^pct_tmp_table_on_disk_now$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:tmptbldsknow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "LINE1.5:tmptbldsknow#$now:\" \" "; + $def[$defcnt] .= "VDEF:vtmptbldsknow=tmptbldsknow,LAST " ; + $def[$defcnt] .= "GPRINT:vtmptbldsknow:\"%3.2lf percent of temp tables were created on disk (recently)\\n\" " ; + } + } + $defcnt++; + } + if(preg_match('/^thread_cache_hitrate_now$/', $NAME[$i])) { + $ds_name[$defcnt] = "Thread cache hitrate"; + $opt[$defcnt] = "--vertical-label \"Percent\" --title \"Thread cache hitrate on $hostname\" --upper-limit 100 --lower-limit 0 "; + $def[$defcnt] = ""; + for ($ii = 1; $ii <= $ds_count; $ii++) { + if(preg_match('/^thread_cache_hitrate$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:hitrate=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "CDEF:ar=hitrate,$CRIT_MIN[$ii],LE,hitrate,0,GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "CDEF:ay=hitrate,$WARN_MIN[$ii],LE,hitrate,$CRIT_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "CDEF:ag=hitrate,100,LE,hitrate,$WARN_MIN[$ii],GT,INF,UNKN,IF,UNKN,IF,ISINF,hitrate,0,IF "; + $def[$defcnt] .= "AREA:ag#$green: " ; + $def[$defcnt] .= "AREA:ay#$yellow: " ; + $def[$defcnt] .= "AREA:ar#$red: " ; + $def[$defcnt] .= "LINE:hitrate#111111:\" \" "; + $def[$defcnt] .= "VDEF:vhitrate=hitrate,LAST " ; + $def[$defcnt] .= "GPRINT:vhitrate:\"Hitratio (since epoch) is %3.2lf percent \\n\" "; + } + if(preg_match('/^thread_cache_hitrate_now$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:hitratenow=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "LINE1.5:hitratenow#$now:\" \" "; + $def[$defcnt] .= "VDEF:vhitratenow=hitratenow,LAST " ; + $def[$defcnt] .= "GPRINT:vhitratenow:\"Hitratio (current) is %3.2lf percent \\n\" "; + } + } + $defcnt++; + $ds_name[$defcnt] = "Connects per second"; + $opt[$defcnt] = "--vertical-label \"Conects / sec\" --title \"Connects per second on $hostname\" "; + $def[$defcnt] = ""; + for ($ii = 1; $ii <= $ds_count; $ii++) { + if(preg_match('/^connections_per_sec$/', $NAME[$ii])) { + $def[$defcnt] .= "DEF:sps=$RRDFILE[$ii]:$DS[$ii]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "AREA:sps#$now:\" \" "; + $def[$defcnt] .= "VDEF:vsps=sps,LAST " ; + $def[$defcnt] .= "GPRINT:vsps:\"%3.2lf Connects per second \\n\" "; + } + } + $defcnt++; + } + if(preg_match('/^threads_connected$/', $NAME[$i])) { + $ds_name[$defcnt] = "Connection threads"; + $opt[$defcnt] = "--vertical-label \"Threads\" --title \"Connection threads on $hostname\" "; + $def[$defcnt] = ""; + $def[$defcnt] .= "DEF:threads=$RRDFILE[$i]:$DS[$i]:AVERAGE:reduce=LAST " ; + $def[$defcnt] .= "AREA:threads#111111 "; + $def[$defcnt] .= "VDEF:vthreads=threads,LAST " ; + $def[$defcnt] .= "GPRINT:vthreads:\"%.0lf Connection threads \" " ; + $defcnt++; + } +} +?> + -- cgit v1.2.3