script query not working

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

Moderators: Developers, Moderators

Post Reply
User avatar
esproul
Posts: 17
Joined: Wed Sep 14, 2005 11:50 am
Location: Baltimore, MD

script query not working

Post by esproul »

I'm trying to build a script query to get statistics of ZFS pools on Solaris 10 hosts. I have followed the howto's and the manual on creating a new data query, and as far as I can tell, it works properly from the command line, but I am having trouble getting it to work in Cacti.

Here is my XML document:

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>perl |path_cacti|/scripts/query_zfs_pools.pl</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_bps</query_name>
    </zpoolReadBytes>
    <zpoolReadOps>
      <name>zpool Read Operations</name>
      <direction>output</direction>
      <query_name>read_ops</query_name>
    </zpoolReadOps>
    <zpoolUsage>
      <name>zpool Percentage Used</name>
      <direction>output</direction>
      <query_name>usage</query_name>
    </zpoolUsage>
    <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_ops</query_name>
    </zpoolWriteOps>
  </fields>
</query>
On the command line, I can get the indexes, do queries and gets:

Code: Select all

$ perl query_zfs_pools.pl hostname index
pool1
pool2
pool3

$ perl query_zfs_pools.pl hostname query read_bps
pool1:675737
pool2:21516779
pool3:23958

$ perl query_zfs_pools.pl hostname get read_bps pool1
623411
What I don't understand is the part about associating graph templates with this query, and how exactly this query gets run when associated with a particular host.

I have graph templates for r/w bytes (read_bps and write_bps), r/w ops (read_ops/write_ops) and usage, but when I try to associate them, the data templates listed have no items in the drop-down. I am very fuzzy on exactly what this does. If I understood it better, I'm sure I'll see what I'm doing wrong.

Can anyone enlighten me?
Thanks.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

You are on course. You need to discect the Network query or the host disk query to get to the end of the tunnel. If you hunt down LVM, he has some good "how-to's" in his signature line. You must first create the data query, followed by the data template, followed then by the graph template. Then, inside of the data query, you will associate the graph templates with the data query and assign autonames for both the data sources and graphs that will be created with the templates.

Good luck,

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?
User avatar
esproul
Posts: 17
Joined: Wed Sep 14, 2005 11:50 am
Location: Baltimore, MD

Post by esproul »

TheWitness wrote:You are on course.
Heh, but the smallest breeze can blow you to a different continent. :) As it turns out, my XML file was invalid, which I discovered by looking at a verbose debug query. If you look carefully at my XML above, you'll see that my index_order tag was not properly closed. DOH!

Now I've got the right fields displayed in my "associated data templates" area, but I'm still unable to create graphs. My RRDs are not being created. I guess I need to revisit the data templates and better understand the "custom data" section for my script query (Index Type, Index Value and Output Type ID).

Thanks,
Eric
User avatar
esproul
Posts: 17
Joined: Wed Sep 14, 2005 11:50 am
Location: Baltimore, MD

Post by esproul »

Would you believe? The problem with the missing names comes down to a misspelling of "delimiter" both in the Cacti docs and in lib/data_query.php. In both places, they spell it "delimeter" which is incorrect. When I read the docs and wrote my XML, my brain must have auto-corrected. Once I "fixed" my XML, all the zpool names are found. I blogged about it out of frustration. :)

Fixing it will be tricky-- you'll have to keep the misspelling so as not to break existing XML files, but also match the correct spelling.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

That's wild. I am trying to put off a heart attack at the moment. Got to stop myself from laughing. Most IT people can't spell anyway. Can you please goto http://bugs.cacti.net and open and open a bug report under spelling. I don't know "how" we will fix it :>

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?
User avatar
esproul
Posts: 17
Joined: Wed Sep 14, 2005 11:50 am
Location: Baltimore, MD

Post by esproul »

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

Post by loke »

I'm trying to basicly do the same thing loosly based on this thread but when I do query pools ( returns poolname:poolname ) cacti doesnt seem to pick up on it :(
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please create a new thread and post more infos, e.g. screenshots. You may find some hints at the links of my signature
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest