Note that there are some explanatory texts on larger screens.

plurals
  1. POCloud9 and snmpjs
    text
    copied!<p>I am currently trying to get the basic example code working for the node.js library node-snmpjs in the c9.io development environment.</p> <p>The example code is here: </p> <p><a href="https://github.com/wesolows/node-snmpjs" rel="nofollow">https://github.com/wesolows/node-snmpjs</a> or </p> <p><a href="https://npmjs.org/package/snmpjs" rel="nofollow">https://npmjs.org/package/snmpjs</a></p> <pre><code>var os = require('os'); var snmp = require('snmpjs'); var logger = require('bunyan'); var log = new logger({ name: 'snmpd', level: 'info' }); var agent = snmp.createAgent({ log: log }); agent.request({ oid: '.1.3.6.1.2.1.1.5', handler: function (prq) { console.log("Request received"); var nodename = os.hostname(); var val = snmp.data.createData({ type: 'OctetString', value: nodename }); snmp.provider.readOnlyScalar(prq, val); } }); agent.bind({ family: 'udp4', port: 161 }); </code></pre> <p>I've tried changing the bind port to: parseInt(process.env.PORT)</p> <p>When I try to execute an snmpget against the address and port that c9 spits out on run, it fails. I've also tried :8080. 8080 is what c9's console output always says is is mapped to process.env.PORT. I've also tried port 80 in the snmpget.</p> <p>As a fallback, I've also tried making a basic telnet, socket connection using c9 and can't get it to work... It seems like the root problem may be that I don't know what IP and port is being used.</p> <p>------------------------- EDIT ------------------------</p> <p>I've tried the following variations on the agent.bind line:</p> <pre><code>agent.bind({ family: 'udp4', port: parseInt(process.env.PORT), addr: process.env.IP}); </code></pre> <p>and</p> <pre><code>agent.bind({ family: 'udp4', port: 17000, addr: process.env.IP}); </code></pre> <p>Output:</p> <pre><code>Your code is running at 'http://node-dev1.thaspius.c9.io'. Important: use 'process.env.PORT' as the port and 'process.env.IP' as the host in your scripts! "127.12.254.129:17000" ex-c9-node47.prod.rhcloud.com {"name":"snmpd","hostname":"ex-c9-node47.prod.rhcloud.com","pid":32758,"component":"snmp-agent","level":30,"msg":"Bound to 127.12.254.129:17000","time":"2013-07-31T17:59:56.376Z","v":0} </code></pre> <p>snmpget result:</p> <pre><code>snmpget -v 2c -c any 127.12.254.129:17000 .1.3.6.1.2.1.1.5 Timeout: No Response from 127.12.254.129:17000. snmpget -v 2c -c any ex-c9-node47.prod.rhcloud.com:17000 .1.3.6.1.2.1.1.5 Timeout: No Response from ex-c9-node47.prod.rhcloud.com:17000. snmpget -v 2c -c any node-dev1.thaspius.c9.io:17000 .1.3.6.1.2.1.1.5 Timeout: No Response from node-dev1.thaspius.c9.io:17000. </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload