rrdtool popen

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

Moderators: Developers, Moderators

Post Reply
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

rrdtool popen

Post by dieter »

hi,
I had cacti running, no problems.
I wanted to install it on drive D and then problems came.
Now, desperately I tried to install it back to c: but get this error when turning debug mode on:

Code: Select all

Warning:  popen(c:/rrdtool/rrdtool.exe graph -  --imgformat=PNG  --start=-86400  --end=-300  --title="|host_description| - Traffic - |query_ifIP| (|query_ifDescr|)"  --rigid  --base=1000  --height=120  --width=500  --alt-autoscale-max  --lower-limit=0  --vertical-label="bits per second"  DEF:a="c\:\inetpub\wwwroot\cacti/rra/mijnepc_traffic_in_8.rrd":traffic_in:AVERAGE  DEF:b="c\:\inetpub\wwwroot\cacti/rra/mijnepc_traffic_in_8.rrd":traffic_out:AVERAGE  CDEF:cdefa=a,8,*  CDEF:cdefe=b,8,*  AREA:cdefa#00CF00:"Inbound"   GPRINT:cdefa:LAST:" Current\:%8.2lf %s"   GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %s"   GPRINT:cdefa:MAX:"Maximum\:%8.2lf %s\n"   LINE1:cdefe#002A97:"Outbound"   GPRINT:cdefe:LAST:"Current\:%8.2lf %s"   GPRINT:cdefe:AVERAGE:"Average\:%8.2lf %s"   GPRINT:cdefe:MAX:"Maximum\:%8.2lf %s"  2>&1,rb): No error in c:\inetpub\wwwroot\cacti\lib\rrd.php on line 58

Warning:  fgets(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\cacti\lib\rrd.php on line 72
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

Post by dieter »

some other errors:

Warning: exec(): Unable to fork [c:\php\php.exe -q c:\inetpub\wwwroot\cacti\scripts\query_host_cpu.php 192.168.0.134 public 1 index] in c:\inetpub\wwwroot\cacti\lib\functions.php on line 777

I have deleted the linux localhost stuff so..
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

Post by dieter »

What nice to reply to your own questions :D
I'm master in writing monologues :wink:

The problem is the permissions of IIS. I changed the account from IUSR_DIETER to \\DIETER\Admin and now it works!

Is IUSR standing for internet user? Then I understand why it didn't work... Users from the internet should'nt be able to run shell commands on my pc...
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

Post by dieter »

Is there a way to let this work with the standard IUSR_ account? My collegue is not very happy to assign an admin account to IIS.

i tried giving full controll to rrdtool.exe to everyone, iurs_ ,... and that doesn't solve the problem...
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

Post by dieter »

I want to see who the 5 top users of bandwidth are. I use a program called windump to do it. So I open a pipe with popen to windump.exe and capture the output. Since this is a never ending stream of packets I put the fread() in an endless loop. Thought my CPU would go to 100 % but this does not seem to be the case. BUT, it seems like he waits to have an amount of packets before processing them. This is bad because I want to update a database every 10 seconds.

Is there a way to have immediate processing? It must be somewhere a buffer value that can be changed I think, but i tried a PHP function but it is only for output buffering :cry:
User avatar
bulek
Cacti Pro User
Posts: 854
Joined: Mon May 20, 2002 2:07 am
Location: Poland
Contact:

Post by bulek »

Maybe this info from Windump FAQ solves your problem:
Q-10: Why WinDump hangs for some seconds while capturing? How can I avoid it?

A: The cause of the slowness is that is that gethostbyaddr(), used by Windump to resolve the host names, on Windows actually uses more than just DNS and hosts files to translate IP addresses to names: it also tries using NetBIOS-over-TCP to do the translation. The translation of an IP address to a NetBIOS name requires to send a NetBIOS Name Service Node Status Request (see section 4.2.17 of RFC 1002) to the IP address, and wait for a reply: the reply will have the machine's NetBIOS name. However, if the machine in question isn't running any NetBIOS name service code (most non-Windows boxes don't), no reply will come back. An ICMP Port Unreachable might get sent out, but that might not cause an error to get delivered to the socket on which the request was sent. Therefore, the machine trying to get the name might have to wait for the request to time out before concluding that it can't get the name for that IP address using NetBIOS. That could take a significant amount of time.

You can use the -n switch to avoid name resolution and speed-up the display process.
- Piotr
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

Post by dieter »

I already use the -n option. The problem is that if I run windump alone then I get immediate results on the screen. When i call windump in a PHP page via popen() and I capture the output then he only works with blocks of lines. He waits till enough lines and start processing then.

Thx for having looked at this piotr!
User avatar
bulek
Cacti Pro User
Posts: 854
Joined: Mon May 20, 2002 2:07 am
Location: Poland
Contact:

Post by bulek »

Ok... then let me try again. Windump uses normal I/O functions by default which buffers certain amount characters before actual writting them to the output (it's 4096 characters in Windows I guess). If you capture the output it is good idea to force Windump to turn on line buffering - as a result your application should see incoming data line by line. The option is "-l".

- Piotr
User avatar
dieter
Cacti User
Posts: 164
Joined: Fri Feb 20, 2004 3:08 pm

Post by dieter »

I have already tried -l and also doesn't work :x

But this must have something to do with PHP and popen since windump itself is displaying packets right away. Only when capturing with popen the lines come out in buffered groups.

here is the code I used:

Code: Select all

$command="c:\windump\windump.exe -n -v -l ip";
$fp = popen($command, "rb");
			$line = "";
while(5)
	{			

		$line = fgets($fp);
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests