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
344 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now