Hi,
=20
I have a problem with memory Table .
My memory table is somewhat like this=20
unsigned char *
var_memoryTable(struct variable *vp,
oid *name,
size_t *length,
int exact,
size_t *var_len,
WriteMethod **write_method)
{
static long long_ret;
static int count=3D0;
FILE *f;
char *p,get_line[100][100];
int j=3D0;
if (header_simple_table(vp,name,length,exact,var_len,write_method, =
table_size)
=3D=3D MATCH_FAILED )
return NULL;
count++; /* which displays how many times the table is called */
printf("Calling Stats (%d) =
time.......................................\n", count);]
statistics(3,"4",Thresh);/* get the information about the memory and =
puts into memory_out log file */
if(f=3Dfopen("/home/admin/yamini/memory_out.log","r"))
{
while(!feof(f))
{
bzero(get_line[j],100);
fscanf(f,"%[^\n]",get_line[j++]);
(void)fgetc(f);
}
=20
table_size=3D --j ;
fflush(stdout);
fclose(f);
}
else
{
printf("unable to open the file\n");
return NULL;
}
if(table_size=3D=3D0)
{
table_size=3D1;
return NULL;
}
index =3D name[*length - 1] - 1;
split_line(get_line[index],3); /* splits the information in =
memory_out.log into word[0],word[1],....... */
/*
* this is where we do the value assignments for the mib results.
*/
switch(vp->magic) {
case MEMINDEX:
long_ret =3D index+1;
return (unsigned char *) &long_ret;
case MEMNAME:
strcpy(memName,word[0]);
case MEMUSED:
strcpy(memUsed,word[1]);
*var_len=3Dstrlen(memUsed);
return (unsigned char *) memUsed;
case MEMFREE:
strcpy(memFree,word[2]);
*var_len=3Dstrlen(memFree);
return (unsigned char *) memFree;
default:
ERROR_MSG("");
}
return NULL;
}
In the memory_out.log i have data which is=20
Mem:|118216K|7844K|
Swap:|0K|530104K|
Even thought there are 2 rows ,the table is called 44 times.
The problem is this table is called several times nearly (44 times) =
whereas other tables like programTable=20
which is similar to the above is called only the no of times the data =
present in the table.
I am also giving the progTable,the progtable table takes data from =
prog.log which is as follows
investigator|/home/admin/girscrap/|0|2002-09-09 17:48:06
messenger|/home/admin/girscrap|0|2002-09-09 17:48:12
analyser|/home/admin/girscrap|0|2002-09-09 17:48:15
filter|/home/admin/|0|2002-09-09 17:48:18
hingi|/home/admin/girscrap|0|2002-09-09 17:55:3
unsigned char *
var_progTable(struct variable *vp,
oid *name,
size_t *length,
int exact,
size_t *var_len,
WriteMethod **write_method)
{
/* variables we may use later */
static long long_ret;
int k=3D0;
static int count=3D0;
count++;
printf("the count is ....................(%d)....\n",count);
if (header_simple_table(vp,name,length,exact,var_len,write_method, =
table_size)
=3D=3D MATCH_FAILED )
return NULL;
bzero(filename,100);
if(strcmp(appName,"all")!=3D0)
{
strcpy(filename,appName);
strcat(filename,"_program.log");
k=3Dfile_read(filename);
if(k=3D=3D1)
return NULL;
}
else
{
strcpy(filename,"_program.log");
k=3Dfile_read_all(filename);
if(k=3D=3D1)
return NULL;
if(table_size=3D=3D0)
{
table_size=3D1;
return NULL;
}
// Extracting the values from the table
index =3D name[*length - 1] - 1;
printf("the index is ...................(%d)......\n",index);
split_line(line[index],4);
/*
/*
* this is where we do the value assignments for the mib results.
*/
switch(vp->magic) {
case PROGINDEX:
long_ret =3D index+1;
return (unsigned char *) &long_ret;
case PROGNAME:
strcpy(progName,word[0]);
*var_len =3Dstrlen(progName);
return (unsigned char *) progName;
case PROGPATH:=20
strcpy(progPath,word[1]);
*var_len =3D strlen(progPath);
return (unsigned char *) progPath;
case PROGSTATUS:
progStatus=3Datoi(word[2]);
return (unsigned char *) &progStatus;
case PROGTIMESTAMP:
strcpy(progTimestamp,word[3]);
*var_len =3Dstrlen(progTimestamp);
return (unsigned char *) progTimestamp;
default:
ERROR_MSG("");
}
return NULL;
}=20
Kindly rectify my problem i have been trying for this since a long time =
and was not able to rectify ,so i thought u would be the best person to =
ask.
Please also tell me what is the work of index=3D name[*length - 1] - 1;
Waiting for your reply
=20
Girish Pai
Cellcloud Technologies
|