Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
357 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 2000 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

Protect Your Retail Business and Reputation

Wi-Fi access doesn't just impact your business & customer experience, it can also affect your security.  Join us for an informative webinar to learn more about the top threats and trends impacting retail today, and the key solutions to protecting retail networks and reputations.

Question has a verified solution.

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

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…
Resolve DNS query failed errors for Exchange
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…
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…
Suggested Courses

670 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