Page 1 of 1

403 Forbidden at .pm file

Posted: Mon Nov 30, 2020 3:59 pm
by lexcorp
#perl import_ocs.pl
403 Forbidden at Ocs/Nagios.pm line 55.

Content file import_ocs.pl

Code: Select all

use strict;
use warnings;
use Ocs::Nagios;

#use LWP::UserAgent 5.834; # need local_address
#use LWP::Simple;
#use LWP

#my $ua = LWP::UserAgent->new;
#$ua->default_header('User-Agent' => 'Mozilla/5.0');

my $server="10.120.7.212";
my $soap_user="admin";
my $soap_pass="admin";
my $soap_port=80;
my $directory="/etc/nagios2/conf.d/";
#my $directory="/etc/init.d/nagios";
my $obj = new Ocs::Nagios( server => $server,
                      soap_user => $soap_user,
                      soap_pass => $soap_pass,
                      soap_port => $soap_port,
                      directory => $directory
);

my %hash=$obj->init();

while ((my $host,my $ip) = each(%hash)) {
print "KEY : $host, Value : $ip\n";
# Create a host Object
$obj->host( host => $host,
         ip => $ip,
         template => "generic-host"
);
# Create a SERVICE for this host
$obj->service( template => "generic-service",
            service_description => "PING",
            check_command => "check_ping!100.0,20%!500.0,60%"
);
}

Re: 403 Forbidden at .pm file

Posted: Tue Dec 01, 2020 3:01 pm
by gormank
I'd look at line 55 in ocs/nagios.pm.