|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T o
Length: 10559 (0x293f)
Types: TextFile
Names: »osilog.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z«
└─⟦d846658bd⟧
└─⟦this⟧ »osimis/smap/osilog.c«
/*
* Copyright (c) 1988 University College London
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the Department of Computer Science, University College London.
* The name of the University may not be used to
* endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* Event logger (osilog) main program */
/*
* By George Pavlou, October 1988
*/
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include "isode/psap.h"
#include "isode/rosap.h"
#include "msap.h"
#include "objectS.h"
#include "report.h"
#include "config.h"
#include "defs.h"
char *progname = "osilog";
int terminate(), setpoll(); /* signal handlers */
T_EntityInvocationS *parseTEntityInvocation();
T_ConnectionEndpointS *parseTConnectionEndpoint();
extern int errno;
int msd[MAXHOSTS]; /* management connection fds */
int logtype;
int mask, nfds;
int poll;
char host[HOSTLEN+1]; /* local host name */
char *hosts[MAXHOSTS]; /* hosts where SMAs run */
int NofHosts; /* how many */
T_EntityInvocationS *Einv;
/* MAIN */
main (argc, argv)
int argc;
char **argv;
{
isodesetailor("./smaptailor");
if (getconfig(hosts, &NofHosts) == NOTOK)
advise(NULLCP, "Warning: failed to read configuration file");
if ((logtype = parse_args(argc, argv)) == NOTOK)
error(NULLCP, "host %s not supported", host);
if (logtype == HOST) /* open management connections */
initialise_host(host, msd);
else /* ALL */
initialise_all(hosts, msd);
log_listen(logtype, msd); /* listen for event reports... */
terminate(OK);
}
static initialise_host (host, msd)
char *host;
int msd[];
{
int i = host2indx(host, hosts, NofHosts);
fprintf(stdout, "connecting to the SMA...\n");
if ((msd[i] = m_init(host)) == NOTOK)
error(NULLCP, "can't get connection to %s\n", host);
mask |= 1 << msd[i];
nfds = msd[i] + 1;
/* set reports: TEinvReport, rcid 2, TCeptReport, rcid 3 */
if (ReportSetRequest(TEINV_REP, m_addValue, msd[i]) == NOTOK ||
ReportSetRequest(TCEPT_REP, m_addValue, msd[i]) == NOTOK) {
m_term(msd[i]);
error(NULLCP, "ReportSetRequest failed");
}
}
static initialise_all (hosts, msd)
char *hosts[];
int msd[];
{
int i, now;
char *evtime;
time(&now);
evtime = ctime(&now) + 11;
*(evtime+8) = '\0';
fprintf(stderr, "%s : ECP started - connecting to the SMAs...\n", evtime);
for (i = 0; i < NofHosts; i++) {
if ((msd[i] = m_init(hosts[i])) == NOTOK) {
fprintf(stderr, "can't get connection to %s\n", hosts[i]);
continue;
}
fprintf(stderr, "connected to %s\n", hosts[i]);
mask |= 1 << msd[i];
if (nfds < msd[i] + 1)
nfds = msd[i] + 1;
/* set reports: TEinvReport, rcid 2, TCeptReport, rcid 3 */
if (ReportSetRequest(TEINV_REP, m_addValue, msd[i]) == NOTOK ||
ReportSetRequest(TCEPT_REP, m_addValue, msd[i]) == NOTOK) {
close_connections(msd, NofHosts);
error(NULLCP, "ReportSetRequest failed");
}
}
}
static terminate (sig)
int sig;
{
char *evtime;
int now;
if (sig != NOTOK) {
unset_reports(msd);
close_connections(msd, NofHosts);
}
time(&now);
evtime = ctime(&now) + 11;
*(evtime+8) = '\0';
fprintf(stderr, "%s : %s exits after signal # %d\n",
progname, evtime, sig);
fflush(stdout);
fflush(stderr);
exit(sig);
}
static unset_reports (msd)
int msd[];
{
int i;
for (i = 0; i < NofHosts; i++)
if (msd[i] > 0) {
ReportSetRequest(TCEPT_REP, m_removeValue, msd[i]);
ReportSetRequest(TEINV_REP, m_removeValue, msd[i]);
}
}
static log_listen (logtype, msd)
int logtype, msd[];
{
struct MSAPindication mis;
int ifds, i;
signal (SIGHUP, terminate);
signal (SIGINT, terminate);
signal (SIGQUIT, terminate);
signal (SIGTERM, terminate);
signal (SIGALRM, setpoll);
if (logtype == ALL)
alarm(WAIT);
fprintf(stderr, "listening for reports...\n");
fflush(stderr);
/* check management connections */
for (EVER) {
if (poll)
do_poll(msd);
ifds = mask;
switch (xselect(nfds, &ifds, NULLIP, NULLIP, 1)) {
case OK:
continue;
case NOTOK:
if (errno != EINTR) {
advise(NULLCP, "xselect failed");
terminate(NOTOK);
}
continue; /* select interrupted by signal */
default:
break;
}
for (i = 0; i < NofHosts; i++)
if (msd[i] > 0 && ifds & (1 << msd[i])) {
if (M_WaitReq(msd[i], NOTOK, &mis) == NOTOK) {
char *evtime; int now;
if (nfds == msd[i] + 1)
nfds--;
mask &= ~(1 << msd[i]);
msd[i] = -1;
time(&now);
evtime = ctime(&now) + 11;
*(evtime+8) = '\0';
fprintf(stderr, "%s : lost connection to %s\n",
evtime, hosts[i]);
fflush(stderr);
continue;
}
switch (mis.mi_type) {
case MI_EVENT_REP:
process_evreport(&mis.mi_eventrepv, i);
break;
default:
advise(NULLCP, "unknown mi_type = %d", mis.mi_type);
continue;
}
mifree(&mis);
}
}
}
static int process_evreport (EventReport, sysid)
struct MSAPeventrepv *EventReport;
int sysid;
{
struct event_rep_arg *eventrep = &EventReport->args;
OID evtype = eventrep->ea_type.mid_global;
MO_ID * inst;
DN dn;
int event, pid, fd = 0;
long now;
ManagedObjectS mobj;
char *evtime, *tim, *utct2disptime(), *secs2disptime();
dn_decode(eventrep->ea_inst.mn_dn);
inst = dn2moid(eventrep->ea_inst.mn_dn);
if (oid_cmp(eventrep->ea_class.mid_global, str2oid("2.37.1.4")) == 0) {
if (oid_cmp(evtype, str2oid("2.37.2.3")) == 0)
event = CRFAILIN_THLD_EVENT;
else
if (oid_cmp(evtype, str2oid("2.37.2.4")) == 0)
event = CRFAILOUT_THLD_EVENT;
else
if (oid_cmp(evtype, str2oid("2.37.2.5")) == 0)
event = CRCONGST_THLD_EVENT;
else
if (oid_cmp(evtype, str2oid("2.37.2.6")) == 0)
event = CRCONFERR_THLD_EVENT;
else
if (oid_cmp(evtype, str2oid("2.37.2.7")) == 0)
event = CRPROTERR_THLD_EVENT;
else
if (oid_cmp(evtype, str2oid("2.37.2.8")) == 0)
event = CKSUMERR_THLD_EVENT;
else
return OK; /* ignore TEinvCreation and Shutdown events */
if (objinst2id(inst, T_EINV, NULLIP, &pid) == NOTOK) {
advise(NULLCP, "process_evrep_host: bad obj_inst");
return NOTOK;
}
if (parse_Report_TEinvReport(eventrep->ea_info,
1, NULLIP, NULLVP, &mobj.einv)
== NOTOK) {
advise(NULLCP, "parse_Report_TEinvReport failed");
return NOTOK;
}
}
else
if (oid_cmp(eventrep->ea_class.mid_global, str2oid("2.37.1.5")) == 0) {
if (oid_cmp(evtype, str2oid("2.37.2.14")) == 0)
event = TCEPT_CREATION_EVENT;
else
if (oid_cmp(evtype, str2oid("2.37.2.15")) == 0)
event = TCEPT_SHUTDOWN_EVENT;
else
return OK; /* ignore TCept PDU Thld Events */
if (objinst2id(inst, T_CEPT, NULLIP, &pid, &fd) == NOTOK) {
advise(NULLCP, "process_evreport: bad obj_inst");
return NOTOK;
}
if (parse_Report_TCeptReport(eventrep->ea_info,
1, NULLIP, NULLVP, &mobj.cept) == NOTOK) {
advise(NULLCP, "parse_Report_TCeptReport failed");
return NOTOK;
}
}
moid_free(inst);
time(&now);
evtime = ctime(&now) + 11;
*(evtime+8) = '\0';
tim = utct2disptime(str2utct(eventrep->ea_time, 12));
tim = tim+7;
*(tim+8) = '\0';
switch (event) {
case TCEPT_CREATION_EVENT:
{ char *cept2rhost(), *tprot2str();
fprintf(stdout, "%s %s CeptCreation id= %d %d EvTime= %s\n\
rhost= %s prot= %s\n\n",
hosts[sysid], evtime, pid, fd, tim,
cept2rhost(mobj.cept, hosts[sysid]),
tprot2str(mobj.cept->tProtocol));
free(mobj.cept);
}
break;
case TCEPT_SHUTDOWN_EVENT:
fprintf(stdout, "%s %s CeptShutdown id= %d %d EvTime= %s\n\
Ps= %d Pr= %d Prs= %d Bs= %d Br= %d Brs= %d\n\n",
hosts[sysid], evtime, pid, fd, tim,
mobj.cept->numberTPDUSent,
mobj.cept->numberTPDUReceived,
mobj.cept->numberTPDURetransmitted,
mobj.cept->numberBytesSent,
mobj.cept->numberBytesReceived,
mobj.cept->numberBytesRetransmitted);
free(mobj.cept);
break;
case CRFAILIN_THLD_EVENT:
fprintf(stdout, "%s %s CrFailIn id= %d %d EvTime= %s\n\n",
hosts[sysid], evtime, pid, fd, eventrep->ea_time);
free(Einv);
break;
case CRFAILOUT_THLD_EVENT:
fprintf(stdout, "%s %s CrFailOut id= %d %d EvTime= %s\n\n",
hosts[sysid], evtime, pid, fd, eventrep->ea_time);
free(Einv);
break;
case CRCONGST_THLD_EVENT:
fprintf(stdout, "%s %s CrCongst id= %d %d EvTime= %s\n\n",
hosts[sysid], evtime, pid, fd, eventrep->ea_time);
free(Einv);
break;
case CRCONFERR_THLD_EVENT:
fprintf(stdout, "%s %s CrConfErr id= %d %d EvTime= %s\n\n",
hosts[sysid], evtime, pid, fd, eventrep->ea_time);
free(Einv);
break;
case CRPROTERR_THLD_EVENT:
fprintf(stdout, "%s %s ProtErr id= %d %d EvTime= %s\n\n",
hosts[sysid], evtime, pid, fd, eventrep->ea_time);
free(Einv);
break;
case CKSUMERR_THLD_EVENT:
fprintf(stdout, "%s %s CkSumErr id= %d %d EvTime= %s\n\n",
hosts[sysid], evtime, pid, fd, eventrep->ea_time);
free(Einv);
break;
}
fflush(stdout);
return OK;
}
static setpoll ()
{
poll = YES;
alarm(WAIT);
}
static do_poll (msd)
int msd[];
{
int i;
poll = NO;
for (i = 0; i < NofHosts; i++)
if (msd[i] == -1 && (msd[i] = m_init(hosts[i])) != NOTOK) {
char *evtime; int now;
/* update mask */
mask |= 1 << msd[i];
if (nfds < msd[i] + 1)
nfds = msd[i] + 1;
/* set reports: TEinvReport, rcid 2, TCeptReport, rcid 3 */
if (ReportSetRequest(TEINV_REP, m_addValue, msd[i]) == NOTOK ||
ReportSetRequest(TCEPT_REP, m_addValue, msd[i]) == NOTOK) {
close_connections(msd);
error(NULLCP, "ReportSetRequest failed");
}
time(&now);
evtime = ctime(&now) + 11;
*(evtime+8) = '\0';
fprintf(stderr, "%s : got connection to %s\n",
evtime, hosts[i]);
fflush(stderr);
}
}