LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   perl script to monitor ubuntu linux computer resources (http://www.linuxquestions.org/questions/linux-newbie-8/perl-script-to-monitor-ubuntu-linux-computer-resources-734783/)

mokona 06-22-2009 11:05 AM

perl script to monitor ubuntu linux computer resources
 
Hi,

I badly need help. Does anyone know any documentation I can refer to about monitoring the computer resources of an ubuntu linux machine (memory [RAM], hard disk, and cpu utilization). I need to make a perl script that would be able to give me the amount of how much these computer resources were used. pls help.

jstephens84 06-22-2009 11:10 AM

Quote:

Originally Posted by mokona (Post 3582405)
Hi,

I badly need help. Does anyone know any documentation I can refer to about monitoring the computer resources of an ubuntu linux machine (memory [RAM], hard disk, and cpu utilization). I need to make a perl script that would be able to give me the amount of how much these computer resources were used. pls help.

I would go with a batch script.

For memory use something like
Code:

free -m
for hard disk you can use
Code:

df -h // the -h is for human readable format
for cpu utilization you can use the top command I think there is an snapshot tag so that it won't go into realtime mode. Also for a deeper disk information look into using du it can give you a display of how much each directory is using in terms of space. Here is an example of du

if you run this from / it will give /, /root , /usr , /etc, /tmp, /var, /boot, /sbin, /bin
Code:

du -c -h --max-depth=1

mokona 06-22-2009 11:46 AM

Quote:

Originally Posted by jstephens84 (Post 3582408)
I would go with a batch script.

For memory use something like
Code:

free -m
for hard disk you can use
Code:

df -h // the -h is for human readable format
for cpu utilization you can use the top command I think there is an snapshot tag so that it won't go into realtime mode. Also for a deeper disk information look into using du it can give you a display of how much each directory is using in terms of space. Here is an example of du

if you run this from / it will give /, /root , /usr , /etc, /tmp, /var, /boot, /sbin, /bin
Code:

du -c -h --max-depth=1

ohh.. soo.. it basically displays it right? uhmm.. I was trying to make a code that would get the computer resources from the linux machine.. then it would give the result to a celphone, then it would display the result on the screen of the celphone. Do you have any idea how to do that?

jstephens84 06-22-2009 11:50 AM

Quote:

Originally Posted by mokona (Post 3582456)
ohh.. soo.. it basically displays it right? uhmm.. I was trying to make a code that would get the computer resources from the linux machine.. then it would give the result to a celphone, then it would display the result on the screen of the celphone. Do you have any idea how to do that?

So kind of like a sms message to your phone. Hmmm... well you will have to interface with your phoneswitch for that or some outside entity that will send sms messages to your phone. Probablly what you will need to do is take the commands form above put in a script of some sorts then have all the commands output to a respective variable then echo the variables values as the message.

jstephens84 06-22-2009 11:53 AM

found this for you. It looks pretty promosing and has a way to send messages from bash to a sms and curl.

**edit

oops would help if I included the link.
http://aql.com/site/sms-bashscript.php

mokona 06-22-2009 12:20 PM

Quote:

Originally Posted by jstephens84 (Post 3582462)
found this for you. It looks pretty promosing and has a way to send messages from bash to a sms and curl.

**edit

oops would help if I included the link.
http://aql.com/site/sms-bashscript.php

alright.. i'll try it. thanks for the help! :)

jstephens84 06-22-2009 12:26 PM

no problem. post back if it works or don't work and try and include your script if we need to work on things more.

chrism01 06-22-2009 06:52 PM

For collecting Linux stats: http://search.cpan.org/~bloonix/Sys-...stics/Linux.pm


All times are GMT -5. The time now is 07:51 AM.