- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script Required
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 12:50 PM
10-02-2001 12:50 PM
Example :
Application server
lsof | grep inet
api6.1 3369 agriffi 8u inet 0x23e14400 0t2004 TCP neptune-2.hdc.bio-rad.com:1969->jupiter-2.hdc.bio-rad.com:1521 (
Database Server
lsof | grep 1969
oraclebaa 10805 oracle 11u inet 0x4d6afc68 0t2004 TCP jupiter-2.hdc.bio-rad.com:listener->neptune-2.hdc.bio-rad.com:196
9 (ESTABLISHED)
If it found the corresponding inet that means connection is fine . But this script takes lots of time to run and is not very effective under some circustnaces. Any better method of achieving the results ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 12:59 PM
10-02-2001 12:59 PM
Re: Script Required
The first lsof could be changed to
lsof -i TCP
This would list all the TCP connections from/to the machine.
Then you can search for the particular connection by:
lsof -i TCP:1969 (from your example).
Also, since the database listener is on a particular port, you could probably narrow the initial search even further, i.e.:
lsof -i TCP:1521
Hope this helps.
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 01:04 PM
10-02-2001 01:04 PM
Re: Script Required
Look at the man page for lsof (it has lots of options)
To simplify your search
lsof -i TCP |grep oracle |grep -v ESTABLISH
Would list all the TCP sessions that are not established.
lsof -i | grep oracle |grep -v ESTABLISH
would list all the sessions that are not extablished
You could modify your script accordingly, based on what you are interested
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 01:15 PM
10-02-2001 01:15 PM
SolutionLet's restrict the lsof output. The other guys have mentioned -i and that's good now let's improve it with -c and -a too.
let's say I want all inet sockets the for command the begin with the letter a OR the letter s. All the -c commands are OR'ed automatically; we then use -a to AND with -i (inet).
e.g.
lsof -c a -c s -a -i
The smaller this list is; the faster the rest of the code executes.
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 01:31 PM
10-02-2001 01:31 PM
Re: Script Required
set -x
#!/bin/ksh
database="baanpcdg baanpeu3 baantap"
> /tmp/notfound.out
for i in $database
do
# Get the hostname
sysname=`awk -F" " ' $1~ /'"$i"'/ {print $2} ' ~dseth/host.txt `
# collect all the process related to INET for a particular database
lsof | grep inet | grep $sysname | awk -F: '{print $1,":", $3}' | awk -F" " '{print $2,$11}' > /tmp/orabaan.$i
# remsh to application server and collect the informaion of lsof
remsh $sysname -n lsof | grep "inet" | grep jupiter | grep -v root | awk -F" " '{print $3,$9}' > /tmp/lsof.$sysname
while read a b
do
if [ `grep $b /tmp/lsof.$sysname | wc -l ` -eq 0 ]
then
RS="-"
# whodb is a script which shows the user login in a particular database
# This is to find the name of user/login id
NAME=`/usr/local/bin/whodb $i | grep $a | awk '{print $1}'`
if [ -n "$NAME" ]
then
echo "$i $a $sysname $b $NAME" >> /tmp/notfound.out
fi
fi
done < /tmp/orabaan.$i
done
# Finally moving the file a different location for the web server to display in HTML format .
rcp /tmp/notfound.out devsun2:/tmp/notfound.out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 01:40 PM
10-02-2001 01:40 PM
Re: Script Required
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 01:42 PM
10-02-2001 01:42 PM
Re: Script Required
You could try using Glance in "adviser only" mode.
In your own "adviser syntax" you can specify any metric available in Glance, including "open files" such as sockets.
I've attached a sample adviser syntax that lists all sockets (you can modify it further if it seems useful).
If you save it to, say, sockets.syntax in your current directory, then you can run it as follows:
glance -adviser_only -syntax sockets.syntax
This will give you a "quick start" so you can get some idea if Glance can be useful or not.
The list of available metrics in Glance is under /opt/perf/paperdocs/gp/C/. More adviser syntax examples are available under /opt/perf/examples/adviser.
Regards ... Mladen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 02:04 PM
10-02-2001 02:04 PM
Re: Script Required
Without rewriting, I see some major things to improve your script.
First that long string of commands 'lsof | grep inet | grep $sysname | awk -F: '{print $1,":", $3}' | awk -F" " '{print $2,$11}' > /tmp/orabaan.$i'
That could be replaced by
lsof (with args above) | awk -f myfile.awk > /tmp/orabann.$i
Let awk do all that stuff you are doing with grep + awk in a single awk script.
Next, if [ `grep $b /tmp/lsof.$sysname | wc -l ` -eq 0 ] can be replaced with
grep -q $b /tmp/lsof.$sysname
STAT=$?
if [ ${STAT} -eq 0 ]
then
do your stuff
fi
In general, the fewer processes you have to fork, the faster your code will execute but thge very first thing to do is limit the input by adding args to lsof.
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 02:07 PM
10-02-2001 02:07 PM
Re: Script Required
i just tried this command .
lsof -c a -c -a -i
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 02:16 PM
10-02-2001 02:16 PM
Re: Script Required
Absolutely, lsof can take a very long time on a busy system especially with no args. I would add the -b arg to avoid functions which can cause blocking. This should not exclude any of the sockets yoiu are looking for.
lsof -c a -c s -a -i -b 2>/dev/null | grep or awk
We redirect stderr so that lsof does not warn you about the possible blocking functions it is avoiding. I think it will not run much faster.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 02:26 PM
10-02-2001 02:26 PM
Re: Script Required
time lsof -c a -c s -a -i
real 4:07.1
user 0.3
sys 0.5
Is it ok .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2001 02:49 PM
10-02-2001 02:49 PM
Re: Script Required
I will assign the points shortly as it is giving some error right now when u try to assign points.
thanx once again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 07:46 AM
10-03-2001 07:46 AM
Re: Script Required
#!/bin/ksh
#/***********************************************************
#* $Header:
#* Name: tkprof_rpt
#* Description: Prompt for tkprof parameters and run tkprof.
#*
#* Inputs: Trace filename. (Std. udump directory is assumed)
#* Output filename.
#* Oracle userid.
#* Oracle password.
#*
#* Outputs: tkprof output in current dir., or home dir.
#*
#* Known limitations:
#*
#* Revisions:
#* Date who Description
#************************************************************/
echo "\n\n"
udump="/home/app/oracle/admin/prd1/udump"
ls -lt $udump | head
echo "\n\nEnter the name of the trace file ................ \c"
read ans
if [ ! -r $udump/$ans ]
then
echo "You must enter a full file name which you have read permissions"
echo "from the directroy: $udump"
exit 1
fi
trcfile=$ans
echo "Enter the name of the output (formatted) file ... \c"
read out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 07:57 AM
10-03-2001 07:57 AM
Re: Script Required
What is this script doing ? Can u explain me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2001 11:20 AM
10-04-2001 11:20 AM
Re: Script Required
why do you not use the information from "V$SESSION",
as I see you are using Oracle as he DB?
IIRC then all the information you need is available in
there...
Just my ?0.02,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2001 12:09 PM
10-04-2001 12:09 PM
Re: Script Required
I was thinking on the same line since yesterday as this will make my script run much faster and i don't have to live on the functioning of "LSOF" command - which still behave differently from time to time.
thanx once again.