Re: SNMP in rails
- From: Atheeq Pasha <atheeq@xxxxxxxxxxxx>
- Date: Mon, 18 Jan 2010 10:50:18 -0500
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/.
.
- Follow-Ups:
- Re: SNMP in rails
- From: Miroslaw Niegowski
- Re: SNMP in rails
- References:
- SNMP in rails
- From: Atheeq Pasha
- Re: SNMP in rails
- From: Miroslaw Niegowski
- SNMP in rails
- Prev by Date: Re: What does ||= represent in this situation?
- Next by Date: Re: basic question: passing a modifiable argument to a routine
- Previous by thread: Re: SNMP in rails
- Next by thread: Re: SNMP in rails
- Index(es):
Relevant Pages
|