Server Using complete disk space and cpu usage to 100 %

Hi, I am having issue. I have written code of uploading the csv file data in mysql. But when I execute php script either locally or on server. It uses all the disk space and CPU usage to 100%. Code is written below :

include 'db.php';
$handle= fopen('file.csv',"r");
while(($csvdata=fgetcsv($handle,1000,",")) !== FALSE)
	$domain	  = $csvdata[0];
	$primary_cid  = $csvdata[1];
	$call_id = $csvdata[2];	
	$from = $csvdata[3];
	$to	 = $csvdata[4];
	$dir = $csvdata[5];
	$type = $csvdata[6];
	$start = $csvdata[7];
	$connect = $csvdata[8];
	$end	 = $csvdata[9];
	$trunk = $csvdata[10];
	$local	 = $csvdata[11];
	$remote	 = $csvdata[12];
	$recloc	 = $csvdata[13];
	$ipadr	 = $csvdata[15];
	$ivr_ext = $csvdata[17];	
	$ivr_user = $csvdata[18];

	$sql= "INSERT INTO cdr (domain,	primary_cid, call_id, source,	destination,	dir, type, start, connect, endlast, trunk, local, remote, recloc, ipadr, ivr_ext, ivr_user) VALUES ('$domain','$primary_cid','$call_id','$from','$to'	,'$dir','$type','$start','$connect','$end','$trunk','$local','$remote','$recloc','$ipadr','$ivr_ext','$ivr_user')";


$close = mysqli_close($con);
if($query && $close)
	echo "success";
	echo "error";

Is it using all the disk space, or all the disk performance?

1 Like

Yes, I think that graph shows disk Activity not used disk space.
I don’t see this as an issue, or is there some kind of problem this is causing you?

I’m not familiar with that UI, but it does look like the 100% means “as much as possible as fast as possible” (which could arguably be a good thing).

I think as long as you aren’t getting any errors like “process terminated, write incomplete” or similar there is little to worry about. If you look at other panes of the manager (eg. processes, details) do they look OK?

1 Like

You know you don’t need PHP for this, right?

You can use LOAD DATA INFILE from MySQL.

1 Like

Looks like Windows 10.

4GB is not a lot of memory for Win 10.

I’d imagine the nature of that code would increase disk activity to the maximum - it just loops around reading data from one disk file and, via a query, inserts it into another disk file. Loops like these are always disk-intensive, regardless of language.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.