script query not reading index

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

Moderators: Developers, Moderators

Post Reply
loke
Posts: 8
Joined: Tue Jul 17, 2007 5:32 am

script query not reading index

Post by loke »

I'm trying to do a script query of zfs filesystems the script returns ( afaik ) the correct values from command line here is the xml file

Code: Select all

<query>
  <name>Get ZFS Pool Stats</name>
  <description>Queries a list of ZFS pools on a host, returning some stats.</description>
  <script_path>ruby |path_cacti|/scripts/zfs_cacti.rb</script_path>
  <arg_prepend>|host_hostname|</arg_prepend>
  <arg_index>index</arg_index>
  <arg_query>query</arg_query>
  <arg_get>get</arg_get>
  <arg_num_indexes>num_indexes</arg_num_indexes>
  <output_delimiter>:</output_delimiter>
  <index_order>zpoolName</index_order>
  <index_order_type>alphabetic</index_order_type>
  <index_title_format>|chosen_order_field|</index_title_format>
  <fields>
    <zpoolName>
      <name>zpool Name</name>
      <direction>input</direction>
      <query_name>pools</query_name>
    </zpoolName>
    <zpoolReadBytes>
      <name>zpool Read Bytes</name>
      <direction>output</direction>
      <query_name>read_bytes</query_name>
    </zpoolReadBytes>
    <zpoolReadOps>
      <name>zpool Read Operations</name>
      <direction>output</direction>
      <query_name>read_opts</query_name>
    </zpoolReadOps>
    <zpoolWriteBytes>
      <name>zpool Write Bytes</name>
      <direction>output</direction>
      <query_name>write_bps</query_name>
    </zpoolWriteBytes>
    <zpoolWriteOps>
      <name>zpool Write Operations</name>
      <direction>output</direction>
      <query_name>write_opts</query_name>
    </zpoolWriteOps>
    <zpoolUsed>
      <name>zpool Used space</name>
      <direction>output</direction>
      <query_name>used</query_name>
    </zpoolUsed>
    <zpoolAvail>
      <name>zpool Available space</name>
      <direction>output</direction>
      <query_name>avail</query_name>
    </zpoolAvail>
  </fields>
</query>
here is the command line output

ruby /usr/share/cacti/scripts/zfs_cacti.rb xxx.xxx.xxx.xxx index
migpool
ruby /usr/share/cacti/scripts/zfs_cacti.rb xxx.xxx.xxx.xxx query pools
migpool:migpool
ruby /usr/share/cacti/scripts/zfs_cacti.rb xxx.xxx.xxx.xxx query avail
migpool:2122057441607
ruby /usr/share/cacti/scripts/zfs_cacti.rb xxx.xxx.xxx.xxx get avail migpool
2155042790440


script queries are executed throu ssh with nopasswd keys

last this is the output from a verbose query in cacti
+ Running data query [12].
+ Found type = '4 '[script query].
+ Found data query XML file at '/usr/share/cacti/resource/script_queries/zfs_cacti.xml'
+ XML file parsed ok.
+ Executing script for list of indexes 'ruby /usr/share/cacti/scripts/zfs_cacti.rb xxx.xxx.xxx.xxx index'
+ Executing script query 'ruby /usr/share/cacti/scripts/zfs_cacti.rb xxx.xxx.xxx.xxx query pools'
+ Found data query XML file at '/usr/share/cacti/resource/script_queries/zfs_cacti.xml'
+ Found data query XML file at '/usr/share/cacti/resource/script_queries/zfs_cacti.xml'
+ Found data query XML file at '/usr/share/cacti/resource/script_queries/zfs_cacti.xml'
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please ake sute that /full/paths/to/everything are provided. Do NOT rely on $PATH
Reinhard
loke
Posts: 8
Joined: Tue Jul 17, 2007 5:32 am

Post by loke »

I tried unsetting the $PATH ( no path at all present ) and the script still works from console , is there anywhere inside cacti I might have missed a path , and is there a way to see the actual output of the script ?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Sure. Please call "ruby" by providing /full/path/to/ruby
The rest depends on the contents of that ruby file
Reinhard
loke
Posts: 8
Joined: Tue Jul 17, 2007 5:32 am

Post by loke »

now the index works ( turned out I need to use rubys ssh lib instead of a shell command since there were no tty )
but after getting an index and creating the graph I cant see any execution of the scripts ( made a logging function ) the permissions are the same as for all other scripts / xml files
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

You should find an entry at "System Utilities -> View Poller Cache" for that host/script after requesting a graph. Please verify
Reinhard
loke
Posts: 8
Joined: Tue Jul 17, 2007 5:32 am

Post by loke »

no poller cache for that item sorry to say :cry:
I'll attach the data template and the graph template
they are based on the unix get mounted partions template
Attachments
cacti_data_template_zfs_pool_usage.xml
(5.25 KiB) Downloaded 129 times
cacti_graph_template_zsf_disk_usage.xml
(14.13 KiB) Downloaded 140 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Those templates don't help. I have no access to such a device, so I can't test your ressources. All I can say is, that filling the poller_command table seems to fail. That's why the script is not executed by the poller
Reinhard
User avatar
TheWitness
Developer
Posts: 17004
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Run the following from the command line and post the output:

Code: Select all

<path_to_ruby> /usr/share/cacti/scripts/zfs_cacti.rb xxx.xxx.xxx.xxx index
Make sure in your XML file, "<path_to_ruby>" is it's full path.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
loke
Posts: 8
Joined: Tue Jul 17, 2007 5:32 am

Post by loke »

/usr/bin/ruby /usr/share/cacti/scripts/zfs_cacti.rb xxx.xxx.xxx.xxx index
migpool

and

<script_path>/usr/bin/ruby |path_cacti|/scripts/zfs_cacti.rb</script_path>

I noticed one odd thing , when doing a verbose query ( before creating graphs the index is found but no names show up
User avatar
TheWitness
Developer
Posts: 17004
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Well, that makes it simple. Your script is not 100% functional. Getting things working at first can be a PITA.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
loke
Posts: 8
Joined: Tue Jul 17, 2007 5:32 am

Post by loke »

+ Running data query [12].
+ Found type = '4 '[script query].
+ Found data query XML file at '/usr/share/cacti/resource/script_queries/zfs_cacti.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/usr/bin/ruby /usr/share/cacti/scripts/zfs_cacti.rb migstage1.slba.se index'
+ Executing script query '/usr/bin/ruby /usr/share/cacti/scripts/zfs_cacti.rb migstage1.slba.se query pools'
+ Found item [zpoolName=''] index: #
+ Found data query XML file at '/usr/share/cacti/resource/script_queries/zfs_cacti.xml'
+ Found data query XML file at '/usr/share/cacti/resource/script_queries/zfs_cacti.xml'
+ Found data query XML file at '/usr/share/cacti/resource/script_queries/zfs_cacti.xml'

Associated Graph Templates
this is what I get fr4om a verbose query now ( I used the http://docs.cacti.net/node/293 ) I tried both with index digits and alphabetic
now index gives
1
and query pools gives
1:migpool
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

loke wrote:+ Executing script for list of indexes '/usr/bin/ruby /usr/share/cacti/scripts/zfs_cacti.rb migstage1.slba.se index'
+ Executing script query '/usr/bin/ruby /usr/share/cacti/scripts/zfs_cacti.rb migstage1.slba.se query pools'
+ Found item [zpoolName=''] index: #
This shows, that the executed query still does not respond with the expected zpoolName.
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests