smtc0097 / mysql-cacti-templates

Automatically exported from code.google.com/p/mysql-cacti-templates
GNU General Public License v2.0
0 stars 0 forks source link

Apache test gets only localhost stats when use_ssh is false #199

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
n my environment, apache status pages are open across our internal network, so 
using ssh is not needed.  I have configured the ss_get_by_ssh to not use ssh.  
I found an issue getting apache stats with this though.

If I test the stats like this, I actually get the stats of the cacti server, 
not the host being queried:

php -q /www/cacti/scripts/ss_get_by_ssh.php --host HOST --type apache --items 
a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af

If I run like this, though, I get the correct results:

php -q www/cacti/scripts/ss_get_by_ssh.php --host localhost --server HOST 
--type apache --items a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af

Digging through the script a bit, I found what I believe to be the issue:

function apache_cmdline ( $options ) {
   global $status_server, $status_url, $http_user, $http_pass, $http_port;
   $srv = isset($options['server']) ? $options['server'] : $status_server;
<SNIP>
}

Changing this to the following fixes the issue, however I'm unsure if it's a 
hack or an actual fix. 

function apache_cmdline ( $options ) {
   global $status_server, $status_url, $http_user, $http_pass, $http_port;
   $srv = isset($options['host']) ? $options['host'] : $status_server;
<SNIP>
}

 Is this actually a bug, or just some kind of unplanned use case?

Original issue reported on code.google.com by w...@gunty.net on 17 Oct 2011 at 8:52

GoogleCodeExporter commented 8 years ago
This is debatably a bug -- by default when you're getting the data via SSH, you 
ssh to the $options[host] and query localhost for the status info. When you're 
not sshing, you need to query $options[host].

It's debatable because you could set the status_server config option to prevent 
this. But I think it's also fixable in the code. Your fix isn't generically 
applicable, but I will refresh my memory on the source code and see if I can 
find one that is.

Original comment by baron.schwartz on 25 Jan 2012 at 3:04

GoogleCodeExporter commented 8 years ago
This seems like the right fix to me:

function apache_cmdline ( $options ) {
   global $status_server, $status_url, $http_user, $http_pass, $http_port;
   $srv = $status_server;
   if ( isset($options['server']) ) {
      $srv = $options['server'];
   }
   elseif ( ! $options['use-ssh'] ) {
      $srv = $options['host'];
   }

I'll be fixing this in the new project.

Original comment by baron.schwartz on 25 Jan 2012 at 3:29