<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: OK... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629528#M807733</link>
    <description>The snmpget values I have in right now are just for testing purposes.  I will change them when I found out exactly what to enter to get what I'm looking for for everything I want to get back. For now, I'm using sysName, one interfaces description, it's admin and oper status.  &lt;BR /&gt;&lt;BR /&gt;The script and the output when I run the script are below.  I only have one device in the nodes file I'm cat 'ing' out for simplicity.  &lt;BR /&gt;&lt;BR /&gt;It doesn't look like each value returned is putting a comma in.  Any ideas?&lt;BR /&gt;&lt;BR /&gt;johnsonr@nmscrme01 &amp;gt;  cat snmptest2&lt;BR /&gt;index=0&lt;BR /&gt;for device in `cat /opt/home/johnsonr/scripts/nodes`&lt;BR /&gt;do&lt;BR /&gt;snmpwalk $device VER143r system.sysName.0&lt;BR /&gt;ret1[$index]=$?","&lt;BR /&gt;snmpwalk $device VER143r interfaces.ifTable.ifEntry.ifDescr.1&lt;BR /&gt;ret2[$index]=$?","&lt;BR /&gt;snmpwalk $device VER143r interfaces.ifTable.ifEntry.ifAdminStatus.1&lt;BR /&gt;ret3[$index]=$?","&lt;BR /&gt;snmpwalk $device VER143r interfaces.ifTable.ifEntry.ifOperStatus.1&lt;BR /&gt;ret4[$index]=$?","&lt;BR /&gt;let index=index+1&lt;BR /&gt;done&lt;BR /&gt;johnsonr@nmscrme01 &amp;gt;  ./snmptest2&lt;BR /&gt;system.sysName.0 = lcacptc18-mob1.2.cpt.ca.kp.org&lt;BR /&gt;interfaces.ifTable.ifEntry.ifDescr.1 = FastEthernet0/1&lt;BR /&gt;interfaces.ifTable.ifEntry.ifAdminStatus.1 = up(1)&lt;BR /&gt;interfaces.ifTable.ifEntry.ifOperStatus.1 = down(2)&lt;BR /&gt;johnsonr@nmscrme01 &amp;gt; &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 20 Sep 2005 08:07:21 GMT</pubDate>
    <dc:creator>Rob Johnson_3</dc:creator>
    <dc:date>2005-09-20T08:07:21Z</dc:date>
    <item>
      <title>OK...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629523#M807728</link>
      <description>I want to put a script together that will do this:&lt;BR /&gt;1. Read the Cisco devices from a file I create: &lt;BR /&gt;host1.domain.com&lt;BR /&gt;host2.domain.com&lt;BR /&gt;host3.domain.com&lt;BR /&gt;2. For each device in this list do snmpgets to get:&lt;BR /&gt;     a. how many ports for each device&lt;BR /&gt;     b. a port description for each port&lt;BR /&gt;     c. the oper status for each port&lt;BR /&gt;     d. the admin status for each port&lt;BR /&gt;     e. the last change status for each port&lt;BR /&gt;3. I want the output to be in a CSV format so the file can be opened with excel. I could then place a., b., c., d. and e. in seperate columns.  If there are 48 ports on a switch, there would be 48 rows and 5 columns for each row.&lt;BR /&gt;&lt;BR /&gt;Can you guys help me get started?</description>
      <pubDate>Mon, 19 Sep 2005 18:16:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629523#M807728</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-09-19T18:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: OK...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629524#M807729</link>
      <description>&lt;A href="http://search.cpan.org/~maxb/SNMP-Info-0.9.0/" target="_blank"&gt;http://search.cpan.org/~maxb/SNMP-Info-0.9.0/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Is a perl SNMP module that has support for Cisco routers:&lt;BR /&gt;&lt;A href="http://search.cpan.org/author/MAXB/SNMP-Info-0.9.0/Info/Layer3/Cisco.pm" target="_blank"&gt;http://search.cpan.org/author/MAXB/SNMP-Info-0.9.0/Info/Layer3/Cisco.pm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;There are quite a few perl modules that deal with Cisco:&lt;BR /&gt;&lt;A href="http://search.cpan.org/search?query=Cisco&amp;amp;mode=all" target="_blank"&gt;http://search.cpan.org/search?query=Cisco&amp;amp;mode=all&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://search.cpan.org/search?query=Cisco+SNMP&amp;amp;mode=all" target="_blank"&gt;http://search.cpan.org/search?query=Cisco+SNMP&amp;amp;mode=all&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 19 Sep 2005 19:35:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629524#M807729</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-09-19T19:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: OK...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629525#M807730</link>
      <description>Here's a start.&lt;BR /&gt;I don't know exactly what snmp commands you would run for "snmpgets" nor the actual snmp command request codes.&lt;BR /&gt;So, I just used "snmpgets" for the command and dummy command codes "sn_desc", "sn_ostat", etc.&lt;BR /&gt;You'll have to flesh it out with actual commands and codes&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;#------------&lt;BR /&gt;echoopt=""  # for bash compatibility&lt;BR /&gt;cat /tmp/dev_list \&lt;BR /&gt;| while read dev trash&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;# headers&lt;BR /&gt;echo $echoopt "$dev,pnum,desc,ostat,astat,cstat"&lt;BR /&gt;nport=$(snmpgets $dev num_ports )&lt;BR /&gt;#nport=3  # for testing&lt;BR /&gt;&lt;BR /&gt;p=0&lt;BR /&gt;while [ $p -lt $nport ]&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;echo $echoopt ",$p\c" ;&lt;BR /&gt;&lt;BR /&gt;for sn_req in \&lt;BR /&gt;sn_desc \&lt;BR /&gt;sn_ostat \&lt;BR /&gt;sn_astat \&lt;BR /&gt;sn_cstat \&lt;BR /&gt;# end snmp req commands&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;result=$(snmpgets $dev sn_req )&lt;BR /&gt;#result="$sn_req" # for testing&lt;BR /&gt;echo $echoopt ",\"$result\"\c"&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;echo # get rid of last \c&lt;BR /&gt;&lt;BR /&gt;p=$(($p+1))&lt;BR /&gt;done&lt;BR /&gt;done&lt;BR /&gt;#------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth&lt;BR /&gt;bv</description>
      <pubDate>Mon, 19 Sep 2005 20:11:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629525#M807730</guid>
      <dc:creator>Bob_Vance</dc:creator>
      <dc:date>2005-09-19T20:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: OK...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629526#M807731</link>
      <description>for device in `cat /opt/home/johnsonr/scripts/nodes`&lt;BR /&gt;do&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifIndex.0&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifDescr.0&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifAdminStatus.0&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifOperStatus.0&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifDescr.0&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifLastChange.0&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I couldnâ  t really understand everything in the script given by Mr. Vance so I think Iâ  m going to have to do something like this.  I wasnâ  t made to be a programmer so I have to stay very simple. &lt;BR /&gt;&lt;BR /&gt;How can I separate the returned value on each line  with a comma?&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Sep 2005 06:10:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629526#M807731</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-09-20T06:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: OK...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629527#M807732</link>
      <description>You can collect return values as,&lt;BR /&gt;&lt;BR /&gt;index=0&lt;BR /&gt;for device in `cat /opt/home/johnsonr/scripts/nodes`&lt;BR /&gt;do&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifIndex.0&lt;BR /&gt;ret1[$index]=$?","&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifDescr.0&lt;BR /&gt;ret2[$index]=$?","&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifAdminStatus.0&lt;BR /&gt;ret3[$index]=$?","&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifOperStatus.0&lt;BR /&gt;ret4[$index]=$?","&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifDescr.0&lt;BR /&gt;ret5[$index]=$?&lt;BR /&gt;snmpget $device public interfaces.ifTable.ifEntry.ifLastChange.0&lt;BR /&gt;ret6[$index]=$?&lt;BR /&gt;let index=index+1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;# Return value&lt;BR /&gt;echo ${ret1[*]}&lt;BR /&gt;echo ${ret2[*]}&lt;BR /&gt;echo ${ret3[*]}&lt;BR /&gt;echo ${ret4[*]}&lt;BR /&gt;echo ${ret5[*]}&lt;BR /&gt;echo ${ret6[*]}&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Tue, 20 Sep 2005 06:23:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629527#M807732</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-20T06:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: OK...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629528#M807733</link>
      <description>The snmpget values I have in right now are just for testing purposes.  I will change them when I found out exactly what to enter to get what I'm looking for for everything I want to get back. For now, I'm using sysName, one interfaces description, it's admin and oper status.  &lt;BR /&gt;&lt;BR /&gt;The script and the output when I run the script are below.  I only have one device in the nodes file I'm cat 'ing' out for simplicity.  &lt;BR /&gt;&lt;BR /&gt;It doesn't look like each value returned is putting a comma in.  Any ideas?&lt;BR /&gt;&lt;BR /&gt;johnsonr@nmscrme01 &amp;gt;  cat snmptest2&lt;BR /&gt;index=0&lt;BR /&gt;for device in `cat /opt/home/johnsonr/scripts/nodes`&lt;BR /&gt;do&lt;BR /&gt;snmpwalk $device VER143r system.sysName.0&lt;BR /&gt;ret1[$index]=$?","&lt;BR /&gt;snmpwalk $device VER143r interfaces.ifTable.ifEntry.ifDescr.1&lt;BR /&gt;ret2[$index]=$?","&lt;BR /&gt;snmpwalk $device VER143r interfaces.ifTable.ifEntry.ifAdminStatus.1&lt;BR /&gt;ret3[$index]=$?","&lt;BR /&gt;snmpwalk $device VER143r interfaces.ifTable.ifEntry.ifOperStatus.1&lt;BR /&gt;ret4[$index]=$?","&lt;BR /&gt;let index=index+1&lt;BR /&gt;done&lt;BR /&gt;johnsonr@nmscrme01 &amp;gt;  ./snmptest2&lt;BR /&gt;system.sysName.0 = lcacptc18-mob1.2.cpt.ca.kp.org&lt;BR /&gt;interfaces.ifTable.ifEntry.ifDescr.1 = FastEthernet0/1&lt;BR /&gt;interfaces.ifTable.ifEntry.ifAdminStatus.1 = up(1)&lt;BR /&gt;interfaces.ifTable.ifEntry.ifOperStatus.1 = down(2)&lt;BR /&gt;johnsonr@nmscrme01 &amp;gt; &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Sep 2005 08:07:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629528#M807733</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-09-20T08:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: OK...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629529#M807734</link>
      <description>OK (;&amp;gt;)&lt;BR /&gt;&lt;BR /&gt;I'll explain my script a little bit.&lt;BR /&gt;&lt;BR /&gt;NOTE1:&lt;BR /&gt;In general, it's better to do an in-line read of a file to get values as I did with with the&lt;BR /&gt;&lt;BR /&gt;cat file| while read ...&lt;BR /&gt;&lt;BR /&gt;loop, than to do the&lt;BR /&gt;&lt;BR /&gt;for x in `cat file`&lt;BR /&gt;&lt;BR /&gt;loop that you did.&lt;BR /&gt;Using `...` means that all of the file's contents would be placed in-line on 'for x' command as arguments as if you had typed it there.&lt;BR /&gt;What if the file were huge (in solving some other problem)??&lt;BR /&gt;On older versions of HPUX, the shell would overflow with not really much argument data.&lt;BR /&gt;True, the current shell can take much more (I think that it is 32meg, now), but I still think the "read" loop is better and cleaner.&lt;BR /&gt;Plus you could have a very complicated set of commands piped together ultimately piping into the 'while read' and it is visually  more "readable' (no pun intended) this way.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;NOTE2:&lt;BR /&gt;The shell 'read' command that I used places the next line of input into the variable(s) that you specify in the command.  Each "word" on the line goes into the next-mentioned variable.  When it runs out of your specified variable names, it puts the rest of the line into the last variable.&lt;BR /&gt;That's why I used 2 variables:&lt;BR /&gt;read device trash&lt;BR /&gt;.&lt;BR /&gt;If a line contained a hostname and then some additional stuff after it, such as comments, or whatever, then the "device" variable would have only the first word, while "trash" has the rest of the line.&lt;BR /&gt;The same result could be achieved via:&lt;BR /&gt;&lt;BR /&gt;cat file \&lt;BR /&gt;| awk '{print $1}' \&lt;BR /&gt;|while read ....&lt;BR /&gt;&lt;BR /&gt;or even&lt;BR /&gt;&lt;BR /&gt;awk &amp;lt; file '{print $1}' \&lt;BR /&gt;|while read ....&lt;BR /&gt;&lt;BR /&gt;but I just wanted to show the above technique.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;NOTE3:&lt;BR /&gt;If you want to see what my script outputs:&lt;BR /&gt;. change the host file name from "/tmp/dev_list" to your actual file&lt;BR /&gt;. uncomment the 2 "for testing" lines&lt;BR /&gt;. comment the line preceding the 2 "for testing" lines.&lt;BR /&gt;)))&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;There are 3 loops:&lt;BR /&gt;&lt;BR /&gt;------&lt;BR /&gt;loop1: reads the device_hostname_file&lt;BR /&gt;&lt;BR /&gt;for each device from loop 1,&lt;BR /&gt;&lt;BR /&gt;. print out a CSV header line:&lt;BR /&gt;"&lt;DEVICE name=""&gt;,pnum,desc,ostat,astat,cstat"&lt;BR /&gt;(You would change these header names to your taste.&lt;BR /&gt;)&lt;BR /&gt;. get the number of ports on the device by some means -- I just had a dummy "snmpgets".&lt;BR /&gt;There may not be a simple "get_number_of_ports" snmp get command.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-----&lt;BR /&gt;loop2: loop thru the ports (0 thru number-1 from previous "get_number_of_ports" get).&lt;BR /&gt;&lt;BR /&gt;for each port, get the 4 pieces of info you wanted via *another* loop&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-----&lt;BR /&gt;loop3:&lt;BR /&gt;for each info you wanted, do a snmpget to obtain it:&lt;BR /&gt;sn_desc \&lt;BR /&gt;sn_ostat \&lt;BR /&gt;sn_astat \&lt;BR /&gt;sn_cstat \&lt;BR /&gt;These are just dummy snmpget command codes that I made up.  You would have to substitute an actual snmpget and proper request code to obtain it.&lt;BR /&gt;&lt;BR /&gt;Since this info is obtained by 4 different commands and we want to display them as CSV on one line, I 'echo'ed the results obtained with the "continuation" option (\c").&lt;BR /&gt;so each port line out looks like:&lt;BR /&gt;&lt;BR /&gt;,&lt;PORT_NUM&gt;,"p_desc","p_ostat","p_astat","p_cstat"&lt;BR /&gt;&lt;BR /&gt;where each "p_item" is the results obtained from the snmpgets for that item.&lt;BR /&gt;Notice that the device_name column is empty.&lt;BR /&gt;&lt;BR /&gt;Unfortunately, I don't have access to any snmp devices nor an OpenView system, so I can't flesh out any of the SNMP stuff.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth&lt;BR /&gt;bv&lt;BR /&gt;&lt;BR /&gt;&lt;/PORT_NUM&gt;&lt;/DEVICE&gt;</description>
      <pubDate>Wed, 21 Sep 2005 11:29:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok/m-p/3629529#M807734</guid>
      <dc:creator>Bob_Vance</dc:creator>
      <dc:date>2005-09-21T11:29:53Z</dc:date>
    </item>
  </channel>
</rss>

