Re: SNMP in rails



Miroslaw Niegowski wrote:
Hello,
You should use: net/snmp library for ruby and get and set methods of
SNMP
Manager.
http://snmplib.rubyforge.org/
I'm guessing that the first snmpset command is used to reset port status
(i
is iterator - you can have
many ports to reset - just a guess).
The second command snmpget is used to read port reset status.
Could you provide more source code ?



2010/1/18 Atheeq Pasha <atheeq@xxxxxxxxxxxx>

Thank you very much..
I am using snmp library of ruby but need to pass the snmpset php
function's parameter to the SNMP Manager set and get functions.

Here is a part of the php code

global $pdb;
$oid = '1.3.6.1.4.1.318.1.1.12.3.3.1.1.4';
$toret = false;
if($pdb->connected) {
$query = "SELECT snmp_community_str, address, reset_port FROM
remote_reboot WHERE device_id=$device_id";
if($result = $pdb->query($query)) {
if($pdb->num_rows($result)) {
$row = $pdb->get_row($result);
snmpset($row['address']$row['snmp_community_str'],$oid.".".$row['reset_port'],'i','3');
$count = 0;
while($count < 20 && $toret == false) {
$status =
snmpget($row['address'],$row['snmp_community_str'],$oid.".".$row['reset_port']);
if($status == 'INTEGER: 2' || $status == 'INTEGER: 3') {
sleep(1);
$count++;
} else if($status == 'INTEGER: 1') {
$toret = true;
} else {
$_SESSION['reboot_error'] = 'The server could not be
rebooted because a proper reboot command could not be issued.';
$count = 20;
}
}
if($count == 10) {
$_SESSION['reboot_error'] = 'Timed out waiting for reboot
confirmation.';
}
} else {
$_SESSION['reboot_error'] = "Unable to locate APC for this
server";
}
$pdb->free_result($result);
} else {
$_SESSION['reboot_error'] = "Unable to locate APC for this
server";
}
}
return $toret;

Thanks in advance:)
--
Posted via http://www.ruby-forum.com/.

.



Relevant Pages

  • Re: How do I get the port on a switch that a PC is connected to.
    ... With SNMP there are two distinct concepts. ... "the command tcpConnLocalPort" - you ... If the switch maintains this information, you are in luck and you can ... The advantage of this method is you can directly get the port of the ...
    (comp.protocols.snmp)
  • Writing SNMP Manager using SNMP4J
    ... Send snmp commands to snmp-agents, and handle thier response. ... for sending a snmp command and for receiving snmp traps. ... receiving of PDUs. ...
    (comp.protocols.snmp)
  • Re: SNMP with PB 4.2 - test sample not being built ?
    ... Because if I add it there my platform nk.bin will not be ... >Basically what you're missing is snmp_snmptestmib showing ... >other SNMP components? ... Did also a command like ...
    (microsoft.public.windowsce.platbuilder)