|host| variable in script query xml definition

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

Moderators: Developers, Moderators

Post Reply
symcacti
Posts: 20
Joined: Tue Jan 24, 2006 7:50 pm

|host| variable in script query xml definition

Post by symcacti »

Hi all,

I'm trying to use script queries to find information about remote hosts. We are using a small client/server protocol rather than snmp.

Well, nothing is working and I think the problem may be due to the fact that I need the |host| variable to be in the script query .xml file. I basically copied the unix_disk.xml file and changed the script_path part like so:

Code: Select all

        <script_path>|path_cacti|/scripts/symcacti_client -s |host| -c partition_query</script_path>
Is this possible?

Thanks
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Yes, use <host> and then in the Input Fields section, Add a field, select host from the dropdown, and then put hostname in the special fields section.

Take a look at other data input methods for ideas.
symcacti
Posts: 20
Joined: Tue Jan 24, 2006 7:50 pm

Post by symcacti »

I don't really understand what you mean. I'm not using a data input method, I'm using a script data query.

I'm following http://forums.cacti.net/viewtopic.php?t=11288 , and I haven't seen an "Imput Fields" section.

Is this possible to do with (script) data queries?

[EDIT]
If I do use <host>, I get:

Code: Select all

+ Running data query [10].
+ Found type = '4 '[script query].
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Error parsing XML file into an array.
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
If I use |host| , I get the following ( note no variable substitution on |host| ):

Code: Select all

+ Running data query [10].
+ Found type = '4 '[script query].
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/var/www/html/cacti-0.8.6h/scripts/symcacti_client -s |host| -c partition_query index'
+ Executing script query '/var/www/html/cacti-0.8.6h/scripts/symcacti_client -s |host| -c partition_query query device'
+ Executing script query '/var/www/html/cacti-0.8.6h/scripts/symcacti_client -s |host| -c partition_query query mount'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
Last edited by symcacti on Tue Jan 31, 2006 1:12 pm, edited 1 time in total.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

You need to re-read the guide then. This is what I'm talking about:

Image

then
Image
symcacti
Posts: 20
Joined: Tue Jan 24, 2006 7:50 pm

Post by symcacti »

I'm not using a data input method

I thought they were distinct methods of getting data.

Am I wrong?

Image[/u]
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

In the XML file, your <arg_prepend> should contain the |host_hostname| along with other variables. Take a look at the SNMP - Get Processor Information or SNMP - Interface Statistics Data Queries for examples.
symcacti
Posts: 20
Joined: Tue Jan 24, 2006 7:50 pm

Post by symcacti »

Thank you, that did the trick. My graphs are created now, but I can't get any data. In the logs, there's this:

Code: Select all


01/31/2006 11:30:01 AM - CMDPHP: Poller[0] Host[7] PING: Host is alive
01/31/2006 11:30:03 AM - CMDPHP: Poller[0] ASSERT: '<' failed. Recaching host '10.127.9.134', data query #10

...

01/31/2006 11:30:03 AM - CMDPHP: Poller[0] Time: 2.0738 s, Theads: N/A, Hosts: 1
01/31/2006 11:30:04 AM - SYSTEM STATS: Time:3.0670 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:6 RRDsProcessed:6
01/31/2006 11:30:04 AM - PCOMMAND: Poller[0] Host[7] WARNING: Recache Event Detected for Host
01/31/2006 11:30:06 AM - RECACHE STATS: RecacheTime:2.1178 HostsRecached:1
Any thoughts on what this could be?

[edit]: verbose query gives me this:

Code: Select all

+ Running data query [10].
+ Found type = '4 '[script query].
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/var/www/html/cacti-0.8.6h/scripts/symcacti_client -c partition_query -s 10.127.9.134 index'
+ Executing script query '/var/www/html/cacti-0.8.6h/scripts/symcacti_client -c partition_query -s 10.127.9.134 query device'
+ Found item [dskDevice='/dev/root'] index: /dev/root
+ Found item [dskDevice='/dev/sda1'] index: /dev/sda1
+ Found item [dskDevice='/dev/mapper/system-var'] index: /dev/mapper/system-var
+ Found item [dskDevice='/dev/mapper/system-cache'] index: /dev/mapper/system-cache
+ Found item [dskDevice='/dev/mapper/system-restore'] index: /dev/mapper/system-restore
+ Executing script query '/var/www/html/cacti-0.8.6h/scripts/symcacti_client -c partition_query -s 10.127.9.134 query mount'
+ Found item [dskMount='/'] index: /dev/root
+ Found item [dskMount='/boot'] index: /dev/sda1
+ Found item [dskMount='/var'] index: /dev/mapper/system-var
+ Found item [dskMount='/logs'] index: /dev/mapper/system-cache
+ Found item [dskMount='/restore'] index: /dev/mapper/system-restore
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
+ Found data query XML file at '/var/www/html/cacti-0.8.6h/resource/script_queries/remote_unix_disk.xml'
symcacti
Posts: 20
Joined: Tue Jan 24, 2006 7:50 pm

Post by symcacti »

Ok, it looks like that has something to do with the re-index method for the data query associated with the host.

I set it to 'none', and 'index count changed', both work ( query_unix_disk.pl doesn't support the 'num_indexes' argument ).

I still don't get any graphs tho. The poller completely ignores my requests (see below).

_any_ suggestions as to why this isn't working?

Code: Select all

01/31/2006 01:15:01 PM - CMDPHP: Poller[0] Host[9] PING: Host is alive
01/31/2006 01:15:01 PM - CMDPHP: Poller[0] Host[9] DS[100] CMD: /var/www/html/cacti-0.8.6h/scripts/symcacti_client -s 10.127.9.134 -c event_count, output: 29571
01/31/2006 01:15:01 PM - CMDPHP: Poller[0] Host[9] DS[102] CMD: /var/www/html/cacti-0.8.6h/scripts/symcacti_client -s 10.127.9.134 -c memstats, output: ram_total:2978184 ram_used:2094124 ram_free:884060 ram_shared:0 ram_buffers:112596 ram_cached:1485064 swap_total:1982456 swap_used:0 swap_free:1982456
01/31/2006 01:15:01 PM - CMDPHP: Poller[0] Host[9] DS[97] CMD: /var/www/html/cacti-0.8.6h/scripts/symcacti_client -s 10.127.9.134 -c loadavg, output: 1min:0.02 5min:0.01 15min:0.00
01/31/2006 01:15:01 PM - CMDPHP: Poller[0] Host[9] DS[98] CMD: /var/www/html/cacti-0.8.6h/scripts/symcacti_client -s 10.127.9.134 -c memstats, output: ram_total:2978184 ram_used:2094124 ram_free:884060 ram_shared:0 ram_buffers:112596 ram_cached:1485064 swap_total:1982456 swap_used:0 swap_free:1982456
01/31/2006 01:15:02 PM - CMDPHP: Poller[0] Host[9] DS[103] CMD: /var/www/html/cacti-0.8.6h/scripts/symcacti_client -s 10.127.9.134 -c uptime, output: 52386000
01/31/2006 01:15:02 PM - CMDPHP: Poller[0] Host[9] DS[99] CMD: /var/www/html/cacti-0.8.6h/scripts/symcacti_client -s 10.127.9.134 -c memstats, output: ram_total:2978184 ram_used:2094124 ram_free:884060 ram_shared:0 ram_buffers:112596 ram_cached:1485064 swap_total:1982456 swap_used:0 swap_free:1982456
01/31/2006 01:15:02 PM - CMDPHP: Poller[0] Time: 0.0792 s, Theads: N/A, Hosts: 1
01/31/2006 01:15:02 PM - SYSTEM STATS: Time:1.1681 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:6 RRDsProcessed:6
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Check the poller cache for the path to your script. Make sure it looks right.
[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]
symcacti
Posts: 20
Joined: Tue Jan 24, 2006 7:50 pm

Post by symcacti »

Thanks for the suggestion.

The commands for the graphs are not in the poller cache at all. I cleared it, and it's still not around.

For sure tho, the num_indexes query is going through to the device.

I must have missed a step somewhere, but I can't figure out where.

any suggestions?

( the graphs and data sources are there ).

Thanks.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Is the device disabled, or has a status of down? This would cause it to not populate the poller cache.

Resolve that and rebuild the poller cache.
[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]
symcacti
Posts: 20
Joined: Tue Jan 24, 2006 7:50 pm

Post by symcacti »

Yeah, the status is 'Up', but I do get 'SNMP Error' instead of 'SNMP not in use' when I click on device->|device_i'm_using|

I have no idea why that's the case.

Could this be part of the problem?

anything else you can think of?

[edit]
I should mention that the other graphs are running o.k.-- it's just the ones that rely on this data query that aren't working
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Really, ok, in the Data Query edit screen when editing associated graph templates, there are these little check boxes off on the right hand side that don't look like they do anything in particular, in the associated data query section. CHECK THEM. :) Save the query and I bet you will be ok.
[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]
symcacti
Posts: 20
Joined: Tue Jan 24, 2006 7:50 pm

Post by symcacti »

Thanks for all your help. I think it's working now.

I think that when I was playing around with the re-index trigger, the graphs got screwed, because when I clicked on 'create graphs for this device', I could choose all of the partition graphs again. This ended up creating 2 graphs for each partition ( the old non-working and the new ones ). Any how, I deleted everything, started again, and all is well.

Now for the interface data queries ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests