Sponsored Content
Operating Systems Solaris Programatically read 'size' shown in top? Post 302397379 by jlliagre on Monday 22nd of February 2010 02:18:45 AM
Old 02-22-2010
There are quite a lot of free and efficient tools too allowing to track down memory leaks under Solaris, including dbx run time checking.
How to find memory leak in solaris?

Back to the original question, here is a sample code to monitor a process size an rss:
Code:
#include <procfs.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
  char psinfo[32];
  struct psinfo p;
  int fd;
  pid_t pid;
  if(argc>1)
    pid=atoi(argv[1]);
  else
    exit(1);
  sprintf(psinfo,"/proc/%ld/psinfo",pid);
  fd=open(psinfo, O_RDONLY);
  if(fd!=-1)
  {
    read(fd,&p,sizeof(p));
    printf("size=%d rss=%d\n", p.pr_size, p.pr_rssize);
    close(fd);
  }

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help with Top and SIZE of process

Hi, what I want to do is get the SIZE of a particular process from top into a shell script so I can put it in a while loop. I want to display a warning message when the process size gets up to a certain amount, but I don't know how to get that one line spit out from Top and thrown into my shell... (5 Replies)
Discussion started by: satraver
5 Replies

2. Programming

Add IpAddress Through Programatically

Hi all, Can u give me some suggestions how to add Ip Address through Programmatically , Actually I done it in Windows But now I want same thing in Unix................................ Can Any body Help to me....... (6 Replies)
Discussion started by: ykmraju
6 Replies

3. UNIX for Dummies Questions & Answers

Unix shell script for finding top ten files of maximum size

I need to write a Unix shell script which will list top 10 files in a directory tree on basis of size. i.e. first file should be the biggest in the whole directory and all its sub directories. Please suggest any ideas (10 Replies)
Discussion started by: abhilashnair
10 Replies

4. Shell Programming and Scripting

command to read file name and size

hi all, there is any command or anything we can use to read the file name and size. thanks (6 Replies)
Discussion started by: s_linux
6 Replies

5. Shell Programming and Scripting

Display top ten directories by size

Hi, I am new to Unix. I want to display top 10 folders by size. I tried with du -ksl * | sort -nr | head -10 command .But I am getting the following error -bash: /usr/bin/du: Argument list too long Can some one help me. Thanks. (5 Replies)
Discussion started by: Satyak
5 Replies

6. UNIX for Dummies Questions & Answers

Query related to swap information shown by top command

Hi I have checked the output of top command in which there is a difference shown between the swap of top command for a process with total swap memory usage of the top command. Swap usage of process is higher than the total swap memory usage. top - 18:28:21 up 7:13, 5 users, load... (2 Replies)
Discussion started by: gagan2914
2 Replies

7. Shell Programming and Scripting

Retrieve RAM memory size from "top" command output

Hi, I am trying to get the system RAM size from "top" command's output by the following but it is not working. top | sed "s/^Mem.**\(*\), *//" (10 Replies)
Discussion started by: royalibrahim
10 Replies

8. Shell Programming and Scripting

Script to read file size and send email only if size > 0.

Hi Experts, I have a script like $ORACLE_HOME/bin/sqlplus username/password # << ENDSQL set pagesize 0 trim on feedback off verify off echo off newp none timing off set serveroutput on set heading off spool Schemaerrtmp.txt select ' TIMESTAMP COMPUTER NAME ... (5 Replies)
Discussion started by: welldone
5 Replies

9. Programming

Maximum buffer size for read()

Hi friends, Hope everybody is fine. First have a look at my code, then we will talk about it. $ cat copy.c #include <stdio.h> #define PERMS 0644 /* RW for owner, R for group, others */ #define BUFSIZE 1 char *progname; int main(int argc,char * argv) { int f1, f2, n; ... (4 Replies)
Discussion started by: gabam
4 Replies

10. Shell Programming and Scripting

SSH Programatically

Hi Experts, Need some help. I am trying below code programatically to login to ssh ip from a csv file. the below code logging into all servers and executing some command line syntax. But what I need is for example if i have 5 IP's ,if first one connects successfully and executes the... (3 Replies)
Discussion started by: onenessboy
3 Replies
pargs(1)							   User Commands							  pargs(1)

NAME
pargs - print process arguments, environment variables, or auxiliary vector SYNOPSIS
pargs [-aceFlx] [pid | core] ... DESCRIPTION
The pargs utility examines a target process or process core file and prints arguments, environment variables and values, or the process auxiliary vector. pargs outputs unprintable characters as escaped octal in the format xxx, unless the character is one of the characters specified in the "Escape Sequences" section of formats(5), in which case the character is printed as specified in that section. pargs attempts to be sensitive to the locale of the target process. If the target process and the pargs process do not share a common char- acter encoding, pargs attempts to employ the iconv(3C) facility to generate a printable version of the extracted strings. In the event that such a conversion is impossible, strings are displayed as 7-bit ASCII. OPTIONS
The following options are supported: -a Prints process arguments as contained in argv[] (default). -c Treats strings in the target process as though they were encoded in 7-bit ASCII, regardless of the locale of the target. The use of iconv(3C) is suppressed. -e Prints process environment variables and values as pointed at by the _environ symbol or by pr_envp in /proc/pid/psinfo. -F Force. Grabs the target process even if another process has control. -l Displays the arguments as a single command line. The command line is printed in a manner suitable for interpretation by /bin/sh. If the arguments contain unprintable characters, or if the target process is in a different locale, a warning message is dis- played. The resulting command line may not be interpreted correctly by /bin/sh. -x Prints process auxiliary vector. OPERANDS
The following operands are supported: pid Process ID list. core Process core file. EXIT STATUS
The following exit values are returned: 0 Successful operation. non-zero An error has occurred (such as no such process, permission denied, or invalid option). FILES
/proc/pid/* Process information and control files. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWesu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
proc(1), iconv(3C), proc(4), ascii(5), attributes(5), environ(5), formats(5) SunOS 5.10 13 Apr 2004 pargs(1)
All times are GMT -4. The time now is 10:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy