Recorder number of process per user


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Recorder number of process per user
# 1  
Old 07-04-2015
Oracle Recorder number of process per user

Hello Team,

I would like to use a shell script that run each 15 minutes in order to recorder the number of process per user

I request your help in order to build an awk script under Solaris from the following command or similar:

Code:
  
ps -fea -o user | sort | uniq -c | sort -k 2
648     oracle
454     sybase
 51     test
327     root

328     oracle
284     sybase
 91     test
727     root

I would like to obtain the following output in the log file:
Code:
Date        Time    User    Num_Proc
07/04/15    08:00    oracle    648
07/04/15    08:00    sybase    454
07/04/15    08:00    test    51
07/04/15    08:00    root    327
07/04/15    08:15    oracle    328
07/04/15    08:15    sybase    284
07/04/15    08:15    test    91
07/04/15    08:15    root    727

Thanks in advance
# 2  
Old 07-04-2015
Is this a homework assignment?

What have you tried?

Why do you think awk would be appropriate for this problem?
# 3  
Old 07-05-2015
Hello Don,

It is not a homework.


The purpose is to identify which user of the server has more process in a peak time of the day.


We identify that the server has a lot syscall between 10:00 am and 12:00 pm.


That is the reason to automation the process to collect information during this period ot time.


I though that the comand awk could the appropiate because it has a field capabilities per row but if you consider to create the script using another tool is welcome.


I look forward for your help and support


Regards,
# 4  
Old 07-05-2015
You can simplify your pipeline a little bit... The uniq won't reorder the output, so the second sort isn't needed. Also note that the standards don't clearly specify what happens when both the -f option and the -o option to ps are given (they place conflicting requirements on the output format; so specifying both is non-portable).

Putting your code in a loop to run your command line (and add a timestamp to the start of each line) is pretty easy. If you start the following script at 10am, by default it will produce reports at about 10:00, 10:15, 10:30, 10:45, 11:00, 11:15, 11:30, 11:45, and noon and then quit. If you pass arguments to the script you can change the number of minutes between samples and the number of samples to be run. It was a written and tested using a Korn shell, but will work with any shell that meets basic POSIX conforming shell requirements for arithmetic and variable expansions.
Code:
#!/bin/ksh
# Usage: counter [ repetition_count [ minutes_between_samples ]]
# Count and report number of processing running for each user.
reps=${1:-9}	# # of samples to collect (default: 9 samples)
delay=${2:-15}	# minutes between samples (default: 15 minutes)

printf "Gathering $reps samples $delay minutes apart\n"
while :
do	DandT=$(date '+%m/%d/%y    %H:%M')
	printf 'Date        Time     User                Num_Proc\n'
	ps -A -o user|sort|uniq -c|while read count user
	do	[ "$user" = "USER" ] && continue
		printf '%-20s %-20s %7d\n' "$DandT" "$user" "$count"
	done
	reps=$((reps - 1))
	[ "$reps" -le 0 ] && break
	echo
	sleep $((delay * 60 - 2))
done

Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. 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

2. UNIX for Dummies Questions & Answers

How to read contents of a file from a given line number upto line number again specified by user

Hello Everyone. I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below: if ; then if ; then tail +$1 $3 | head -n $2 else ... (5 Replies)
Discussion started by: grc
5 Replies

3. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

4. Solaris

Number of process per user session

Hi All, Do we have any option through which we can limit the number of process which can be started by single user session. Thanks (3 Replies)
Discussion started by: kumarmani
3 Replies

5. Infrastructure Monitoring

System Data Recorder

Monitoring the IT infrastructure is an important key to ensure your business continuity and prepare for future grow. SDR is a simple toolkit, containing a number of data collectors, used to record and report data from your Solaris servers. SDR is mainly designed around Solaris operating system due... (0 Replies)
Discussion started by: Linux Bot
0 Replies

6. UNIX for Advanced & Expert Users

number of process

Hi, under AIX 5.2 which (environment) parameter defins the number of processes for the server ? Many thanks. (2 Replies)
Discussion started by: big123456
2 Replies

7. Shell Programming and Scripting

number of process?

how i know number of process are currently run on my user area (2 Replies)
Discussion started by: piyush_movadiya
2 Replies
Login or Register to Ask a Question