Edit - Script server...

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
Darck
Posts: 7
Joined: Tue Jan 31, 2006 4:26 am

Edit - Script server...

Post by Darck »

Hello

I want to use Cacti to graph stats of my databases tables. I think the simpliest way is to use a Data Query... so I made some perl scripts returning requested values like the "interfaces" scheme :

Code: Select all

tree.index.1 = 1
tree.index.2 = 2
tree.name.1 = name1
tree.name.2 = name2
tree.value1 = 42
tree.value2 = 54
That works well, however, as I have more than 500 tables and 7 values (index, name, reads, creates, deletes, updates), meaning that I need 3500 snmp requests... and resulting in a severe cpu load on my server. My idea was to use only one tree to return in a string all 7 values.

Code: Select all

SNMPv2-SMI::enterprises.x.2.3.4.3.1 = STRING: "1 hactdif 19 0 0 1"
SNMPv2-SMI::enterprises.x.2.3.4.3.2 = STRING: "2 hactdifd 6 0 0 1"
SNMPv2-SMI::enterprises.x.2.3.4.3.3 = STRING: "3 hadart 5 0 0 0"
SNMPv2-SMI::enterprises.x.2.3.4.3.4 = STRING: "4 hartrf 5 0 0 0"
SNMPv2-SMI::enterprises.x.2.3.4.3.5 = STRING: "5 hbr 61 0 0 44" 
SNMPv2-SMI::enterprises.x.2.3.4.3.6 = STRING: "6 hbrd 92 0 0 86" 
SNMPv2-SMI::enterprises.x.2.3.4.3.7 = STRING: "7 hbrdana 82 0 0 77" 
SNMPv2-SMI::enterprises.x.2.3.4.3.8 = STRING: "8 hbrdd 124 0 0 119"
SNMPv2-SMI::enterprises.x.2.3.4.3.9 = STRING: "9 hbrrf 30 0 0 25" 
SNMPv2-SMI::enterprises.x.2.3.4.3.10 = STRING: "10 hcmde 23 0 0 16" 
SNMPv2-SMI::enterprises.x.2.3.4.3.11 = STRING: "11 hcmded 53 0 0 45" 
SNMPv2-SMI::enterprises.x.2.3.4.3.12 = STRING: "12 hcmdedd 55 0 0 47" 
SNMPv2-SMI::enterprises.x.2.3.4.3.13 = STRING: "13 hcmderf 10 0 0 5"
SNMPv2-SMI::enterprises.x.2.3.4.3.14 = STRING: "14 hcom 41 0 0 36" 
SNMPv2-SMI::enterprises.x.2.3.4.3.15 = STRING: "15 hcriv 108 9 0 84"
("x" is my enterprise OID, that's not an error :))

With this XML file :

Code: Select all

<interface>
        <name>Tables stats</name>
        <description>Queries a host for a list of monitorable tables stats</description>
        <oid_index>.1.3.6.1.4.1.x.2.3.4.3</oid_index>
        <oid_num_indexes>.1.3.6.1.4.1.x.2.3.4.1.0</oid_num_indexes>
        <index_order>pgIndex:pgName</index_order>
        <index_order_type>numeric</index_order_type>
        <index_title_format>|chosen_order_field|</index_title_format>

        <fields>
                <pgIndex>
                        <name>Index</name>
                        <method>walk</method>
                        <source>VALUE/REGEXP:^([0-9]*) .*$</source>
                        <direction>input</direction>
                        <oid>.1.3.6.1.4.1.x.2.3.4.3</oid>
                </pgIndex>
                <pgName>
                        <name>Table name</name>
                        <method>walk</method>
                        <source>VALUE/REGEXP:^[0-9]* ([^ ]*) .*$</source>
                        <direction>input</direction>
                        <oid>.1.3.6.1.4.1.x.2.3.4.3</oid>
                </pgName>
                <pgReads>
                        <name>Reads</name>
                        <method>walk</method>
                        <source>VALUE/REGEXP:^[0-9]* [^ ]* ([0-9]*) .*$</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.4.1.x.2.3.4.3</oid>
                </pgReads>
                <pgCreates>
                        <name>Creates</name>
                        <method>walk</method>
                        <source>VALUE/REGEXP:^[0-9]* [^ ]* [0-9]* ([0-9]*) .*$</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.4.1.x.2.3.4.3</oid>
                </pgCreates>
                <pgUpdates>
                        <name>Updates</name>
                        <method>walk</method>
                        <source>VALUE/REGEXP:^[0-9]* [^ ]* [0-9]* [0-9]* ([0-9]*) .*$</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.4.1.x.2.3.4.3</oid>
                </pgUpdates>
                <pgDeletes>
                        <name>Deletes</name>
                        <method>walk</method>
                        <source>VALUE/REGEXP:^[0-9]* [^ ]* [0-9]* [0-9]* [0-9]* ([0-9]*)$</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.4.1.x.2.3.4.3</oid>
                </pgDeletes>
        </fields>
</interface>
When all values are set to "input" mode, everything "works" and Cacti shows me the right values.

My query verbose is normal :

Code: Select all

+ Running data query [17].
+ Found type = '3' [snmp query].
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress_vif5_7.xml'
+ XML file parsed ok.
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.4.1.x.2.3.4.3'
+ Located input field 'pgIndex' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.4.1.x.2.3.4.3'
+ Found item [pgIndex='1'] index: 1 [from regexp value parse]
etc...
pgName is ok, and next values too if I use a full input mode.

Code: Select all

+ Located input field 'pgName' [walk]
+ Executing SNMP walk for data @ '.1.3.6.1.4.1.x.2.3.4.3'
+ Found item [pgName='hactdif'] index: 1 [from regexp value parse]
etc...
I get more and more of those, even after cleaning sources/rrd/etc... :

Code: Select all

+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/progress.xml'
When polling, the debug mode return me these rrd call :

Code: Select all

01/31/2006 10:37:31 AM - POLLER: Poller[0] CACTI2RRD: /usr/local/rrdtool-1.2.12/bin/rrdtool update /var/www/html/cacti/r
ra/qualite_pgreads_302.rrd --template pgDeletes:pgUpdates:pgCreates:pgReads 1138700246:U:U:U:U
01/31/2006 10:37:31 AM - POLLER: Poller[0] CACTI2RRD: /usr/local/rrdtool-1.2.12/bin/rrdtool update /var/www/html/cacti/r
ra/qualite_pgreads_307.rrd --template pgDeletes:pgUpdates:pgCreates:pgReads 1138700246:U:U:U:U
01/31/2006 10:37:31 AM - POLLER: Poller[0] CACTI2RRD: /usr/local/rrdtool-1.2.12/bin/rrdtool update /var/www/html/cacti/r
ra/qualite_pgreads_306.rrd --template pgReads:pgDeletes:pgUpdates:pgCreates 1138700246:U:U:U:U
01/31/2006 10:37:31 AM - POLLER: Poller[0] CACTI2RRD: /usr/local/rrdtool-1.2.12/bin/rrdtool update /var/www/html/cacti/r
ra/qualite_pgreads_305.rrd --template pgDeletes:pgUpdates:pgCreates:pgReads 1138700246:U:U:U:U
01/31/2006 10:37:31 AM - POLLER: Poller[0] CACTI2RRD: /usr/local/rrdtool-1.2.12/bin/rrdtool update /var/www/html/cacti/r
ra/qualite_pgreads_304.rrd --template pgDeletes:pgUpdates:pgCreates:pgReads 1138700246:U:U:U:U
Should I deduce that using VALUE/REGEXP is impossible on output values, like written in an old topic (but fixed oO).

I use :
Cacti : 0.8.6h
PHP : 5.0.4
MySQL : 4.1.16

And now I must use cmd.php due to this timeout error with cactid (0.8.6g) :

Code: Select all

CACTID: Host[7] DS[299] WARNING: SNMP timeout detected [500 ms], ignoring host 'qualite'
And when I set timeout to 1 or 2s and try again cactid :

Code: Select all

*** buffer overflow detected ***: /usr/bin/cactid terminated
======= Backtrace: =========
/lib/libc.so.6(__chk_fail+0x41)[0x3c9c45]
/lib/libc.so.6(__vsprintf_chk+0x0)[0x3c9510]
/lib/libc.so.6(_IO_default_xsputn+0x97)[0x34c858]
/lib/libc.so.6(_IO_vfprintf+0x363f)[0x32a141]
/lib/libc.so.6(__vsprintf_chk+0xa1)[0x3c95b1]
/usr/bin/cactid[0x804bb6b]
/usr/bin/cactid[0x804a00b]
/usr/bin/cactid[0x804fab4]
/usr/bin/cactid[0x80502f5]
/lib/libpthread.so.0[0x45eb80]
/lib/libc.so.6(__clone+0x5e)[0x3b69ce]
I think I need a miracle to solve my problemes... :'(

Thanks.
Last edited by Darck on Wed Feb 01, 2006 5:02 pm, edited 1 time in total.
Darck
Posts: 7
Joined: Tue Jan 31, 2006 4:26 am

Post by Darck »

I have recompiled cactid.

Code: Select all

CACTID: Host[7] DS[305] SNMP: v1: qualite, dsname: pgDeletes, oid: .1.3.6.1.4.1.10596.2.3.4.3.8, value: 8 hbrdd 124 0 0 119
CACTID: Host[7] DS[305] SNMP: v1: qualite, dsname: pgReads, oid: .1.3.6.1.4.1.10596.2.3.4.3.8, value: 8 hbrdd 124 0 0 119
CACTID: Host[7] DS[305] SNMP: v1: qualite, dsname: pgCreates, oid: .1.3.6.1.4.1.10596.2.3.4.3.8, value: 8 hbrdd 124 0 0 119
CACTID: Host[7] DS[305] SNMP: v1: qualite, dsname: pgUpdates, oid: .1.3.6.1.4.1.10596.2.3.4.3.8, value: 8 hbrdd 124 0 0 119
CACTID: Host[7] DS[306] SNMP: v1: qualite, dsname: pgReads, oid: .1.3.6.1.4.1.10596.2.3.4.3.9, value: 9 hbrrf 30 0 0 25
CACTID: Host[7] DS[306] SNMP: v1: qualite, dsname: pgCreates, oid: .1.3.6.1.4.1.10596.2.3.4.3.9, value: 9 hbrrf 30 0 0 25
CACTID: Host[7] DS[306] SNMP: v1: qualite, dsname: pgUpdates, oid: .1.3.6.1.4.1.10596.2.3.4.3.9, value: 9 hbrrf 30 0 0 25
CACTID: Host[7] DS[306] SNMP: v1: qualite, dsname: pgDeletes, oid: .1.3.6.1.4.1.10596.2.3.4.3.9, value: 9 hbrrf 30 0 0 25
...


edit :

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1263121488 (LWP 16457)]
0x0804b57a in cacti_log (format=Cannot access memory at address 0x73755f7d
) at util.c:605
605     }
(gdb) bt
#0  0x0804b57a in cacti_log (format=Cannot access memory at address 0x73755f7d
) at util.c:605
Cannot access memory at address 0x73755f75
When using the highest debug level.

edit² :
http://bugs.cacti.net/view.php?id=444

Ok, so that's not done :|
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

That bug your reference.... More like a feature request, will not exist in 0.8.6 code, we are implementing it in 0.9.0.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
Darck
Posts: 7
Joined: Tue Jan 31, 2006 4:26 am

Post by Darck »

So, could it be possible to do that without killing my cpu with net-snmp and staying on an indexed method ?

I think about a Data Query parsed like a Data Input Method (list of "index:1 name:the_name var1:value1 var2:value2")... Or a table commit ? I don't know what to use for collecting so much data.
Darck
Posts: 7
Joined: Tue Jan 31, 2006 4:26 am

Post by Darck »

I've switched to a script server method, retrieving the stat file on my graph server to parse it localy. Everything seemed working, however some strange things occur :

On the graph creating page, lines are not highlighted in yellow instead others... but they can be created. The second problem is that Cacti doesn't disable already created graph...

Another problem when retrieving data : when polling cacti tell me that some value are "U" whereas they are valid... (when tested with script_server.php and with php) :

Code: Select all

02/01/2006 05:42:19 PM - POLLER: Poller[0] CACTI2RRD: /usr/local/rrdtool-1.2.12/bin/rrdtool update /var/www/html/cacti/rra/qualite_pgupdates_334.rrd --template pgReads:pgCreates:pgDeletes:pgUpdates 1138812136:0:U:0:U

02/01/2006 05:42:19 PM - POLLER: Poller[0] CACTI2RRD: /usr/local/rrdtool-1.2.12/bin/rrdtool update /var/www/html/cacti/rra/qualite_pgupdates_336.rrd --template pgCreates:pgDeletes:pgUpdates:pgReads 1138812136:0:U:19039:U
pgReads and pgDeletes was at 0, like pgCreates, but Cacti said "U" for them... why ?

Never happend on the same variable :

Code: Select all

02/01/2006 05:46:46 PM - PHPSVR: Poller[0] SERVER: /var/www/html/cacti/scripts/ss_progress.php ss_progress qualite 7 1:161:20000:public:::MD5::[None] get reads zuserf output U
So I put a small spy in my php script to check returned values :

Code: Select all

Start : qualite, 7, get, reads, zuser
  Retrieving data file...
  Data : 6532

Start : qualite, 7, get, reads, zuserf
  Data : 19039

Start : qualite, 7, get, updates, zuserf
  Data : 0

Start : qualite, 7, get, deletes, zuserf
  Data : 0

Start : qualite, 7, get, creates, zuserf
  Data : 0

Start : qualite, 7, get, updates, zusco
  Data : 0

Start : qualite, 7, get, deletes, zusco
  Data : 74

Start : qualite, 7, get, creates, zusco
  Data : 75

Start : qualite, 7, get, reads, zusco
  Data : 2642

Start : qualite, 7, get, updates, zuser
  Data : 0

Start : qualite, 7, get, deletes, zuser
  Data : 0

Start : qualite, 7, get, creates, zuser
  Data : 0
That seems good... so I don't understand. Even restarting the cacti configuration from scratch doesn't solve these bugs.
Darck
Posts: 7
Joined: Tue Jan 31, 2006 4:26 am

Post by Darck »

I've found why I've no highlight on selected lines, and why Cacti can't find if an entry is already graphed...

That due to the fact I've more than 500 entries in my data query... let's go searching in php files to find if it can be fixed :|


Edit: The bug appears right after 96 entries...

Edit²: Ok, that's the "Maximum JavaScript Rows" options... you should show that a graph is already graphed even when we have more rows than that option.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest