I did get it to work by modifying the session.pm but if there is a better way I would rather use it. Also it is sending the alert to the SA, I would prefer to send it to the OI but when I do that it give me an error: [15] CI-E-EGENERIC-At ICS_Notification.c:3450 MR-E-CALL_ON_NULL_OBJECT-Tried to
AdaDie
54 Posts
0
May 21st, 2007 08:00
we run perl api scripts without runcmd. How do you connect to the broker in your script?
Junior4
2 Posts
0
May 23rd, 2007 10:00
[15] CI-E-EGENERIC-At ICS_Notification.c:3450 MR-E-CALL_ON_NULL_OBJECT-Tried to
make a call on a NULL repository object; in
. file
.
"/work/blackcurrent/SAM-7.0.1/77/smarts/ics/linux-i586/optimize/ICS_Action
. Scheduler.h" at line 621
. : Tried to make a call on a NULL repository object
Here is the code that I'm using to connect and send an alert:
use strict;
use Data::Dumper;
use lib "/root/perlAPI/lib";
$0 =~ s|.*/([^>+)|$1|; ## basename of app invocation
use InCharge::session;
sub usageError {
print "Usage: perl $0 [options]\n\n"."$_[0]\n";
exit 2;
}
#$session = InCharge::session->init( );
my $session = InCharge::session->new(
broker=>"jpaynesmarts",
username=>"admin",
password=>"changeme",
domain=>"INCHARGE-SA",
);
#$obj = $session->create("ICIM_Notification");
my $factory=$session->object("ICS_NotificationFactory","ICS-NotificationFactory");
$factory->makeNotification("Host","EXAM","Down","ICS_Notification");
my $noti = $session->object("ICS_Notification","NOTIFICATION-Host_EXAM_Down");
$noti->{DisplayName}="Host Down 100%:EXAM";
$noti->{InstanceDisplayName}="EXAM";
$noti->{ClassDisplayName}="juniorHost";
$noti->{EventDisplayName}="Down";
$noti->{Certainty}=100;
$noti->{EventText}="Test Foo";
$noti->{Severity}=1;
$noti->{Category}="";
#$noti->{ElementClassName}="Host";
#$noti->{ElementName}="EXAM";
$noti->{OccurredOn}="Host::jpaynesmarts.rim.net";
$noti->{EventType}="DURABLE";
#$noti->{EventType}="MOMENTARY";
#$noti->insertElement("NotifiedBy","InChargeDomain::InChargeDomain_INCHARGE_AM");
#$noti->notify("DXA","PERL-API","Server:INCHARGE-SA");
$noti->invoke("notify","DXA","PERL-API","Server:INCHARGE-SA",0,60);
#print Dumper($noti);
$noti->changed();
AdaDie
54 Posts
0
May 30th, 2007 04:00
Try to connect OI adapter as follow:
my $s = InCharge::session->new( broker => "$broker",
domain => "$domain",
username => "example",
password => "example");
where $domain is the name of the OI adapter.
Note the user must have the rights to connect to the OI adapter. Try it first with the Domain Manager Console if the user can connect OI adapter.