| 1 | package Net::SolarWinds::Helper; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Net::SolarWinds::Helper - Common OO Methods | ||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | use base qw(Net::SolarWinds::Helper); | ||
| 13 | |||
| 14 | =head1 DESCRIPTION | ||
| 15 | |||
| 16 | This class provides common OO methods used to for Solarwinds development. These methods are all stand alone. | ||
| 17 | |||
| 18 | =over 4 | ||
| 19 | |||
| 20 | =item * my $reverse_hex=$self->ip_to_reverse_hex($ip); | ||
| 21 | |||
| 22 | Converts an IP into hex with the octets swapped to reverse order. | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | 0 | ▶ | sub ip_to_reverse_hex { |
|
Subroutine
ip_to_reverse_hex: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 27 | |||
| 28 | 0 | my ($self,$ip)=@_; | |
| 29 | |||
| 30 | 0 | my $hex=unpack("H8",reverse(pack("C4",split(/\./,$ip)))); | |
| 31 | |||
| 32 | 0 | return $hex; | |
| 33 | } | ||
| 34 | |||
| 35 | =item * my $gui_ip=$self->ip_to_gui($ip); | ||
| 36 | |||
| 37 | Converts a quad notation ip to the gui display version SolarWinds uses.. | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | 0 | ▶ | sub ip_to_gui { |
|
Subroutine
ip_to_gui: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 42 | 0 | my ($self,$ip)=@_; | |
| 43 | |||
| 44 | 0 | my $hex=$self->ip_to_reverse_hex($ip); | |
| 45 | |||
| 46 | 0 | $hex .="-0000-0000-0000-000000000000"; | |
| 47 | |||
| 48 | 0 | return $hex; | |
| 49 | } | ||
| 50 | |||
| 51 | =item * my $swis=$self->nodeUri($node_id); | ||
| 52 | |||
| 53 | Returns the node Uri based on the $node_id | ||
| 54 | |||
| 55 | =cut | ||
| 56 | |||
| 57 | 0 | ▶ | sub nodeUri { |
|
Subroutine
nodeUri: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 58 | 0 | my ($self,$nodeId)=@_; | |
| 59 | 0 | return "swis://localhost/Orion/Orion.Nodes/NodeID=$nodeId"; | |
| 60 | } | ||
| 61 | |||
| 62 | =back | ||
| 63 | |||
| 64 | =head1 Query Drivers | ||
| 65 | |||
| 66 | Many of the internals use site spesific SWQL statements, they are defined as constants in this class. Since some of these queries are Solarwinds install spesific it may be required to overload some of these queries. | ||
| 67 | |||
| 68 | =head2 Query Drivers For: Net::SolarWinds::REST | ||
| 69 | |||
| 70 | =over 4 | ||
| 71 | |||
| 72 | =item * my $sql=$self->SWQL_getInterfacesOnNode; | ||
| 73 | |||
| 74 | =cut | ||
| 75 | |||
| 76 | 2 | ▶ | use constant SWQL_getInterfacesOnNode=>'SELECT Caption, InterfaceID, DisplayName, FullName, ifname, interfacetype as ifType,Uri FROM Orion.NPM.Interfaces where NodeID=%s'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 77 | |||
| 78 | =item * my $sql=$self->SWQL_getNodesByDisplayName; | ||
| 79 | |||
| 80 | =cut | ||
| 81 | |||
| 82 | 2 | ▶ | use constant SWQL_getNodesByDisplayName=>q{SELECT |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 83 | NodeID, | ||
| 84 | IPAddress, | ||
| 85 | IPAddressGUID, | ||
| 86 | Caption, | ||
| 87 | DynamicIP, | ||
| 88 | EngineID, | ||
| 89 | Status, | ||
| 90 | UnManaged, | ||
| 91 | Allow64BitCounters, | ||
| 92 | ObjectSubType, | ||
| 93 | SysObjectID, | ||
| 94 | MachineType, | ||
| 95 | VendorIcon, | ||
| 96 | SNMPVersion, | ||
| 97 | Community, | ||
| 98 | RediscoveryInterval, | ||
| 99 | PollInterval, | ||
| 100 | StatCollection, | ||
| 101 | Uri, | ||
| 102 | DisplayName | ||
| 103 | 2 | FROM Orion.Nodes where DisplayName='%s' OR Caption='%s'}; | |
| 104 | |||
| 105 | =item * my $sql=$self->SWQL_getNodesByID; | ||
| 106 | |||
| 107 | =cut | ||
| 108 | |||
| 109 | 2 | ▶ | use constant SWQL_getNodesByID=>q{SELECT |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 110 | NodeID, | ||
| 111 | IPAddress, | ||
| 112 | IPAddressGUID, | ||
| 113 | Caption, | ||
| 114 | DynamicIP, | ||
| 115 | EngineID, | ||
| 116 | Status, | ||
| 117 | UnManaged, | ||
| 118 | Allow64BitCounters, | ||
| 119 | ObjectSubType, | ||
| 120 | SysObjectID, | ||
| 121 | MachineType, | ||
| 122 | VendorIcon, | ||
| 123 | SNMPVersion, | ||
| 124 | Community, | ||
| 125 | RediscoveryInterval, | ||
| 126 | PollInterval, | ||
| 127 | StatCollection, | ||
| 128 | Uri | ||
| 129 | 2 | FROM Orion.Nodes where NodeId='%s'}; | |
| 130 | |||
| 131 | =item * my $sql=$self->SWQL_getApplicationTemplate; | ||
| 132 | |||
| 133 | =cut | ||
| 134 | |||
| 135 | 2 | ▶ | use constant SWQL_getApplicationTemplate=>q{SELECT ApplicationTemplateID, Created, CustomApplicationType, Description, DisplayName, HasImportedView, InstanceType, IsMockTemplate, LastModified, Name, Uri, ViewID, ViewXml FROM Orion.APM.ApplicationTemplate where %s}; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 136 | |||
| 137 | =item * my $sql=$self->SWQL_getTemplatesOnNode; | ||
| 138 | |||
| 139 | =cut | ||
| 140 | |||
| 141 | 2 | ▶ | use constant SWQL_getTemplatesOnNode=>q{SELECT ApplicationID, ApplicationTemplateID, Description, DetailsUrl, DisplayName, HasCredentials, ID, InstanceType, Name, NodeID, Uri FROM Orion.APM.Application where nodeid=%s}; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 142 | |||
| 143 | =item * my $sql=$self->SWQL_getNodesByIp; | ||
| 144 | |||
| 145 | =cut | ||
| 146 | |||
| 147 | 2 | ▶ | use constant SWQL_getNodesByIp=>q{SELECT |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 148 | n.NodeID, | ||
| 149 | n.IPAddress, | ||
| 150 | n.IPAddressGUID, | ||
| 151 | n.Caption, | ||
| 152 | n.DynamicIP, | ||
| 153 | n.EngineID, | ||
| 154 | n.Status, | ||
| 155 | n.UnManaged, | ||
| 156 | n.Allow64BitCounters, | ||
| 157 | n.ObjectSubType, | ||
| 158 | n.SysObjectID, | ||
| 159 | n.MachineType, | ||
| 160 | n.VendorIcon, | ||
| 161 | n.SNMPVersion, | ||
| 162 | n.Community, | ||
| 163 | n.RediscoveryInterval, | ||
| 164 | n.PollInterval, | ||
| 165 | n.StatCollection, | ||
| 166 | n.Uri, | ||
| 167 | n.DisplayName | ||
| 168 | FROM | ||
| 169 | Orion.NodeIPAddresses i | ||
| 170 | inner join Orion.Nodes n on n.ObjectSubType='SNMP' and i.NodeID=n.NodeID | ||
| 171 | where | ||
| 172 | 2 | i.IPAddress='%s'}; | |
| 173 | |||
| 174 | =item * my $sql=$self->SWQL_bulk_ip_lookup | ||
| 175 | |||
| 176 | =cut | ||
| 177 | |||
| 178 | 2 | ▶ | use constant SWQL_bulk_ip_lookup=>q{SELECT |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 179 | n.NodeID, | ||
| 180 | n.IPAddress, | ||
| 181 | n.IPAddressGUID, | ||
| 182 | n.Caption, | ||
| 183 | n.DynamicIP, | ||
| 184 | n.EngineID, | ||
| 185 | n.Status, | ||
| 186 | n.UnManaged, | ||
| 187 | n.Allow64BitCounters, | ||
| 188 | n.ObjectSubType, | ||
| 189 | n.SysObjectID, | ||
| 190 | n.MachineType, | ||
| 191 | n.VendorIcon, | ||
| 192 | n.SNMPVersion, | ||
| 193 | n.Community, | ||
| 194 | n.RediscoveryInterval, | ||
| 195 | n.PollInterval, | ||
| 196 | n.StatCollection, | ||
| 197 | n.Uri, | ||
| 198 | n.DisplayName, | ||
| 199 | i.IPAddress as LookupIP, | ||
| 200 | n.SysName | ||
| 201 | FROM | ||
| 202 | Orion.NodeIPAddresses i | ||
| 203 | inner join Orion.Nodes n on n.ObjectSubType='SNMP' and i.NodeID=n.NodeID | ||
| 204 | where | ||
| 205 | 2 | i.IPAddress in('%s')}; | |
| 206 | |||
| 207 | =item * my $sql=$self->SWQL_getVolumeTypeMap; | ||
| 208 | |||
| 209 | =cut | ||
| 210 | |||
| 211 | 2 | ▶ | use constant SWQL_getVolumeTypeMap=>q{SELECT distinct VolumeType, VolumeTypeIcon, VolumeTypeID FROM Orion.Volumes}; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 212 | |||
| 213 | =item * my $sql=$self->SWQL_getEngines; | ||
| 214 | |||
| 215 | =cut | ||
| 216 | |||
| 217 | 2 | ▶ | use constant SWQL_getEngines=>q{SELECT AvgCPUUtil, BusinessLayerPort, CompanyName, CustomerID, Description, DisplayName, Elements, EngineID, EngineVersion, EvalDaysLeft, Evaluation, FailOverActive, FIPSModeEnabled, InstanceType, InterfacePollInterval, Interfaces, InterfaceStatPollInterval, IP, KeepAlive, LicensedElements, LicenseKey, MaxPollsPerSecond, MaxStatPollsPerSecond, MemoryUtil, MinutesSinceFailOverActive, MinutesSinceKeepAlive, MinutesSinceRestart, MinutesSinceStartTime, MinutesSinceSysLogKeepAlive, MinutesSinceTrapsKeepAlive, NodePollInterval, Nodes, NodeStatPollInterval, PackageName, Pollers, PollingCompletion, PrimaryServers, Restart, SerialNumber, ServerName, ServerType, ServicePack, StartTime, StatPollInterval, SysLogKeepAlive, TrapsKeepAlive, Uri, VolumePollInterval, Volumes, VolumeStatPollInterval, WindowsVersion FROM Orion.Engines}; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 218 | |||
| 219 | =item * my $sql=$self->SWQL_getNodeUri; | ||
| 220 | |||
| 221 | =cut | ||
| 222 | |||
| 223 | 2 | ▶ | use constant SWQL_getNodeUri=>'Select Uri from Orion.Nodes where NodeId=%s'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 224 | |||
| 225 | =item * my $sql=$self->SWQL_getEngine; | ||
| 226 | |||
| 227 | =cut | ||
| 228 | |||
| 229 | 2 | ▶ | use constant SWQL_getEngine=>q{SELECT AvgCPUUtil, BusinessLayerPort, CompanyName, CustomerID, Description, DisplayName, Elements, EngineID, EngineVersion, EvalDaysLeft, Evaluation, FailOverActive, FIPSModeEnabled, InstanceType, InterfacePollInterval, Interfaces, InterfaceStatPollInterval, IP, KeepAlive, LicensedElements, LicenseKey, MaxPollsPerSecond, MaxStatPollsPerSecond, MemoryUtil, MinutesSinceFailOverActive, MinutesSinceKeepAlive, MinutesSinceRestart, MinutesSinceStartTime, MinutesSinceSysLogKeepAlive, MinutesSinceTrapsKeepAlive, NodePollInterval, Nodes, NodeStatPollInterval, PackageName, Pollers, PollingCompletion, PrimaryServers, Restart, SerialNumber, ServerName, ServerType, ServicePack, StartTime, StatPollInterval, SysLogKeepAlive, TrapsKeepAlive, Uri, VolumePollInterval, Volumes, VolumeStatPollInterval, WindowsVersion FROM Orion.Engines where ServerName='%s' or DisplayName='%s'}; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 230 | |||
| 231 | =item * my $sql=$self->SWQL_getVolumeMap; | ||
| 232 | |||
| 233 | =cut | ||
| 234 | |||
| 235 | 2 | ▶ | use constant SWQL_getVolumeMap=>q{SELECT |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 236 | VolumeIndex, | ||
| 237 | Caption, | ||
| 238 | VolumeDescription, | ||
| 239 | Status, | ||
| 240 | Type , | ||
| 241 | Icon , | ||
| 242 | VolumeSpaceAvailable, | ||
| 243 | VolumeSize, | ||
| 244 | VolumePercentUsed, | ||
| 245 | VolumeSpaceUsed, | ||
| 246 | VolumeTypeID, | ||
| 247 | PollInterval, | ||
| 248 | StatCollection, | ||
| 249 | RediscoveryInterval, | ||
| 250 | VolumeID, | ||
| 251 | Uri, | ||
| 252 | NodeID | ||
| 253 | |||
| 254 | 2 | FROM Orion.Volumes where NodeID=%s}; | |
| 255 | |||
| 256 | =item * my $sql=$self->SWQL_GetAlertSettings; | ||
| 257 | |||
| 258 | =cut | ||
| 259 | |||
| 260 | 2 | ▶ | use constant SWQL_GetAlertSettings=>'SELECT NodeID, EntityType, InstanceId, MetricId, MetricName, InstanceCaption, ThresholdType, Timestamp, MinDateTime, MaxDateTime, CurrentValue, WarningThreshold, CriticalThreshold, CapacityThreshold, Aavg, Bavg, Apeak, Bpeak, DaysToWarningAvg, DaysToCriticalAvg, DaysToCapacityAvg, DaysToWarningPeak, DaysToCriticalPeak, DaysToCapacityPeak, InstanceUri, DetailsUrl, DisplayName, Description, InstanceType, Uri, InstanceSiteId |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 261 | FROM Orion.ForecastCapacity | ||
| 262 | 2 | where nodeid=%s'; | |
| 263 | |||
| 264 | |||
| 265 | |||
| 266 | =item * my $sql=$self->SWQL_GetNodePollers; | ||
| 267 | |||
| 268 | =cut | ||
| 269 | |||
| 270 | 2 | ▶ | use constant SWQL_GetNodePollers=>q{SELECT Description, DisplayName, Enabled, InstanceType, NetObject, NetObjectID, NetObjectType, PollerID, PollerType, Uri FROM Orion.Pollers where NetObjectID=%s and NetObjectType='%s'}; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 271 | |||
| 272 | =back | ||
| 273 | |||
| 274 | =head2 Query Drivers For: Net::SolarWinds::REST::Batch | ||
| 275 | |||
| 276 | =over 4 | ||
| 277 | |||
| 278 | =item * my $sql=$self->SWQL_getPollerInterfaceMap; | ||
| 279 | |||
| 280 | =item * my $sql=$self->SWQL_GetNodeInterfacePollers; | ||
| 281 | |||
| 282 | =item * my $sql=$self->SWQL_get_poller_map; | ||
| 283 | |||
| 284 | =cut | ||
| 285 | |||
| 286 | 2 | ▶ | use constant SWQL_getPollerInterfaceMap=>q{select |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 287 | p.PollerType, | ||
| 288 | i.interfacetype as ifType, | ||
| 289 | count(i.interfaceid) as totalinterfaces | ||
| 290 | FROM | ||
| 291 | Orion.NPM.Interfaces as i | ||
| 292 | inner join Orion.Pollers as p on i.InterfaceID=p.NetObjectID and p.NetObjectType='I' | ||
| 293 | where | ||
| 294 | i.NodeID=%s | ||
| 295 | 2 | group by p.PollerType,i.interfacetype}; | |
| 296 | |||
| 297 | |||
| 298 | 2 | ▶ | use constant SWQL_GetNodeInterfacePollers=>q{select |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 299 | p.PollerType, | ||
| 300 | i.interfacetype as ifType, | ||
| 301 | i.InterfaceName as ifName, | ||
| 302 | i.InterfaceID, | ||
| 303 | i.Uri as InterfaceUri, | ||
| 304 | p.Uri as PollerUri | ||
| 305 | FROM | ||
| 306 | Orion.NPM.Interfaces as i | ||
| 307 | left join Orion.Pollers as p on i.InterfaceID=p.NetObjectID and p.NetObjectType='I' | ||
| 308 | where | ||
| 309 | i.NodeID=%s | ||
| 310 | 2 | order by i.InterfaceID}; | |
| 311 | |||
| 312 | |||
| 313 | 2 | ▶ | use constant SWQL_get_poller_map=>q{SELECT Description, DisplayName, Enabled, InstanceType, NetObject, NetObjectID, NetObjectType, PollerID, PollerType, Uri FROM Orion.Pollers where NetObjectID=%s and NetObjectType='%s'}; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 314 | |||
| 315 | =back | ||
| 316 | |||
| 317 | =head1 Author | ||
| 318 | |||
| 319 | Michael Shipper | ||
| 320 | |||
| 321 | =cut | ||
| 322 | |||
| 323 | 2 | 1; | |
| 324 | |||
| 325 | __END__ | ||