HPUX::Ioscan - Perl function to handle HPUX ioscan command
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";
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)
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.
Here's 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' }, }
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 )
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.
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 access_user values: root(default) or remote username
The value is another hash ref containing there keys :
return a refrence to an array of all the disk controller paths.
example method that traverses the main object.
returns an array refrence to an array that lists all disk devices on a particular controller
returns a scalar value of the hwpath to the device used for further device info lookups
The iocan command is run in blocking mode and may indeed block for several seconds on big systems.
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.
ioscan(1M)
## end
To install HPUX::Ioscan, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HPUX::Ioscan
CPAN shell
perl -MCPAN -e shell install HPUX::Ioscan
For more information on module installation, please visit the detailed CPAN module installation guide.