dbTalk Databases Forums  

Get instance names from PIDS?

comp.databases.informix comp.databases.informix


Discuss Get instance names from PIDS? in the comp.databases.informix forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Malc
 
Posts: n/a

Default Get instance names from PIDS? - 04-21-2011 , 08:11 AM






Here's one for you:
HP-UX 11i, IDS9.5
Imagine I'm trying to find out which instances are up and running in
an automated shutdown script,and I have no prior knowledge of the
setup. Although I know where the onconfig files are, I don't know
which ones have been started up.

I can see there are some instances running using ps -fu informix; I
can then find the informix main cpuvp PIDs from ps -ef and looking for
the ones with PPID=1; there could be one or several.

How can I find the instance names that are running (from that PID
info?) so that I can automatically set INFORMIXSERVER to that value
and run onmode -yuck?

I've looked in /INFORMIXTMP, and all there is in there is several
"VP.<instancename>soc.<number>.s" files, some relating to running
instances and some not, and they're length 0 anyway.
I've looked in ${INFORMIXDIR}/etc/ and the .conf.<instancename>
and .infos.<instancename> files don't hold any PID info either.

I could look in the message logs and see which instances don't have
"Informix Dynamic Server Stopped" at the end, but that's similarly not
reliable.

ipcs isn't useful either.

Any clues?

Reply With Quote
  #2  
Old   
Jack Parker
 
Posts: n/a

Default Re: Get instance names from PIDS? - 04-21-2011 , 08:45 AM






onstat -g dis

j.
On Apr 21, 2011, at 9:11 AM, Malc wrote:

Quote:
Here's one for you:
HP-UX 11i, IDS9.5
Imagine I'm trying to find out which instances are up and running in
an automated shutdown script,and I have no prior knowledge of the
setup. Although I know where the onconfig files are, I don't know
which ones have been started up.

I can see there are some instances running using ps -fu informix; I
can then find the informix main cpuvp PIDs from ps -ef and looking for
the ones with PPID=1; there could be one or several.

How can I find the instance names that are running (from that PID
info?) so that I can automatically set INFORMIXSERVER to that value
and run onmode -yuck?

I've looked in /INFORMIXTMP, and all there is in there is several
"VP.<instancename>soc.<number>.s" files, some relating to running
instances and some not, and they're length 0 anyway.
I've looked in ${INFORMIXDIR}/etc/ and the .conf.<instancename
and .infos.<instancename> files don't hold any PID info either.

I could look in the message logs and see which instances don't have
"Informix Dynamic Server Stopped" at the end, but that's similarly not
reliable.

ipcs isn't useful either.

Any clues?
_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list

Reply With Quote
  #3  
Old   
Malc
 
Posts: n/a

Default Re: Get instance names from PIDS? - 04-21-2011 , 08:55 AM



On Apr 21, 2:45*pm, Jack Parker <jack.park... (AT) verizon (DOT) net> wrote:
Quote:
onstat -g dis

doh <facepalm>

Reply With Quote
  #4  
Old   
Jack Parker
 
Posts: n/a

Default Re: Get instance names from PIDS? - 04-21-2011 , 09:14 AM



Although I've noted that the "up" / "down" indicator is not always accurate, and should be taken with a grain of salt.

j.
On Apr 21, 2011, at 9:55 AM, Malc wrote:

Quote:
On Apr 21, 2:45 pm, Jack Parker <jack.park... (AT) verizon (DOT) net> wrote:
onstat -g dis


doh <facepalm
_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list

Reply With Quote
  #5  
Old   
Jack Parker
 
Posts: n/a

Default Re: Get instance names from PIDS? - 04-21-2011 , 09:18 AM



If you like, I have a shell wrapper that loops through all active instances setting up environment variables for each subsequent instance.

j.
On Apr 21, 2011, at 10:14 AM, Jack Parker wrote:

Quote:
Although I've noted that the "up" / "down" indicator is not always accurate, and should be taken with a grain of salt.

j.
On Apr 21, 2011, at 9:55 AM, Malc wrote:

On Apr 21, 2:45 pm, Jack Parker <jack.park... (AT) verizon (DOT) net> wrote:
onstat -g dis


doh <facepalm
_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list

_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list

Reply With Quote
  #6  
Old   
Malc
 
Posts: n/a

Default Re: Get instance names from PIDS? - 04-21-2011 , 09:47 AM



Jack kindly sent me some pretty awk.
Here's some NASTY shell I just put together:
cd ${INFORMIXDIR}/
etc
for file in `ls
onconfig.*"`
do
SERVERNAME=`grep DBSERVERNAME $file|awk '{print $2}
`
if [ "${SERVERNAME}" != "#" -a "${SERVERNAME}" !=
"" ];then
export INFORMIXSERVER=$
{SERVERNAME}
export ONCONFIG=$
{file}
onstat -|grep -q "On-
Line"
[ $? -eq 0 ] && echo "${SERVERNAME} is
Up"
onstat -|grep -q "not
initialized"
[ $? -eq 0 ] && echo "${SERVERNAME} is
Down"

fi
done

Yuk.

Reply With Quote
  #7  
Old   
Malc
 
Posts: n/a

Default Re: Get instance names from PIDS? - 04-21-2011 , 09:58 AM



It's look far better without the reformatting kindly supplied by the
google groups front end, really!

Reply With Quote
  #8  
Old   
Superboer
 
Posts: n/a

Default Re: Get instance names from PIDS? - 04-22-2011 , 01:52 AM



Hello Malc,

ipcs -m with servernum 0


is 0x52564801 -->> see onstat -g seg.

where 0x56 is used to differ between servers using servernum
ex servernum = 7
shm is:
0x525d4801

so add 0x56 + 0x(servernum).

Superboer.

Reply With Quote
  #9  
Old   
Fernando Nunes
 
Posts: n/a

Default Re: Get instance names from PIDS? - 04-22-2011 , 08:21 AM



I usually have a config file with all the instances and a function to get
all the environments.
So if I had to do that I would go through the list, set every environment,
check if it was up and stop it.

This is useful for a lot of other situations, so I usually wouldn't bother
in trying tricks that only solve one issue.
Regards.

On Thu, Apr 21, 2011 at 2:11 PM, Malc <malcrp (AT) googlemail (DOT) com> wrote:

Quote:
Here's one for you:
HP-UX 11i, IDS9.5
Imagine I'm trying to find out which instances are up and running in
an automated shutdown script,and I have no prior knowledge of the
setup. Although I know where the onconfig files are, I don't know
which ones have been started up.

I can see there are some instances running using ps -fu informix; I
can then find the informix main cpuvp PIDs from ps -ef and looking for
the ones with PPID=1; there could be one or several.

How can I find the instance names that are running (from that PID
info?) so that I can automatically set INFORMIXSERVER to that value
and run onmode -yuck?

I've looked in /INFORMIXTMP, and all there is in there is several
"VP.<instancename>soc.<number>.s" files, some relating to running
instances and some not, and they're length 0 anyway.
I've looked in ${INFORMIXDIR}/etc/ and the .conf.<instancename
and .infos.<instancename> files don't hold any PID info either.

I could look in the message logs and see which instances don't have
"Informix Dynamic Server Stopped" at the end, but that's similarly not
reliable.

ipcs isn't useful either.

Any clues?
_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list



--
Fernando Nunes
Portugal

http://informix-technology.blogspot.com
My email works... but I don't check it frequently...

Reply With Quote
  #10  
Old   
Jonathan Leffler
 
Posts: n/a

Default Re: Get instance names from PIDS? - 04-22-2011 , 09:22 AM



You can deduce the server number from the shared memory key number - for
example, using a script like this:

#!/bin/perl -w
#
# @(#)$Id: shmkeynum.pl,v 1.1 2008/07/03 00:18:57 jleffler Exp $
#
# Convert IDS shared memory key to Informix server number

# 0x52754803 ==> Server 31
# 0x52754802 ==> Server 31
# 0x52754801 ==> Server 31
# 0x52674805 ==> Server 17
# 0x52674804 ==> Server 17
# 0x52674803 ==> Server 17

sub implausible
{
my($hex) = @_;
return 1 if (($hex & 0xFF00) != 0x4800);
return 1 if (($hex & 0xFF000000) != 0x52000000 &&
($hex & 0xFF000000) != 0x53000000);
return 0;
}

foreach my $arg (@ARGV)
{
my ($hex) = hex($arg);
my ($num) = (($hex & 0x01FF0000) >> 16) - 0x56;
if (implausible($hex) || ($num < 0 || $num > 255))
{
printf "Invalid $arg\n";
}
else
{
printf "%3d $arg\n", $num;
}
}

Example use:

$ shmkeynum 52674805 52564800 53554800
17 52674805
0 52564800
255 53554800
$

On Fri, Apr 22, 2011 at 06:21, Fernando Nunes <domusonline (AT) gmail (DOT) com> wrote:

Quote:
I usually have a config file with all the instances and a function to get
all the environments.
So if I had to do that I would go through the list, set every environment,
check if it was up and stop it.

This is useful for a lot of other situations, so I usually wouldn't bother
in trying tricks that only solve one issue.
Regards.


On Thu, Apr 21, 2011 at 2:11 PM, Malc <malcrp (AT) googlemail (DOT) com> wrote:

Here's one for you:
HP-UX 11i, IDS9.5
Imagine I'm trying to find out which instances are up and running in
an automated shutdown script,and I have no prior knowledge of the
setup. Although I know where the onconfig files are, I don't know
which ones have been started up.

I can see there are some instances running using ps -fu informix; I
can then find the informix main cpuvp PIDs from ps -ef and looking for
the ones with PPID=1; there could be one or several.

How can I find the instance names that are running (from that PID
info?) so that I can automatically set INFORMIXSERVER to that value
and run onmode -yuck?

I've looked in /INFORMIXTMP, and all there is in there is several
"VP.<instancename>soc.<number>.s" files, some relating to running
instances and some not, and they're length 0 anyway.
I've looked in ${INFORMIXDIR}/etc/ and the .conf.<instancename
and .infos.<instancename> files don't hold any PID info either.

I could look in the message logs and see which instances don't have
"Informix Dynamic Server Stopped" at the end, but that's similarly not
reliable.

ipcs isn't useful either.

Any clues?
_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list




--
Fernando Nunes
Portugal

http://informix-technology.blogspot.com
My email works... but I don't check it frequently...

_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list



--
Jonathan Leffler <jonathan.leffler (AT) gmail (DOT) com> #include <disclaimer.h>
Guardian of DBD::Informix - v2008.0513 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.