Index


Overview

The Statseeker Discovery process can be refined to include/exclude devices based on supplied IP ranges, and the contents of a hosts file, supplied to the discovery process. It can be further refined through SNMP filtering using: and iftype rules.

  • System description rules - matching a string against the contents of the device's sysDescr field/oid
  • Interface type rules - matching against an interface's iftype field/oid

The discovery process references a list of supplied SNMP community strings to communicate with the devices on your network. These community strings, along with the SNMP filtering rules, are applied globally across your network during discovery.

In this article we'll be looking at using the Statseeker API to override these global settings, and employ IP range specific community strings and filtering rules.

For more information on:

Note: these range specific configurations are not currently exposed to the UI. Once configured they will only be visible via the API, and if not documented on your end, could lead to confusion at a later time.

[top]


Update the Existing Discovery Configuration

The following example will update the current discovery configuration to provide additional community strings to select IP ranges:

  • Devices in the 10.100.89[10, 30, 250-254] range will be sent the default public string, and the range specific secretCommunity community string, and an exclusion rule for Cisco devices will also be applied to this range
  • Devices in the 10.100.90.* range will be sent the default public string, and the range specific verySecretCommunity community string
cURLPythonRubyResponse

curl \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -X PUT \
    -u username:password "https://myStatseekerServer/api/latest/discover_config/1?indent=3&links=none" \
    -d '{"data":[{"ip_range_configurations":[{"enabled":"true","includes":[""],"excludes":["Cisco"],"iftype":["ethernetCsmacd"],"communities":["secretCommunity","public"],
"ip_range_text":"include 10.100.89.[10,30,250-254]","title":"10.100.89_nonCisco_discovery"},{"enabled":"true","includes":[""],"excludes":[""],"iftype":["ethernetCsmacd"],"communities":["verySecretCommunity","public"],
"ip_range_text":"include 10.100.90.[0-255]","title":"10.100.90_discovery"}]}]}'

#!/usr/bin/python 

# import requests for handling connection and encoding
import requests, json

# specify the api endpoint to be used
url = "https://myStatseekerServer/api/latest/discover_config/1"

# credentials
user = "username"
pword = "password"

# headers
headers = {"Accept":"application/json", "Content-Type":"application/json"}


# data
data = json.dumps({"data":[{"ip_range_configurations":[{"enabled":"true","includes":[""],"excludes":["Cisco"],"iftype":["ethernetCsmacd"],"communities":["secretCommunity","public"],
"ip_range_text":"include 10.100.89.[10,30,250-254]","title":"10.100.89_nonCisco_discovery"},{"enabled":"true","includes":[""],"excludes":[""],"iftype":["ethernetCsmacd"],"communities":["verySecretCommunity","public"],
"ip_range_text":"include 10.100.90.[0-255]","title":"10.100.90_discovery"}]}]})

# send request 
r = requests.put(url, headers=headers, auth=(user, pword), data=data)
print(r.status_code)
print(r.json())

# install with: $ gem install rest-client
require 'rest_client'
require 'json'


$user = 'username'
$pword = 'password'
$baseUri = 'https://myStatseekerServer/api/latest/'

# this is simply used to format the contents of the response object for readability.
$rspFormat = '?&indent=3&links=none'

# set target endpoint
$targetEndpoint = 'discover_config/1'

# set payload in json format
$jData = '{"data":[{"ip_range_configurations":[{"enabled":"true","includes":[""],"excludes":["Cisco"],"iftype":["ethernetCsmacd"],"communities":["secretCommunity","public"],
"ip_range_text":"include 10.100.89.[10,30,250-254]","title":"10.100.89_nonCisco_discovery"},{"enabled":"true","includes":[""],"excludes":[""],"iftype":["ethernetCsmacd"],"communities":["verySecretCommunity","public"],
"ip_range_text":"include 10.100.90.[0-255]","title":"10.100.90_discovery"}]}]}'

# send request
response = RestClient::Request.execute(
	:method => :put,
	:url => $baseUri+$targetEndpoint+$rspFormat,
	:headers => {:content_type => :json},
	:user => $user,
	:password => $pword,
	:payload => $jData,
	) 
	
#output response to screen
puts "#{response.to_str}"


{
   "info":"The Statseeker RESTful API",
   "version":"2.1",
   "data":{
      "errmsg":"ok",
      "success":true,
      "time":1518576528
   },
   "revision":"2"
}

[top]


Review the New Discovery Configuration

The following code is checking the Discovery Configuration to ensure that the changes specified above have been applied.

cURLPythonRubyResponse

curl \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -X GET \
    -u username:password "https://myStatseekerServer/api/latest/discover_config/1?fields=ip_range_configurations&indent=3&links=none"

#!/usr/bin/python 

# import requests for handling connection and encoding
import requests, json


# credentials
user = "username"
pword = "password"

# API root endpoint
rootUri = "https://myStatseekerServer/api/latest/"

# specify target endpoint
targetUri = "discover_config/1"

# specify fields to be returned and filters to use
getFields = "?fields=ip_range_configurations"

# optional response formatting
rspFormat = "&indent=3&links=none"

# set URL to be used
url = rootUri + targetUri + getFields + rspFormat


# headers
headers = {"Accept":"application/json", "Content-Type":"application/json"}

# send request and 
r = requests.get(url, headers=headers, auth=(user, pword))
print(r.status_code)
print(r.json())

# install with: $ gem install rest-client
require 'rest_client'
require 'json'

# api user credentials
$user = 'username'
$pword = 'password'

# api root endpoint
$baseUri = 'https://myStatseekerServer/api/latest/'

# this is simply used to format the contents of the response object for readability.
$rspFormat = '&indent=3&links=none'

# set target endpoint
$targetEndpoint = 'discover_config/1/'

# set fields to return
$fields = '?fields=ip_range_configurations'


# send request
response = RestClient::Request.execute(
	:method => :get,
	:url => $baseUri + $targetEndpoint + $fields + $rspFormat, 
	:headers => { 
		:content_type => :json,
  	},
	:user => $user,
	:password => $pword
)
#output response to screen
    puts "#{response.to_str}"

{
   "info":"The Statseeker RESTful API",
   "version":"2.1",
   "data":{
      "objects":[
         {
            "status":{
               "errcode":0,
               "success":true
            },
            "data":[
               {
                  "id":1,
                  "ip_range_configurations":[
                     {
                        "excludes":[
                           "Cisco"
                        ],
                        "iftype":[
                           "ethernetCsmacd"
                        ],
                        "title":"10.100.89_nonCisco_discovery",
                        "ip_range_text":"include 10.100.89.[10,30,250-254]",
                        "enabled":true,
                        "ip_ranges":[
                           [
                              174348554,
                              174348554
                           ],
                           [
                              174348574,
                              174348574
                           ],
                           [
                              174348794,
                              174348798
                           ]
                        ],
                        "includes":[
                           ""
                        ],
                        "communities":[
                           "secretCommunity",
                           "public"
                        ]
                     },
                     {
                        "excludes":[
                           ""
                        ],
                        "iftype":[
                           "ethernetCsmacd"
                        ],
                        "title":"10.100.90_discovery",
                        "ip_range_text":"include 10.100.90.[0-255]",
                        "enabled":true,
                        "ip_ranges":[
                           [
                              174348800,
                              174349055
                           ]
                        ],
                        "includes":[
                           ""
                        ],
                        "communities":[
                           "verySecretCommunity",
                           "public"
                        ]
                     }
                  ]
               }
            ],
            "type":"discover_config",
            "data_total":1
         }
      ],
      "errmsg":"ok",
      "success":true,
      "time":1518580220
   },
   "revision":"2"
}


[top]