Cactid 0.86c & d changing backslashes to forward slashes

Post support questions that relate to the Windows 2003/2000/XP operating systems.

Moderators: Developers, Moderators

Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Cactid 0.86c & d changing backslashes to forward slashes

Post by Brashquido »

Hi All,

Sorry if this is a newbie question (which I have little doubt it won't be), but I am having trouble with cacti altering the syntax of the command line options given to a perl script I am trying to run. I've created my data input method, and have specified the two input fields that it needs.

Wether I run it via poller.php or cactid, the same things happens where specific characters are stripped or changed. Below is an example of the output from running cactid;
D:\cactid>cactid
CACTID: Using cactid config file [cactid.conf]
CACTID: Windows Environment, root permissions not required for ICMP Ping
CACTID: Version 0.8.6d starting
CACTID: Host[2] PING: Result UDP: Host is Alive
CACTID: Host[2] ERROR: Empty result [127.0.0.1]: 'perl D:/cacti/scripts/w32_perfmon.pl "C:PerfLogsada.csv" "/ADA-1048Processor(_Total)/Processor Time"'
CACTID: Host[2] WARNING: Result from SCRIPT not valid. Partial Result: U...
CACTID: Host[2] SCRIPT: perl D:/cacti/scripts/w32_perfmon.pl "C:PerfLogsada.csv" "/ADA-1048Processor(_Total)/Processor Time", output: U
CACTID: Execution Time: 0.6240 s, Threads: 1, Hosts: 1

D:\cactid>
If you look at line 6 that cacti is trying to execute;
perl D:/cacti/scripts/w32_perfmon.pl c:/Perflogs/cpu-usage.csv "/ADA-1048Processor(_Total)/% Processor Time"
The syntax I need Cacti to use is this;
perl D:/cacti/scripts/w32_perfmon.pl "C:\PerfLogs\ada.csv" "\\ADA-1048\Processor(_Total)\% Processor Time"
The only other options in the input fields are for regex and special type code, both of which I have no idea about. Could someone help me out with this one?
Last edited by Brashquido on Thu Jan 27, 2005 5:01 am, edited 1 time in total.
Dominic Ryan
www.iis-aid.com
Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Post by Brashquido »

Is there anything I can do to force Cacti to use backslashes? This is a bit of a brick wall for me as my script will not work without backslashes.
Dominic Ryan
www.iis-aid.com
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

I have no problems with cacti converting the \ to /. It works just fine with logging and accessing what it needs locally. As for remote computers, I use their full DNS name (i.e. mycomputer.mydomain.mywebsite.com), which does not require the netbios usage.

Might want to set up your HOSTS file with the computers you need to you can access them via the dns name instead of netbios.
Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Post by Brashquido »

Everything is being done locally on my test machine at the moment. The second argument to the command is not looking for a share or path, it is looking for a name in the specified CSV file.
perl D:/cacti/scripts/w32_perfmon.pl "C:\PerfLogs\ada.csv" "\\ADA-1048\Processor(_Total)\% Processor Time"
The first argument to this ("C:\PerfLogs\ada.csv") defines the physical location of the file. Here I am able to change the baclslashes for forward slashes without a problem. The second argument ("\\ADA-1048\Processor(_Total)\% Processor Time") is looking for this exact text string in the CSV file, which it then outputs the value of.

You are not able to alter the names of performance counters in Windows which is why for this script to work I need to be able to look for the literal string that the counter is named.
Dominic Ryan
www.iis-aid.com
Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Post by Brashquido »

Would I be right in thinking that script_server.php is where these backslashes are being stripped out and replaced?
Dominic Ryan
www.iis-aid.com
Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Post by Brashquido »

Ok, I think I am pretty much stumped :( . I'll try and clearly summarise what I'm trying to do in the hope someone can help me:

1) I have set my Windows performance monitor to log CPU usage in CSV format, updated every minute. Windows performance monitor identifies the counter name in this format;
\\<computername>\<performance object>(<counter instance>)\<counter item>
So in the case of monitoring the total CPU usage as a percentage on my machine (ADA-1048), this is what the Performance monitor name looks like;
\\ADA-1048\Processor(_Total)\% Processor Time
2) I have a small perl script that you parse the logfile location and performance monitor name to which then returns the most recent (last entry) value for that counter. This is the syntax;
w32_perfmon.pl <path to CSV log file> <full performance monitor name as in CSV log>
Running this from the command line manually in the scripts directory of my cacti install works without a problem.

3) I setup a data input method in Cacti with the Input Type of "Script/Command". I also created two input fields called <perflog> for the Performance monitor log path, and <perfcount> for the Performance monitor counter name. The input string looks like;
perl <path_cacti>/scripts/w32_perfmon.pl <perflog> <perfcount>
I also have created an output field with the "Update RRA" enabled.

4) I then created a data template, and under the custom fields section I placed;
c:\Perflogs\cpu-usage.csv
for the performance monitor logfile location value, and;
"\\ADA-1048\Processor(_Total)\% Processor Time"

for the performance monitor counter name value.

This should create a script command line of;
perl D:/cacti/scripts/w32_perfmon.pl c:\Perflogs\cpu-usage.csv "\\ADA-1048\Processor(_Total)\% Processor Time"
5) However, when cacti runs the script, according to the Cacti log file it is being executed as;
perl D:/cacti/scripts/w32_perfmon.pl c:Perflogscpu-usage.csv "/ADA-1048Processor(_Total)/% Processor Time"
From this you can see that all the backslashes have been stripped, and in a few places replaced by forward slashes.


Finally my question ;) . Why is it that Cacti strips these backslashes, and what do I have to do so that Cacti does not do it?
Dominic Ryan
www.iis-aid.com
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

It probably has something to do with its Linux compatability.

Here is the example of a perl script I use for network machines:

Code: Select all

Script: perl c:/auntie/cacti/scripts/w32_query_OperatingSystem.pl ares.zeus.mydomain.com get TotalVirtualMemorySize

1) why won't you use forward slashes for your paths? They work just fine (well at least on win2k3)

2) Since you're accessing the computer localy, why not just use localhost or 127.0.0.1 for the computer name?
Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Post by Brashquido »

I can use forward slashes for the logfile path name without a problem, it is the second argument specifying the countername that I need to be able to use back slashes for. This is because the second argument is specifying a literal string in the CSV log file to look for. If I try swaping forward slashes for back slashes then this alters the literal string my perl script is looking for, which won't exist.
Dominic Ryan
www.iis-aid.com
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Cacti does convert backslashes to forward slashes. Don't know why we did it, it had to be for a reason some time ago. Possibly a cygwin thing in Windows. I am not entirely cretain what function it's in right now. Maybe in the PM on Monday I can look into this. Time for beddie by.

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?
Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Post by Brashquido »

No worries, thanks witness. I'd be very grateful for any help you can give me :) .
Dominic Ryan
www.iis-aid.com
Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Post by Brashquido »

OK, I think I've found what is causing this, but due to the fact I'm using Turck I still seem to be stuck for a total solution.

I started again from scratch, and instead of creating data or graph templates I just created a data source for my data input method, and then created a graph from that. What I found was;

1) If I use cactid then all backslashes are converted to forward slashes.

2) If I use cmd.php mode then the backslashes remain as backslashes, and the command is executed correctly and I get my graph :D

3) However, as I use Turck everytime the poller.php is run I get errors saying Turck MMcache was unable to create shared memory area. From what I've read this is because Turck MMCache can't be run in command line mode. I tried using the -c option with php.exe to specify a different php.ini file which did not have Turck loaded which didn't work either, as it seems that php.exe is called by cacti internally twice other than what I specify in my shedueled task.

However, I am pretty confident this would work IF you were able to set cacti to use command line options for php.exe. The reason I think this is;

1) If I set the cacti poller to cmd.php, and set a scheduled task to run "php.exe x:/cacti/poller.php" then I am present with 3 warning windows saying Turck MMcache was unable to create shared memory area when the scheduled task is executed.

2) However, if I set the cacti poller to cmd.php, but set a scheduled task to run the extra command line option to specify php.exe to use an alternate php.ini file where Turck is not loaded, such as "php.exe -c x:/path/to/alternate/php.ini x:/cacti/poller.php" then I am presented with only 2 warning windows saying Turck MMcache was unable to create shared memory area when the scheduled task is executed. This meaning that when php is initially executed, the correct php.ini file with Turck not loaded is being used and I don't get a warning window. However, somewhere else along the line Cacti must execute php.exe twice more, but without the alternate php.ini file being used which is then using the default php.ini file which does have Turck loaded, causing the errors.

I have tried adding the additional command line options to the path section of the settings area in Cacti, but when I do that I am just given a waiting for poller 1/1 message which just loops.



So the crux of it is when I try and use cactid 0.8.6d (which I would prefer to use) the backslashes are converted to forward slashes, making it unusable for me, but the command is executed witout error apart from the altered syntax in my data source. When I use cmd.php mode the backslashes are not altered and the scripts are executed without a problem and data is graphed, but the use of Turck MMcache means that I am unable to execute php.exe in command line mode without specifically telling php not to load Turck through the use of an alternate php.ini file. Problem here being that cacti will not accept command line options to php.exe when called inernally from Cacti.


Any ideas?
Dominic Ryan
www.iis-aid.com
Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Post by Brashquido »

I've fixed this for now by disabling Turck MMcache in my main php.ini file. However, I would still MUCH rather be using cactid over the cmd.php method as I am going to be wanting to monitor CPU, Disk I/O and Memory usage with 1 minute averages on 30 or so Windows XP machines.

I would love to help find a fix for cactid for this......
Dominic Ryan
www.iis-aid.com
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Please copy the attached files to your cactid source directory and remake. Should correct your problem.

Please post results.

Thanks,

TheWitness
Attachments
cactid_086_host_0_noclean_string.zip
(36.73 KiB) Downloaded 182 times
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
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

If you need binary, please post as well.
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?
Brashquido
Cacti User
Posts: 99
Joined: Sat Feb 28, 2004 10:16 pm
Location: Melbourne, Australia
Contact:

Post by Brashquido »

Sorry for my Windows lameness, but I will need binary :oops: .
Dominic Ryan
www.iis-aid.com
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests