# $Header: emagent/sysman/admin/scripts/Ptdpm0.pm /stpl_db_11.2.0.2.0_aix.ppc64/2 2010/04/29 23:34:26 nparaddi Exp $ # # Package : Ptdpm0.pm # # Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. # # NAME # Ptdpm0.pm # # DESCRIPTION # Collects platform-specific Hardware and Software data # # NOTES # # MODIFIED (MM/DD/YY) # nparaddi 04/28/10 - fix bug 8791320 # nparaddi 04/12/10 - add MOUNT defintion bug 9206261 # rrawat 09/19/07 - Bug-6343367 # nsharma 03/22/06 - Show if SMT is enabled in CPU Implementation # cvaishna 02/16/06 - bug 4702350 # mkiran 08/10/05 - 4519766: Use oslevel instead of uname # mgoodric 05/03/05 - add DMESG # mgoodric 09/27/04 - code cleanup # skumar 01/13/04 - fix getIOInfo() for FAStT devices # skumar 01/09/04 - fix getIOInfo() for SSA devices # skumar 01/02/04 - fix getIOInfo() for UNKNOWN values # skumar 12/31/03 - AIX changes # mgoodric 06/16/03 - fix converting Solaris timezone to JAVA timezones # mgoodric 05/11/03 - added -debug tracing # mgoodric 04/15/03 - fix using uname for arch # mgoodric 04/07/03 - fix finding MAC address # goramamo 01/21/03 - Make scripts more portable # goramamo 12/12/02 - Changes for SPARC III+ machines # goramamo 11/21/02 - Changes to include tvmlet8x tests # goramamo 08/16/02 - Error Msg and getent changes # goramamo 08/16/02 - 904 Changes # goramamo 06/26/02 - Added getent call # xxu 06/25/02 - remove /usr/local/bin/perl # goramamo 06/20/02 - Added GIT5 collection # goramamo 04/12/02 - Pass errorstream to calling Java code # goramamo 03/28/02 - Make NLS compliant; # - Added code to generte XML from files # goramamo 02/28/02 - Fix domainname collection bug 2226505 # mgoodric 02/15/02 - Make scripts more portable # mgoodric 02/13/02 - Creation # ##************************************************************* use strict; package Ptdpm0; use Carp; require 5.005; #require 5.6.1; require Exporter; use ecmErrorMsgs; use Ptdpm3; #****************************************** # Export Subroutines #****************************************** @Ptdpm0::ISA = ('Exporter'); @Ptdpm0::EXPORT = qw( &setupOSD &getOSname &getOSName &getHostName &getDomainName &getCCinfo &getHardwareProvider &getHardwareName &getProcessorType &getArchType &getDiskInfo &getHardwareDetails &getOSrelease &getOSversion &getSwapSpaceInfo &getEtcSystemLocation &getLoadedKernelModules &getNICDetails &getMACAddress &getInstructionSetList &getCurrSysDef &getSysConf &getKernelDriverTunables &getKernelDriverTunableValues &getEtcMnttabLocation &getPkginfoFilesLocation &getAdminEntries &getIPCSStatus &getGlobalVariables &getDefaultRouter &getResolvConf &getGetConfig &getTotalMemory &getTotalLocalDiskSpaceInGB &getProcessorInfo &getIOInfo &execCmd ); #****************************************** # Global Variables #****************************************** use constant NIL => ''; $Ptdpm0::DATALOC = NIL; $Ptdpm0::DEVNULL = '/dev/null'; $Ptdpm0::ARP = '/usr/sbin/arp'; $Ptdpm0::BIN = '/bin'; $Ptdpm0::CAT = '/bin/cat'; $Ptdpm0::DF = '/bin/df'; $Ptdpm0::EGREP = '/bin/egrep'; $Ptdpm0::GETCONF = '/bin/getconf'; $Ptdpm0::GETENT = '/bin/getent'; $Ptdpm0::HOSTNAME = '/bin/hostname'; $Ptdpm0::IFCONFIG = '/usr/sbin/ifconfig'; $Ptdpm0::IPCS = '/bin/ipcs'; $Ptdpm0::ISALIST = '/bin/isalist'; $Ptdpm0::MACH = '/bin/mach'; $Ptdpm0::MODINFO = '/usr/sbin/modinfo'; $Ptdpm0::NDD = '/usr/sbin/ndd'; $Ptdpm0::NSLOOKUP = '/usr/bin/nslookup'; $Ptdpm0::SHOWREV = '/bin/showrev'; $Ptdpm0::SORT = '/bin/sort'; $Ptdpm0::SWAP = '/usr/sbin/swap'; $Ptdpm0::SYSDEF = '/usr/sbin/sysdef'; $Ptdpm0::TAIL = '/bin/tail'; $Ptdpm0::UNAME = '/bin/uname'; $Ptdpm0::PRTDIAG = '/sbin/prtdiag'; $Ptdpm0::KVMPRTDIAG = '/usr/kvm/prtdiag'; $Ptdpm0::LSATTR = '/usr/sbin/lsattr'; $Ptdpm0::LSFS = '/usr/sbin/lsfs'; $Ptdpm0::AWK = '/usr/bin/awk'; $Ptdpm0::LSPS = '/usr/sbin/lsps'; $Ptdpm0::LSDEV = '/usr/sbin/lsdev'; $Ptdpm0::LSCFG = '/usr/sbin/lscfg'; $Ptdpm0::NO = '/usr/sbin/no'; $Ptdpm0::YPMATCH = '/usr/bin/ypmatch'; $Ptdpm0::ODMGET = '/usr/bin/odmget'; $Ptdpm0::LSLPP = '/usr/bin/lslpp'; $Ptdpm0::INSTFIX = '/usr/sbin/instfix'; $Ptdpm0::MOUNT = '/usr/sbin/mount'; $Ptdpm0::PLATFORMLOC = '/usr/platform/'; $Ptdpm0::ETCDEFAULTINITFILE = '/etc/default/init'; $Ptdpm0::ETCSYSTEMFILE = '/etc/system'; $Ptdpm0::ETCMNTTABFILE = '/etc/mnttab'; $Ptdpm0::ETCDEFAULTROUTERFILE = '/etc/defaultrouter'; $Ptdpm0::ETCRESOLVCONFFILE = '/etc/resolv.conf'; $Ptdpm0::TIMEZONEFILE = '/etc/TIMEZONE'; $Ptdpm0::PKGLOC = '/var/sadm/pkg'; $Ptdpm0::VOSRELEASEFILE = '/etc/opt/SUNWvosr/release'; $Ptdpm0::OSLEVEL = '/usr/bin/oslevel'; #****************************************** # Exported Subroutines #****************************************** sub setupOSD { $Ptdpm0::DATALOC = $_[0]; if (equalsIgnoreCase($main::OS, 'linux')) { $Ptdpm0::ARP = '/sbin/arp'; $Ptdpm0::GETCONF = '/usr/bin/getconf'; $Ptdpm0::GETENT = '/usr/bin/getent'; $Ptdpm0::IFCONFIG = '/sbin/ifconfig'; $Ptdpm0::IPCS = '/usr/bin/ipcs'; $Ptdpm0::MODINFO = '/sbin/modinfo'; $Ptdpm0::NSLOOKUP = '/usr/bin/nslookup'; $Ptdpm0::TAIL = '/usr/bin/tail'; } } sub getOSname { debugTrace('Calling... getOSname()'); # Purpose: To get the OS name my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::UNAME); if ($rc == 1) { $cmd = "$Ptdpm0::UNAME -s"; } else { return $value; } } else { $cmd = catCmd('unames.out'); } $value = execCmd($cmd); return $value; } sub getOSName { return $main::OSNAME; } sub getOSrelease { debugTrace('Calling... getOSrelease()'); # Purpose: To get OS Release my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::OSLEVEL); if ($rc == 1) { $cmd = "$Ptdpm0::OSLEVEL"; } else { return $value; } } else { $cmd = catCmd('unamer.out'); } $value = execCmd($cmd); return $value; } sub getOSversion { debugTrace('Calling... getOSversion()'); # Purpose: To get OS Version my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::OSLEVEL); if ($rc == 1) { $cmd = "$Ptdpm0::OSLEVEL -r"; } else { return $value; } } else { $cmd = catCmd('unamev.out'); } $value = execCmd($cmd); return $value; } sub getHardwareName { debugTrace('Calling... getHardwareName()'); # Purpose: To get hardware platform my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::UNAME); if ($rc == 1) { $cmd = "$Ptdpm0::UNAME -M"; } else { return $value; } } else { $cmd = catCmd('unameM.out'); } $value = execCmd($cmd); return $value; } sub getProcessorType { debugTrace('Calling... getProcessorType()'); # Purpose: To get processor type my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; my @ptype = (); if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::MACH); if ($rc == 1) { $cmd = "$Ptdpm0::LSATTR -l proc0 -a type -E"; } else { return $value; } } else { $cmd = catCmd('lsattr.out'); } $value = execCmd($cmd); @ptype = split(' ', $value); return $ptype[1]; } sub getArchType { debugTrace('Calling... getArchType()'); # Purpose: To get architecture type my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::UNAME); if ($rc == 1) { $cmd = "$Ptdpm0::UNAME -p"; } else { return $value; } } else { $cmd = catCmd('unamep.out'); } $value = execCmd($cmd); return $value; } sub getHostName { debugTrace('Calling... getHostName()'); # Purpose: To get hostname my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::HOSTNAME); if ($rc == 1) { $cmd = "$Ptdpm0::HOSTNAME"; } else { return $value; } } else { $cmd = catCmd('hostname.out'); } $value = execCmd($cmd); $Ptdpm0::hostname = $value; return $value; } sub getDomainName { debugTrace('Calling... getDomainName()'); # Purpose: To get domain name my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; my @domarr = (); if ($datadir eq NIL) { #Changed to fix the bug 2226505 my $rc = checkCmd($Ptdpm0::NSLOOKUP); if ($rc == 1) { # $cmd = "$Ptdpm0::NSLOOKUP $Ptdpm0::hostname 2>&1 | $Ptdpm0::EGREP $Ptdpm0::hostname"; $cmd = "$Ptdpm0::NSLOOKUP $Ptdpm0::hostname 2>&1"; } else { return @domarr; } } else { $cmd = catCmd('nslookuphost.out'); } #my $dom =`$cmd 2>$Ptdpm0::DEVNULL`; $value = evalCmd($cmd); my @dom = split ("\n", $value); @domarr = grep /$Ptdpm0::hostname/, @dom; chomp(@domarr); return @domarr; } sub getHardwareProvider { debugTrace('Calling... getHardwareProvider()'); # Purpose: To get hardware vendor return "IBM Corporation"; my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; my @info = (); my @info1 = (); if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::SHOWREV); if ($rc == 1) { $cmd = "$Ptdpm0::SHOWREV"; } else { return @info; } } else { $cmd = catCmd('showrev.out'); } $value = execCmd($cmd); @info1 = split ("\n", $value); @info = grep /Hardware provider:/, @info1; chomp(@info); return @info; } sub getDiskInfo { debugTrace('Calling... getDiskInfo()'); # Purpose: To get disk space/filesystem space my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; my $disk = NIL; my (@diskinfo) = (); if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::LSFS) & checkCmd($Ptdpm0::TAIL); if ($rc == 1) { $cmd = "$Ptdpm0::LSFS -c | $Ptdpm0::TAIL +2 | $Ptdpm0::EGREP \":jfs\" | $Ptdpm0::AWK -F':' '{printf(\"%s \", \$1)}'"; } else { return @diskinfo; } } else { $cmd = catCmd('dfFufsk.out'); } $value = execCmd($cmd); $value = execCmd("$Ptdpm0::DF -k $value | $Ptdpm0::TAIL +2"); @diskinfo = split ("\n", $value); chomp(@diskinfo); return @diskinfo; } sub getHardwareDetails { debugTrace('Calling... getHardwareDetails()'); # Purpose: To get hardware details on Sun SPARC machines my $datadir = $Ptdpm0::DATALOC; my $cmd = ''; my $value = ''; my @md = (); my @hw = (); my $i = 0; my $platform = getHardwareName($datadir); chomp(my @plat = split (' ', $platform)); my $prtdiag = ''; return @hw; if ($datadir eq '') { for ($i = 1 ; $i > -1 ; $i--) { $cmd = ''; $prtdiag = join ($plat[$i], $Ptdpm0::PLATFORMLOC, $Ptdpm0::PRTDIAG); if (-x "$prtdiag") { $cmd = "$prtdiag -v"; last; } } if ($cmd eq '' && -x $Ptdpm0::KVMPRTDIAG) { $cmd = $Ptdpm0::KVMPRTDIAG; } if ($cmd eq '') { throwECMError('CmdNotFound', "$prtdiag or $Ptdpm0::KVMPRTDIAG"); return @hw; } } else { $md[0] = $datadir . 'prtdiagv' . "$plat[1].out"; $md[1] = $datadir . 'prtdiagv' . "$plat[0].out"; $md[2] = $datadir . 'prtdiagv' . 'kvm.out'; for ($i = 0 ; $i < 3 ; $i++) { if (-e "$md[$i]") { $cmd = "$Ptdpm0::CAT $md[$i]"; last; } } } $value = execCmd($cmd); @hw = split ("\n", $value); chomp(@hw); return @hw; } sub getEtcSystemLocation { debugTrace('Calling... getEtcSystemLocation()'); # Purpose: To confirm the presence of /etc/system my $datadir = $Ptdpm0::DATALOC; my $value = $Ptdpm0::ETCSYSTEMFILE; if ($datadir ne NIL) { $value = $datadir . $value; } if (!(-e "$value")) { throwECMError('FileNotFound', $value); $value = NIL; } return $value; } sub getCCinfo { debugTrace('Calling... getCCinfo()'); # Purpose: To get certified config info (obsolete) my $datadir = $Ptdpm0::DATALOC; # For VOS configurations, the release file is at /etc/opt/SUNWvosr/release my $releasefile = $Ptdpm0::VOSRELEASEFILE; if ($datadir ne NIL) { $releasefile = $datadir . 'CCrelease.out'; } my (@ccdet) = (); if (-e "$releasefile") { $ccdet[0] = 'Sun Microsystems, Veritas' . "\n"; ## 11/08/2001 debugTrace('Opening... ' . $releasefile); open(IN5, $releasefile); my $i = 1; while () { if (index($_, "Copyright") == -1) { $ccdet[$i] = $_; $i++; } } close(IN5); } else { #print HWInfo "$star The VOS Image release file $releasefile NOT found $star"; } return @ccdet; } sub getLoadedKernelModules { debugTrace('Calling... getLoaderKernelModules()'); # Purpose: To get loaded kernel modules my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; my @modinfo = (); if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::MODINFO); if ($rc == 1) { $cmd = "$Ptdpm0::MODINFO"; } else { return @modinfo; } } else { $cmd = catCmd('modinfo.out'); } $value = execCmd($cmd); @modinfo = split ("\n", $value); chomp(@modinfo); return @modinfo; } sub getSwapSpaceInfo { debugTrace('Calling... getSwapSpaceInfo()'); # Purpose: To get swap space my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; my @swap = (); if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::LSPS); if ($rc == 1) { $cmd = "$Ptdpm0::LSPS -as | $Ptdpm0::TAIL +2"; } else { return @swap; } } else { $cmd = catCmd('swapl.out'); } $value = execCmd($cmd); @swap = split ("\n", $value); chomp(@swap); return @swap; } # GIT5 Additions sub getNICDetails { debugTrace('Calling... getNICDetails()'); # Purpose: To get network interface details my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; my @nic = (); if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::IFCONFIG); if ($rc == 1) { $cmd = "$Ptdpm0::IFCONFIG -a"; } else { return @nic; } } else { $cmd = catCmd('ifconfiga.out'); } $value = execCmd($cmd); @nic = split ("\n", $value); chomp(@nic); return @nic; } sub getMACAddress { debugTrace('Calling... getMACAddress()'); # Purpose: To get MAC address for a given inet address my $inet = $_[0]; my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::ARP); if ($rc == 1) { $cmd = "$Ptdpm0::ARP $inet 2>&1"; } else { return $value; } } else { $cmd = catCmd("arp/$inet.out"); } $value = evalCmd($cmd); return $value; } sub getInstructionSetList { debugTrace('Calling... getInstructionSetList()'); # Purpose: To get the set of instruction lists that can be run Sun SPARC machines my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::GETCONF); if ($rc == 1) { $cmd = "$Ptdpm0::GETCONF HARDWARE_BITMODE"; } else { return $value; } } else { $cmd = catCmd('getconf.out'); } $value = execCmd($cmd) . "-bit"; return $value; } sub getIPCSStatus { debugTrace('Calling... getIPCStatus()'); # Purpose: To report inter-process communication facilities status my $cmd = NIL; my $value = NIL; if (-x "$Ptdpm0::IPCS") { my $rc = checkCmd($Ptdpm0::IPCS); if ($rc == 1) { $cmd = "$Ptdpm0::IPCS -a"; } else { return; } } $value = execCmd($cmd); return; } sub getCurrSysDef { debugTrace('Calling... getCurrSysDef()'); # Purpose: To get current system definition my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; my @sdef = (); if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::LSDEV); if ($rc == 1) { $cmd = "$Ptdpm0::LSDEV"; } else { return @sdef; } } else { $cmd = catCmd('sysdefi.out'); } $value = execCmd($cmd); @sdef = split ("\n", $value); chomp(@sdef); return @sdef; } sub getSysConf { debugTrace('Calling... getSysConf()'); # Purpose: To get system configuration values my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; my @sdef = (); if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::GETCONF); if ($rc == 1) { $cmd = "$Ptdpm0::GETCONF -a"; } else { return @sdef; } } else { $cmd = catCmd('getconfa.out'); } $cmd = "$Ptdpm0::GETCONF OPEN_MAX"; $value = execCmd($cmd); $sdef[0] = "OPEN_MAX: $value"; $cmd = "$Ptdpm0::GETCONF CHILD_MAX"; $value = execCmd($cmd); $sdef[1] = "CHILD_MAX: $value"; return @sdef; } sub getGetConfig { debugTrace('Calling... getGetConfig()'); # Purpose: To get value for given system configuration setting my $parm = $_[0]; my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::GETCONF); if ($rc == 1) { $cmd = "$Ptdpm0::GETCONF $parm"; } else { return $value; } } else { $cmd = catCmd('getconfa.out'); } $value = execCmd($cmd); return $value; } sub getKernelDriverTunables { debugTrace('Calling... getKernelDriverTunables()'); # Purpose: To get kernel driver tunables, only parameters alone for a given protocol my $protocol = $_[0]; my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; my @parms = (); my $parm = NIL; my @retparms = (); if ($datadir eq NIL) { my $rc = checkCmd($Ptdpm0::NO); if ($rc == 1) { $cmd = "$Ptdpm0::NO -a 2>$Ptdpm0::DEVNULL"; } else { return @retparms; } } else { my @temp = split ("\/", $protocol); $cmd = catCmd("ndddev/$temp[2].out"); } $value = execCmd($cmd); @parms = split ("\n", $value); foreach $parm (@parms) { $parm =~ s/=.*//; push @retparms, trim($parm); } return @retparms; } sub getKernelDriverTunableValues { debugTrace('Calling... getKernelDriverTunableValues()'); # Purpose: To get values for the given set of kernel driver tunable parameters for a given protocol my $parmlist = $_[0]; my $datadir = $Ptdpm0::DATALOC; my $cmd = ''; my $value = ''; my @parms = (); my $parm = ''; my @retparms = (); if ($datadir eq '') { my $rc = checkCmd($Ptdpm0::NO); if ($rc == 1) { $cmd = "$Ptdpm0::NO -a 2>$Ptdpm0::DEVNULL"; } else { return @retparms; } } else { my @temp1 = split (' ', $parmlist, 2); my @temp2 = split ('_', $temp1[1], 2); my $temp = $temp2[0] . 'values'; $cmd = catCmd("ndddev/$temp.out"); } $value = execCmd($cmd); @parms = split ("\n", $value); foreach $parm (@parms) { $parm =~ s/.*=//; push @retparms, trim($parm); } return @retparms; } sub getEtcMnttabLocation { debugTrace('Calling... getEtcMnttabLocation()'); # Purpose: To confirm the presence of /etc/mnttab return NIL; my $datadir = $Ptdpm0::DATALOC; my $value = $Ptdpm0::ETCMNTTABFILE; if ($datadir ne NIL) { $value = $datadir . $value; } if (!(-e "$value")) { throwECMError('FileNotFound', $value); $value = NIL; } return $value; } sub getGlobalVariables { debugTrace('Calling... getGlobalVariables()'); # Purpose: To get global variables my $datadir = $Ptdpm0::DATALOC; my $value = $Ptdpm0::ETCDEFAULTINITFILE; if ($datadir ne '') { $value = $datadir . $value; } if (!(-e "$value")) { $value = NIL; } return $value; } sub getDefaultRouter { debugTrace('Calling... getDefaultRouter()'); # Purpose: To get default router my $datadir = $Ptdpm0::DATALOC; my $value = $Ptdpm0::ETCDEFAULTROUTERFILE; if ($datadir ne NIL) { $value = $datadir . $value; } if (!(-e "$value")) { $value = NIL; } return $value; } sub getResolvConf { debugTrace('Calling... getResolvConf()'); # Purpose: To get name servers my $datadir = $Ptdpm0::DATALOC; my $value = $Ptdpm0::ETCRESOLVCONFFILE; if ($datadir ne NIL) { $value = $datadir . $value; } if (!(-e "$value")) { $value = NIL; } return $value; } sub getPkginfoFilesLocation { debugTrace('Calling... getPkginfoFilesLocation()'); # Purpose: To confirm the presence of /var/sadm/pkg my $datadir = $Ptdpm0::DATALOC; my $value = $Ptdpm0::PKGLOC; if ($datadir ne NIL) { $value = $datadir . 'pkg'; } if (!(-d "$value")) { # When /var/sadm/pkg dir is NOT present # pkginfo: neither returns output nor error # showrev: opendir throwECMError('PackNotFound', $Ptdpm0::PKGLOC); $value = NIL; } return $value; } sub getAdminEntries { debugTrace('Calling... getAdminEntries()'); # Purpose: To get the entries from administrative database for given database and value my $parm = $_[0]; my $datadir = $Ptdpm0::DATALOC; my $cmd = NIL; my $value = NIL; if ($datadir eq NIL) { if (-x "$Ptdpm0::YPMATCH") { $cmd = "$Ptdpm0::YPMATCH $parm hosts"; } else { $cmd = "$Ptdpm0::EGREP $parm /etc/hosts"; } } else { my $temp1 = NIL; my $temp2 = NIL; ($temp1, $temp2) = split (' ', $parm, 2); $cmd = catCmd("getent/$temp2.out"); } $value = evalCmd($cmd); return $value; } sub getTotalMemory { debugTrace('Calling... getTotalMemory()'); my $cmd = NIL; my $value = NIL; my @parm = (); my $size; my @memory = (); my $i; $cmd = "$Ptdpm0::LSATTR -l sys0 -a realmem -E"; $value = execCmd($cmd); @parm = split (" ", $value); chomp(@parm); return $parm[1]/1024; # in MB } sub getTotalLocalDiskSpaceInGB { #Outputs : total local disk space in GB debugTrace('Calling... getTotalLocalDiskSpaceInGB()'); my @diskinfo; my $totalDiskCap; my $diskCap; my %diskCaps = (); my $line; my $fileSystem; @diskinfo = getDiskInfo(); $totalDiskCap = 0; foreach $line (@diskinfo) { $_ = $line; ($fileSystem) = /(.*?)\s+/; # get the file system column ($diskCap) = /\w+\s+(\w+)/i; # get at the disk capacity column next if defined $diskCaps{$fileSystem}; $diskCaps{$fileSystem} = $diskCap; $totalDiskCap += $diskCap; } $totalDiskCap=sprintf("%.3f",$totalDiskCap/(1024*1024)); return $totalDiskCap; } sub getProcessorInfo { debugTrace('Calling... getProcessorInfo()'); my $cmd = NIL; my $value = NIL; my @value1 = (); my @value2 = (); my $line1 = NIL; my $line2 = NIL; my @temp = (); my $processor = NIL; my $i; my $j; my $k = 0; my @cpuinfo = (); my $smtenabled = NIL; $cmd = "$Ptdpm0::LSDEV -c processor | $Ptdpm0::EGREP ' Available ' "; $value = execCmd($cmd); @value1 = split ("\n", $value); foreach $line1 (@value1) { chomp($line1); @temp = split(' ', $line1); $cmd = "$Ptdpm0::LSATTR -l $temp[0] -E"; $value = execCmd($cmd); @value2 = split ("\n", $value); $smtenabled = NIL; foreach $line2 (@value2) { chomp($line2); @temp = split(' ', $line2); if ($line2 =~ /frequency/) { $cpuinfo[$k] = $temp[1]/(1000*1000); } if ($line2 =~ /smt_enabled/) { if ( $temp[1] =~ /true/ ) { $smtenabled = "(SMT_Enabled)"; } } if ($line2 =~ /type/) { if ( $smtenabled ne NIL ) { $cpuinfo[$k] = $cpuinfo[$k] . " " . $temp[1] . $smtenabled; } else { $cpuinfo[$k] = $cpuinfo[$k] . " " . $temp[1]; } } } $k++; } return @cpuinfo; } sub getIOInfo { debugTrace('Calling... getIOInfo()'); my $vendor ='NOT_AVAILABLE'; my $devname = NIL; my $bustype = NIL; my $type = NIL; my $subclass = NIL; my $model = 'NOT_AVAILABLE'; # we consider only these 10 classes from the set of predefined classes # in the device database, as they are the ones which correspond to IO cards my @classes = ('PCM', 'adapter', 'aio', 'array', 'bus', 'concentrator', 'posix_aio', 'tmscsi', 'tmssa', 'usb','disk'); my $class = NIL; my $cmd = NIL; my $value = NIL; my @value = (); my $line = NIL; my @ioc_results = (); my $NoOfCards = 0; foreach $class (@classes) { $cmd = "$Ptdpm0::LSDEV -S a -c $class -F'name;type;subclass'"; $value = evalCmd($cmd); @value = split ("\n", $value); foreach $line (@value) { $bustype = "NOT_AVAILABLE"; $type = "NOT_AVAILABLE"; $subclass = "NOT_AVAILABLE"; ($devname, $type, $subclass) = split (";", $line); # bustype is represented as a combination of type, and subclass of the device $bustype = $class.':'.$type.':'.$subclass; # With the current facilities in aix, it is not possible to extract information # about $vendor, $model for the IO cards, in an efficient # manner. Until then, these fields will be reported as blank. $ioc_results[$NoOfCards++] = "$devname $vendor $class $bustype $model"; } } return @ioc_results; } sub catCmd { return join ($Ptdpm0::DATALOC, $Ptdpm0::CAT . ' ', $_[0]); } sub checkCmd { # Purpose: To check whether the given command is present and executable my $cmd = $_[0]; my $rc = 1; if (!(-x "$cmd")) { $rc = 0; throwECMError('CmdNotFound', $cmd); } return $rc; } sub execCmd { # Purpose: To execute the given command checking for errors my $cmd = $_[0]; my $value = NIL; debugTrace('Executing... ' . $cmd); chomp($value = `$cmd` || throwECMError('Failed', $cmd)); return $value; } sub evalCmd { # Purpose: To execute the given command w/o checking for errors my $cmd = $_[0]; my $value = NIL; debugTrace('Executing... ' . $cmd); chomp($value = `$cmd`); return $value; } 1; # End of the Program