Friday, April 16, 2010

Solaris 9: Missing dladm show-dev


Solaris 9: Missing dladm show-dev

Abstract:
Solaris 10 has included a new feature referred to as the Data Link Admin tool. This tool provides a simple way to configure and check the status of the layer 2 ethernet interfaces. Some of the information commonly used in dladm under Solaris 10 can be derived in Solaris 9.

Solaris 10: dladm show-dev
The Data Link Administration tool under Solaris 10 has some very nice features, including quickly seeing the interface name, speed, and duplex.

sunt2000# dladm show-dev
ipge0 link: unknown speed: 100 Mbps duplex: full
ipge1 link: unknown speed: 100 Mbps duplex: full
ipge2 link: unknown speed: 100 Mbps duplex: half
ipge3 link: unknown speed: 0 Mbps duplex: unknown


Solaris 9: kstat & nawk
A simple nawk script can be used on a Solaris 9 platform, to perform similar output.

sunt2000# kstat -p | nawk '/duplex/ || /speed/ { split($1,Array,":") ; Dev=Array[3] } /link_duplex/ && $2=="2" { Duplex[Dev]="full" } /link_duplex/ && $2=="1" { Duplex[Dev]="half" } /link_speed/ { if ( Duplex[Dev] == "" ) Duplex[Dev]="unknown" ; Speed[Dev]=$2 ; print Dev "\tlink: unknown\tspeed: " Speed[Dev] "\tMbit\tduplex: " Duplex[Dev] }'
ce0 link: unknown speed: 100 Mbit duplex: full
ce1 link: unknown speed: 1000 Mbit duplex: full
ce2 link: unknown speed: 1000 Mbit duplex: full
ce3 link: unknown speed: 1000 Mbit duplex: full
ce4 link: unknown speed: 0 Mbit duplex: unknown
ce5 link: unknown speed: 0 Mbit duplex: unknown

1 comment:

  1. Hi, Nice one liner. Thanks for providing this.

    One enhancement could be to include link status:

    kstat -p | nawk '/duplex/ || /speed/ || /link_up/ { split($1,Array,":") ; Dev=Array[3] } /link_duplex/ && $2=="2" { Duplex[Dev]="full" } /link_duplex/ && $2=="1" { Duplex[Dev]="half" } /link_speed/ { Speed[Dev]=$2 } /link_up/ { if ($2=="1") { Status[Dev]="up" } else { Status[Dev]="unknown" }; if (Duplex[Dev] == "") { Duplex[Dev]="unknown"} print Dev "\tlink: " Status[Dev] "\tspeed: " Speed[Dev] "\tMbit\tduplex: " Duplex[Dev] }'

    ce0 link: up speed: 1000 Mbit duplex: full
    ce1 link: up speed: 1000 Mbit duplex: full
    ce2 link: unknown speed: 0 Mbit duplex: unknown
    ce3 link: up speed: 1000 Mbit duplex: full
    ce4 link: up speed: 1000 Mbit duplex: full
    ce5 link: up speed: 1000 Mbit duplex: full

    ReplyDelete