<?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: snmp script question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630728#M807712</link>
    <description>&lt;BR /&gt;This noe topic appears to be a continuation of topic:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=958181" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=958181&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If you could attach a txt file with sample input and perhaps a few lines of sample output then more people will be able to try to help you.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 20 Sep 2005 19:41:28 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2005-09-20T19:41:28Z</dc:date>
    <item>
      <title>snmp script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630727#M807711</link>
      <description>I would like to have the 4 returned values from snmptest2 ending with a comma.  How can I do this.  What I have below is something "Muthukumar" asked me to do but it still doesn't appear to be quiet right.  In the nodes file, there is currently only one hostname that snmptest2 is reading.&lt;BR /&gt;&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 public system.sysName.0&lt;BR /&gt;ret1[$index]=$?","&lt;BR /&gt;snmpwalk $device public interfaces.ifTable.ifEntry.ifDescr.1&lt;BR /&gt;ret2[$index]=$?","&lt;BR /&gt;snmpwalk $device public interfaces.ifTable.ifEntry.ifAdminStatus.1&lt;BR /&gt;ret3[$index]=$?","&lt;BR /&gt;snmpwalk $device public 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 = hostname.domain.com&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;</description>
      <pubDate>Tue, 20 Sep 2005 19:21:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630727#M807711</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-09-20T19:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: snmp script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630728#M807712</link>
      <description>&lt;BR /&gt;This noe topic appears to be a continuation of topic:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=958181" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=958181&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If you could attach a txt file with sample input and perhaps a few lines of sample output then more people will be able to try to help you.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Sep 2005 19:41:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630728#M807712</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-09-20T19:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: snmp script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630729#M807713</link>
      <description>The input is this: &lt;BR /&gt;&lt;BR /&gt;A file called nodes. See the second line in the snmptest2 script above.&lt;BR /&gt;&lt;BR /&gt;In the nodes file is one line of text that is this:&lt;BR /&gt; lca-sfa-rtr1.somewhere.com&lt;BR /&gt;&lt;BR /&gt;Additional device names can be added to this nodes file once I get it working.&lt;BR /&gt;&lt;BR /&gt;The output of the script is:&lt;BR /&gt;&lt;BR /&gt;johnsonr@nmscrme01 &amp;gt; ./snmptest2&lt;BR /&gt;system.sysName.0=lca-sfa-rtr1.somewhere.com  interfaces.ifTable.ifEntry.ifDescr.1=Fa0/1&lt;BR /&gt;interfaces.ifTable.ifEntry.ifAdminStatus.1=up&lt;BR /&gt;interfaces.ifTable.ifEntry.ifOperStatus.1=down&lt;BR /&gt;johnsonr@nmscrme01 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;I would like to have a comma at the end of each of these lines so I can easily open the file as a comma seperated value file using MS excel.</description>
      <pubDate>Tue, 20 Sep 2005 20:05:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630729#M807713</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-09-20T20:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: snmp script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630730#M807714</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Ok, I have something to get you going, based on a similar problem I recently solved for myself. &lt;BR /&gt;&lt;BR /&gt;The PERL script test.pl code is below, and in the attachment.&lt;BR /&gt;&lt;BR /&gt;It is completely dynamic.&lt;BR /&gt;It reads the list of nodes from a file you can optionally specify defaulting to nodes.txt&lt;BR /&gt;It readd the list of columns from a variable you can readily edit.&lt;BR /&gt;It stores output in a file you can optionally specify defaulting to test.csv.&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;Enjoy,&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I can not do that 'snmpwalk' function on my system, so i replaced it with input data from a file. The test inputfile looked like:&lt;BR /&gt;&lt;BR /&gt;------------------------- sample snmpdata.txt ------------&lt;BR /&gt;&lt;BR /&gt;system.sysName.0=lca-sfa-rtr1.somewhere.com&lt;BR /&gt;interfaces.ifTable.ifEntry.ifDescr.1=Fa0/1&lt;BR /&gt;interfaces.ifTable.ifEntry.ifAdminStatus.1=up&lt;BR /&gt;interfaces.ifTable.ifEntry.ifOperStatus.1=down&lt;BR /&gt;system.sysName.0=lca-sfa-rtr1.elsewhere.com&lt;BR /&gt;interfaces.ifTable.ifEntry.ifDescr.1=Fa0/test&lt;BR /&gt;interfaces.ifTable.ifEntry.ifAdminStatus.1=left&lt;BR /&gt;interfaces.ifTable.ifEntry.ifOperStatus.1=right&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-------------------------- sample nodes.txt --------------------------&lt;BR /&gt;&lt;BR /&gt;lca-sfa-rtr1.somewhere.com&lt;BR /&gt;lca-sfa-rtr1.elsewhere.com&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;----- test result -----------------&lt;BR /&gt;&lt;BR /&gt;C:\sap&amp;gt;perl test.pl &amp;lt; snmpdata.txt&lt;BR /&gt;&lt;BR /&gt;C:\sap&amp;gt;type test.csv&lt;BR /&gt;system.sysName.0,interfaces.ifTable.ifEntry.ifDescr.1,interfaces.ifTable.ifEntr&lt;BR /&gt;.ifAdminStatus.1,interfaces.ifTable.ifEntry.ifOperStatus.1&lt;BR /&gt;lca-sfa-rtr1.somewhere.com,Fa0/1,up,down&lt;BR /&gt;lca-sfa-rtr1.elsewhere.com,Fa0/test,left,right&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;my @columns = qw/system.sysName.0 interfaces.ifTable.ifEntry.ifDescr.1 interfaces.ifTable.ifEntry.ifAdminStatus.1 interfaces.ifTable.ifEntry.ifOperStatus.1/;&lt;BR /&gt;my $CSV = "test.csv";&lt;BR /&gt;my $NODES = "nodes.txt";&lt;BR /&gt;#&lt;BR /&gt;use strict 'vars';&lt;BR /&gt;use Getopt::Std;&lt;BR /&gt;use vars qw/ %opt /;&lt;BR /&gt;my (%snmpwalk);&lt;BR /&gt;my ($csv, $nodes, $tmp, $i, $x, $nam, $val, $node);&lt;BR /&gt;my ($opt_d, $opt_c, $opt_n, $debug, $column, $node, $line);&lt;BR /&gt;&lt;BR /&gt;getopts ('dc:n:',\%opt) or &amp;amp;usage;&lt;BR /&gt;$debug = $opt{d} ? 1 : 0;&lt;BR /&gt;$csv = $opt{c} ? $opt{c} : $CSV;&lt;BR /&gt;$nodes = $opt{n} ? $opt{n} : $NODES;&lt;BR /&gt;sub usage()&lt;BR /&gt;    {&lt;BR /&gt;        print STDERR &amp;lt;&amp;lt; "EOF";&lt;BR /&gt;&lt;BR /&gt;    This program read a nodes files and creates a csv file with snmp values for each node.&lt;BR /&gt; &lt;BR /&gt;    usage: $0 [-d] [-c:csv_file] [-n:nodes_file]  [test-input-file-just-for-demo] &lt;BR /&gt;&lt;BR /&gt;     -d        : print debugging messages to stderr&lt;BR /&gt;     -c        : csv output file name. Default $CSV &lt;BR /&gt;     -n        : nodes input file name. Default $NODES &lt;BR /&gt;&lt;BR /&gt;EOF&lt;BR /&gt;        exit;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# temporary code to replace 'snmpwalk' which I do not have.&lt;BR /&gt;# just fakes it with an array read from STDIN&lt;BR /&gt;#&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt; chop;&lt;BR /&gt; ($nam,$val)=split /=/;&lt;BR /&gt; $node = $val if (/sysName/);&lt;BR /&gt;    $snmpwalk{$node.$nam}=$val;&lt;BR /&gt;    print "$node|$nam|$val\n" if $debug;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;open (NODES, "&amp;lt;$nodes") or die "could not open nodes file $nodes";&lt;BR /&gt;&lt;BR /&gt;open (CSV, "&amp;gt;$csv") or die "could not open scv file $csv";&lt;BR /&gt;$tmp = join(",",@columns);&lt;BR /&gt;print CSV "$tmp\n";&lt;BR /&gt;&lt;BR /&gt;while (&lt;NODES&gt;) {&lt;BR /&gt; chop;&lt;BR /&gt; $node = $_;&lt;BR /&gt; $line = "";&lt;BR /&gt; print "- $node\n" if $debug;&lt;BR /&gt; foreach $column (@columns) {&lt;BR /&gt;  $val = $snmpwalk{$node.$column}; # replace with snmpwalk code&lt;BR /&gt;  $line .=  $val . ",";&lt;BR /&gt;  print "-- $column, $val\n" if $debug;&lt;BR /&gt; }&lt;BR /&gt; chop $line;&lt;BR /&gt; print CSV $line."\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/NODES&gt;</description>
      <pubDate>Tue, 20 Sep 2005 22:19:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630730#M807714</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-09-20T22:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: snmp script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630731#M807715</link>
      <description>Use this code:&lt;BR /&gt;&lt;BR /&gt;index=0&lt;BR /&gt;for file in `ls`&lt;BR /&gt;do&lt;BR /&gt;  ls -l $file &amp;gt;/dev/null&lt;BR /&gt;  arr[$index]=$?","&lt;BR /&gt;  let index=index+1&lt;BR /&gt;done&lt;BR /&gt;echo ${arr[*]}&lt;BR /&gt;&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;  ret1[$index]=$(snmpwalk $device public system.sysName.0)&lt;BR /&gt;  ret2[$index]=$(snmpwalk $device public interfaces.ifTable.ifEntry.ifDescr.1)&lt;BR /&gt;  ret3[$index]=$(snmpwalk $device public interfaces.ifTable.ifEntry.ifAdminStatus.1)&lt;BR /&gt;  ret4[$index]=$(snmpwalk $device public interfaces.ifTable.ifEntry.ifOperStatus.1)&lt;BR /&gt;  let index=index+1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;i=0&lt;BR /&gt;while [[ $i -lt ${#ret1[*]} ]]&lt;BR /&gt;do&lt;BR /&gt;  echo ${ret1[$i]},${ret2[$i]},${ret3[$i]},${ret4[$i]}&lt;BR /&gt;  let i=i+1&lt;BR /&gt;done  &lt;BR /&gt;&lt;BR /&gt;### Problem is, $? is used to get Return code not the strings returned from there. It will work now. ###&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Wed, 21 Sep 2005 00:44:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630731#M807715</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-21T00:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: snmp script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630732#M807716</link>
      <description>See the attached text file.  I copied the updated script you provided but it still has a small problem. &lt;BR /&gt;&lt;BR /&gt;I can walk a single device but when I tried to run the script you provided against the same device, I get an snmp timeout.  &lt;BR /&gt;&lt;BR /&gt;Please take a look.  &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Sep 2005 06:49:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630732#M807716</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-09-21T06:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: snmp script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630733#M807717</link>
      <description>Message of "Timeout: No Response from lcacptc23.cpt.ca.kp.org" is a error message. I hope reachablity to lcacptc23.cpt.ca.kp.org is not working there. &lt;BR /&gt;&lt;BR /&gt;How will check reachablity to lcacptc23.cpt.ca.kp.org machine. Check like with ping as,&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;ping lcacptc23.cpt.ca.kp.org -n 1 1&amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;if [[ $? -ne 0 ]]&lt;BR /&gt;then&lt;BR /&gt;  echo "It is not reachable to lcacptc23.cpt.ca.kp.org"&lt;BR /&gt;  exit 1&lt;BR /&gt;fi&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;  ret1[$index]=$(snmpwalk $device public system.sysName.0)&lt;BR /&gt;  ret2[$index]=$(snmpwalk $device public interfaces.ifTable.ifEntry.ifDescr.1)&lt;BR /&gt;  ret3[$index]=$(snmpwalk $device public interfaces.ifTable.ifEntry.ifAdminStatus.1)&lt;BR /&gt;  ret4[$index]=$(snmpwalk $device public interfaces.ifTable.ifEntry.ifOperStatus.1)&lt;BR /&gt;  let index=index+1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;i=0&lt;BR /&gt;while [[ $i -lt ${#ret1[*]} ]]&lt;BR /&gt;do&lt;BR /&gt;echo ${ret1[$i]},${ret2[$i]},${ret3[$i]},${ret4[$i]}&lt;BR /&gt;let i=i+1&lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;Execute this script and let us know.&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Sep 2005 06:56:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630733#M807717</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-21T06:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: snmp script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630734#M807718</link>
      <description>Message of "Timeout: No Response from lcacptc23.cpt.ca.kp.org" is a error message. Try to debug that problem. Configuration with snmpd.conf is not working.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.ibr.cs.tu-bs.de/pipermail/jasmin/2002-May/000522.html" target="_blank"&gt;http://www.ibr.cs.tu-bs.de/pipermail/jasmin/2002-May/000522.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Wed, 21 Sep 2005 06:59:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630734#M807718</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-21T06:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: snmp script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630735#M807719</link>
      <description>&lt;BR /&gt;Rob, &lt;BR /&gt;&lt;BR /&gt;Did you give the perl code a try?&lt;BR /&gt;I think all you need to do is to replace the dummy snmpwalk with the real one:&lt;BR /&gt;&lt;BR /&gt;$_ = `snmpwalk $node public $column`;&lt;BR /&gt;  if (/=\s*(.*)$/) {&lt;BR /&gt;   $val = $1;&lt;BR /&gt;  } else {&lt;BR /&gt;   $val = "???";&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This also allows for spaces after the "=" in the snmpwalk output which I now see in the actual data lines in your attached text file.&lt;BR /&gt;&lt;BR /&gt;Modifies, but untested, code attached.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Sep 2005 07:15:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630735#M807719</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-09-21T07:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: snmp script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630736#M807720</link>
      <description>Correct. I didn't change the community string in the original script provided from public to what it is.  &lt;BR /&gt;&lt;BR /&gt;The perl script worked too.  I actually like it better because it writes the output directly to a .csv file.  That's the next thing I was going to request in the original script provided.  &lt;BR /&gt;&lt;BR /&gt;That's why I love this forum...when I need something like this, I always come away with a solution.&lt;BR /&gt;&lt;BR /&gt;Thanks for you guys' help on this.</description>
      <pubDate>Wed, 21 Sep 2005 09:40:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/snmp-script-question/m-p/3630736#M807720</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-09-21T09:40:53Z</dc:date>
    </item>
  </channel>
</rss>

