{"id":3730,"date":"2012-06-01T14:49:53","date_gmt":"2012-06-01T12:49:53","guid":{"rendered":"https:\/\/ingmarverheij.com\/?p=3730"},"modified":"2013-11-30T13:05:30","modified_gmt":"2013-11-30T12:05:30","slug":"powershell-query-cisco-catalyst-4500-flow-control-statistics","status":"publish","type":"post","link":"https:\/\/ingmarverheij.com\/en\/powershell-query-cisco-catalyst-4500-flow-control-statistics\/","title":{"rendered":"PowerShell: Query Cisco (Catalyst 4500) Flow Control statistics"},"content":{"rendered":"<p>Last week I attended <a href=\"https:\/\/www.e2evc.com\/\" target=\"_blank\">E2EVC<\/a> in Vienna, a non-commercial,virtualization community Event, and attended a session of <a href=\"https:\/\/de.linkedin.com\/pub\/sa%C5%A1a-ma%C5%A1i%C4%87\/20\/818\/2\" target=\"_blank\">Sa\u0161a Ma\u0161i\u0107<\/a> about an issue he had at a customer. In short, the problems where caused by a switch that couldn\u2019t process IP packets because it overflowed, and therefore <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ethernet_flow_control\" target=\"_blank\">Ethernet flow control<\/a> temporarily stopped the transmission of some attached devices. Although I\u2019m no network expert I do know this might be a serious issue. After reading <a href=\"https:\/\/virtualthreads.blogspot.nl\/2006\/02\/beware-ethernet-flow-control.html\" target=\"_blank\">this article<\/a>, you might agree.<\/p>\n<p><em>If you\u2019re looking for the PowerShell script, scroll to the bottom.<\/em><\/p>\n<h4><\/h4>\n<h4>RxPause and TxPause<\/h4>\n<p>This week I\u00a0 was asked to troubleshoot performance issues at a customer and got informed that the core switches (Cisco Catalyst 4500) might be over capacity. A quick look in the flow control statistics (<a href=\"https:\/\/www.cisco.com\/en\/US\/docs\/switches\/lan\/catalyst4500\/12.2\/31sg\/configuration\/guide\/sw_int.html\" target=\"_blank\"># show flowcontrol<\/a>) indicated there where send numerous RxPause and TxPause packages, a sign Flow Control has been active.<\/p>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n<pre heigh=\"100px\">Port       Send FlowControl  Receive FlowControl  RxPause TxPause\r\n           admin    oper     admin    oper\r\n---------  -------- -------- -------- --------    ------- -------\r\nGi1\/1      off      off      desired  on          0       0\r\nGi1\/2      off      off      desired  off         0       0\r\nGi2\/1      on       on       desired  on          0       0\r\nGi2\/2      on       on       desired  on          72982   0\r\nGi2\/3      on       on       desired  on          0       0\r\nGi2\/4      on       on       desired  on          0       0\r\n(...)\r\nPo1        Unsupp.  Unsupp.  desired  off         0       0\r\nPo2        Unsupp.  Unsupp.  desired  off         0       0\r\nPo3        Unsupp.  Unsupp.  desired  off         0       315\r\nPo4        Unsupp.  Unsupp.  desired  off         386006  12387\r\n(...)<\/pre>\n<p>Since the IOS (not to confuse with the OS on Apple devices) was recently upgraded the statistics where\u00a0 \u201cfresh\u201d. In order to troubleshoot I need to collect the metrics over a longer period from multiple (core) switches, I needed an automated solution.<\/p>\n<h4><\/h4>\n<h4>SNMP<\/h4>\n<p>The easiest (and most obvious) method would be to use SNMP to query the statistics. I found it the \u201ceasiest\u201d way of finding the correct OID by \u201cwalking\u201d the values (querying all exposed values) and match it with the values I found in the terminal session (# show flowcontrol).. In short, it wasn\u2019t exposed.<\/p>\n<p>&nbsp;<\/p>\n<h4>PowerShell<\/h4>\n<p>I needed an automated solution that queried multiple switches and store to a file it so I can analyze the data later. Since it temporary I didn\u2019t find it necessary to store it in a SQL database, a comma-separated-file (CSV) would be just fine (if you need to store it in SQL, contact me).<\/p>\n<p><em>I\u2019ve localized the \u2018comma\u2019 in the comma-separated-file since this is different in some countries. A Dutch operating system for instance has a semicolon.<\/em><\/p>\n<p>The IOS on the core switches didn\u2019t have cryptography so I was unable to use SSH, therefore I used telnet to connect to the switches.<\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"download\">Download<\/h2>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"Version 1.0\" href=\"https:\/\/ingmarverheij.com\/en\/download\/5823\/?tmstv=1776457276\" rel=\"nofollow\" id=\"download-link-5823\" data-redirect=\"false\" >\n\tFlowControl.ps1<\/a>\n\n<p>&nbsp;<\/p>\n<p><strong>Usage<\/strong>: FlowControl.ps1 \u2013remoteHost [\u2013remotePort] [\u2013username] \u2013password\u00a0 [-enablePassword]\u00a0 [-timeout]<\/p>\n<ul>\n<li>remoteHost\u00a0 : <em>The host where to connect to (FQDN or IP)<\/em><\/li>\n<li>remotePort (optional): <em>The port to connect to (default 23)<\/em><\/li>\n<li>username (optional) : <em>The user to authenticate with (default: admin)<\/em><\/li>\n<li>password:\u00a0 <em>The password to authenticate with<\/em><\/li>\n<li>enablePassword (optional): <em>The enable password (default equal to password)<\/em><\/li>\n<li>timeout (optional): <em>The timeout in seconds for each action (default 30)<\/em><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4>Credits<\/h4>\n<p><em>The wheel is round, we all know that, so why should I reinvent it? <\/em>I used a PowerShell script to do an <a href=\"https:\/\/gsexdev.blogspot.nl\/2006\/09\/doing-smtp-telnet-test-with-powershell.html#!\/2006\/09\/doing-smtp-telnet-test-with-powershell.html\" target=\"_blank\">SNMP telnet test<\/a> from Glen Scales and worked from there. Appending data to a CSV file is by default not possible, so I\u2019ve used the <a href=\"https:\/\/dmitrysotnikov.wordpress.com\/2010\/01\/19\/export-csv-append\/\" target=\"_blank\">altered function<\/a> from Dmitry Sotnikov.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week I attended E2EVC in Vienna, a non-commercial,virtualization community Event, and attended a session of Sa\u0161a Ma\u0161i\u0107 about an issue he had at a customer. In short, the problems where caused by a switch that couldn\u2019t process IP packets because it overflowed, and therefore Ethernet flow control temporarily stopped the transmission of some attached [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[152],"tags":[453,454,672,352],"class_list":["post-3730","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-cisco","tag-flow-control","tag-powershell","tag-statistics"],"_links":{"self":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/3730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/comments?post=3730"}],"version-history":[{"count":6,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/3730\/revisions"}],"predecessor-version":[{"id":5888,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/3730\/revisions\/5888"}],"wp:attachment":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/media?parent=3730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/categories?post=3730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/tags?post=3730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}