Christopher White > HPUX-Ioscan > HPUX::Ioscan

Download:
HPUX-Ioscan-1.010.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.09_01   Source  

NAME ^

HPUX::Ioscan - Perl function to handle HPUX ioscan command

SYNOPSIS ^

 use HPUX::Ioscan ;
 my $result = ioscan ();

 print "All hardware paths: ", join(" ", keys %$result),"\n";

 print "One device file of disk :\n",
       $result->{'2/1.6.0'}{device_files}[0],
       "\n";

DESCRIPTION ^

This module works on top of the HP-UX command ioscan. It forks a process to run the ioscan command and parses its STDOUT. The result is returned in a hash.

This module is quite basic but it may be interesting if you need to write administration program on HP-UX.

You may call ioscan several time in your program without any problem sicne the result is cached. Only the first call to ioscan will actually run the ioscan command. (But you may override the caching of the result)

FUNCTION ^

ioscan ( [force => 1] )

Will return the result of the ioscan command. The ioscan command is run the first time or if the force parameter is set to 1.

This function returns a hash ref. The keys of the hash are all the hardware paths found on your system.

The value is another hash ref containing these keys :

  bus_type
  cdio
  is_block
  is_char
  is_pseudo
  block_major_number
  character_major_number
  minor_number
  class
  driver
  hardware_path
  identify_bytes
  instance_number
  module_path
  module_name
  software_state
  hardware_type 
  description
  card_instance
  device_files

See ioscan(1M) for the meaning of these keys.

The value of device_files is an array containing the name of the device files attached to the hardware path.

EXAMPLE ^

Heres an example of the structure returned for 1 disk:

 $result = 
  {
    '0/0/2/1.6.0' => 
       {
         'description' => 'SEAGATE ST318203LC',
         'block_major_number' => '31',
         'cdio' => 'wsio',
         'driver' => 'sdisk',
         'instance_number' => '1',
         'is_pseudo' => 'F',
         'character_major_number' => '188',
         'class' => 'disk',
         'bus_type' => 'scsi',
         'hardware_path' => '0/0/2/1.6.0',
         'identify_bytes' => '0 0 2 18 0 0 0 0 95 227 197 13  8 127 87 40 32 ',
         'device_files' => [
                             '/dev/dsk/c2t6d0',
                             '/dev/rdsk/c2t6d0'
                           ],
         'module_path' => 'root.sba.lba.c720.tgt.sdisk',
         'minor_number' => '155648',
         'is_block' => 'T',
         'is_char' => 'T',
         'card_instance' => '2',
         'software_state' => 'CLAIMED',
         'hardware_type' => 'DEVICE',
         'module_name' => 'sdisk'
       },
 }

OO SYNOPSIS ^

  use HPUX::Ioscan;

  my $ioscan_data = new HPUX::Ioscan(
                                target_type     =>"local",
                                persistance     =>"new",
                                access_prog     =>"ssh",
                                access_system   =>"localhost",
                                access_user     =>"root"
                                        );

  $arref = $ioscan_data->get_disk_controllers();
  foreach $contr ( @$arref )      {
    $instance = $ioscan_data->get_instance_number(
                                controller      => $contr
                                                );
                                  }
  $hwpath = $ioscan_data->get_device_hwpath(
                device_name => "/dev/dsk/c1t4d0"
                                        )
  $hwpathinfo = $ioscan_data->get_class(
                hwpath  => $hwpath
                                        )
  $disk_size = $ioscan_data->get_device_diskinfo(
                device_name => "/dev/dsk/c1t4d0"
                attribute   => "size"
                                        )

DESCRIPTION ^

This module takes the output from the ioscan command and hashes it into an object. You can then access its attributes via its AUTOLOADED methods i or other custom methods.

It utilizes the Storable module for persistance so once called you can then recall it without re-running the command and/or wait for the network by setting persistance from "new" to "old".

Remote node access is supported via remsh or ssh. ssh is highly recommended since the ioscan command that the script runs needs root.

FUNCTION ^

new

The main object constructor that returns the hash refrence. The keys of the hash are all the hardware paths on your system. It accepts the following paramters:

        target_type     values: local(default) or remote
        persistance     values: new(default) or old
        access_prog     values: ssh(default) or remsh
        access_system   values: localhost(default) or remote system name
        extended_disk_info values:yes or no(default)
        access_user     values: root(default) or remote username

The value is another hash ref containing there keys :

  bus_type
  cdio
  is_block
  is_char
  is_pseudo
  block_major_number
  character_major_number
  minor_number
  class
  driver
  hardware_path
  identify_bytes
  instance_number
  module_path
  module_name
  software_state
  hardware_type 
  description
  card_instance
  device_files

See ioscan(1M) for the meaning of these keys.

EXAMPLE ^

Heres an example of the structure returned for 1 disk:

 $result = 
  {
    '0/0/2/1.6.0' => 
       {
         'description' => 'SEAGATE ST318203LC',
         'block_major_number' => '31',
         'cdio' => 'wsio',
         'driver' => 'sdisk',
         'instance_number' => '1',
         'is_pseudo' => 'F',
         'character_major_number' => '188',
         'class' => 'disk',
         'bus_type' => 'scsi',
         'hardware_path' => '0/0/2/1.6.0',
         'identify_bytes' => '0 0 2 18 0 0 0 0 95 227 197 13  8 127 87 40 32 ',
         'device_files' => [
                             '/dev/dsk/c2t6d0',
                             '/dev/rdsk/c2t6d0'
                           ],
         'module_path' => 'root.sba.lba.c720.tgt.sdisk',
         'minor_number' => '155648',
         'is_block' => 'T',
         'is_char' => 'T',
         'card_instance' => '2',
         'software_state' => 'CLAIMED',
         'hardware_type' => 'DEVICE',
         'module_name' => 'sdisk'
       },
 }

EXAMPLE ^

Partial Ioscan Object (disk only). Illustrates the optional extended diskinfo option.

 $result =
  {
'0/12/0/0.104.7.19.1.7.0' => HASH(0x403c18b8)
   'block_major_number' => 31
   'bus_type' => 'scsi'
   'card_instance' => 9

   'cdio' => 'wsio'
   'character_major_number' => 188
   'class' => 'disk'
   'description' => 'HP      OPEN-L'
   'device_files' => ARRAY(0x403c19c0)
      0  '/dev/dsk/c9t7d0'
      1  '/dev/rdsk/c9t7d0'
   'diskinfo' => HASH(0x403c1924)
      '/dev/rdsk/c9t7d0' => HASH(0x403c193c)
         'bytes_per_sector' => ' 0
'
         'product_id' => ' OPEN-L          
'
         'size' => ' 0 Kbytes
'
         'type' => ' direct access
'
         'vendor' => ' HP      
'
   'driver' => 'sdisk'
   'hardware_path' => '0/12/0/0.104.7.19.1.7.0'
   'hardware_type' => 'DEVICE'
   'identify_bytes' => '32 0 2 2 0 0 0 0 175 10 43 213 190 8 246 137 '
   'instance_number' => 76
   'is_block' => 'T'
   'is_char' => 'T'
   'is_pseudo' => 'F'
   'minor_number' => 618496
   'module_name' => 'sdisk'
   'module_path' => 'root.sba.lba.td.fcp.fcparray.tgt.sdisk'
   'software_state' => 'CLAIMED'
 }

get_disk_controllers()

  return a refrence to an array of all the disk controller paths.

traverse()

  example method that traverses the main object.

get_all_disks_on_controller(controller=>'1/2/3/4.5')

  returns an array refrence to an array that lists all disk devices on a particular controller

get_device_hwpath(device_name=>'/dev/dsk/c4t3d0')

  returns a scalar value of the hwpath to the device used for further device info lookups

get_device_diskinfo(device_name=>'/dev/dsk/c4t3d0', attribute=>'size')

  returns a scalar value of the diskinfo commands attributes

CAVEATS ^

The iocan command is run in blocking mode and may indeed block for several seconds on big systems.

AUTHORs ^

Dominique Dumont <Dominique_Dumont@hp.com>

OO by Christopher White <chrwhite@seanet.com>

Copyright (c) 2001 Dominique Dumont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

ioscan(1M)

## end

syntax highlighting: