Widget for hard drive activity

Discussion in 'Mac Programming' started by Eric L, May 2, 2008.

  1. Eric L macrumors member

    Joined:
    Jan 25, 2008
    #1
    Does anyone know where I might find a Widget that can tell me the rate that information is being passed to or from my various hard drives in real time (i.e. Mb/s)? I googled but came up empty. If not, would anyone be interested in developing one? I don't know squat about programming.
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    Does it have to be a widget?

    Do you need each drive separately or would a total of the data transfer to/from the disk subsystem work?

    Activity monitor has the latter, but it may not work for you.

    -Lee
     
  3. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #3
    Also not a widget, but MenuMeters is awesome, and it's free. Not only will it indicate hard drive activity, but can monitor memory, cpu, and networking, all in a compact space in your menu bar. I always have it installed on every Mac I use.

    EDIT: Oops, I see you need the transfer rate. Well, MenuMeters doesn't show that (just network bandwidth) but it's still awesome. Might be worth emailing the developer about, they might be able to add that option.
     
  4. Eric L thread starter macrumors member

    Joined:
    Jan 25, 2008
    #4
    I thought it would be interesting and telling to see the different connections (USB, FW, etc) and drives in action, real-time. I thought a widget would be easiest and unobtrusive.
     
  5. todd2000 macrumors 68000

    Joined:
    Nov 14, 2005
    Location:
    Danville, VA
    #5
    It's not a widget, but Activity Monitor will do this for you. It's in your Utilities folder. Just click on the Disk Activity tab on the bottom.
     
  6. mabedan macrumors newbie

    Joined:
    Jul 3, 2008
    #6
  7. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #7
    This seems to be the meat of this widget:
    Code:
    function disky(){
    	if(number!=1){
    			window.resizeTo(wid, (number*33)+46);
    		}else{
    			window.resizeTo(wid, (number*33)+47);
    		}
    	
    	line = widget.system("/bin/df -l -k", null).outputString;	
    	n=line.split("\n");
    	j=0;
    	listline=new Array();
    	max=0;
    	for(i=1;i<n.length-1;i++){
    		listline[j] = n[i].split(" ");
    		j++;
    	}
    	clistline=new Array();
    	names={};
    	capacities={};
    	percents={};
    	diskets={};
    	if(widget.preferenceForKey("indicator")=="d" && timist!=50){
    		bill = widget.system("/usr/sbin/iostat -d -c 2", tracker);	
    	}
    	for(i in listline){
    		j=0;
    		clistline[i]=new Array();
    		for(l in listline[i]){
    			if(listline[i][l]!==" " && listline[i][l]!==""){
    				clistline[i][j]=listline[i][l];
    				j++;
    			}
    		}
    		names[i]="";
    		for(j=5;j<clistline[i].length-1;j++) 
    			names[i]=names[i]+clistline[i][j].replace("/Volumes/","")+' ';
    		names[i]=names[i]+clistline[i][j].replace("/Volumes/","");
    		if(names[i]=="/")
    			names[i]='/ <span style="font-size:10px">'+getLocalizedString('root')+'</span>';
    		capacities[i]=clistline[i][1];
    		if(capacities[i]/capacities[max]>1){
    			max=i;
    		}
    		if(widget.preferenceForKey("numer")=="d")
    			avalables[i]=Math.floor(100*clistline[i][3]/(1024*1024))/100;
    		percents[i]=clistline[i][4].replace("%","");
    		if(i==0){
    			diskets[0]=parseInt(clistline[i][0].replace("/dev/disk","").split("s")[0]);
    		}else if(clistline[i][0].replace("/dev/disk","").split("s")[0]==clistline[i-1][0].replace("/dev/disk","").split("s")[0]){
    			diskets[i]=diskets[i-1];
    		}else{
    			diskets[i]=diskets[i-1]+1;
    		}
    	}
    }
    
    As far as I can tell it is wrapping df and iostat. This is a tack that the OP could take. I don't know if iostat performs privileged calls to the kernel or not in Darwin, but someone could grab the Darwin source and check out what iostat is doing to get this info, and perhaps those calls could be used in a new program.

    This may be just the thing for the OP though, i'm just mentioning this for academic reasons more than anything.

    -Lee
     

Share This Page