[Panicsel-developers] RE: About the showsel in Todo List.
Brought to you by:
arcress
|
From: Cress, A. R <and...@in...> - 2003-03-20 14:24:26
|
Guo Min,
Thanks for looking at this. This change really isn't what I meant, and that
note may have been too cryptic.
The problem with efficiency is that showsel still does a GetSelEntry() to
read every record in the SEL each time it is invoked. This can take a while
if the SEL is getting full. I think the answer will be to keep track of the
RecordID as well as the time, and (only if fwriteit) initialize the RecordID
to the saved value before starting the loop.
Having thought that far, I just made the above change for showsel 1.11.
Here is the patch that should do it.
Andy
--- showsel.c.orig Thu Mar 20 09:17:41 2003
+++ showsel.c Thu Mar 20 09:13:25 2003
@@ -30,6 +30,8 @@
* 02/18/03 Andy Cress v1.9 trim out some fields so it fits on 1 line,
* decode Boot Event subcodes
* 02/27/03 Andy Cress v1.10 change OS Crit Stop decoding to handle new
types
+ * 03/20/03 Andy Cress v1.11 for -w, save id also, so we don't have to
start
+ * over at the beginning each time.
*/
/*M*
Copyright (c) 2002, Intel Corporation
@@ -73,8 +75,8 @@
{
short record_id;
uchar record_type;
- int timestamp;
- ushort generator_id;
+ uint timestamp;
+ short generator_id;
uchar evm_rev; //event message revision
uchar sensor_type;
uchar sensor_number;
@@ -97,14 +99,15 @@
#define MIN_FREE 128 /* minimal bytes of free SEL space */
char progname[] = "showsel";
-char progver[] = "1.10";
+char progver[] = "1.11";
char idxfile[] = "/usr/share/panicsel/sel.idx";
char fdebug = 0;
char fall = 1;
char fwritesel = 0;
char fclearsel = 0;
char fonlyver = 0;
-int savtime = 0;
+uint savtime = 0;
+short savid = 0;
static const char *sensor_types[] = {
/* 00h */ "reserved",
@@ -388,35 +391,38 @@
} /* end GetSelEntry() */
-void StartWriting(int *plasttime)
+void StartWriting(uint *plasttime, short *plastid)
{
FILE *fd;
+ uint lasttime;
+ short lastid;
int ret;
+ lasttime = 0;
+ lastid = 0;
// Open the index file
fd = fopen(idxfile,"r");
- if (fd == NULL) {
- *plasttime = 0;
- } else {
- // Read the file & get savtime
- ret = fscanf(fd,"%x",&savtime);
- if (fdebug) printf("StartWriting: ret = %d, savtime = %d\n",
- ret,savtime);
- if (ret != 1) savtime = 0;
-
+ if (fd != NULL) {
+ // Read the file, get savtime & savid
+ ret = fscanf(fd,"%x %x",&lasttime,&lastid);
fclose(fd);
}
+ if (fdebug) printf("StartWriting: ret = %d, savtime = %x, savid =
%x\n",
+ ret,lasttime,(ushort)lastid);
+ *plasttime = lasttime;
+ *plastid = lastid;
// Open syslog
openlog( "SEL: ", LOG_CONS, LOG_KERN);
return;
}
-void StopWriting(int lasttime)
+void StopWriting(uint lasttime, short lastid)
{
FILE *fd;
+ // Rewrite the saved time & record id
fd = fopen(idxfile,"w");
if (fd != NULL) {
- fprintf(fd,"%x\n",lasttime);
+ fprintf(fd,"%x %x\n",lasttime,lastid);
fclose(fd);
}
// Close syslog
@@ -465,7 +471,7 @@
void ReadSEL(uchar mytype, char fwriteit)
{
- short RecordID = 0; //first record
+ short RecordID = 0; /* 0 = first record, -1 = end */
SEL_RECORD selRecord;
SEL_RECORD *pSelRecord = &selRecord;
uchar dtype;
@@ -480,7 +486,10 @@
uchar timebuf[40];
memset(pSelRecord, 0, sizeof(SEL_RECORD));
- if (fwriteit) StartWriting(&savtime);
+ if (fwriteit) {
+ StartWriting(&savtime,&savid);
+ RecordID = savid;
+ }
while( GetSelEntry( &RecordID, pSelRecord) == 0 ) {
if (mytype == 0xff || pSelRecord->sensor_type == mytype) {
/* set dtype, used as array index below */
@@ -573,8 +582,9 @@
/* Write the given SEL record to the syslog. */
syslog(LOG_INFO,output);
savtime = pSelRecord->timestamp;
+ savid = pSelRecord->record_id;
}
- }
+ } /*endif fwriteit*/
} /*endif match*/
if( pSelRecord->record_id == -1 )
break;
@@ -582,7 +592,7 @@
break;
memset(pSelRecord, 0, sizeof(SEL_RECORD));
} /*endwhile*/
- if (fwriteit) StopWriting(savtime);
+ if (fwriteit) StopWriting(savtime,savid);
} /* end ReadSEL()*/
ushort vfree;
> -----Original Message-----
> From: Guo, Min
> Sent: Tuesday, March 11, 2003 4:00 AM
> To: Cress, Andrew R
> Cc: pan...@li...
> Subject: About the showsel in Todo List.
>
> Hi ,Andy
>
> I don't understand the following TODO list clearly, I think it means
> that we should insert the new SEL record plus the last record (has been
> written to syslog last time) to syslog,if write_to_syslog,we need not go
> so many judgment code to make showsel more efficient,so that customer can
> locate the latest SEL log promptly, is that right?
>
> "make showsel scan for syslog more efficient.
> Currently reads all SEL records if normal or if write_to_syslog;
> then if write_to_syslog, write newer SEL records to syslog.
> Change: if write_to_syslog, read last SEL plus new SEL records
> only."
>
> If so ,then just apply the following patch,I have tested it on my
> langley machine.
> --------------------------------------------------------------------------
> ------------------------------
> --- panicsel/panicsel/util/showsel.c Thu Feb 27 22:15:32 2003
> +++ panicsel_new/panicsel/util/showsel.c Tue Mar 11 16:38:50 2003
> @@ -482,6 +482,7 @@
> memset(pSelRecord, 0, sizeof(SEL_RECORD));
> if (fwriteit) StartWriting(&savtime);
> while( GetSelEntry( &RecordID, pSelRecord) == 0 ) {
> + if (( fwriteit && pSelRecord->timestamp >= savtime ) ||
> !fwriteit ){
> if (mytype == 0xff || pSelRecord->sensor_type == mytype) {
> /* set dtype, used as array index below */
> if (pSelRecord->sensor_type > 0x29) dtype = 0;
> @@ -568,14 +569,13 @@
> pSelRecord->event_data3 );
> printf(output);
> if (fwriteit) {
> - /* Only write newer records */
> - if (pSelRecord->timestamp > savtime) {
> /* Write the given SEL record to the syslog.
> */
> syslog(LOG_INFO,output);
> - savtime = pSelRecord->timestamp;
> - }
> + if (pSelRecord->timestamp > savtime)
> + savtime = pSelRecord->timestamp;
> }
> } /*endif match*/
> + }
> if( pSelRecord->record_id == -1 )
> break;
> if( RecordID == pSelRecord->record_id )
> --------------------------------------------------------------------------
> ----------------
>
> Thanks
> Guo Min
> The content of this email message solely contains my own personal views,
> and not those of my employer.
>
|