Peak Ram Usage


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Peak Ram Usage
# 8  
Old 10-11-2016
Quote:
Originally Posted by dellanicholson
Thank for your help. I want to get my code running.
Sorry to be blunt, but you first need to learn the basics of shell scripting, only then you can expect to get something - anything - running.

Quote:
Originally Posted by dellanicholson
I'm getting an error message when I run my code. Error message: too many errors to read.
That's what i figured.

Code:
/bin/ksh

shebang missing

Code:
group=hasasvmi
date1=09/29/2016
n=1
|{
read "$group"
read "$date1"
read "$n"

This will not only not work, it is also superfluous. If you use a pipeline you connect processes: process1 | process2 means: start process1 and whatever comes out of its stdout output channel (the part usually printed on screen) put into process2s stdin (normally connected to the keyboard). Since variable=value is not a process, there will be no output and hence nothing to feed your pipe.

Code:
WHILE
[...]
DO
[...]
ELSE
[...]
DONE

I have told you already that capitalisation matters and that keywords are not "WHILE", but "while". What do you expect the shell to do if you write gibberish (^=unknown commands/keywords)?

My suggestion is to get some introductory book on shell programming and start reading it. You cannot expect to guess your way to some working code without knowing (obviously) neither UNIX nor shell and while we are willing to answer your questions we will not write complete scripts for you. Anything less than that, i suppose, would not suffice to get working code, though.

I hope this helps.

bakunin
# 9  
Old 10-11-2016
If there are "too many errors to read", split the script into executable blocks and test run those, block by block, line by line if need be.
# 10  
Old 10-25-2016
I am getting one error in my program. The path and files do exist.

This is the error message after adding information to each prompt entries

Code:
./grpdsku.sh

Enter Group name:
hasasvmi

Enter Current Date:
10/25/2016

Enter number of records:
6


File: ./sas/scripts/OPTUMize/output/disk_utilization/disk_2016.10.25.txt not found. Exiting.

here are the path and example of files that are read in the program

Code:
pwd /sas/scripts/OPTUMize/output/disk_utilization/


-rwxr--r--    1 ffxsas  ffxsas     1462455 Mar 04 2016  disk_2016.03.04.txt
-rwxr--r--    1 ffxsas  ffxsas      698461 Oct 23 23:39 disk_2016.10.23.txt
-rwxr--r--    1 ffxsas  ffxsas      407624 Oct 24 13:35 disk_2016.10.24.txt
-rwxr--r--    1 ffxsas  ffxsas      407624 Oct 25 18:35 disk_2016.10.25.txt

Here is the code:
Code:
#!/bin/ksh

fpath=. /sas/scripts/OPTUMize/output/disk_utilization/

# get input
echo "Enter Group name: "
read gname

echo "Enter Current Date: "
read cdate
# format: 09/30/2016

# parse date
yyyy=$(echo ${cdate} | cut -d"/" -f3)
dd=$(echo ${cdate} | cut -d"/" -f2)
mm=$(echo ${cdate} | cut -d"/" -f1)

echo "Enter number of records: "
read nrec

# construct file name to parse
diskfile=${fpath}/disk_${yyyy}.${mm}.${dd}.txt

# check if file exists
if [ ! -f ${diskfile} ]
then
	echo File: ${diskfile} not found. Exiting.
	exit 1
fi

# generate output on screen
(echo "Filesystem	GB_blocks	Free	GB/%Used	%Iused	Mounted_on	Group	Date	Time" ; grep ${gname} ${diskfile} | \
awk -v gname=${gname} '{gsub(/_/," ",$7); print $1 " " $2 " " $3 " " $4 " " $5 " " $6 " " gname " " $7 " " $8}' | \
head -${nrec}) | column -t

Moderator's Comments:
Mod Comment Please use CODE tags for sample input, sample output, and code segments as you have been requested to do many times before.

Continued failure to use CODE tags appropriately may result in being banned from this site.

Last edited by Don Cragun; 10-26-2016 at 12:16 AM.. Reason: Add CODE tags for sample input and output.
# 11  
Old 10-26-2016
The 3rd line in your script:
Code:
fpath=. /sas/scripts/OPTUMize/output/disk_utilization/

sets the variable fpath to the string . and places it in the environment of the command it will then try to execute:
Code:
/sas/scripts/OPTUMize/output/disk_utilization/

which will fail with one of two errors producing a diagnostic message similar to:
Code:
./grpdsku.sh: /sas/scripts/OPTUMize/output/disk_utilization/: not found

or:
Code:
./grpdsku.sh: /sas/scripts/OPTUMize/output/disk_utilization/:  cannot execute [Is a directory]

Since you didn't show us anything like that in the output of the script that you ran, you didn't show us the script that you ran.

If, instead of:
Code:
fpath=. /sas/scripts/OPTUMize/output/disk_utilization/

your script had contained the command:
Code:
fpath=./sas/scripts/OPTUMize/output/disk_utilization/

(with no space between the period and the slash and assuming that your current working directory when you ran your script was not /), that would be likely to lead to the results you showed us. If instead of either of the above, your script had contained the command:
Code:
fpath=/sas/scripts/OPTUMize/output/disk_utilization/

(with neither the period nor the space), your script might do what you want. All of this is based on the assumption that the file you want to process is named /sas/scripts/OPTUMize/output/disk_utilization/disk_2016.10.25.txt and that there is no file named $PWD/sas/scripts/OPTUMize/output/disk_utilization/disk_2016.10.25.txt (where $PWD expands to your current working directory).
This User Gave Thanks to Don Cragun For This Post:
# 12  
Old 10-26-2016
Ram peak

thank for your help. I remove the period in the path of the program. Another error occurred.

input entries:

Code:
Enter Group name:
hasasvmi

Enter Current Date:
10/25/2016

Enter number of records:
8

here is the error message after the program ran:

Code:
./grpdsku.sh[39]: column:  not found.

Here is my script:


Code:
#!/bin/ksh

fpath=/sas/scripts/OPTUMize/output/disk_utilization/

# get input
echo "Enter Group name: "
read gname

echo "Enter Current Date: "
read cdate
# format: 09/30/2016

# parse date
yyyy=$(echo ${cdate} | cut -d"/" -f3)
dd=$(echo ${cdate} | cut -d"/" -f2)
mm=$(echo ${cdate} | cut -d"/" -f1)

echo "Enter number of records: "
read nrec

# construct file name to parse
diskfile=${fpath}/disk_${yyyy}.${mm}.${dd}.txt

# check if file exists
if [ ! -f ${diskfile} ]
then
	echo File: ${diskfile} not found. Exiting.
	exit 1
fi

# generate output on screen
(echo "Filesystem	GB_blocks	Free	GB/%Used	%Iused	Mounted_on	Group	Date	Time" ; grep ${gname} ${diskfile} | \
awk -v gname=${gname} '{gsub(/_/," ",$7); print $1 " " $2 " " $3 " " $4 " " $5 " " $6 " " gname " " $7 " " $8}' | \
head -${nrec}) | column -t

# 13  
Old 10-26-2016
Is the column command available at all on your system?
This User Gave Thanks to RudiC For This Post:
# 14  
Old 10-27-2016
Quote:
Originally Posted by RudiC
Is the column command available at all on your system?
As it is, i suppose there isn't:

Quote:
Originally Posted by dellanicholson
OS is AIX
Code:
# uname -a
AIX myhostname 1 7 00F7CA254C00

# oslevel -s
7100-03-04-1441

# which column
no column in /usr/bin /etc /usr/sbin /usr/ucb /usr/bin/X11 /sbin /usr/local/bin /usr/local/sbin ~/bin

As an aside, i suggest you write ksh (instead of bash) scripts when it comes to AIX system maintenance, because the systems default shell is ksh. I have seen nothing in your scripts so far which would require bash.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Ubuntu 14.04 - how to less ram usage

Hello, I have an ubuntu14.04 installed pc with 32GB ram. Operating System: Ubuntu 14.04.5 LTS Kernel: Linux 4.9.148-xxxx-std-ipv6-64 Architecture: x86_64 When I check free memory it shows: total used free shared buffers cached Mem: 31882 ... (2 Replies)
Discussion started by: baris35
2 Replies

2. UNIX for Dummies Questions & Answers

Average CPU and RAM usage for a process

Hi, I will be creating a process myself and I want to know the average CPU and RAM used by the process over the lifetime of the process. I see that there are various tools available(pidstat) for doing , I was wondering if it possible to do it in a single command while creation. Thanks in... (3 Replies)
Discussion started by: koustubh
3 Replies

3. OS X (Apple)

RAM Usage discrepancy

Hey there! I'm a new user here who registered because I couldn't get these kind of questions answered in the place I directly com from. :o I've found a discrepancy in total RAM used and I can't figure out why it is. My only guess is there are some RAM used by some stuff impossible to identify,... (2 Replies)
Discussion started by: dasx
2 Replies

4. Red Hat

High RAM usage, extremely low swapping

Hi team I have three physical servers running on Red Hat Enterprise Linux Server release 6.2 with the following memory conditions: # cat /proc/meminfo | grep -i mem MemTotal: 8062888 kB MemFree: 184540 kB Shmem: 516 kB and the following swap conditions: ... (6 Replies)
Discussion started by: hedkandi
6 Replies

5. Solaris

Server RAM Usage checkup & support

Hi RAM of my system is 24 GB however when i checked the processes pids and counted the memory usage by pmap i found out that the total memory usage is 36 GB It s obvious that my system might be using some of virtual memory or swap space . How can i check which memory it is using and how .. ... (9 Replies)
Discussion started by: Paarth
9 Replies

6. Linux

Ram Usage

Hi one of our applications that runs on our Linux server leaks memory resulting in Ram that was used by the program not being released back to the operating system once a file has been processed. the result is over a very short period virtual all the memory has been used. an example currently ... (8 Replies)
Discussion started by: treds
8 Replies

7. Shell Programming and Scripting

RAM usage Information

Hi i just wanted to know what is the code to display amount of RAM and also the percentage used? I know i can possibly use the vmstat code but what part indicates the RAM? Any help would be much appreciated. Thanks (1 Reply)
Discussion started by: warlock129
1 Replies

8. UNIX for Dummies Questions & Answers

Command to check RAM usage

Hi Guys, How can i check the RAM usage for a particular user on the Linux machine. What command can be used. Thanks in advance, Swapna (1 Reply)
Discussion started by: Swapna173
1 Replies

9. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

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)
Discussion started by: alert0919
3 Replies

10. Solaris

RAM Physical Memory usage by each Process.

Hi All, I am trying to find the physical memory usage by each process/users. Can you please let me know how to get the memory usage?. Thanks, bsraj. (12 Replies)
Discussion started by: bsrajirs
12 Replies
Login or Register to Ask a Question