0

好吧,我已经为该进程挖掘了各个 OID,并且我能够获取每个 OID 的内存使用情况,但问题是我如何获得整个进程使用情况。问题是单个进程使用的 OID 是 1.3.6.1.2.1.25.5.1.1.2.X
现在 X 可以是用于识别进程的任何数字,这增加了难度,它不是按顺序排列的。例如,我可以按以下顺序拥有 OID

1.3.6.1.2.1.25.5.1.1.1.1 = 整数:971526993 1.3.6.1.2.1.25.5.1.1.1.4 = 整数:3562884 1.3.6.1.2.1.25.5.1.1.1.296 = 整数:496 1.3.6.1.2.1 .25.5.1.1.1.340 = 整数:12804 1.3.6.1.2.1.25.5.1.1.1.344 = 整数:68178 1.3.6.1.2.1.25.5.1.1.1.348 = 整数:40 1.3.6.1.2.1.25.5.1.1。 1.372 = 整数:3535 1.3.6.1.2.1.25.5.1.1.1.424 = 整数:3985009 1.3.6.1.2.1.25.5.1.1.1.436 = 整数:27875212 1.3.6.1.2.1.25.5.1.1.1.480 = 7221 整数1.3.6.1.2.1.25.5.1.1.1.592 = 整数:4820



等等 。. .

目前我的 perl 脚本是这样的:

      my ($session, $error) = Net::SNMP->session(
           -hostname  => shift || 'hostname',
              -community => shift || 'public',
      );

      if (!defined $session) {
                 printf "ERROR: %s.\n", $error;
                    exit 1;
            }
      //$OId_number will hold the OId of the particular process       
      my $result = $session->get_request(-varbindlist => [ $OID_number ],);

      if (!defined $result) {
                       printf "ERROR: %s.\n", $session->error();
                          $session->close();
                             exit 1;
       }

       printf "The Memory allocated  for process is  '%s' is %s.\n",
       $session->hostname(), $result->{$OID_number};
       $session->close();
       exit 0;
4

1 回答 1

0

使用Net::SNMP 的 get_bulk_request怎么样?您应该一次获得所有数据。

于 2012-01-16T18:39:23.030 回答