NAME
Net::SolarWinds::REST - SolarWinds Rest interface
SYNOPSIS
use strict;
use warnings;
use Net::SolarWinds::REST;
use Data::Dumper;
my $rest=new Net::SolarWinds::REST();
my $result=$rest->DiscoverInterfacesOnNode(444);
if($result) {
print Dumper($result->get_data);
} else {
print $result,"\n";
}
DESCRIPTION
Perl Module for interfacing with SolarWinds.
GLOBAL OBJECTS
$Net::SolarWinds::REST::JSON
This is a JSON object with the following options endabled: JSON->new->allow_nonref->utf8
my $json=$class->get_json;
Returns the class level JSON object.
$Net::SolarWinds::REST::UA
This is a LWP::UserAgent used to talk to CPM servers
my $ua=$class->get_ua;
Returns the Class level UA object.
Class Constants
The following constants are accessable via: Net::SolarWinds::REST->CONSTANT
DEFAULT_USER=>'admin';
DEFAULT_PASS=>'ChangeMe';
DEFAULT_SERVER=>'SolarWindsServer';
DEFAULT_PORT=>17778;
DEFAULT_PROTO=>'https';
BASE_URI=>'%s://%s:%i/SolarWinds/InformationService/v3/Json/%s';
OO Methods
This section covers the OO Methods of the class.
Object Constructor.
The object constructor takes key=>value pairs all aguments are optional, default values are pulled from the constants DEFAULT_*.
my $sw=new Net::SolarWinds::REST( USER =>'User', PASS =>'Passxxx', SERVER =>'SolarwindsServer', PORT =>17778, PROTO =>'https', # Logging is not enabled by default! log=> Net::SolarWinds::Log->new('/var/log/Solarwinds.log') );
my $request=$self->build_request('GET|POST|PUT|DELETE',$path,undef|$ref);
Creates an HTTP::Request object with the default options set.
my $result=$self->run_request($request);
Takes a given HTTP::Request object and runs it returing a Net::SolarWinds::Result object. What the object contains is relative to the request run.. If the result code of the request was not a 20x value then the object is false.
my $result=$self->DiscoverInterfacesOnNode($nodeId)
Returns a Net::SolarWinds::Result Object: When true it contains the results, when false it contains the error.
my $result=$self->DiscoverInterfaceMap($nodeId);
Returns a Net::SolarWinds::Result object:
When true it contains an anonymous hash that maps interface objects to interface names. When false it contains why it failed.
my @names=$self->InterfaceCaptionTranslation($Caption);
Takes an interface caption and converts it to a list of valid interface names that should match what is on a given device.
my $result=$self->NodeInterfaceAddDefaultPollers($nodeId,$interfaec_ref);
Returns a Net::SolarWinds::Result Object: When true it contains the results, when false it contains the error. $interface_ref represents object listed from the DiscoverInterfacesOnNode that need to be added to the default pollers.
my $result=$self->NodeAddInterface($node_id,[$interface]);
Adds an interface to the cpm for the node but does not add any pollers.
my $result=$self->NodeInterfaceCustomProperties($nodeId,$interfaceId,$hash_ref|undef);
Used to get or set custom properties of an interfaec on a node. Returns a Net::SolarWinds::Result Object: When true it contains the results, when false it contains the error.
my $result=$self->getInterfacesOnNode($NodeID);
Returns a Net::SolarWinds::Result Object
when true: Gets the interfaces from the node when false: returns why it failed
my $result=$self->NodeCustomProperties($nodeId,$interfaceId,$hash_ref|undef);
Used to get or set custom properties of an interfaec on a node. Returns a Net::SolarWinds::Result Object: When true it contains the results, when false it contains the error.
my $result=$self->Query($sql);
Used to run an sql query against CPM. Returns a Net::SolarWinds::Result Object: When true it contains the results, when false it contains the error.
my $result=$self->getNodesByIp($ip);
Find a list of nodes by a given ip. Returns a Net::SolarWinds::Result Object: When true it contains an array ref of the results, when false it contains the error.
my $result=$self->getNodesByDisplayName($hostname);
Find a list of nodes by a given hostname. Returns a Net::SolarWinds::Result Object: When true it contains an array ref of the results, when false it contains the error.
my $result=$self->createNode(key=>value);
Creates a node. Returns a Carter::Result Object: Retuns a data structure on sucess returns why it faield on false.
my $result=$self->getNodeUri($node_id);
When true the Net::SolarWinds::Result object contains the node uri. When false it contains why it failed.
my $result=$self->deleteSwis($uri);
Returns a charter result object showing status.
my $result=$self->deleteNode($node_id);
Deletes a given node.
my $result=$self->getApplicationTemplate(@names);
This is a wrapper for the Query interface. Returns the results that match applications by this name.
my $result=$self->addTemplateToNode($node_id,$template_id); =item * my $result=$self->addTemplateToNode($node_id,$template_id,$cred_id);
Adds a monitoring template with the default credentals to the node. Returns true on success false on failure.
my $result=$self->getTemplatesOnNode($node_id);
Returns a Net::SolarWinds::Result object When true it contains the templates on the node when false it contains why it failed.
my $result=$self->UpdateNodeProps($nodeID,key=>values);
Has 2 use cases Read/Write: When called with just the $nodeID the result object is populated with the node properties. When called with a hash the given values are pushed to the node. Returns a Net::SolarWinds::Result object: true on success false on failure.
my $result=$self->AddPollerToNode($nodeID,$Poller);
Adds a poller to a node.
my $result=$self->add_poller($node_id,$t,$poller)
Returns a Net::SolarWinds::Result object when true it returns the result information that shows the results of the poller being added.
my $result=$self->add_volume(key=>value);
Creates a volume given the arguments passed in.
Returns a Net::SolarWinds::Result object: When false it contains why it failed When true it returns a swis uri
my $result=$self->getVolumeTypeMap;
Returns a Net::SolarWinds::Result Object When true Returns the volume type map. When false it returns why it failed.
my $result=$self->getEngines;
Returns a Net::SolarWinds::Result object: When true it contains the list of poller engins. When false it contains why it failed.
my $result=$self->getEngine($engine);
Returns a Net::SolarWinds::Result Object: When true it contains the list of matching engines. When false it cointains why it failed.
Notes: if no matching engines were found the result object can be true.. but will not contain any data.
my $result=$self->getVolumeMap($nodeID);
Returns a Net::SolarWinds::Result object: When true it contains a hash that maps volumes to objects. When false it returns why it failed.
my $result=$self->getSwisProps($uri);
Returns a Net::SolarWinds::Result object: When true it the uri is set in the result hash when false the explanation as to why it failed is gven.
my $result=$self->GetNodePollers($node_id,"N|V|I");
Returns a Net::SolarWinds::Result Object that contains the nodes when true when false it contains why it failed.
SEE ALSO
Net::SolarWinds::REST::Batch
AUTHOR
Michael Shipper
COPYRIGHT AND LICENSE
Copyright (C) 2016 by Mike Shipper
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.