menu
Setting Preferred Interfaces Programatically « US English

Setting Preferred Interfaces Programatically

SHARE ON:

With the introduction of high-speed interface reporting in SteelCentral NetProfiler and SteelCentral NetExpress (the all-in-one version of NetProfiler for small and medium enterprises), we’ve begun a new age in interface troubleshooting and monitoring! The key is to select the interfaces for which high-speed metrics are calculated. Making good decisions about the interfaces chosen is extremely important since there is a limited amount of storage space available for these metrics. While the number and type of metrics is constant no matter the quantity of interfaces chosen, the more interfaces you choose to calculate metrics for, the less historical data that will be available. Inversely, the fewer interfaces, the more historical data. Striking the correct balance between the two is critically important. Choose too many interfaces and you may not have the information you need. Choose too few interfaces and you may not have the interface you need.

There are different ways you can choose metrics for monitoring. The NetProfiler UI provides an easy-to-use approach that allows you to select the interfaces you care about, including a search option so you can easily find the proverbial interface in a haystack. Choosing interfaces is a simply matter of checking the appropriate box and applying the changes.Of course there may be times when you want to be able to dynamically update the list of interfaces. Perhaps you want to choose interfaces based on:

  • Devices that are experiencing specific criteria (such as interfaces with a certain amount of utilization)
  • Devices that have specific naming characteristics (such as with NY in the interface name)
  • Based on weekly change controls

For all of these use cases and many more, there is an easy way to automatically update the list of interfaces for which the NetProfiler generates these advanced metrics. Through the wonders of the REST API and scripting it is easy to programmatically make the necessary changes.

Let’s take the example of updating the list of selected interfaces based on percentage utilization. The script requires only a few steps:

1. Run an interface traffic report sorting by percent utilization to get a list of interfaces

2. Filter the list based on the desired percent utilization you care about (i.e. all interfaces about 90% utilized in the last day)

3. Get a list of all interfaces currently in the system (you need this so we can clean up the list and unmark interfaces we no longer care about)

4. Merge the interfaces currently in the system with the interfaces we want to mark to calculate the advanced metrics

5. PUT the new list to the NetProfiler and allow it to update the list of devices/interfaces

While not a trivial process, it is also not incredibly complex. One of the benefits of the REST API is that it is very easy to use. For example from our above steps to get the list of all interfaces on the system you can use the following command (assuming you are running Linux in this case):


curl -v --insecure -H "Content-Type: text/xml" -X GET -u <username>:<password> 
https://<netprofiler>/api/profiler/1.7/interfaces


This command returns XML output showing each interface on the device and various information about it:

<interface fast_data_tracked="true" id="406" ifalias="" ifdescr="mon3" ifindex="5" 
inbound_speed="10000000000" ipaddr="192.168.1.51" label="" mac="00:0c:29:e2:8d:d2" 
outbound_speed="10000000000"/>
<interface fast_data_tracked="true" id="2027" ifalias="" ifdescr="mon0" ifindex="6" 
inbound_speed="10000000000" ipaddr="192.168.1.51" label="" mac="00:0c:29:e2:8d:b4" 
name="cascade-express-VE" outbound_speed="10000000000"/>
<interface fast_data_tracked="true" id="4024" ifalias="" ifdescr="mon1" ifindex="7" 
inbound_speed="10000000000" ipaddr="192.168.1.51" label="" mac="00:0c:29:e2:8d:be" 
name="cascade-express-VE" outbound_speed="10000000000"/>


On the other hand once we know what interfaces we want to update we can create a file containing either JSON or XML data with the interfaces to update (JSON in this case):


[ 
    { 
        "ipaddr": "192.168.1.1", 
        "ifindex": 3,
        "fast_data_tracked": true
    }, 
    { 
        "ipaddr": "192.168.1.1", 
        "ifindex": 5,
        "fast_data_tracked": false
    }, 
    { 
        "ipaddr": "192.168.2.1", 
        "ifindex": 6,
        "fast_data_tracked": true
    }, 
    { 
        "ipaddr": "192.168.2.1", 
        "ifindex": 7, 
        "fast_data_tracked": false
    } 
]  


And then issue another curl command to PUT the data on the NetProfiler and perform the update:

 

curl -v --insecure -H "Content-Type: application/json" -X PUT --data "@data.json" -u 
<username>:<password> https://<netprofiler>/api/profiler/1.7/interfaces


Obviously to fully implement the steps outlined above would require much more code, however this covers the basics of interacting with the NetProfiler and programmatically updating the interfaces. As you can see, due to the wonders of REST, it really is a pretty simple process.

 

top.name