Shell script for logging cpu and memory usage of a Linux process
I am looking for a way to log and graphically display cpu and RAM usage of linux processes over time. Since I couldn't find a simple tool to so (I tried zabbix and munin but installation failed) I started writing a shell script to do so
The script file parses the output of top command through awk and logs into a csv file. It
1. Figures out the pid of the processes through ps command
2. Uses top and awk to log cpu and memory usage.
Here is how the script looks like
How do I
1. Print the resource usage for multiple processes. Specifying multiple variables in the awk pattern is not working. It prints the usage for the first pid (redis in the above script)
2. Print current timestamp when printing the resource details (through date +"%T")
3. Print the process name along with the resource usage. Redis, Logstash, ElasticSearch or Kibana in the above case
4. Redirect the above commands output to a log file. I tried > $LOG_FILE but it didn't work.
Thoughts/Inputs?
I'm a newbie to shell scripting, I was given this script to modify. This script that monitors when CPU Usage is too high based off the top command. The comparison is not working as it should. Its comparing a decimal to a regualar interger. When it send me an email, it send an email and ignores the... (21 Replies)
Hi all
I was wondering if its possible to write a script to keep CPU usage at 90%-95%? for a single cpu linux server?
I have a perl script I run on servers with multple cpu's and all I do is max all but one cpu to get into the 90'% utilised area. I now need a script that raises the CPU to... (4 Replies)
Hi all
can any one help me to script monitoring
CPU load avg when reaches threshold value
and disk usage if it exceeds some %
tried using awk but when df -h out put is in two different lines awk doesnt work for the particular output in two different line ( output for df -h is in two... (7 Replies)
I don't know when the process will start and end, I need write a script to trace it's cpu/memory usage when it is runing. How to write this script? (2 Replies)
Hi,
By using time command we can determine the execution time of a process or command.
bash-2.04$ time ls -l
total 0
-rw-r--r-- 1 admin tac 0 Oct 6 04:46 file1
-rw-r--r-- 1 admin tac 0 Oct 6 04:46 file2
real 0m0.002s
user 0m0.000s
sys 0m0.001s... (5 Replies)
Hi,
I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP.
I want the oids for above tasks.
can you please tell me that
Thank you (2 Replies)
how can I find cpu usage memory usage swap usage and
I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times
my final destination is monitor process
logical volume usage above X % and number of Logical voluage above
can I not to... (3 Replies)
Hi All,
Does anyone know what the best commands in the UNIX command line are for obtaining this info:
current CPU usage
memory usage
virtual memory usage
preferably with date and time parameters too?
thanks
ocelot (4 Replies)
how can i monitor usages of CPU, Memory, Hard disk etc. under SUN Solaries
through a c program or java program
i want to store that data into database so i can show it graphically
thanks in advance (2 Replies)