Automate data collection with SecureCRT

Posted on April 11, 2017

0



On a network device sometimes we have to collect outputs of multiple commands that contains a counter within its output.

To get a state from those counters in outputs we must issue the commands that generates the output multiple times and we should realise if a specific counter value increasing quickly or slowly or does not change.

If those counters in the output of the commands could be visualized easily, that could take it easier to get a clear picture of the current state or issue that is described with the specific counters.

Let me show you an example. If there is a connection issue somewhere in the network and let say the most suspected part is between the switch and the server than the first thing you will check is the show interface interface name multiple times to see if a drop or error counter increases or if the input output counter changes its counters or just stopped counting.

Or if you have a Palo Alto Firewall and for some reason specific application jsut dont want to work. You can check if there is any drop or error counter that increases its value to quickly that is not usual in your network. You may know the command in cli “show counter global filter value non-zero delta yes”. With that command you see all the counters that has a value more than zero.

By filtering the command to drop and error only, the commands look like this:

“show counter global filter value non-zero delta yes | match drop”

or

“show counter global filter value non-zero delta yes | match error”

So if you have to collect the values from counters many times to analyse something, you should use a tool that collects the outputs in defined timerange and convert the outputs so that they could be easily imported in tools where the data visualisation is quick and easy.

For that purpose I choosed now securecrt and a simple excel and this is what I got quickly and easily:

As you see the global counter values are presented in excel with a quick and dirty but working way.

For that I made a new button in securecrt with a python script that collected me the data, the values of the error and drop global counters that have non-zero values, for the defined times with the defined period. Just to demonstrate it with screenshots:

1. Klick on your Button and start define the parameters

2. Lets run it

Done!

3. Copy the clipboard to notepad

4. Save the data as a csv file

5. Import the data in excel

6. Create a pivot table

7. From the pivot table create a stacked area chart.

The python script for the button for securecrt is on github Link.

If some python developer read it, please feel free to add the missing steps in python that I made with excel. I wanted to do it from Step 1 till Step 7 in python, but I have no time for it… :-(

The python script with global counters is just a beginning, I am planning to create a script that finds the variables within an output of any command and create the data, that can be easily visualised. This first script is written only for palo alto global counters and only for drop and error  counters…

Advertisement