hello,

I am trying to convert a php script into a rails script. I came accross
snmpset() and snmpget() functions and I am stuck here.

Here is a part of the php script. Please help me in converting these two
functions.

$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
gd_portal_apc_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;


Any help will be extremely appreciated. Thanks in advance:)
-- 
Posted via http://www.ruby-forum.com/.
-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to