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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
new server install 2012 r2 essentials 1 37
Rate limit for DNS queries 7 83
awk sed 8 65
moving away from .local domain 5 67
I wrote this article to explain some important DNS concepts that should be known to avoid some typical configuration errors I often see in forums. I assume that what is described here is the typical behavior of Microsoft DNS client. I don't know …
There have been a lot of times when we have seen the need to enter a large number of DNS entries in a forward lookup zone. The standard procedure would be to launch the DNS Manager console, create the Zone and start adding new hosts using the New…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.:

856 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