mostafamemariani / 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

data returned from ss_Get_by_ssh does not get put into rra file #140

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Okay I've tried now every possible solution on the planet but I'm still stuck.
I'm on CentOS 5.4 and Cacti 0.8.7e. httpd runs as user "apache".

I set up the SSH data gathering (user "cacti", ssh public key
authentication) as outlined in the documentation. I then tried the "su -
apache -c 'env -i php ....'" and it works perfectly:

=======================
[root@server htdocs-80]# su - apache -c 'env -i php -q
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php --host target.host.name --type
diskstats --items bm,bq --device sdc'

bm:918078 bq:5485784[root@server htdocs-80]#
=======================

So I actually *do* get the data. I enabled debugging in ss_get_by_ssh.php
and there the log also shows all the numbers, like here:

=======================
2010-04-16 10:28:06 at /srv/www/htdocs-80/scripts/ss_get_by_ssh.php:107
array (
  0 => '/srv/www/htdocs-80/scripts/ss_get_by_ssh.php',
  1 => '--host',
  2 => 'target.host.name',
  3 => '--type',
  4 => 'proc_stat',
  5 => '--items',
  6 => 'ag,ah,ai,aj,ak,al,am,an,ao',
)
2010-04-16 10:28:06 parse_cmdline() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:230
array (
  'host' => 'target.host.name',
  'type' => 'proc_stat',
  'items' => 'ag,ah,ai,aj,ak,al,am,an,ao',
)
2010-04-16 10:28:06 validate_options() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:163
array (
  'host' => 'target.host.name',
  'type' => 'proc_stat',
  'items' => 'ag,ah,ai,aj,ak,al,am,an,ao',
)
2010-04-16 10:28:06 ss_get_by_ssh() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:245
'Functions: \'proc_stat_cachefile\', \'proc_stat_cmdline\',
\'proc_stat_parse\''
2010-04-16 10:28:06 check_cache() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:431 <- ss_get_by_ssh() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:259
'Cache file: /tmp/target.host.name_proc_stat_cacti_stats.txt'
2010-04-16 10:28:06 check_cache() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:439 <- ss_get_by_ssh() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:259
'Using the cache file'
2010-04-16 10:28:06 ss_get_by_ssh() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:261
'The cache is usable.'
2010-04-16 10:28:06 extract_desired() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:145 <- ss_get_by_ssh() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:262
'a0:-1 a1:-1 a2:-1 a3:-1 a4:-1 a5:-1 a6:-1 a7:-1 a8:-1 a9:-1 aa:-1 ab:-1
ac:-1 ad:-1 ae:-1 af:-1 ag:396777 ah:106187 ai:900738 aj:134057181
ak:114715 al:72019 am:20667 an:0 ao:-1 ap:1302444144 aq:70498349 ar:937234
as:-1 at:-1 au:-1 av:-1 aw:-1 ax:-1 ay:-1 az:-1 b0:-1 b1:-1 b2:-1 b3:-1
b4:-1 b5:-1 b6:-1 b7:-1 b8:-1 b9:-1 ba:-1 bb:-1 bc:-1 bd:-1 be:-1 bf:-1
bg:-1 bh:-1 bi:-1 bj:-1 bk:-1 bl:-1 bm:-1 bn:-1 bo:-1 bp:-1 bq:-1 br:-1
bs:-1 bt:-1 bu:-1 bv:-1 bw:-1 bx:-1 by:-1 bz:-1 c0:-1 c1:-1 c2:-1 c3:-1
c4:-1 c5:-1 c6:-1 c7:-1 c8:-1 c9:-1 ca:-1 cb:-1 cc:-1 cd:-1 ce:-1 cf:-1
cg:-1 ch:-1 ci:-1 cj:-1 ck:-1 cl:-1 cm:-1 cn:-1 co:-1 cp:-1 cq:-1 cr:-1
cs:-1 ct:-1 cu:-1 cv:-1 cw:-1 cx:-1'
2010-04-16 10:28:06 extract_desired() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:155 <- ss_get_by_ssh() at
/srv/www/htdocs-80/scripts/ss_get_by_ssh.php:262
'ag:396777 ah:106187 ai:900738 aj:134057181 ak:114715 al:72019 am:20667
an:0 ao:-1'
2010-04-16 10:28:06 at /srv/www/htdocs-80/scripts/ss_get_by_ssh.php:112
'ag:396777 ah:106187 ai:900738 aj:134057181 ak:114715 al:72019 am:20667
an:0 ao:-1'
=======================

I tried disabling the cache files for one or two data sources but that
didn't change anything at all. the permissions on the temp cache files are
correct and they contain the correct data:

=======================
[root@server htdocs-80]# ls -l /tmp
total 1848
-rw-r--r--  1 apache apache     1856798 Apr 16 10:28 ss_get_by_ssh.log
-rw-r--r--  1 apache apache         681 Apr 16 10:28
target.host.name_diskstats_sdc_cacti_stats.txt
-rw-r--r--  1 apache apache         660 Apr 16 10:31
target.host.name_memory_cacti_stats.txt
-rw-r--r--  1 apache apache         681 Apr 16 10:31
target.host.name_proc_stat_cacti_stats.txt
-rw-r--r--  1 apache apache         636 Apr 16 10:31
target.host.name_w_cacti_stats.txt
[root@server htdocs-80]#
=======================

also, the permissions on the cacti scripts and rra files are correct:

=======================
[root@server htdocs-80]# find /srv/www/htdocs-80/ -not -user apache
[root@server htdocs-80]# find /srv/www/htdocs-80/ -not -group apache
[root@server htdocs-80]# ls -l scripts/ss_get_by_ssh.php
-rw-r--r-- 1 apache apache 43635 Apr 16 10:23 scripts/ss_get_by_ssh.php
[root@server htdocs-80]#
=======================

The data values don't hit the rra file, however:

=======================
[root@server htdocs-80]# rrdtool fetch
rra/target_host_name_stat_membuffer_155.rrd AVERAGE
                 STAT_membuffer        STAT_memused        STAT_memfree   
  STAT_memcached      STAT_memshared

1271320560: nan nan nan nan nan
1271320920: nan nan nan nan nan
....
=======================

The cacti log shows the standard "Result not valid, Partial Result: U"
message. I added a dump of the command it tries to run and the correct command:

=======================
/usr/bin/php -q /srv/www/htdocs-80/scripts/ss_get_by_ssh.php --host
target.host.name --type diskstats --items bj,bk,bn,bo --nocache 1 --device sdc
=======================

This command runs perfectly when I start it with the "su - apache -c ..."
method from the command prompt. The full output just consists os a newline
character.

I'm running out of ideas here. Maybe my PHP or HTTPD setup is somehow
broken? Or is it a problem with the template scripts?

One Idea I have: I get a "newline" first as output from ss_get_by_ssh.php,
the actual data follows in the second line. I have not found out, however,
from where this additional newline comes from. Might this be the problem?

Thanks for any help
-Michael

Original issue reported on code.google.com by michael....@gmail.com on 16 Apr 2010 at 8:43

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hm after removing my .cnf file and changing username and identity file directly 
in
the script, the stray newline at the beginning is gone. Now it works. Strange
however, why a file like

<?php
  $foo = 'bar';
  $baz = 'bof';
?>

...would result in a newline at the beginning of the output?

Original comment by michael....@gmail.com on 16 Apr 2010 at 11:36

GoogleCodeExporter commented 8 years ago
Please ask for help on the mailing list, not the bug tracker.

Original comment by baron.schwartz on 16 Apr 2010 at 2:10

GoogleCodeExporter commented 8 years ago
I have the smae problem... any fix??

Original comment by karlosn...@gmail.com on 26 May 2011 at 1:18

GoogleCodeExporter commented 8 years ago
I fixed :)

Just change: 
$nc_cmd     = 'nc -C -q1'; 
by
$nc_cmd     = 'nc -C ';

Now I have memcached graph 

Original comment by karlosn...@gmail.com on 26 May 2011 at 2:27

Attachments: