SAM

"How to generate a SAM Notification using the Perl API."
emc109583 6

ID: Usage:

Date Created: 05/13/2005 Last Modified: 05/30/2007 STATUS: Audience: Approved Customer

Knowledgebase Solution Question: Environment: How to generate a SAM Notification using the Perl API. EMC SW: EMC Smarts SAM Suite Service Assurance Manager (Smarts SAM) The following code will correctly generate an ICS_Notification Object in the SAM repository. #!/bin/perl # no warnings; use lib "/opt/InCharge6.2/SDK/smarts/perl/5.6.1/lib"; use InCharge::session; use InCharge::object; use Data::Dumper; $DEBUG = 0; $SMARTS_broker = "localhost:426"; $SMARTS_domain = "INCHARGE-SA"; $SMARTS_username= "admin"; $SMARTS_password= "changeme"; $session = InCharge::session->new( broker=>"$SMARTS_broker", domain=>"$SMARTS_domain", username=>"$SMARTS_username", password=>"$SMARTS_password", traceServer => 1 ); $factory=$session->object("ICS_NotificationFactory", "ICS-NotificationFactory"); # This should work (and appears to), but later call to insertElement says that the method cannot be located. # $notification=$factory->makeNotification("Host", "EXAM", "Down", "ICS_Notification"); Fix: # Instead, create the notification and then get the reference explicitly. $factory->makeNotification("Host", "EXAM", "Down", "ICS_Notification"); $notification = $session->object("ICS_Notification", "NOTIFICATION-Host_EXAM_Down"); $notification->{DisplayName} = "Host Down 100%: EXAM"; $notification->{InstanceDisplayName} = "EXAM"; $notification->{ClassDisplayName} = "Host"; $notification->{EventDisplayName} = "Down"; $notification->{Certainty} = 100; $notification->{EventText} = "Test Foo"; $notification->{Severity} = 1; $notification->{Category} = ""; # The ElementName and ElementClassName Cannot be set directly. Set OccurredOn and # the notify() method will set ElementName and ElementClassName provide the device # exists in the SAM topology. If the device does not exist notify() will clear OccurredOn # and leave ElementClassName and ElementName empty. # $notification->{ElementClassName} = "Host"; # $notification->{ElementName} = "EXAM"; $notification->{OccurredOn} = "Host::EXAM"; $notification->{EventType} = "DURABLE"; $notification->insertElement("NotifiedBy", "InChargeDomain::InChargeDomain_INCHARGE-AM" ); # Again, this should work, but gives error about incorrect # of arguments.

it works if you use the underlying invoke() method $notification->invoke("notify". $notification->changed(). # Uncomment the following to make a "MOMENTARY" notification with an expiration # $notification->invoke("notify". "DXA". 60). The value of "0" in the invocation of notify represents the creation time of the notification in Unix epoch format. "PERL-API".60). This script only needs to be slightly modified to generate a "MOMENTARY" event 1) Prior to the invoke() call.# $notification->notify("DXA". "DXA". "Server: INCHARGE-SA"). "DXA". Use 0 for the current time. 0. set the EventType to "MOMENTARY" as follows: $notification->{EventType} = "MOMENTARY". . However. "PERL-API". Notes: 2) modify the invoke() call to add an expiration time (60 seconds) to the call as follows: $notification->invoke("notify". "PERL-API".0. "Server: INCHARGE-SA". "Server: INCHARGE-SA"). "Server: INCHARGE-SA". "PERL-API".