toooki
asked on
Perl program to obtain a machine's memory usage
I am trying to use the below code to obtain the memory usage (used, unused, etc) of a machine. I need to use CPAN module (not system command like "free -m").
#myprog.pl=====
#!/usr/bin/perl
use Sys::MemInfo qw(totalmem freemem totalswap);
print "total memory: ".(&totalmem / 1024)."\n";
print "free memory: ".(&freemem / 1024)."\n";
print "total swap: ".(&totalswap / 1024)."\n";
print "free swap: ".(Sys::MemInfo::get("free swap") / 1024)."\n";
#======
But I get error that the module Sys::MemInfo does not exist. Could you please assist me to resolve the issue. It is urgent. Thank you.
#myprog.pl=====
#!/usr/bin/perl
use Sys::MemInfo qw(totalmem freemem totalswap);
print "total memory: ".(&totalmem / 1024)."\n";
print "free memory: ".(&freemem / 1024)."\n";
print "total swap: ".(&totalswap / 1024)."\n";
print "free swap: ".(Sys::MemInfo::get("free
#======
But I get error that the module Sys::MemInfo does not exist. Could you please assist me to resolve the issue. It is urgent. Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What kinds of errors?
toooki, please answer the following questions
1) Which version of Perl are you using?
2) On what platform are you running Perl?
3) What kind of errors are you getting? Please provide a screenshot of the terminal / errors
1) Which version of Perl are you using?
2) On what platform are you running Perl?
3) What kind of errors are you getting? Please provide a screenshot of the terminal / errors
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I have recommended this question be closed as follows:
Split:
-- ozo (http:#a40662893)
-- Shaji (http:#a40663295)
If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.
suhasbharadwaj
Experts-Exchange Cleanup Volunteer
I have recommended this question be closed as follows:
Split:
-- ozo (http:#a40662893)
-- Shaji (http:#a40663295)
If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.
suhasbharadwaj
Experts-Exchange Cleanup Volunteer
ASKER