This post is more than 5 years old

2913

August 10th, 2011 06:00

clear momentary notification

sm_service:

linux-x86_64_64BIT/206090000

SAM_SUITE: V8.1.0.6/64(103203), 10-Dec-2010 14:50:37 Copyright 1995-2010, EMC Corporation - Build 52

Foundation V7.2.0.1/64(101210), 18-Sep-2010 14:44:40 Copyright 1995-2010, EMC Corporation - Build 143

Is it possible to clear a MOMENTARY notification via the Perl API?

I have successfully created a notification like so:

######## START SNIPPET ########

my $systemClass = 'Host';

my $systemName = 'myTestHostName';

my $strEventName = 'SchedMaint';

$notificationFactory = $session->object("ICS_NotificationFactory", "ICS-NotificationFactory");

my $notification = $notificationFactory ->findNotification($systemClass, $systemName, $strEventName);
if ($notification eq "") {
   eval {
      $schedMaintNotiObj = $notificationFactory ->makeNotification($systemClass, $systemName, $strEventName);
   } or do {
      die("MakeNotificationException:\n$@")
   };
}
my $currentTime = time;

my $auditLogEntry = 'Maint window created';

$session->object($notification)->{EventType}  = "MOMENTARY";

$session->object($notification)->{EventText}  = "Setting Host In Maintenance";

$session->object($notification)->{EventName} = $strEventName;

$session->object($notification)->{OccurredOn}  = $systemName;

$session->object($notification)->{Severity} = 5;

$session->object($notification)->{InMaintenance} = 1;

$session->object($notification)->invoke("notify", "maint", 'INCHARGE-SA', $auditLogEntry, $currentTime, 9000, " ", 1, "MOMENTARY");

$session->object($notification)->takeOwnership("maint");

$session->object($notification)->changed();

######## END SNIPPET ########

I have tried to clear this event with the following code sample to no avail.

######## START SNIPPET ########

$session->object($systemClass, $systemName)->clear($strEventName);

######## END SNIPPET ########

Any help is greatly appreciated.

August 11th, 2011 06:00

Hi,

using the PERL API or dmctl you have access to almost the same functionalities: using classes, instances and calling methods on those instances allow you to implement new functionalities. In your PERL code, you are using ICS_NotificationFactory, you can use the same singleton (unique instance of this class) in dmctl to create a new notification. Or you can also use sm_ems to create one quickly.

Now, when I said "clear the notification using dmctl", I was refering to the notification you did create using your PERL script. Lets say that you create a notification like this one:

ClassTest InstanceTest EventTest

you can search for this notification using dmctl:

dmctl -s findi ICS_Notification::.*Test.*

and invoke a clear:

echo | /opt/InCharge8/SAM/smarts/bin/dmctl -s INCHARGE-SA invoke clear

Don't forget one thing: the has to be the same as the one used in the "notify" ... this is key, as a notification can have multiple source and has to be cleared in all sources to be cleared in SAM.

HTH,

--Fred

== APG5 ReportPack4Event for Smarts can report on millions of notifications in seconds ==
Frederic Meunier
Solutions Watch4Net Inc
APG & Smarts InCharge integration
http://www.watch4net.com

August 10th, 2011 06:00

Hi,

you need to call the "clear" method on the notification itself, not the associated system/device. See the signature from the ICS_Notification class:

/opt/InCharge/IP/smarts/bin/dmctl -s INCHARGE-SA getop ICS_Notification

Operations for class ICS_Notification:
...

   clear User Source AuditTrailText clearTime

...

HTH,

== APG5 ReportPack4Event for Smarts can report on millions of notifications in seconds ==
Frederic Meunier
Solutions Watch4Net Inc
APG & Smarts InCharge integration
http://www.watch4net.com

August 10th, 2011 06:00

Thanks for the reply.  I was following the API documentation (https://powerlink.emc.com/nsepn/webapps/btg548664833igtcuup4826/km/live1//en_US/Offering_Technical/Technical_Documentation/300-007-783.pdf) page 37

clear
$obj->clear( $event_name );
Clears the specified event for the object.
$objref->clear( "Unresponsive" );

I tried your suggestion, and the event still is not clearing and not receiving any exceptions/errors.

#### START SNIPPET ####

my $currentTime = time;

my $auditLogEntry = "Clearing Maint window from " . __PACKAGE__;

eval {

   $session->object($notification)->invoke('clear', 'maint', 'INCHARGE-SA', $auditLogEntry, $currentTime);

} or do {

   die("$@");

};

#### END SNIPPET ####

August 10th, 2011 13:00

How do you get the $notification ?

Try by using dmctl (and the clear operation) to see if this works. If so, then, it is within your code.

--Fred

== APG5 ReportPack4Event for Smarts can report on millions of notifications in seconds ==
Frederic Meunier
Solutions Watch4Net Inc
APG & Smarts InCharge integration
http://www.watch4net.com

August 10th, 2011 19:00

I am not familiar with how to use the dmctl commands. The Host::myTestHostName element exists in the topology, however I have tried the following to create a notification, and failed. The command below is what I am trying to execute.

% dmctl -s INCHARGE-SA notify Host:myTestHostName::TestEvent

as for your other question, this is how I am getting the $notification:

$notificationFactory = $session->object("ICS_NotificationFactory", "ICS-NotificationFactory");
my $notification = $notificationFactory ->findNotification($systemClass, $systemName, $strEventName);
if ($notification eq "") {
   eval {
      $notification = $notificationFactory ->makeNotification($systemClass, $systemName, $strEventName);
   } or do {
      die("MakeNotificationException:\n$@")
   };
}

August 11th, 2011 08:00

Thanks!

looks like the SOURCE was my problem.

No Events found!

Top