Anomaly with Percona MySQL Poller

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
mmccaugh
Cacti User
Posts: 100
Joined: Mon Apr 09, 2018 1:37 pm

Anomaly with Percona MySQL Poller

Post by mmccaugh »

I am playing with the Percona MySQL template and having a perplexing issue I am having trouble fixing (Fixing the right way anyhow)

I have defined the MySQL Username and Password in the script file.

And note if I manually execute the script as below I get valid results back (As noted)

/usr/bin/php -q /var/www/html/cacti-1.1.36/scripts/ss_get_mysql_stats.php --host '10.<redacted>' --items kx,ky

kx:46745279089 ky:14653778591

When executed by Cacti however here is what is being sent :

2018/11/28 22:25:10 - POLLER: Poller[1] Device[281] DS[5260] CMD: /usr/bin/php -q /var/www/html/cacti-1.1.36/scripts/ss_get_mysql_stats.php --host '10.<redacted>' --items ku,kv,kw --user '' --pass '' --port '' --server-id '', output: ku:-1 kv:-1 kw:-1

From my old 0.8.8 server (Running an older version of the template) I see below in my logs.
11/28/2018 10:21:19 PM - CMDPHP: Poller[0] Host[549] DS[10044] CMD: /usr/bin/php -q /srv/share/sites/web/httpdocs/cacti-0.8.7g/scripts/ss_get_mysql_stats.php --host <redacted> --items im,in,io --user --pass --port , output: im:2702941 in:14927 io:37405

I have confirmed on the new server if I pass the flags as shown on the old version (Minus the single quotes) it DOES work.

/usr/bin/php -q /var/www/html/cacti-1.1.36/scripts/ss_get_mysql_stats.php --host '10.<redacted>' --items ku,kv,kw --user --pass --port --server-id

ku:37161327 kv:146538 kw:56

So the conundrum here is 'where' do I fix this? I can look at the ss_get_mysql_stats.php and try to fix it not handling the blank vs null values passed (I assume this is the difference anyway), or am I missing something in the data input method (I have been looking at it side by side for hours and can see nothing) that would instruct cacti to pass the null value when executing this method versus the single quotes?

Running Cacti Version is 1.1.36

I believe I could fix this in the Percona script, but if there is a better place to correct this I would much prefer that to changing a script (And having to remember that change in the event of a future update that re-breaks my change)
mmccaugh
Cacti User
Posts: 100
Joined: Mon Apr 09, 2018 1:37 pm

Re: Anomaly with Percona MySQL Poller

Post by mmccaugh »

OK Temp solution I have tested and am deploying for now.

A normal data input method looks like this.

Code: Select all

 <path_php_binary> -q <path_cacti>/scripts/ss_get_mysql_stats.php --host <hostname> --items gu,gv,gw --user <username> --pass <password> --port <port> --server-id <serverid>
What I have done is removed the variable tags completely as show below.

Code: Select all

<path_php_binary> -q <path_cacti>/scripts/ss_get_mysql_stats.php --host <hostname> --items nj,nk --user --pass --port --server-id 
Now the obvious down side here is that after this change I CANNOT dynamically sent unique values to these queries, and they will always use what is defined in my config file. But for me I do not think this will be a problem, at least not in the immediate term.

Trying to walk through the code I believe poller.php (Or rather an included component) is what constructs the actual php call to ss_get_mysql_stats.php so either there is a difference there causing the single quotes to be passed, or my php config has a problem, but as everything EXCEPT this script works I really don't want to go screwing with those components, when IMO the percona script really should properly interpret the blank variable and still load the static values defined in the file.

If others look at this and concur, my approach is going to be to fix the percona php file as soon as I have the free time, so it properly handles what cacti sends, but for now this solution gets me working so I can at least evaluate the graphs.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Anomaly with Percona MySQL Poller

Post by netniV »

Wait, this is a percona script? Check this out:
https://github.com/percona/percona-moni ... ns/pull/98

That was for one of the other scripts I think.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
mmccaugh
Cacti User
Posts: 100
Joined: Mon Apr 09, 2018 1:37 pm

Re: Anomaly with Percona MySQL Poller

Post by mmccaugh »

netniV wrote: Wait, this is a percona script? Check this out:
https://github.com/percona/percona-moni ... ns/pull/98

That was for one of the other scripts I think.
Son of ...

I SWEAR I combed through the Cacti Git page for issues, I didn't even think to check the Percona repo too (Though I did check their forums which are DEAD)!! Looks like you fixed the exact thing I was going to fix (As soon as I found it) though, and would concur the fault here is with the Percona script and non Cacti :)

Thanks sir! I am going to make the same fix to my code, and re-test with the original unmodified templates but I'm confident this is going to work from reading your code!
mmccaugh
Cacti User
Posts: 100
Joined: Mon Apr 09, 2018 1:37 pm

Re: Anomaly with Percona MySQL Poller

Post by mmccaugh »

/usr/bin/php -q /var/www/html/cacti-1.1.36/scripts/ss_get_mysql_stats.php --host '10.<redacted>' --items it,iu,iv,iw,iy --user --pass --port --server-id
it:17 iu:70 iv:286 iw:1 iy:151

Code: Select all

         ##Changed 11-29-2019 by MJM Deploying codefix for cacti command line issue
         ##Codefix by netniV under Git commit ba4cb8b ro percona:master
         ##if ($nextparam !== false && strpos($nextparam, '--') !==0) {
         if (!empty($nextparam) && strpos($nextparam, '--') !==0) {
            list($tmp, $value) = each($args);
         }
/usr/bin/php -q /var/www/html/cacti-1.1.36/scripts/ss_get_mysql_stats.php --host '10.<redacted>' --items it,iu,iv,iw,iy --user '' --pass '' --port '' --server-id ''
it:17 iu:70 iv:286 iw:1 iy:151
Confirming your code fix perfectly resolves the issue!

It may be worth updating the package at https://docs.cacti.net/template:package ... sql_server with the fix, as that is the "1.x.x" compatible template, and as far as I can tell it won't actually work for anyone without your fix.

Unless you're defining auth credentials in the methods, (but that just sounds awful).

Tremendous thanks as usual sir!
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Anomaly with Percona MySQL Poller

Post by netniV »

Yeah they haven't responded since I submitted that fix. Unfortunately, when I tried to find some way of contacting them to get some traction as an official member of the Cacti group, I struggled to find who what or how I should contact them. Makes me wonder if whomever was supporting it has maybe left the company or moved onto other projects and is no longer actively monitoring the situation.

It's just lucky that it was the fix I submitted so I was fully aware of it :)
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: Anomaly with Percona MySQL Poller

Post by Osiris »

I think a fork is required and a new templates repo that is not read only.
Before history, there was a paradise, now dust.
polandar
Posts: 1
Joined: Thu Jun 10, 2021 1:23 am

Re: Anomaly with Percona MySQL Poller

Post by polandar »

Hey! does percona always comes up with these complexity? As, I've been using it for my modx hosting and it never indents to create such db problems.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests