[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference csc32::consolemanager

Title:POLYCENTER Console Manager
Notice:Kits, Scans, Docs on CSC32:: as PCM$KITS:,PCM$DOCS:, PCM$SCANS:
Moderator:CSC32::BUTTERWORTH
Created:Thu Aug 06 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1541
Total number of notes:6564

845.0. "V1.6 API problems" by KETJE::MICHIELS (OpenVMS: No compromise computing!) Thu Jun 29 1995 19:04

I just encountered the following problem with the use of the ConsoleManager
API V1.6. I never noticed this problem with V1.5, but I can't test it anymore
as all our systems are running now V1.6.

I striped the code down to something that can be troubleshooted quickly.
The program and extract of the logfile is at the end of this note.
To compile and link:
$ CC CPT$EVENT_WATCHER
$ LINK/NOTRACE CPT$EVENT_WATCHER,SYS$INPUT/OPT
SYS$SHARE:CONSOLE$LIB.OLB/LIB
SYS$SHARE:DECW$XMLIBSHR/SHARE
SYS$SHARE:DECW$DXMLIBSHR/SHARE
SYS$SHARE:DECW$XLIBSHR/SHARE
SYS$SHARE:DECW$XTSHR/SHARE


CPT$EVENT_WATCHER.C is the code for an action routine in ConsoleManager.
I only kept the part where the event is analyzed completely.

I created the filter, as follows:

PCM Edit> sho filter event_watcher
Full or Brief listing? [f=full, b=brief] (b): f
Output file (SYS$OUTPUT):
Filter Name      = EVENT_WATCHER
    Information = Log all events
    Interval = 0 seconds
    Event Interval = 0 seconds
    Filter all events (445)
    Filter all classes
    Filter all systems (15)
    Filter all Subsystems
    Filter all groups (1)
    Notify regardless of event priority
    Actions: (1)
      Action 1: CPT$EVENT_WATCHER    Log all events.
        Information : Log all events
        Schedule:
            Run at any hour on any day
        User data passed to action:
            ** N/A **

Thus: every event will be analyzed by this action routine.


The first thing I had to modify for V1.6 was the use of the new call 
CMRetrieveEventText, for the case the event source is "Console".
(I use ConsoleManager for notification of many things, that I feed in with 
CMUserSendEvent.)
The call to CMEventContextLine did not work anymore for messages from
the console; it generated an access violation. In V1.5 this worked fine.

But then I also remarked that the log file only contained 1 event per 2
that were generated. An extract of the log file below shows only events
with even numbers. I'm missing the odd ones!

What's going wrong here?

Thanks a lot in advance for all help.

Johan Michiels
Digital OMS Brussels.

------------------------------------------

#include      <stdio.h>
#include      <string.h>
#include      <ssdef.h>
#include      <console.h>

#define       CMEventSequence(event)      event->sequence

CMContext     context;
CMEvent       event;
FILE          *log;
int           status;
char          event_text[160];
int           start;


void error_cb()
  {
  CMUserShutdown(&context);
  exit(1);
  }


main()
  {

  log  = fopen("SYS$MANAGER:CPT$EVENT_WATCHER.LOG","a+");

  /* ----- Initialize PCM ----- */
  status = CMUserInit(&context,NULL,error_cb,NULL);
  if (status != CM_NORMAL) 
    {
    fprintf(log,"Error in CMUserInit. Status: %d\n",status);
    exit(1);
    }

  /* -----
     Start an endless loop
  ----- */
  while(1)
    {

    /* -----
       Read synchronously an event from the Event Notification Services daemon.
    ----- */
    
    fclose(log);

    event = CMUserGetEvent(&context);

    log  = fopen("CPT$LOG:CPT$EVENT_WATCHER.LOG","a+");

    /* -----
       Retrieve the event context from the services system's log files
    ----- */

    status = CMGetEventContext(event);

    fprintf(log,"--------------------------------------------------------------------------------\n");
    fprintf(log,"event    ---> %d\n",event);
    fprintf(log,"time     ---> %d\n",*CMEventTime(event));
    fprintf(log,"time     ---> %s",ctime(CMEventTime(event)));
    fprintf(log,"context  ---> %d\n",CMEventContext(event));
    fprintf(log,"type     ---> %d\n",CMEventType(event));
    fprintf(log,"sequence ---> %d\n",CMEventSequence(event));
    fprintf(log,"logtime  ---> %d\n",CMEventLogtime(event));
    fprintf(log,"priority ---> %d\n",CMEventPriority(event));
    fprintf(log,"start    ---> %d\n",CMEventStart(event));
    fprintf(log,"count    ---> %d\n",CMEventCount(event));
    fprintf(log,"text     ---> %s\n",CMEventText(event));
    fprintf(log,"name     ---> %s\n",CMEventName(event));
    fprintf(log,"class    ---> %s\n",CMEventClass(event));
    fprintf(log,"info     ---> %s\n",CMEventInfo(event));
    fprintf(log,"source   ---> %s\n",CMEventSource(event));
    fprintf(log,"subsyst  ---> %s\n",CMEventSubSystem(event));
    fprintf(log,"host     ---> %s\n",CMEventHost(event));
    fprintf(log,"system   ---> %s\n",CMEventSystem(event));
    fprintf(log,"user     ---> %s\n",CMEventUserdata(event));

    /* -----
       Get from the event context the actual event message.
    ----- */
    if (strcmp("Console",CMEventSource(event)) == 0)
      {
      strcpy(event_text,CMRetrieveEventText(event));
      }
    else
      {
      start = CMEventStart(event);
      strcpy(event_text,CMEventContextLine(event,(int)start));
      } 

    fprintf(log,"text     ---> %s\n",event_text);

    /* -----
       Exit if this an shutdown event.
    ----- */
    if (strcmp(CMEventName(event),CMEventNameShutdown) == 0)
      {
      CMUserShutdown(&context);
      exit(1);
      }

    CMFreeEvent(event);

    }

  }  


--------------------------------------------------------------------------------
event    ---> 3261072
time     ---> 804452296
time     ---> Thu Jun 29 18:58:16 1995
context  ---> 1
type     ---> 1
sequence ---> 271843602
logtime  ---> 0
priority ---> 4
start    ---> 0
count    ---> 1
text     ---> %CPT_LOGFAI,*^
name     ---> CPT_LOGFAI
class    ---> SECURE
info     ---> Login failures are detected
source   ---> Console
subsyst  ---> CockpitMgr Security
host     ---> BRSADV
system   ---> BRSADV
user     ---> ** N/A **
text     ---> %CPT_LOGFAI, Login failure by DEC:.BRO.KWAK::MICHIELS : error reading command input
--------------------------------------------------------------------------------
event    ---> 3261072
time     ---> 804452298
time     ---> Thu Jun 29 18:58:18 1995
context  ---> 1
type     ---> 1
sequence ---> 271843604
logtime  ---> 0
priority ---> 4
start    ---> 0
count    ---> 1
text     ---> %CPT_LOGFAI,*^
name     ---> CPT_LOGFAI
class    ---> SECURE
info     ---> Login failures are detected
source   ---> Console
subsyst  ---> CockpitMgr Security
host     ---> BRSADV
system   ---> BRSADV
user     ---> ** N/A **
text     ---> %CPT_LOGFAI, Login failure by DEC:.BRO.KWAK::MICHIELS : error reading command input
--------------------------------------------------------------------------------
event    ---> 3261072
time     ---> 804452301
time     ---> Thu Jun 29 18:58:21 1995
context  ---> 1
type     ---> 1
sequence ---> 271843606
logtime  ---> 0
priority ---> 4
start    ---> 0
count    ---> 1
text     ---> %CPT_LOGFAI,*^
name     ---> CPT_LOGFAI
class    ---> SECURE
info     ---> Login failures are detected
source   ---> Console
subsyst  ---> CockpitMgr Security
host     ---> BRSADV
system   ---> BRSADV
user     ---> ** N/A **
text     ---> %CPT_LOGFAI, Login failure by DEC:.BRO.KWAK::MICHIELS : error reading command input

    
T.RTitleUserPersonal
Name
DateLines
845.1OPG::PHILIPAnd through the square window...Thu Jun 29 1995 20:0214
Johan,

  You are using synchronous calls to PCM, there is a know problem with this 
  that I fixed a couple of days ago and will be in the first ECO kit. Until 
  the ECO kit, you should recode your action to use the asynchronous
  mechanism, this is far safer as if your synchronous calls dont happen fast
  enough, you could cause ENS to hang in a RWMBX state!!! 

  As for the to CMEventContextLine generating an access violation, this 
  shouldnt be, I will try and look into this one.

Cheers,
Phil

845.2KETJE::MICHIELSOpenVMS: No compromise computing!Fri Jun 30 1995 09:0011
    
    Thanks Phil.
    
    
    By the way, I just noticed I did not change a logical in my example
    program in the second fopen call. Just replace CPT$LOG by SYS$MANAGER
    like in the first fopen, and you don't have to define CPT$LOG.
    
    Please keep me informed on this first ECO.
    
    Johan
845.3Context line still ACCVIO in V1.6 ECO124515::EAGLEThu Sep 14 1995 16:096
    Has any progress been made on the context line call? I've run accross
    the same thing using V1.6 ECO1 and need to resolve it.
    
    Any help would be greatly appreciated.
    
    Thanks in advance, Scot.
845.4ZENDIA::DBIGELOWInnovate, Integrate, EvaporateFri Sep 15 1995 10:436
    Scot,
    
       Sorry, but no progress yet. It's on the list. Phil has since left
    Digital and as a result the new support team is just gearing up.
    
    dave
845.5CSC32::BUTTERWORTHGun Control is a steady hand.Fri Sep 15 1995 12:237
    Scott,
      I haven't had any problems with this at all. Both the C3 and 
    Eventlist use the routine. I'd take a look at the application. If I get 
    a chance I'll code up a simple example.
    
    Regs,
      Dan
845.6An example would help.24515::EAGLEFri Sep 15 1995 15:247
    Dan:
    
    It would br greatly appreciated. I'll have the opportunity to look at
    it tonight or this weekend As always, Dan tothe rescue.
    
    Thanks, Scot.
    
845.7How to modify event text prior to ENS notification?24515::EAGLETue Sep 19 1995 14:4515
    I think I've gotten around the problem with the accvio. It helps if you
    code it correctly (I'm not a strong C programmer). I do have a bigger
    question, and if someone has any ideas, they would be greatly
    appreicated.
    
    The customer will get messages on the console in two line chunks. The
    first line will always have the text string that PCM keys off of. Thus
    I can do a two line event scan and get both parts. I've got a
    preprocess written that can get to both lines of the event. The first
    line is typically pretty short. Does it make sense to take the two
    lines and concatenate them togethat, package them back into the event
    and fire them off to the multi-line window? or should I be considering
    something else?
    
    Any help would be greatly appreciated. Thanks, Scot. 
845.8CSC32::BUTTERWORTHGun Control is a steady hand.Mon Oct 09 1995 12:0412
    Sorry about the example. I totally forgot about it and I was on
    vacation for 3 weeks so I wasn't ignoring you!
    
    As to your question, is the point here to display as much event text
    and context as possible without a user having to click on the Eventlist
    window and select "Show Event Context"? If so then concatentating the
    two lines is a good idea but you could get into some scr5een width
    problems where it can't display the whole thing (unless you used a 
    microscopic font!).
    
    Regs,
      Dan
845.9Still working on things...24515::EAGLEThu Oct 12 1995 00:1511
    Dan, that's quite all right. The important questions is how is the new
    house coming?. As to the customer issues, the first line will generally
    be about 10-15 characters long and tell them which application
    component is complaining. The second line actually gives them a clue as
    to what is wrong.
    
    I haven't had a chance to work on it very much. As near a s I can tell,
    I should be able to do a strcat if I can get the pointer nomenclature
    down.
    
    Thanks, Scot.
845.1029067::BUTTERWORTHGun Control is a steady hand.Thu Oct 12 1995 12:4320
    Scot,
      I wasn't going to mention how to do this but there is a way to
    actually trigger an event that spans lines of text. You must use 
    regular expressions. here's an example of what the string might look
    like:
    
    this is line1*^this is line 2*^
    
    Now, this event will be triggered by the string literal
    
    "this is line1" followed by anything followed by a CR, LF, or FF
    followed by the string literal "this is line 2" followed by anything
    and terminated with a CR, LF of FF. You'll have to play with it
    and see if it would meet your needs and how the Multi-line window
    display looks.
    
    Regs,
      Dan
    
    P.S. The house is moving along pretty well.