Passing parameters to perl scripts

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

Moderators: Developers, Moderators

dpearcePNG
Posts: 14
Joined: Tue Jan 09, 2007 2:48 pm

Passing parameters to perl scripts

Post by dpearcePNG »

I'm trying to get a data template working so it will passing the host's IP address to a perl script.

Here is the input_string from the data template:

Code: Select all

<input_string>c:/perl/bin/wperl.exe c:/inetpub/wwwroot/cacti/scripts/netscreen_stats.pl <management_ip></input_string>
I've tried <management_ip> and <ip> and neither seems to get evaluated into the IP address.

management_ip is defined in the <fields> section:

Code: Select all

			<hash_070000645a30ad4b36e40977e118cab0b8b8ce>
				<name>ip address</name>
				<update_rra></update_rra>
				<regexp_match></regexp_match>
				<allow_nulls></allow_nulls>
				<type_code></type_code>
				<input_output>in</input_output>
				<data_name>management_ip</data_name>
			</hash_070000645a30ad4b36e40977e118cab0b8b8ce>
This is 0.8.6i on a Windows box.

Any ideas on what I am doing wrong? If I hardcode the IP address inside the perl script, it does work.

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

Post by gandalf »

Please follow my Tutorials
Reinhard
dpearcePNG
Posts: 14
Joined: Tue Jan 09, 2007 2:48 pm

Post by dpearcePNG »

I have once already, but I'm stuck. I'll look again.

Dave
An old hand at MRTG
A noob at Cacti
dpearcePNG
Posts: 14
Joined: Tue Jan 09, 2007 2:48 pm

Post by dpearcePNG »

My installation being a brand new one, I don't have the experience of seeing what is "normal". :-?

When I am looking at the View Poller Cache page, under the data sources and "Script", I see my perl script being called. Should I also see the command line parameters listed after the script?

Dave
dpearcePNG
Posts: 14
Joined: Tue Jan 09, 2007 2:48 pm

Post by dpearcePNG »

dpearcePNG wrote:When I am looking at the View Poller Cache page, under the data sources and "Script", I see my perl script being called. Should I also see the command line parameters listed after the script?
I've determined that I should be seeing the command line parameters in the cache.

I have <hostname> defined on the Data Input Methods page and have rebuilt the Poller cache with no change.

I've gone through want I think is the pertinant document and tutorials and not made any progress. Can someone at least give me a hint?

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

Post by TheWitness »

<hostname>

It's a special case of an input parameter type.
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?
dpearcePNG
Posts: 14
Joined: Tue Jan 09, 2007 2:48 pm

Post by dpearcePNG »

Well, I guess I'm the most dense person around. :cry:

I created an "Advanced Ping" Data input which uses the <hostname> tag and it works fine. I've compared the data templates between it and mine and see no problems.

I guess I need more than a hint. I deleted and recreated evertyhing and I'm getting nowhere.

Sorry to be such a pain, but no matter what Special Type Codes I put in, it doesn't show up in the poller cache. If I put something that isn't a tag in the Input String, it shows up in the poller cache. It's like it's rejecting all of the tags I use.

Thanks for you help.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please post a screenshot of yor Data Input Method
Reinhard
dpearcePNG
Posts: 14
Joined: Tue Jan 09, 2007 2:48 pm

Post by dpearcePNG »

Thanks! The complete input string is:
perl <path_cacti>/scripts/netscreen_stats.pl <ip>
From the poller cache:
Netscreen - Netscreen Stats
Script: perl c:/Inetpub/wwwroot/cacti/scripts/netscreen_stats.pl
RRD: c:\Inetpub\wwwroot\cacti\rra\netscreen_cpu1_113.rrd
Attachments
Data Input Method
Data Input Method
screen1.jpg (61.78 KiB) Viewed 2884 times
Input Field
Input Field
Screen2.jpg (47.79 KiB) Viewed 2884 times
dpearcePNG
Posts: 14
Joined: Tue Jan 09, 2007 2:48 pm

Post by dpearcePNG »

At one point, I modified the input string to be:
perl <path_cacti>/scripts/netscreen_stats.pl 1 <ip> 2
And the poller chache showed:
Script: perl c:/Inetpub/wwwroot/cacti/scripts/netscreen_stats.pl 1 2
Thanks again.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Change it from "<ip>" to "<hostname>" and see what becomes of it. Oh, and after each change of a Data Input method, you MUST repopulate your poller cache. I little subtlety that not to many people understand right way.

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?
dpearcePNG
Posts: 14
Joined: Tue Jan 09, 2007 2:48 pm

Post by dpearcePNG »

Yeah, I picked up on the poller cache refresh after a few changes. :wink:

I've tried <hostname>, <manaagement_ip> and <ip>. All produce the same thing: nothing.

:-?
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Hmm, that should not happen. I am writing thiese things more and more and they always seem to work. There were a couple of import/export bugs to be corrected in the next release, but nothing that would cuase this to break.

I guess I would have to see it for myself. If you are still online, we can do a GotoMeeting....

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?
dpearcePNG
Posts: 14
Joined: Tue Jan 09, 2007 2:48 pm

Post by dpearcePNG »

I'm sort of online. I live in Papua New Guinea (just above Australia) connectted to the internet via a VSAT connection. It's OK for chat, web and email, but the pits for anything fancy. It's way better than what we had last year though.

I agree with your "I need to see it" comment though. It's so freaky to have one data templete interpret the tags and another data templete not.

I've blown away all of the settings in the template but never started from scratch. I guess I'll do this next. At least with Cacti, swapping out the data template is realitivly easy.

News to come...
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

You could always export it and attach it here.

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?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest