title: pysnmp - get output from NET-SNMP-EXTEND-MIB extend script?
body: <p>How can I properly invoke an SNMP extend script by MIB with pysnmp 4.3?</p>
  
  <p>I have this entry in the remote server's snmpd.conf file:</p>
  
  <pre><code>extend check_fd_wap /app/users/nagios_checks/check_fd_wap.sh
  </code></pre>
  
  <p>which in turn can be invoked by:</p>
  
  <pre><code>snmpwalk -t 60 -v2c -c greendale remoteserver 'NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."check_fd_wap"'
  NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."check_fd_wap" = STRING: { "sys_inuse" : 32640, "proc_data" : {  "ssl-mmsib" : { "proc_used" : 22, "proc_limit" : 200000 } , (...) }
  </code></pre>
  
  <p>In pysnmp I'm trying to invoke MIB <code>NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."check_fd_wap"</code> using the sample code:</p>
  
  <pre><code>errorIndication, errorStatus, errorIndex, varBinds = next(
      getCmd(SnmpEngine(),
          CommunityData(community, mpModel=1),
          UdpTransportTarget((hostname, port)),
          ContextData(),
          ObjectType(ObjectIdentity('NET-SNMP-EXTEND-MIB','nsExtendOutput1Line','check_fd_wap')))
  )
  
  for varBind in varBinds:
      print(' = '.join([x.prettyPrint() for x in varBind]))
  </code></pre>
  
  <p>However, this fails with the <code>'DisplayString' failed to cast value OctetString</code> error message:</p>
  
  <pre><code>raise SmiError('MIB object %r having type %r failed to cast value %r: %s' % (self.__args[0].prettyPrint(), self.__args[0].getMibNode().getSyntax().__class__.__name__, self.__args[1], sys.exc_info()[1]))
  ;SmiError: MIB object u'NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.check_fd_wap' having type 'DisplayString' failed to cast value OctetString('{ "sys_inuse" (...)"" at DisplayString
  </code></pre>
  
  <p>However, calling it with the translated OID works fine (<code>'.1.3.6.1.4.1.8072.1.3.2.3.1.1.12.99.104.101.99.107.95.102.100.95.119.97.112'</code>).</p>
  
  <pre><code>SNMPv2-SMI::enterprises.8072.1.3.2.3.1.1.12.99.104.101.99.107.95.102.100.95.119.97.112 = { "sys_inuse" : 31110, "proc_data" : {  "ssl-mmsib" : { "proc_used" : 19, "proc_limit" : 200000 } } }
  </code></pre>
  
  <p><strong>What is the reason for this error?</strong></p>
  
  <p>Also, if I invoke the getCmd with the full <code>MIB NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.check_fd_wap</code> as one argument, I get the error:</p>
  
  <pre><code>pysnmp.smi.error.NoSuchObjectError: NoSuchObjectError({'str': 'Can\'t resolve node name ::(\'NET-SNMP-EXTEND-MIB::nsExtendOutput1Line\', \'"check_fd_wap"\') at &lt;pysnmp.smi.view.MibViewController instance at 0x2989638&gt;'})
  </code></pre>
  
  <p><strong>Is it possible to invoke the SNMP get with the full MIB in one string?</strong></p>