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
353 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I've written instructions for one router type, but this principle may be useful for others of the same brand and even other brands of router. Problem: I had an issue especially with mobile devices that refused to use DNS information supplied via…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

739 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