1835228 Members
7749 Online
110078 Solutions
New Discussion

Re: Need to use pkg ip.

 
brian_31
Super Advisor

Need to use pkg ip.

Hi Team:

We need to script on a service guard requirement and we need to use the package ip in that script. how do i get the package ip from a running box. Can anyone help please?

Thanks
Brian.
14 REPLIES 14
Jeff Schussele
Honored Contributor

Re: Need to use pkg ip.

Check the control file for that package.
Usually in /etc/cmcluster/pkg_name
It will be defined in there.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
PIYUSH D. PATEL
Honored Contributor

Re: Need to use pkg ip.

Hi,

The package ip will be there if you have defined so. It is there in the package control scripts. /etc/cmcluster/pkgname/pkg.script

When you configure the packgae on the cluster you can define the ip for the package which works with the package. When your users want to use that package they can access the package using the package ip

You can define it in package control script and the variable is

IP[0]=a.b.c.d
SUBNET[0]=a.b.c.0 # Netmask = 255.255.255.0

Here a.b.c.d is the package ip of the package

Piyush
Jeff Schussele
Honored Contributor

Re: Need to use pkg ip.

The file *normally* is named pkg_name.ctl ...BUT... is not required to be named anything in particular.
In the file it will be in the field
IP[0]=111.222.111.222
The # in brackets could be larger IF there are mult IPs being asserted by the pkg.

IF you can't check that file you could do
netstat -in
And virtual IPs will have entries like

lan0:1 1500 111.222.111.0 111.222.111.222 ...etc
The key is the colon in the lan name. Note there may be several AND the pkg MUST be up to check it this way.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Sanjay_6
Honored Contributor

Re: Need to use pkg ip.

Hi Brian,

Try "netstat -i". Look at the ipaddress associated with lan0:1 lan0:2, lan1:1, lan1:2 and such. These are virtual ip's associated with lan0 and lan1 and are actually virtual ip's of the packages.

Hope this helps.

Regds
PIYUSH D. PATEL
Honored Contributor

Re: Need to use pkg ip.

Hi,

If you have not configured the virtual ip address the use ifconfig to configure them.

Piyush
brian_31
Super Advisor

Re: Need to use pkg ip.

Hi Team:

I am sorry. I should have given more detail. we have /etc/cmluster/pkdir and then pkg.script and all those stuff. But is there a way around with a command to get the package ip.

Thanks
Brian.
Jeff Schussele
Honored Contributor

Re: Need to use pkg ip.

Hi Brian,

You could grep for it in the file & cut it out - EX:

grep IP pkg_name.ctl | grep = | grep -v "*" | cut -d = -f 2

That should give only the actual IP.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Sanjay_6
Honored Contributor

Re: Need to use pkg ip.

Hi Brian,

I don;t think there is any SG command which can tell you about the package virtual ip address. If the package virtual ip address is configued into the dns then you can get this ipaddress from the DNS.

nslokup pkh_name.domain.com

Hope this helps.

Regds
Rich Wright
Trusted Contributor

Re: Need to use pkg ip.

I'm still not sure what you are needing.
But "cmviewcl -n $(hostname)" will show what is running on the current node. A package does not have to have an IP number. We have a SG monitor package that has no package IP.
But you could take the above output and grep for "enabled" and then "awk '{print $1}'" to get local running packages. Then grep for the IP from the /etc/cmcluster//.cntl file provided you used the recomended naming conventions.
brian_31
Super Advisor

Re: Need to use pkg ip.

Hi:

We already have the package name and the machines are running in production now for 6 mounths with service guard. We have one package on each box(total 4 boxes). The script which i run when it installs tries to query the system for package ip. I do not want to query the /etc/cmluster/pkg dir.
Currently i do netstat -i, i find on the address column (4 th column) the package name but strangely the Network coloumn(ip address)
i find is that of the router. Is that not strange?? why would that happen?

Thanks
Brian.
Rich Wright
Trusted Contributor

Re: Need to use pkg ip.

"netstat -i" will show the resolved name and the network number. To see the IP number, you need to run "netstat -in". Perhaps you can do a "netstat -i" getting the line for the package and save the first field. Then run "netstat -in" and grep for the first field and extract the column with the IP number.
PIYUSH D. PATEL
Honored Contributor

Re: Need to use pkg ip.

Hi,

run netstat -ni to find out and check the output properly.

Piyush
Jeff Schussele
Honored Contributor

Re: Need to use pkg ip.

Hi Brian,

Well you can certainly use netstat -in to get the virtual IP, but what happens IF down the road you add more virtual IPs? Which one would be correct - and - how would you determine that?
If you obtain the IP from the pkg definition or control script you KNOW you've got the correct IP(s). And this method would work on any system using any NIC. You just check the proper filename.
Then you can determine what you need from there - like is it asserted (pkg up?) or whatever (stats?) else you might need.

My 2 cents,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Sridhar Bhaskarla
Honored Contributor

Re: Need to use pkg ip.

Jeff is correct. netstat -in is not very reliable.

You will surely get correct information from your cntl file. So, I also suggest you to get it from there.

awk '/^IP/ {FS="=";printf $2 " " } END {print }' /etc/cmcluster/package/package.cntl

If you have multiple virtual IPs, the above will list them in one line.

-Sri

You may be disappointed if you fail, but you are doomed if you don't try