Custom parameters to a script server query

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

Moderators: Developers, Moderators

Post Reply
jsemczyk
Posts: 1
Joined: Mon Mar 12, 2007 8:52 am

Custom parameters to a script server query

Post by jsemczyk »

Hi,

Any of you knows a way to give custom parameters to a query script, executed through the PHP script server, from a DataTemplate or DataQuery ?

What I mean is, I created a new data input method with some custom input fields, those fields gets created for each datasources and I wish I could get them from my script.

I tried with the xml tag <arg_prepend> inside my XML dataquery definition but it did not work. It seems I can only fetch variables from the host.

Regards,
Jon.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

<arg_prepend> is the only one I can think about. But what kind of parm do you want to pass to the script? Would the script be able to fetch the parms instead?
Reinhard
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Yes, for a regular script you can provide additional input variables, but for a Data Query you currently can not. I've needed this a few times myself and sadly don't have time at the moment to fix it.

However, there is hope. Please goto http://bugs.cacti.net and request that a feature be added to allow additional input parameters to a Data Query. No promises, but we will have the request.

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?
artagel
Cacti User
Posts: 226
Joined: Wed May 21, 2008 11:33 pm

Post by artagel »

Hi,
I'm actually trying to pass some args from my a query I have to a get call. I can't seem to do it using arg_prepend.
I want to have the arg_prepend pass |query_ifindex| |query_ifvpi| |query_ifvci|
Anyway to pass non-host args yet? The most recent post I can find on this is this one from 2002.
artagel
Cacti User
Posts: 226
Joined: Wed May 21, 2008 11:33 pm

Post by artagel »

For now I'm handling this as a sql request to the host_snmp_cache table that pulls the info I want to pass to my script...but I would prefer to handle this in the xml.
-Dan
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

artagel wrote:Hi,
I'm actually trying to pass some args from my a query I have to a get call. I can't seem to do it using arg_prepend.
I want to have the arg_prepend pass |query_ifindex| |query_ifvpi| |query_ifvci|
Anyway to pass non-host args yet? The most recent post I can find on this is this one from 2002.
So this is a Script Server Data Query? At least, all |host_*| parameters should be resolved as they are static with regard to running a script.
ifIndex should be passed by the get request, then. But if you have "multiple indexes" like "index, vpi, vci", things get worse.
We do support "multiple indexes" with SNMP Data Queries as long as they can be handles as a "single string", e.g. "OID1.OID2.OID3". In this case, we use the whole string as the index.
This may be extended to Script (Server) Data Queries. but in this case again we would not use arg_prepend in the suggested way.
R.
artagel
Cacti User
Posts: 226
Joined: Wed May 21, 2008 11:33 pm

Post by artagel »

Yes, It's a script server data query.
The problem is that my devices only have a high level PVC traffic mib that tells me in/out bytes, etc, but doesn't tell give me an index of ifindex/vpi/vci I need to properly call it in snmp.
the oid is like this: oid.ifindex.vpi.vci
The ifindex vpi and vci change every query.
All of the |host* queries work, but I was hoping to append the get with the ifindex.vpi.vci so the script server can append that to the oid when doing the cacti_snmp_get.
My solution with pulling the data from the sql server is currently working, but if my snmp_query_index changes I'd have to update that in the script.
-Dan
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

artagel wrote:Yes, It's a script server data query.
The problem is that my devices only have a high level PVC traffic mib that tells me in/out bytes, etc, but doesn't tell give me an index of ifindex/vpi/vci I need to properly call it in snmp.
the oid is like this: oid.ifindex.vpi.vci
The ifindex vpi and vci change every query.
How do you detemine the current "ifIndex.vpi.vci", then?
Is it ok to post the script to understand better?
R.
artagel
Cacti User
Posts: 226
Joined: Wed May 21, 2008 11:33 pm

Post by artagel »

I'll post it in the morning a long with the stuff for the other post.
Thanks!
-Dan
artagel
Cacti User
Posts: 226
Joined: Wed May 21, 2008 11:33 pm

Post by artagel »

Here is the script and script server xml.
-Dan
Attachments
ss_pvcpol.php.txt
(9.78 KiB) Downloaded 96 times
pvc.xml
(1.75 KiB) Downloaded 164 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Custom parameters to a script server query

Post by gandalf »

There are some new upcoming features; find them here: http://docs.cacti.net/manual:088:3a_adv ... xml_syntax
Does this help?
R.
Toddles18
Posts: 22
Joined: Fri Feb 20, 2009 1:28 pm

Re: Custom parameters to a script server query

Post by Toddles18 »

I found this trick, which doesn't require modifying any cacti code and is a simple solution http://forums.cacti.net/viewtopic.php?f=6&t=55704
Technical Support
General Information
Date Wed, 02 Mar 2016 13:35:32 -0500
Cacti Version 0.8.8f
Cacti OS win32
SNMP Version NET-SNMP version: 5.5
RRDTool Version RRDTool 1.4.x
Hosts 4
Graphs 34
Data Sources Script - Script Server (PHP): 16
Script Query - Script Server: 18
Total: 34
Poller Information
Interval 60
Type cmd.php
Items Action[2]: 72
Total: 72
Concurrent Processes 8
Max Threads 4
PHP Servers 4
Script Timeout 25
Max OID 10
Last Run Statistics Time:12.0814 Method:cmd.php Processes:8 Threads:N/A Hosts:5 HostsPerProcess:1 DataSources:72 RRDsProcessed:30
PHP Information
PHP Version 5.5.20
PHP OS WINNT
PHP uname Windows NT MIHQDBMONITOR01 6.3 build 9200 (Windows Server 2012 R2 Standard Edition) AMD64
PHP SNMP Installed
max_execution_time 60
memory_limit 512M
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests