Unsolved
This post is more than 5 years old
2 Posts
0
1382
May 11th, 2007 12:00
Perl api
I'm working with the perl api with smarts and found that the only way to run the perl script is with runcmd. e.g. runcmd perlscript.pl.
I'm wondering what I have to do to allow the script to run independently. I was hoping to run the script from a box where smarts is not installed.
using smarts 7.
The error I get when not using the runcmd to launch the script is:
[7] Can't connect to broker 'smartserver.smarts.net:426', stopped at ./perlscript.pl line 34
Message was edited by:
Junior
I'm wondering what I have to do to allow the script to run independently. I was hoping to run the script from a box where smarts is not installed.
using smarts 7.
The error I get when not using the runcmd to launch the script is:
[7] Can't connect to broker 'smartserver.smarts.net:426', stopped at ./perlscript.pl line 34
Message was edited by:
Junior
No Events found!
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.