I want to calculate CPU Usage of aprticular process.I have calculated Memory USage and CPU Time
use Win32::Process::Info; my $pi = Win32::Process::Info->new(); my @process_information = $pi->GetProcInfo(1333); while(1){ foreach $info (@process_information) { foreach my $key (keys %{$info}) { if ($key eq "WorkingSetSize") { $value_Mem = ${$info}{$key}/1024; print "$key:=>$value_Mem \t" } if ($key eq "KernelModeTime") { $value_Ker=${$info}{$key}; print "$key:=$value_Ker \t" } if ($key eq "UserModeTime") { $value_User=${$info}{$key}; print "$key:=$value_User \t" } } $value_CPU=$value_Ker+$value_User; $value_CPU=$value_CPU/10000000; print "CPU Time :=$value_CPU\t"; print "\n" } }
In the code I have passed the process ID.Since the process id changes I want to pass the process name.Is this possible
In reply to How to calculate CPU Usage by mld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |