I'm currently working on a little script to go out and query our switches for IP thoughput, broadcast throughput, and basic utilization, and everyhting seems to be going well but for one small thing.. My system uptime that my managers want to see is being returned to me in 'ticks'. I am fairly sure there is an easy way to convert this value to a human readable stamp, but have hit the proverbial brickwall. Does anyone here know how that stamp is formatted so I can write a subroutine to convert it to 'managerese'? I'm assuming it looks something like Hours:Min:Sec:Millisec or somesuch, but I am probably wrong as usual.. I would appreciate any help you can offer! Thanks!
Here is a little snippet to fetch the system uptime for those that may not know what I referring to:
#!/usr/local/bin/perl -w
use strict;
use warnings;
use diagnostics;
use SNMP;
### Equipment Array ###
our @Equipment =
(
"10.190.16.200",
);
### Equipment Type Hash ###
our %EquipmentType =
(
"10.190.16.200" => "switch",
);
### Switch MIB Hash ###
our %SwitchMIBs =
(
"uptime" => "sysUpTime,0",
"description" => "sysDescr,0",
);
our $uptime;
our $snmp;
# Main
{
my $Equipment;
foreach $Equipment(@Equipment)
{
if ($EquipmentType{$Equipment} =~ "switch")
{
$snmp = new SNMP::Session(DestHost=> "$Equipment",
Community => 'emacs2000',
);
$uptime=$snmp->get("$SwitchMIBs{uptime}");
printf ("Uptime for $Equipment is $uptime\n");
}
}
exit;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.