title: SNMP V3 and Perl
body: <p>I'm trying to use SNMPget on linux to get information regarding devices on my network. I'm able to successfully use snmpget on the linux terminal but now would like to write a script in perl/python and have it do the work for me.</p>
  
  <p>SNMPget example</p>
  
  <pre><code>snmpgetnext -v 3 -n "" -u USER -a MD5 -A PASSWORD -l authNoPriv 192.168.1.1 sysDescr
  </code></pre>
  
  <p>I'm trying to do the same thing in perl, but I can't seem to find any good documentation on how to do it.
  What I found on the internet (but this is not SNMP v3):</p>
  
  <p>$cat snmp</p>
  
  <pre><code>#!/usr/bin/perl
  use Net::SNMP;
  my $desc = 'sysDescr';
  ( $session, $error ) = Net::SNMP-&gt;session(
      -hostname  =&gt; "192.168.1.1",
      -community =&gt; "public",
      -timeout   =&gt; "30",
      -port      =&gt; "161"
  );
  
  if ( !defined($session) ) {
      printf( "ERROR: %s.\n", $error );
      exit 1;
  }
  my $response = $session-&gt;get_request($desc);
  my %pdesc    = %{$response};
  
  my $err = $session-&gt;error;
  if ($err) {
      return 1;
  }
  print %pdesc;
  exit 0;
  </code></pre>
  
  <p>I tried to modify it to snmp v3 but was unable to. Anybody familiar with this?</p>