Hi,

After successfully using  SmartOS for some time nom, and managing it from the 
command line, I've started to get fed up with copy-pasting  unfriendly uuids 
and disk device names.
So I've written some bash functions to make my life easier. Hope this can help 
others as well. If you want to use them permanently, just paste them in your 
/root/.bashrc

the functions I use most are:

-vmuuid it allows me to turn an alias to a uuid, so zlogin is more convenient: 
zlogin `vmuuid fred`
-vmaliases replaces all uuids by the corresponding alias. So "prstat 
-Z|vmaliases" is more meaningfull:


-devalias and aliasdev allows me to just forget about those complex Solaris 
disk names. I use it a lot with iostat and zpool commands

[root@smartos ~]#  iostat -xn | devalias

  r/s    w/s   kr/s   kw/s wait actv wsvc_t asvc_t  %w  %b device
    0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.0   0   0 lofi1
    0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.0   0   0 ramdisk1
    0.2   19.9    0.1  288.3  0.0  0.0    0.0    1.6   0   3 tosh_600_disk2
    0.0   19.9    0.0  288.3  0.0  0.0    0.0    1.6   0   3 tosh_600_disk3
    0.0   22.7    0.0  370.4  0.0  0.0    0.0    1.4   0   3 tosh_600_disk1
    0.1   23.1    0.2  370.4  0.0  0.0    0.0    1.6   0   4 tosh_600_disk4


Hope it can be useful to someone,

Michel

--


#bash alias/uuid conversion functions for SmartOS 
#use and modify freely
#
##
#vmalias converts a vm uuid to alias
#
##

function vmalias ()
{
    vmadm list -H -o alias uuid=$1
}


##
#vmuuid converts a vm  alias to an uuid
#example: zlogin `vmuuid tommy`
##

function vmuuid ()
{
    vmadm list -H -o uuid alias=$1
}


##
#vmaliases replaces uuids to aliases from standard input.
#example: prstat -Z|vmaliases
##

function vmaliases (){
    vmadm list -H -o uuid,alias|awk '{print 
"s,"$1","$2",g"}'>/tmp/vmuuid2aliases.$$.sed
    sed -f /tmp/vmuuid2aliases.$$.sed
    rm /tmp/vmuuid2aliases.$$.sed
}


##
#devalias replaces disk  device numbers by aliases from input.
#/opt/local/etc/devalias.conf file should contain one line per disk device like 
this: "c2t50000394183AE50Ed0 tosh_600_disk1"
#To locate disk just use dd and see which one is blinking more: dd 
if=/dev/rdsk/c2t50000394183AE50Ed0 of=/dev/null
#example: iostat -xn 5|devalias 
##

function devalias (){
    cat /opt/local/etc/devalias.conf | awk '{print 
"s,"$1","$2",g"}'>/tmp/devalias.$$.sed
    sed -f /tmp/devalias.$$.sed
    rm /tmp/devalias.$$.sed
}



##
#aliasdev replaces disk aliases to disk device names (conversion table taken 
from /opt/local/etc/devalias.conf)  from standard input.
#example: zpool create testpool `aliasdev sea_900_disk11`
##

function aliasdev (){
    cat /opt/local/etc/devalias.conf | awk '{print 
"s,"$2","$1",g"}'>/tmp/aliasdev.$$.sed
    sed -f /tmp/aliasdev.$$.sed
    rm /tmp/aliasdev.$$.sed
}





-------------------------------------------
smartos-discuss
Archives: https://www.listbox.com/member/archive/184463/=now
RSS Feed: https://www.listbox.com/member/archive/rss/184463/25769125-55cfbc00
Modify Your Subscription: 
https://www.listbox.com/member/?member_id=25769125&id_secret=25769125-7688e9fb
Powered by Listbox: http://www.listbox.com

Reply via email to