i am working on a project here is part of script that i need a help in
get process SpectroSERVER current size if it exceed 3850 MB then
#pkill -TERM ArchMgr and wait to succfull shutdown message from the log file to proceed to the next step #tail -f $SPECROOT/SS/DDM/ARCHMGR.OUT ArchMgrhas successfully shut down if got above message then # pkill -TERM SpectroSERVER and wait to succfull shutdown message from the log file to proceed to the next step #tail -f $SPECROOT/SS/VNM.OUT SpectroSERVER has successfully shut down if got above message then proceed to next step
get process SpectroSERVER current size if it exceed 3850 MB then
What do you mean by that?
That if the process's resident set size, or virtual size, of it alone,
or including all its children, or those belonging to the same process group etc. exceed this threshold of memory.
What about memory mapped pages or shared memory,
reserved or even used pages on swap?
What do you mean by that?
That if the process's resident set size, or virtual size, of it alone,
or including all its children, or those belonging to the same process group etc. exceed this threshold of memory.
What about memory mapped pages or shared memory,
reserved or even used pages on swap?
hello when do top i got the following
PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND
19202 specadm 29 42 0 3497M 3222M sleep 42.8H 0.00% SpectroSERVER
i need script to check the SIZE if it is > 3850 to proceed
Ah, you were reading top's output.
Then I gather the proc's resident set size is meant,
roughly what the proc used from physical memory.
For that to get you could run a ps command.
Do we know the proc's PID beforehand (maybe from some pid file),
or do we need to parse the proc table first?
Assumed we knew the PID you could run
Depends on the ps/OS; on Linux this number should be in KB.
Other ps return number of memory pages.
If you want to check it on a regular basis
you could set up a cronjob which checks every 5 mins or so.
Even better yet would be a monitoring solution like Nagios
(but maybe overkill?)
From the Nagios Plugins you could set up a check command
involving the check_procs plugin.
Ah, you were reading top's output.
Then I gather the proc's resident set size is meant,
roughly what the proc used from physical memory.
For that to get you could run a ps command.
Do we know the proc's PID beforehand (maybe from some pid file),
or do we need to parse the proc table first?
Assumed we knew the PID you could run
Depends on the ps/OS; on Linux this number should be in KB.
Other ps return number of memory pages.
If you want to check it on a regular basis
you could set up a cronjob which checks every 5 mins or so.
Even better yet would be a monitoring solution like Nagios
(but maybe overkill?)
From the Nagios Plugins you could set up a check command
involving the check_procs plugin.
allright this can be a good start ,, what about rest of the script ?
Hello have created script like follwoing ,,, thanks anybody to check and advice
set a=3800000
if [ $a -lt'ps -p `pgrep SpectroSERVER` -o rss=' ]
then
pkill -TERM ArchMgr
b= tail -f $SPECROOT/SS/DDM/ARCHMGR.OUT | grep "ArchMgr has successfully shut down"
if [ $b ='ArchMgr has successfully shut down' ];
then
pkill -TERM SpectroSERVER
fi
c= tail -f $SPECROOT/SS/VNM.OUT | grep "SpectroSERVER has successfully shut down"
if [ $c ="SpectroSERVER has successfully shut down" ]
then sudo /opt/spectrum/lib/SDPM/processd.pl stop
fi
if [ `pgrep processd`]
then pkill processd
fi
procs2kill="LocServer NSAgent telnetd osagent VnmShd"
for proc in `echo $procs2kill`
do
pkill $proc
done
sudo /opt/spectrum/lib/SDPM/processd.pl start
. /home/specadm/spectrum_env ; $SPECROOT/bin/launchinstdbapp `/usr/bin/hostname` SS n VNM.OUT
x= tail -f $SPECROOT/SS/VNM.OUT | grep "is now ready on port 0xbeef..."
if [ $c ="is now ready on port 0xbeef..." ]
then . /home/specadm/spectrum_env ; $SPECROOT/bin/launchinstdbapp `/usr/bin/hostname` ARCHMGR y ARCHMGR.OUT
fi
If the script you came up with is working for you
then it's quite ok.
But because you asked maybe just some suggestions
(although this is probably only a matter of personal taste)
Quote:
if [ $a -lt'ps -p `pgrep SpectroSERVER` -o rss=' ]
I think here you mixed up single quotes (embracing the whole ps command)
with backticks.
Though it may look daft it is quite ok to have nested backticks.
Nevertheless, I am not particularly fond of backticks because they have become obsolete in modern posix shells,
and thus their use is deprecated.
With bash, ksh, zsh, hp-ux sh etc. you should use $(...) instead.
So this would be how I would rewrite it
But this is still quite ugly.
With all those pairs of parens one easily could lose counting the closing ones.
So better split it up into several statements.
Also, what if the inner cmd expansion of pgrep fails?
Also, as you are going to calculate with these vars
you should better declare them as integers.
Also better use meaningful, imaginative variable names
Maybe one could rewrite it this way?
On the other hand you could parse the RSS in one proc table lookup like so
Yet another variant was to retrieve the RSS from the procfs like
These shall only serve as examples that there is more than one way to do it
(viz. TIMTOWTDI, spoken "timtowdy" as the Perl hailers use to say)
It's not clear to me how this should work
since it ought to produce a syntax error
though I think I can gather what the intension is;
viz. tail on the log until a certain expression appears
and then assign this line to variable b, right?
I wish to by pass a process if the file is over a certain size?
not sure this makes sense
current bit of the script below
#if we are bypAssing the OCR
if ; then
echo Bypassing HOTFOLDER OCR
HOT_FOLDER_DIR=$BATCH_POST_OCR_DIR;
potential change below? would this work would I need... (1 Reply)
Hi All, Looking for a quick LINUX shell script which can continuously monitors the flle size, report the process which is creating a file greater than certain limit and also kill that process. Can someone please help me on this? (4 Replies)
Hi
I have to find size of subdirectory and automate it in CRON.
Eg: parent directory name is NVBKP inside it there are several subdirectories
I want to get the size of recent two subdirectories.
I have tried ls -ltr diretory path | tail -2
But it is providing only size of the folder not... (8 Replies)
Hi,
I am looking to work on unix systems which include (hp-ux, ibm aix, solaris and linux). I want to get the total virtual address space of a process, the used virtual memory i am able to get without any problem. I have tried using getrlimit and getrlimit64, but that gives only ... (4 Replies)
Hi,
I need to execute a script to find the tablespace size in oracle.But i get an error.:confused:
Script Executed:-
#!/bin/ksh
ORACLE_SID= oracelinstance
ORACLE_HOME= oracle path
PATH=$ORACLE_HOME/bin
export ORACLE_SID ORACLE_HOME PATH
sqlplus... (4 Replies)
Hi, I have a directory PRIVATE in which I have several directories and each of these have several files. Therefore, I need to find those files by size and date to back up those files in another directory.
I don't know how to implement this shell script using ''find''.
appreciate any... (1 Reply)
Hi,
I am writing a script which takes the input file name and concat as a new file by appending a "1" to the file name. However i am not able to get the size of this new file. I am not sure where i am going wrong. Please check the script and help me get this working.
#!/bin/sh ... (1 Reply)
Hi,
In Linux how to find out what will be the stack size allocated for a process?
Actually i have to fork n number of processess, and will call exec. I will be execing an executable which is already multithreaded and each thread size is defined. My doubt is how to know if the size of the... (2 Replies)
Hello,
Please help me to know, How to find out the how much amount of process addres space is required/is used for/by a process.
Tnx & Regards
Vishwa. (1 Reply)