Thursday, July 9, 2009

Get detailed disk info with Caiman libraries

Using Caiman libraries you can write small programs which can be very useful in sysadmin's daily work or can help making your own installer. For example, using libtd (Target Discovery) library you can get info about system disks and partitions very fast. Here's an example of using libtd test program (test_td):

# ./test_td -d
Disk discovery
Total number of disks: 3
---------------------------------
num | name| ctype|size [MB]|
---------------------------------
1 | c2t0d0| usb| 976|
2 | c0d0| ata| 76350|
3 | c1d0| ata| 38166|
---------------------------------

# ./test_td -p all
Partition discovery for all disks
-------------------------------------
num | name| active| ID| lswp|
-------------------------------------
1 | c2t0d0p1| Yes| BF| No|
2 | c0d0p1| Yes| BF| No|
3 | c1d0p3| No| 83| No|
4 | c1d0p2| Yes| 83| No|
5 | c1d0p1| No| 82| Yes|
-------------------------------------

Now verbose output:

# ./test_td -d -v
Disk discovery
Total number of disks: 3
-------------------------------------------------------------------------------
num | name| vendor| ctype| mtype| rem| lbl| bsize|#of blocks|size [MB]|
-------------------------------------------------------------------------------
1 | c2t0d0| Multi| usb| FIXED| Yes| VF| 512| 1999872| 976|
2 | c0d0| unknown| ata| FIXED| No| VF| 512| 156364992| 76350|
3 | c1d0| unknown| ata| FIXED| No| VF| 512| 78164352| 38166|
-------------------------------------------------------------------------------

# ./test_td -p all -v
Partition discovery for all disks
---------------------------------------------------------------------
num | name| active| ID| lswp| 1st block|#of blocks|size [MB]|
---------------------------------------------------------------------
1 | c2t0d0p1| Yes| BF| No| 2048| 1996800| 975|
2 | c0d0p1| Yes| BF| No| 16065| 156344580| 76340|
3 | c1d0p3| No| 83| No| 20547135| 57609090| 28129|
4 | c1d0p2| Yes| 83| No| 1012095| 19535040| 9538|
5 | c1d0p1| No| 82| Yes| 63| 1012032| 494|
---------------------------------------------------------------------

2 comments:

Francois said...

Very interesting! , any links to source or scripts examples ?
Would it run under solaris 10 ?

Glynn Foster said...

Nice! Would be cool to package these up somewhere!