note 45540 added to function.snmprealwalk
| From: | StephenCope at osu1 dot php dot net | Date: | Fri, 10 Sep 2004 03:38:09 +0000 |
| Subject: | note 45540 added to function.snmprealwalk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76370@lists.php.net to get a copy of this message | ||
Here's a way to find the uptime and number of users on a machine. (Note that uptime is the
uptime of the snmpd daemon, which should be fairly close to the uptime for the host.)
<?php
$state = snmprealwalk($host, "public", ".1.3.6.1.2.1.25.1", 50, 1);
$uptime = ereg_replace("^.*\) ([0-9]+ .*):[0-9][0-9]\.[0-9]{2}.*$",
"\\1", $state['host.hrSystem.hrSystemUptime.0']);
$users = (int)ereg_replace("Gauge32: ", "",
$state['host.hrSystem.hrSystemNumUsers.0']);
printf('<div
class="machine"><dt>%s</dt><dd>%s</dd>', $host, $desc);
printf('<dd>up %s</dd>', $uptime);
if ( $users ) printf('<dd>%d user%s</dd>', $users, ($users > 1) ?
's' : '');
printf('</div>');
?>
----
Manual Page -- http://www.php.net/manual/en/function.snmprealwalk.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45540
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45540&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45540&report=yes
Search -- http://master.php.net/manage/user-notes.php