script required to get cpu and memory utlization graphs

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
sumeet_ruiwale
Posts: 4
Joined: Mon Aug 01, 2005 1:41 pm

script required to get cpu and memory utlization graphs

Post by sumeet_ruiwale »

i need a script to get cpu and memory utlization for a host which it pings to see if its alive. once we have the data it should output it in a graph , updated 5 secs. can anyone help me with that.
here is the ping script i have so far.. it takes hostnames from a file and ping to see it its alive or dead.



use Net::Ping;
use Win32::Registry;
my $Host;

my @VALID_SHARES = qw(
DFS$
CHEYUPD$
CHEYALERT$
COMCFG
);
my $Ping_Timeout = 10;
my $PingObject = Net::Ping->new( "icmp", $Ping_Timeout ) || die;
my $LogFile = $0;
$LogFile =~ s/\.[^.]*$/.log/;
if( open( LOG, "> $LogFile" ) )
{
my $BackupHandle = select( LOG );
$| = 1;
select( $BackupHandle );
}
# Check for any online hosts...
#foreach my $Host ( sumeet-d600 )

$file = "hostnames.txt";

#open( FILE, "< $file" )
open file
or die "ERROR: Couldn't open $file for reading: $!\n";

# Read input file
while (<file>)
{
#print "Line $. is : $_";
chomp;
$LINE =$_;

next if /^(\s)*$/;

my $hostname = "$LINE";
my $IP = "$LINE";
#print "Checking $IP...";
if( $PingObject->ping( $IP ) )
{

#print "alive";
#ProcessHost( $IP );

$p = Net::Ping->new();
$p->hires();
($ret, $duration, $IP) = $p->ping($hostname, 5.5);
printf("$host [hostname: $hostname ,ip : $IP] is alive (packet return time: %.2f ms)\n", 1000 * $duration)
if $ret;
$p->close();
}
else
{
print "host not reachable.";
}
print "\n";
if( fileno LOG )
{
close( LOG );
}
}
sumeet_ruiwale
Posts: 4
Joined: Mon Aug 01, 2005 1:41 pm

Post by sumeet_ruiwale »

no help?
paulbeard206
Cacti User
Posts: 150
Joined: Sat Jul 30, 2005 2:15 pm

isn't most of what you want built-in to Cacti?

Post by paulbeard206 »

Failing that, I suspect you could find something close to -- or exactly -- what you want in the forums.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests