eventlog.c revision 03831d35f7499c87d51205817c93e9a8d42c4bae
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* eventlog.c: support for the scadm loghistory option (to display the
* service processor log history)
*/
#include <libintl.h>
#include <stdio.h>
#include <string.h>
#include "librsc.h"
#include "adm.h"
#include "event_mess.h"
#define TAB '\t'
#define BACKSLASH_ESCAPE '\\'
/* #define DEBUG */
static char *
{
int category;
int event;
char **alertCategory;
char *alertMessage;
if (alertCategory) {
} else {
return (NULL);
}
if (alertMessage) {
return (alertMessage);
} else {
return (NULL);
}
}
/*
* getNextEventLogParam
*
* Return the next message from a TAB delimited message parameter list.
* Given a string message "mess1\tmess2\tmess3\t\t", this function will
* return a ponter to "mess2" the first time it is called.
*/
static char *
getNextEventLogParam(char *mess)
{
char *p = mess;
do {
/* ESCAPE means interpret the next character literally */
p++;
continue;
}
/* Double tab means end of list */
return (NULL);
}
p++;
} while (*p != TAB);
/* return pointer to char after TAB */
p++;
return (p);
}
/*
* expandEventLogMessage
*
* passed in with the TAB delimited parameters passed in via messParams.
* The expanded message will be returned in the buf character buffer.
*/
static int
char *buf)
{
char *alertMessage;
char *s;
char *d;
char *param;
/* Get Alert message from internal tables */
if (alertMessage == NULL) {
return (strlen("Unknown alert"));
}
/* No message parameters to copy */
if (messParamsLen == 0) {
}
/* A %s in the base message means we expand with a parameter */
s = alertMessage;
d = buf;
param = messParams;
do {
if ((*s == '%') && (*(s+1) == 's')) {
if (param) {
char *p = param;
while ((*p) && (*p != TAB)) {
*d++ = *p++;
}
}
/* Get next parameter on list for next %s */
s += 2;
}
} while ((*d++ = *s++));
} else {
/* If no %s tokens to expand, just copy message */
}
}
static void
{
char timebuf[32];
char messBuff[256];
char eventMsgBuf[256];
char *datap;
int i, len, entryhdrsize;
ADM_Start();
DP_GET_EVENT_LOG_R, sizeof (*rscReply));
/* Print the event log messages */
for (i = 0; i < rscReply->entry_count; i++) {
datap += entryhdrsize;
}
}
static int
{
char timebuf[32];
char messBuff[256];
char eventMsgBuf[256];
char *datap;
ADM_Start();
/*
* Start by sending a zero-length request to ALOM, so that
* we can learn the length of the console log. We expect
* ALOM to return the length of the entire log. We get
* a snapshot of the length of the log here - it may however
* continue to grow as we're reading it. We read only as
* much of the log as we get in this snapshot.
*
* If the command fails, we quietly return failure here so
*/
if (ADM_Send_ret(&Message) != 0) {
return (1);
}
DP_GET_EVENT_LOG2_R, sizeof (*rscReply));
/*
* Fetch an fixed number of events from the end of
* the log if at least that many exist, and we were not
* asked to fetch all the events.
*/
if ((all == 0) &&
} else {
}
/*
* This loop runs as long as there is data in the log, or until
* we hit the default limit (above). It's possible that ALOM may
* shrink the log - we need to account for this. If ALOM returns
* no data, we bail out.
*/
while (events_remaining) {
DP_GET_EVENT_LOG2_R, sizeof (*rscReply));
/* If ALOM returns zero events, we're done. */
if (returned_events == 0) {
break;
}
/*
* if the event at the original sequence number is no
* longer in the log, print a message
*/
}
/*
* get ready for next main loop iteration
*/
/* Print the event log messages */
for (i = 0; i < returned_events; i++) {
datap += entryhdrsize;
"%b %d %H:%M:%S",
}
}
return (0);
}
void
ADM_Process_event_log(int all)
{
if (ADM_Process_new_event_log(all) != 0) {
}
}