how to calculate overall network load and cpu performance of a client?
hi all,
i wrote a script which sends the server,files from /proc/ like dev,netstat,loadavg etc of a client. i want to calculate the network load and the overall cpu performance of the client using the information from the files.I donot know how to calculate that as i have too many values in those. Can anyone please tell me which values will be useful and how to calculate?? |
Delete My account
|
thanks for the links. i used Top for getting cpu info, memory , network load etc..but i need a formula to calculate the overall performance of a system considering all the above values.i dont know how to generate such a formula, as each of the above fields are different from each other. i have pasted my code below. pls help.
#include<stdio.h> #include<ctype.h> void main( void ) { int i,j,flag=0; float num1,num2,no1,no2; char line[128]="/0",out[120]="/0",out1[120]="/0",out2[120]="/0",out3[120]="/0",out4[120]="/0",out5[120]="/0"; char s,avg1[10]; system("top -n 1 -b > output.txt"); //Execution of 'top' function to retreive the files. static const char filename[] = "/home/teena/Main_project/output.txt"; FILE *file = fopen ( filename, "r" ); if ( file != NULL ) { while(s!=EOF) { if(flag==0) //To retrieve the load average value. { line[0]=s; i=1; do { line[i]=fgetc(file); i++; }while( (line[i-1]!=' ')&&(line[i-1]!='\n')); if((line[0]=='a')&&(line[1]=='v')&&(line[2]=='e')&&(line[3]=='r')&&(line[4]=='a')&&(line[5]=='g')&&(line[6]=='e')&&(line[7]==':')) { flag=1; i=0; while((s=fgetc(file))!=',') { out[i]=s; i++; } } no1 = (((out[0]-48)*1)+((out[2]-48)*0.1)+((out[3]-48)*0.01)); } if(flag==1) //To retreive the total number of tasks. { line[0]=s; i=1; do { line[i]=fgetc(file); i++; }while( (line[i-1]!=' ')&&(line[i-1]!='\n')); if((line[0]=='T')&&(line[1]=='a')&&(line[2]=='s')&&(line[3]=='k')&&(line[4]=='s')&&(line[5]==':')) { flag=2; i=0; while((s=fgetc(file))!='t') { out1[i]=s; i++; } j=i-1; } } if(flag==2) //To retrieve the total number of running tasks. { line[0]=s; i=1; j=0; do { line[i]=fgetc(file); if(isdigit(line[i])) { flag=3; out2[j]=line[i]; j++; } i++; }while((line[i-1])!='r'); out2[j]='\0'; } if(flag==3) //To calculate the current total CPU Utilisation. { line[0]=s; i=1; j=0; do { line[i]=fgetc(file); i++; }while((line[i-1])!='('); do { line[i]=fgetc(file); i++; }while((line[i-1])!='n'); do { line[i]=fgetc(file); if((isdigit(line[i]))||(line[i]=='.')) { flag=4; out3[j]=line[i]; j++; } i++; }while((line[i-1])!='%'); out3[j]='\0'; num1 = (((out3[0]-48)*10)+((out3[1]-48)*1)+((out3[3]-48)*0.1)); num2 =(100-num1); } if(flag==4) //To retrieve the total amount of RAM available. { line[0]=s; i=1; j=0; do { line[i]=fgetc(file); i++; }while((line[i-1])!=':'); do { line[i]=fgetc(file); if(isdigit(line[i])) { flag=5; out4[j]=line[i]; j++; } i++; }while((line[i-1])!='t'); out4[j]='\0'; } if(flag==5) //To retrieve the amount of used RAM. { line[0]=s; i=1; j=0; do { line[i]=fgetc(file); if(isdigit(line[i])) { flag=6; out5[j]=line[i]; j++; } i++; }while((line[i-1])!='u'); out5[j]='\0'; } s=fgetc(file); } //printf("%c",out); printf("\n\nProcesses running averaged over the last 1 minute: %f\n\n",no1); printf("Total no. of tasks given to the system: %s\n\n",out1); printf("Total no. of currently running tasks: %s\n\n",out2); printf("Current Total CPU Utilisation: %f %\n\n",num2); printf("Total RAM memory: %sk\n\n",out4); printf("Used RAM memory: %sk\n\n",out5); fclose ( file ); } return 0; } |
All times are GMT -5. The time now is 01:16 PM. |