[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

248.0. "Program which sends events to PCM V1.1" by EEMELI::OJUSSILA (Olli Jussila, IS/SMGT Finland) Thu Apr 21 1994 14:42

    
    
    	We are building Polycenter demo where PCM V1.1 has important
    	role. But we would like to send events from other Polycenter
    	products (PSW, SLS, etc) events to ENS.  Does anyone of
    	ypu have piece of code which uses PCM callable interface
    	to send event from command level (DCL or OSF/1 shell).
    
    	-Olli
    	
T.RTitleUserPersonal
Name
DateLines
248.1A piece of UNSUPPORTED code!!!OPG::SIMONThu Apr 21 1994 15:19263
Olli,
     the code segment below is NOT supported by the PCM team, although it does
work. I wrote it as an exercise to check out the API for Phil.

Cheers SImon......



/* Routine to send events from the PSWX action interface in to the ENS
   subsystem. This routine will use the example read file descriptor 0
   routine described in dca.h and will send the data in to ENS through
   the CMUserSendEvent() call in to ENS.
   Most of this code is really used to translate between the values
   of the data presented by PSWX and the event attributes supported by
   ENS.
*/

/*
 Declarations
*/
#include <stdio.h>  
#include <time.h>  
#include "dca.h" 
#include <console.h>
#include <string.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/errno.h>

     FILE *Errors;         


CMContext ENS_Context;

     char*  class = "PSWX";
     char  info[512];
     char*  text;
     int    priority;
     char*  subsystem;
     char*  source = "PSWX";
     int    My_index;
     time_t event_time;
     int    status;
     char*  name  = "PSWX";
     char  *ErrString;
 
/* I am declaring a couple of structuure types here for convenience as 
   I have to be able to translate the priority names to ENS priority
   integers and the PSWX code to an ENS subsystem.
*/

typedef struct _PswPriorities
{
        char *PswPriority;
        int   ENSPriority;
} PswPriorities;

typedef struct _PswCodes
{
	char *code;
	char *subsystem;
} PswCodes;


/* Here we will declare the array of the possible values of the PSW
   event code and the corresponding ENS subsystem which will be passed
   in the subsystem field of the packet.
*/

PswCodes EventCode[] =
{
 {"PSW_C_EXT","Unknown"},
 {"PSW_C_CPU","CPU"},
 {"PSW_C_MEM","Memory"},
 {"PSW_C_DSK","Disk"},
 {"PSW_C_ETH","Ethernet"},
 {"PSW_C_HSC","Disk"},
 {"PSW_C_CIC","Bus"},
 {"PSW_C_PRS","Printer"},
 {"PSW_C_LOP","Software"},
 {"PSW_C_DNF","Disk"},
 {"PSW_C_DSS","Disk"},
 {"PSW_C_DQP","Printer"},
 {"PSW_C_BQP","Batch"},
 {"PSW_C_QCP","Batch"},
 {"PSW_C_BAT","Batch"},
 {"PSW_C_DMM","Memory"},
 {"PSW_C_SWL","Disk"},
 {"PSW_C_PRO","Software"},
 {"PSW_C_SHS","Disk"},
 {"PSW_C_ILL","Software"},
 {"PSW_C_SMP","CPU"},
 {"PSW_C_UNR","Software"},
 {"PSW_C_ORS","Software"},
 {"PSW_C_UNK","Software"},
 {"PSW_C_TIM","Software"},
 {"PSW_C_WDM","Software"},
 {"PSW_C_OTH","Unknown"},
 {"PSW_C_VAL","Software"},
 {"PSW_C_PSW","Software"},
 {NULL, NULL}
};


/* Here we will declare the array of the possible values of the PSW
   severity and the corresponding ENS priority which will be passed
   in the priority field of the packet.
*/

PswPriorities Priorities[] =
{
 {"Fatal",CMPriorityCritical},
 {"Error",CMPriorityMajor},
 {"Warning",CMPriorityWarning},
 {"Success",CMPriorityClear},
 {"Information",CMPriorityIndeterminate},
 {NULL, 0}
};









/*
     Main routine. This don't need to initialise the ENS callable 
     interface as we are only sending events so we will just set up
     PSWX interface and then format the packets we require. 
    
*/

main ()

{

     actor_packet_type PSW_Packet;

     
/* Loop to Read Packet from File Descriptor 0 */

 while (read(0,&PSW_Packet,sizeof(actor_packet_type))>0)

  { 


     if (strlen(PSW_Packet.message) == 0 )
        {
        continue;
        }

           
/* Got a packet now we need to format it to send to ENS */

  /*

     We need to format from the PSWX packet or supply defaults 
     for each of the following:


     PSWX             ENS
    
     Node             System
     "PSWX Event"     Name
     "PSWX"           class
     Req_str          Information (this will be set up to reflect
                                   whether this is new event,updated
                                   event or deleted event from PSWX).
     message          Text
       -              Time
     severity         priority  
     event_str        subsystem   ( this is converted in a lookup table)
     "PSWX"           Source

  */

/*
  First lets make up the Information Field from the Req String and
  the message from PSWX.

*/           

          if ((strncasecmp(PSW_Packet.req_str,
               "PSW_C_NEW",strlen("PSW_C_NEW"))) == 0 )
              {
                sprintf( info,"Message from PSW:  %s", PSW_Packet.message); 
              }

          if ((strncasecmp(PSW_Packet.req_str,
               "PSW_C_UPD",strlen("PSW_C_UPD"))) == 0 )
              {
              sprintf( info,"Update from PSW: %s", PSW_Packet.message);
              }

           if ((strncasecmp(PSW_Packet.req_str,
                "PSW_C_REM",strlen("PSW_C_REM"))) == 0 )
              {
                sprintf( info,"Cleared PSW message  %s", PSW_Packet.message); 
              }


/*
  Next comes the priority and we shall use the conversion tables
  created above. If it is a remove event the priority will be 
  set to clear in all cases.
*/
          if ((strncasecmp(PSW_Packet.req_str,
               "PSW_C_REM",strlen("PSW_C_REM"))) == 0 )
              {
                   priority = CMPriorityClear;
              }
           else
              {
                My_index = 0;
                   while (Priorities[My_index].PswPriority != NULL)
                      {
                          if (strcasecmp(PSW_Packet.severity_lvl, 
                              Priorities[My_index].PswPriority) == 0)
                          {
                          priority = Priorities[My_index].ENSPriority;
                            break;
                          }
                          My_index++;
                      }
              }
/*
  Do the same as above to convert the subsystem to the right sort of
  thing.
*/

         My_index = 0;
           while (EventCode[My_index].code != NULL)
                 {
                     if (strcmp(PSW_Packet.event_str,
                         EventCode[My_index].code) == 0)
                     {
                     subsystem = EventCode[My_index].subsystem;
                     break;
                     }
                   My_index++;
                 }


/* I think I have all I need. the time bit will be done in the call. */

         event_time = time(0);

         status = CMUserSendEvent(&ENS_Context,
                                  PSW_Packet.node,
                                  name,
                                  class,
                                  info,
                                  PSW_Packet.message,
                                  event_time,
                                  priority,
                                  subsystem,
                                  source);
  }

}
248.2VMS version comming soonEEMELI::OJUSSILAOlli Jussila, IS/SMGT FinlandFri Apr 22 1994 13:4314
    
    Simon,
    
    	This was much more I expected!  I'll make changes to
    	make it work with PSW (VMS).
    
    	Propably I'll also write programs which takes
    	parameters from command line.
    
    	Thanks,
    
    	-Olli
    
    	
248.3OSCint v2SUPER7::HUGHESASwimming against the tide @#%*Fri Apr 22 1994 16:547
Hi Olli,

	This work is already been officially engineered as part of the
	OSCint v2 package. Please speak to Robin Cole and Christian 
	Heusbourg to save re-inventing the wheel.

Andy.
248.4Now that's quick!ZENDIA::DBIGELOWInnovate, Integrate, EvaporateFri Apr 22 1994 20:166
    Andy,
    
       So you're saying that OSCint now supports PCM? Have they dropped
    support for VCS?
    
    DAve
248.5EEMELI::OJUSSILAOlli Jussila, IS/SMGT FinlandSat Apr 23 1994 09:1821
    
    re .3
    
    Yes I know. But It is not possible to get one piece of OSCint tool
    kit and we need this functionality at this Thursday when we start
    series of Polycenter demos to customers.
    
    And at least here in Finland we have implemented with customers 
    PSW_TO_ENS (of VCS) integration with example program in
    SNS$EXAMPLES directory. This has done as a part of PSW/VCS consultancy.
    
    I am sure they want to have this functionality with PCM also.
    
    But when OSCint V2.0 is available and the price is right for small
    customers (One management station, 2-20 PSW and VCS nodes) then
    OSCint V2.0 can be sell to them also.
    
    -Olli
    
    
    -Olli
248.6WOTVAX::ELLISMAre you all sitting too comfybold square on your botty? - Then wSun Apr 24 1994 14:077
    Yep,
    
    OSCint V2.0 does not support VCS.
    
    By the way, Olli, where are you getting your prices from?
    
    Martin
248.7EEMELI::OJUSSILAOlli Jussila, IS/SMGT FinlandMon Apr 25 1994 10:1411
    
> By the way, Olli, where are you getting your prices from?
    
    For OSCint V1.1 I asked price from Guy Balaguer.
    
    I haven't asked yet how pricing of OSCint V2.0 will work.
    
    
    -Olli