Solved

I need a simple script to tell me the IP addresses of the zones running on a solaris system

Posted on 2010-08-31
4
352 Views
Last Modified: 2012-05-10
I do not have access to a solaris 10 with zones but I do need a script for the sysadmin to run nightly.

As I understand if you do a:
global# /usr/sbin/zoneadm list -vc
 
it shows the zones.  Now for each zone if you do a:
global# zonecfg -z myzone info

it gives the ip address.  

I need someone to "grep out" the zone and then run the secon command on each zone.  


http://www.logiqwest.com/dataCenter/Demos/RunBooks/Zones/zoneStatus.html
0
Comment
Question by:TIMFOX123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 6

Accepted Solution

by:
apresence earned 500 total points
ID: 33569929
root@some-global-zone # for i in `/usr/sbin/zoneadm list -vc | perl -ne 'print "$1 $2\n" if /^\s+ (\d+) ([^\s]+)/' | grep -v "^0 " | cut -d' ' -f2`; do echo "--- Zone configuration for $i ---"; zonecfg -z $i info; done
--- Zone configuration for some-local-zone ---
zonename: some-local-zone
zonepath: /zones/slzroot-q310patchesBE
brand: native
autoboot: true
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
inherit-pkg-dir:
        dir: /lib
inherit-pkg-dir:
        dir: /platform
inherit-pkg-dir:
        dir: /sbin
inherit-pkg-dir:
        dir: /usr
fs:
        dir: /opt/app
        special: /dev/vx/dsk/slzdg/optapp
        raw: /dev/vx/rdsk/slzdg/optapp
        type: vxfs
        options: [rw]
fs:
        dir: /var/app
        special: /dev/vx/dsk/slzdg/varapp
        raw: /dev/vx/rdsk/slzdg/varapp
        type: vxfs
        options: [rw]
fs:
        dir: /var/opt/oracle
        special: /dev/vx/dsk/slzdg/varoptoracle
        raw: /dev/vx/rdsk/slzdg/varoptoracle
        type: vxfs
        options: [rw]
net:
        address: 192.168.179.112/24
        physical: bge0
        defrouter not specified
net:
        address: 192.168.119.109/23
        physical: bge1
        defrouter not specified
root@some-global-zone #

If you want all the details, use the attached code (assuming 'sh' shell).

Open in new window

0
 
LVL 6

Expert Comment

by:apresence
ID: 33570123
As you might guess, there may be more than one IP address assigned to a zone.  The following code will get you a list of zones and their IP addresses.
for i in `/usr/sbin/zoneadm list -vc | perl -ne 'print "$1 $2\n" if /^\s+ (\d+) ([^\s]+)/' | grep -v "^0 " | cut -d' ' -f2`; do zonecfg -z $i info; done | perl -ne 'print $_ if /(zonename:|address:)\s+([^\s]+)/'

Open in new window

0
 
LVL 6

Expert Comment

by:apresence
ID: 33570140
Sample output from the previous command:
zonename: some-local-zone
        address: 192.168.10.112/24
        address: 192.168.119.109/24
0
 

Author Closing Comment

by:TIMFOX123
ID: 33572457
What a great solution !!!!!!!!!!!!!!!!!!!!!!!

This realllllly helps us.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question