Sponsored Content
Full Discussion: Monitor Memory of a process
Top Forums UNIX for Dummies Questions & Answers Monitor Memory of a process Post 302335257 by DeCoTwc on Saturday 18th of July 2009 01:57:46 AM
Old 07-18-2009
This is something I through together once when I had to do something similar. (Actually at the time it was a one liner, but I'm really bored at the moment, so I played around)

Code:
(01:40:26+deco@DeCoBuntu)
[~]$cat track
#!/bin/bash
if [[ -z $1 ]];then
echo "Usage: `basename $0` <process to watch> <delay between checks>"
echo "If Delay not specified, default is 5 seconds"
exit
fi

usage=`top -b1 -n1|grep -i $1|awk '{print $10}'`
while true
do 
echo -ne "$1 is using $usage percent of the total memory"
echo -ne "\r"
if [[ -n $2 ]];then
sleep $2
else
sleep 5
fi
usage=`top -b1 -n1|grep -i $1|awk '{print $10}'`
done
(01:42:10+deco@DeCoBuntu)
[~]$./track
Usage: track <process to watch> <delay between checks>
If Delay not specified, default is 5 seconds
(01:45:45+deco@DeCoBuntu)
[~]$./track firefox 2
firefox is using 16.5 percent of the total memory

I'm pretty certain the switches on top could be done better, but honestly, I'm not very good at this kind of thing.
 

10 More Discussions You Might Find Interesting

1. HP-UX

monitor memory usuage

Hi, We have HP-UX 11.23 and i want to use glance utility to monitor the memory usuage. Can someone tell me how to sort by memory usuage in glance utility? Thx (1 Reply)
Discussion started by: rockcapri
1 Replies

2. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

3. UNIX for Advanced & Expert Users

How often should I monitor the CPU and memory usage ?

Hi all, When you monitor the CPU and memory usage, how often do you do it ? Do it too often or too rarely will both cause the problem. So does anyone have hand-on experience ? And for my case, the requirement says that when CPU usage is above X% or memory usage is above Y%, I should reject... (5 Replies)
Discussion started by: qiulang
5 Replies

4. Emergency UNIX and Linux Support

How to monitor a process memory utilization?

hi frnds, I want to monitor a particular process very closly on how much memory it is taking. i tried with TOP and PRSTAT commands that is not giving what exactly i need. In my application, there is a memory leak happening, i want to know when it is occuering, means which transcation is... (9 Replies)
Discussion started by: vij_krr
9 Replies

5. Shell Programming and Scripting

script to monitor the process system when a process from user takes longer than 15 min run.

get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same. hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Discussion started by: kirankrishna3
1 Replies

6. Linux

Monitor memory

Suppose our application limit use for up to 20GB of data. How to monitor the usage? Do we need to consider swap? Thanks. (2 Replies)
Discussion started by: zhshqzyc
2 Replies

7. UNIX for Dummies Questions & Answers

What to monitor for memory usage?

hi guys I am having a doubt about memory monitoring on linux system what I should be monitoring? memory usage? o swap usage? I am using some monitoring tools but I am confused to what monitor for alerting for example this case looks the memory usage is very high and it's like that all... (2 Replies)
Discussion started by: karlochacon
2 Replies

8. AIX

Script to monitor CPU , Memory

Hello. I am using AIX 6 and did lot of searches on google for this script and found so many results. Just thought to ask you being the real good place for centralised answer: a) Could you tell me the aix script, which may tell me If the CPU load is above e.g. 60% ? b) Could you tell me the AIX... (2 Replies)
Discussion started by: panchpan
2 Replies

9. Solaris

[DOUBT] Memory high in idle process on Solaris 10 (Memory Utilization > 90%)

Hi Experts, Our servers running Solaris 10 with SAP Application. The memory utilization always >90%, but the process on SAP is too less even nothing. Why memory utilization on solaris always looks high? I have statement about memory on solaris, is this true: Memory in solaris is used for... (4 Replies)
Discussion started by: edydsuranta
4 Replies

10. Red Hat

Best way to monitor use of memory resources for an RHEL instance

I wanted to know what is the best way to monitor use of memory on an RHEL server. We have 16 GB of memory for the RHEL instance but the usage at any time is more than 99%. I use /proc/meminfo on the server to check memory. I hope, my question is clear that what is the best way to monitor use of... (2 Replies)
Discussion started by: RHCE
2 Replies
AFGETFRAMECOUNT(3)														AFGETFRAMECOUNT(3)

NAME
afGetFrameCount, afGetTrackBytes, afGetDataOffset - get the total sample frame count, length of audio track in bytes, offset of the audio track for a track in an audio file SYNOPSIS
#include <audiofile.h> AFframecount afGetFrameCount (AFfilehandle file, int track); AFfileoffset afGetTrackBytes (AFfilehandle file, int track); AFfileoffset afGetDataOffset (AFfilehandle file, int track); PARAMETERS
file is an audio file handle created by a previous call to afOpenFile(3). track is an integer which specifies an audio track within file. All supported file formats contain exactly one audio track per file, so the constant AF_DEFAULT_TRACK should always be used. DESCRIPTION
afGetFrameCount returns the total number of sample frames contained within the specified track of the specified file. Each sample frame of audio consists of a fixed number of samples (equal to the number of audio channels in the track. For monaural data, a sample frame consists of one audio sample. For stereophonic data, a sample frame consists of a stereo pair. afGetTrackBytes returns the total number of bytes of raw audio data (i.e., prior to decompression or conversion) in the track. afGetDataOffset returns the offset in bytes of the start of the audio data contained within the specified track of the specified file. RETURN VALUE
afGetFrameCount returns the total number of sample frames in track. afGetTrackBytes returns the total number of bytes of audio data in track. afGetDataOffset returns the offset in bytes to the beginning of the audio data in track. Each of these routines returns -1 in case of error. AUTHOR
Michael Pruett <michael@68k.org> Audio File Library 0.3.6 03/06/2013 AFGETFRAMECOUNT(3)
All times are GMT -4. The time now is 05:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy