mcsysinfoperl — MagniComp™ SysInfo™ Perl API to obtain detailed system information in a platform neutral manner
use lib ('/opt/sysinfo/lib/mcSysInfo'); use mcSysInfo; $mcSysInfo = mcSysInfo->New; # Optional: Specify pathname to sysinfo(1) $mcSysInfo->Program($SysInfoPath); # Optional: Use $InFile in place of sysinfo(1) $mcSysInfo->InputFile($InFile); # Optional: Limit data to class List $mcSysInfo->Class(@List); # Retrieve data and populate $mcSysInfo $mcSysInfo->Retrieve(%Options); # Raw report interface $mcSysInfo->ReportSet($Options); for ( ; ; ) { my $Line = $SysInfo->ReportLine; if (!defined($Line)) { last; } printf "%s\n", $Line; } $mcSysInfo->ReportEnd;
The mcSysInfo perl(1) interface is part of the MagniComp SysInfo software. (See mcsysinfo(1) for an overview.) It provides a perl(1) object API for obtaining detailed data about the local or remote system's configuration via a platform neutral interface.
Please see mcsysinfoc(3) if a C API is required.
When mcSysInfo->Retrieve is called it obtains the requested data from a source determined as follows:
If this member is set, the data is read from this file. The file should be in mcsysinforeport(5) format.
If mcSysInfo->Host is set, then data is retrieved via the SSP protocol from the specified host.
If a local file cache of the requested data is available, the data is read from the cache.
The SysInfo Engine (SIE) is run locally to obtain data. As the data is read from SIE it is saved to a local file cache (see FILE CACHE for more details).
In all cases, the data is parsed into perl(1) objects and made available as members of mcSysInfo (see below for details).
If you wish to retrieve raw "report" format data one line at a time, first call mcSysInfo->ReportSet and then call mcSysInfo->ReportLine to retrieve one line of "report" format data. This function returns undef when all data has been read. The mcSysInfo->ReportEnd function will close any open file descriptors.
When data is retrieved via mcSysInfo->Retrieve it is cached in files under the /tmp/mcsysinfo.cache.UID (where UID is the UID of the user calling the API) directory. An alternate directory can be specified by passing the hash value of CacheDir=>Dir to mcSysInfo->Retrieve.
Each class of data requested is stored in its own cache file.
Cache files have a limited lifespan after which they are considered invalid. When a cache file expires, it is replaced with a new cache upon the next request for the same data. By default, cache files expire after 5 minutes. You may specify an expiration time (in seconds) by passing the hash value of ExpireTime=>Seconds to mcSysInfo->Retrieve.
The following is a list of object members available for the mcSysInfo object:
Limit the class of information retrieved and returned to @List. The contents of @List should be valid class names as returned by sysinfo --list class. The default is to return all class types.
This function should be called when the object is no longer needed. It will gracefully destroy the object including shutting down any remote connections which were established.
Retrieve all information from server host Name which can either be a hostname or IP address. The host must be running mcsysinfod(1).
Use the file specified by Path as input instead of running the mcsysinfo(1) program. The file must be in mcsysinforeport(5) format. The default is to run the mcsysinfo(1) program.
Use String as the plain text password to authenticate as (when required) when connecting to a mcsysinfod(8) server. You must set Password in conjunction with Username.
Connect to mcsysinfod(8) on port Number on the host specified by the Host member. Defaults to the standard SSP port.
Use Path as the pathname to the mcsysinfo(1) program. The default is /opt/sysinfo/bin/sysinfo.
Specify @Array as a list of arguments (options) to be passed to Program.
Perform retrieval of requested data. It accepts a hash argument of options and understands the following:
If Cache is set to 1 or no Cache value is specified (the default), caching will be enabled. If Cache is set to 0 caching will be disabled.
Cache directory.
Number of seconds before cached data expires.
Refresh all requested data in the cache. Data is retreived directly from authorative sources and the cache files are updated.
Use Name as the username to authenticate as (when required) when connecting to a mcsysinfod(8) server. You must set Username in conjunction with Password.
Returns a hash of version information. The following hash members may be returned:
The overall product version.
The version of the SysInfo Engine (SIE).
The version of mcsysinfod(8). This is only returned if the Host object member is set and access to Host succeeded.
The version of the SysInfo Service Protocol (SSP) that Host speaks. This is only available if we can talk to mcsysinfod(8) on Host.
The following mcSysInfo object members contain the system configuration data after mcSysInfo->Retrieve is called:
Table 25. Data Members of mcSysInfo
Member | Content | More Info |
---|---|---|
FileSys | Filesystem configuration data. | OBJECT mcFileSys |
General | General system configuration data. | OBJECT mcGeneral |
Hardware | Hardware (device) configuration data. | OBJECT mcHardware |
Kernel | Kernel configuration data. | OBJECT mcKernel |
MagniCompLic | MagniComp License information. | OBJECT mcMagniCompLic |
NetIf | Network Interface information. | OBJECT mcNetIf |
Network | Network configuration information. | OBJECT mcNetwork |
License | License information. | OBJECT mcLicense |
SiteInfo | Site specific information. | OBJECT mcSiteInfo |
Software | Installed software data. | OBJECT mcSoftware |
SysConf | System configuration data. | OBJECT mcSysConf |
Partition | Disk partition data. | OBJECT mcPartition |
Printer | Printer queue data. | OBJECT mcPrinter |
The mcFileSys object contains data on all filesystems on a system. The following are valid members:
Returns a hash of mcFileSysInfo objects each of which details a specific filesystem. The hash key is a unique filesystem name. The value is an mcFilesysInfo object. See OBJECT mcFileSysInfo for details.
The table below specifies the valid members of the mcFileSysInfo object and describes their usage.
Member | Description | Returns |
---|---|---|
Name | Filesystem Name | Scalar |
DevName | Device Name | Scalar |
DevPath | Device Path | Scalar |
DevPathRaw | Device Path Raw | Scalar |
Server | Server of Filesystem | Scalar |
Type | Filesystem Type | Scalar |
MntOpts | Mount Options | Array |
Size | Total size of filesystem | Scalar |
AmtUsed | Amount of space used | Scalar |
AmtAvail | Amount of space available | Scalar |
The mcHardware object contains data on what hardware (devices) is installed on the system. The following are valid members:
Returns a hash of mcDevInfo objects each of which details an installed device. The hash key is a unique device name. The value is an mcDevInfo object. See OBJECT mcDevInfo for details.
A special device entry with a key of TOTAL DISK contains the total amount of disk space on the system.
The table below specifies the valid members of the mcDevInfo object and describes their usage.
Member | Description | Returns |
---|---|---|
Aliases | Aliases | Array |
AltName | AKA Name | Scalar |
Bus | Bus no. of device | Scalar |
Capacity | Capacity (size) of device | Scalar |
ClassType | Class Type | Scalar |
DescList | List of misc descriptions | Array |
DevNum | Device no. on Bus | Scalar |
DevSpec | Device type specific data | varies |
Driver | Driver name | Scalar |
Files | Files | Array |
Ident | Identifier | Scalar |
Model | Model | Scalar |
ModelDesc | Model Description | Scalar |
Name | Name of device | Scalar |
Next | Next peer device | Scalar |
NodeID | Node ID | Scalar |
Part | Part # | Scalar |
Port | Port no. on Bus | Scalar |
Revision | Revision | Scalar |
Serial | Serial # | Scalar |
Slaves | List of child devices | Array |
Speed | Speed of device | Scalar |
Type | Type | Scalar |
Unit | Unit | Scalar |
Vendor | Manufacturer | Scalar |
The table below specifies the valid members of the mcCpuInfo object and describes their usage. A mcCpuInfo object is usually available via mcDevInfo->DevSpec when mcDevInfo->Type is CPU.
Member | Description | Returns |
---|---|---|
Arch | Architecture | Scalar |
ArchVer | Architecture Version | Scalar |
BitSize | Bit Size | Scalar |
Caches | List of onboard caches | Array |
HasFPU | Has FPU | Scalar |
Man | Manufacturer | Scalar |
Model | Model | Scalar |
Serial | Serial # | Scalar |
Speed | Clock Speed | Scalar |
Stepping | Stepping | Scalar |
The table below specifies the valid members of the mcCacheInfo object and describes their usage. A mcCacheInfo object is usually available via the mcDevInfo->DevSpec->Caches array when mcDevInfo->Type is processor.
Member | Description | Returns |
---|---|---|
Name | Name of the cache | Scalar |
Device | Name of device cache is on | Scalar |
Enabled | Is the cache enabled? | Scalar |
Type | The type of cache | Scalar |
Size | The size of the cache (KB) | Scalar |
Speed | Clock Speed | Scalar |
Assoc | Associativety | Scalar |
Lines | # of Lines | Scalar |
LineSize | Line Size | Scalar |
TLB | # TLB | Scalar |
TLBAssoc | TLB Associativety | Scalar |
Socketed | Is cache socketed? | Scalar |
Location | Location relative to CPU | Scalar |
SramType | Type of SRAM | Scalar |
EccType | ECC Type | Scalar |
Mode | Mode of operation | Scalar |
The mcGeneral object contains general system configuration data. The table below specifies the valid members of the mcGeneral object and describes their usage.
Member | Description | Returns |
---|---|---|
Hostname | Host Name | Scalar |
HostAliases | Host Aliases | Array |
HostAddrs | Host Addresses | Array |
HostId | Host ID | Scalar |
Serial | Serial # | Scalar |
ManShort | Manufacturer (Short) | Scalar |
ManLong | Manufacturer (Long) | Scalar |
Man | Manufacturer | Scalar |
Model | Model | Scalar |
PhysMem | Physical Memory | Scalar |
VirtMem | Virtual Memory | Scalar |
RomVer | ROM Version | Scalar |
NumCpu | Number of CPU (Physical) | Scalar |
NumCpuVirt | Number of CPU (Virtual) | Scalar |
CpuType | CPU Type | Scalar |
CpuModel | CPU Model | Scalar |
CpuSpeed | CPU Speed | Scalar |
AppArch | App Architecture | Scalar |
KernArch | Kernel Architecture | Scalar |
KernBits | Kernel Bit Size | Scalar |
OSname | OS Name | Scalar |
OSver | OS Version | Scalar |
OSdist | OS Distribution | Scalar |
OSdistName | OS Distribution Name | Scalar |
OSdistShName | OS Distribution Short Name | Scalar |
OSdistVer | OS Distribution Version | Scalar |
KernVer | Kernel Version | Scalar |
BootTime | Boot Time | Scalar |
CurrentTime | Current Time | Scalar |
LibcName | Libc Name | Scalar |
LibcVer | Libc Version | Scalar |
TimeZone | Time Zone | Scalar |
PrimaryUserLogin | System's Primary User Login | Scalar |
PrimaryUserName | System's Primary User (full) Name | Scalar |
This object contains information about all licenses which were obtained from license servers or other sources on the system scanned by this API. The following are the valid members for this object:
A hash table of mcLicenseInfo objects, each of which contains the actual license data.
This object contains information about one license. The members of this object are:
Member | Description | Returns |
---|---|---|
SoftName | Software Name | Scalar |
SoftVer | Software Version | Scalar |
Type | Type of license | Scalar |
TypeDesc | Description of Type of license | Scalar |
Port | Port license server listens on | Scalar |
File | File containing license | Scalar |
ServerSoft | Name of license server software | Scalar |
ServerVer | Version of license server software | Scalar |
VendorServerSoft | Name of license vendor's server software | Scalar |
VendorServerVer | Version of license vendor's server software | Scalar |
Count | # of licenses (RTUs) | Scalar |
Issuer | Who issued license | Scalar |
Hostid | Hostid license is tied to | Scalar |
IssueDate | Date license was issued | Scalar |
StartDate | Date license starts | Scalar |
ExpireDate | Date license expires | Scalar |
DaysLeft | # days before expiration | Scalar |
Key | License key | Scalar |
Serial | Serial # of license | Scalar |
MinCPU | Minimum # of CPUs license is valid for | Scalar |
MaxCPU | Max # of CPUs license is valid for | Scalar |
AccountName | Name of customer's account | Scalar |
AccountNumber | Customer account number | Scalar |
Comment | Free form comment field | Scalar |
LicenseURL | URL of license terms | Scalar |
HomePageURL | URL of product | Scalar |
Status | Status of license | Scalar |
HostName | Name of host license is tied to | Scalar |
The mcMagniCompLic object contains data on MagniComp SysInfo licenses. The following are valid members:
A hash table of SysInfo licenses each contained in a mcLicenseInfo object.
A hash table of SysInfo licenses in mcsysinforeport(5) (report) format.
The mcKernel object contains data on kernel variables and configuration. The following are valid members:
Returns a hash of mcName objects each of which details a kernel entry. The hash key is a unique variable name. The value is an mcName object. See OBJECT mcName for details.
This object contains information about all network interfaces found on the scanned system. The following are the valid members for this object:
A hash table of mcNetIfInfo objects, each of which contains the actual network interface data.
The table below specifies the valid members of the mcNetIfInfo object and describes their usage. A mcNetIfInfo object is usually available via mcDevInfo->DevSpec when mcDevInfo->Type is netif as well as in the Entries hash in the mcNetIf object.
Member | Description | Returns |
---|---|---|
Name | NIC Name | Scalar |
Type | NIC Address Type | Scalar |
IfType | NIC Interface Type | Scalar |
HostAddr | NIC Host Address | Scalar |
HostName | NIC Host Name | Scalar |
MACaddr | NIC MAC Current Address | Scalar |
MACname | NIC MAC Current Name | Scalar |
FacMACaddr | NIC MAC Factory Address | Scalar |
FacMACname | NIC MAC Factory Name | Scalar |
NetAddr | NIC Network Address | Scalar |
NetName | NIC Network Name | Scalar |
NetMask | NIC Network Mask | Scalar |
BroadAddr | NIC Broadcast Address | Scalar |
MtuSize | NIC MTU Size | Scalar |
Speed | NIC Link Speed | Scalar |
Duplex | NIC Link Duplex | Scalar |
Flags | NIC flags | Hash |
MediaType | NIC Media Type | Scalar |
MediaSubType | NIC Media Sub Type | Scalar |
This object contains information about network configuration. The following are the valid members for this object:
A hash table of mcNetIfInfo objects, each of which contains the actual network interface data. There is currently only one supported keyword called Network.
The table below specifies the valid members of the mcNetworkInfo object and describes their usage. A mcNetworkInfo object is usually available via the Entries hash in the mcNetwork object.
Member | Description | Returns |
---|---|---|
DefGatewayIP | Default gateway IP address | Scalar |
DefGatewayName | Default gateway hostname | Scalar |
DnsDomain | DNS domain name | Scalar |
DnsServerIPs | DNS server IP addresses | Array |
DnsServerNames | DNS server hostnames | Array |
NisDomain | NIS domain name | Scalar |
NisServerMethod | NIS server selection method | Scalar |
NisServerIPs | NIS server IP addresses | Array |
NisServerNames | NIS server hostnames | Array |
NisServerCurrent | Currently bound NIS server | Scalar |
NisMaster | NIS master server | Scalar |
The mcPartition object contains data on what disk partitions are on the system. The following are valid members:
Returns a hash of mcPartInfo objects each of which details a partition entry. The hash key is a unique partition name. The value is an mcPartInfo object. See OBJECT mcPartInfo for details.
The table below specifies the valid members of the mcPartInfo object and describes their usage.
Member | Description | Returns |
---|---|---|
Name | Partition Name | Scalar |
DevName | Device Name | Scalar |
DevPath | Device Path | Scalar |
DevPathRaw | Device Path Raw | Scalar |
BaseName | Base Name | Scalar |
Slice | Slice | Scalar |
Num | Partition # | Scalar |
Type | Type | Scalar |
TypeDesc | Type Description | Scalar |
TypeNum | Type Number | Scalar |
UsageStatus | Usage Status | Scalar |
MntName | Mount Name | Scalar |
MntOpts | Mount Options | Array |
Size | Size (MB) | Scalar |
AmtUsed | Amount Used (MB) | Scalar |
SecSize | Sector Size (bytes) | Scalar |
StartSect | Starting Sector | Scalar |
EndSect | Ending Sector | Scalar |
NumSect | Number of Sectors | Scalar |
The mcPrinter object contains data on what printer queues are on the system. The following are valid members:
Returns a hash of mcPrinterInfo objects each of which details a printer queue. The hash key is a unique printer name. The value is an mcPrinterInfo object. See OBJECT mcPrinterInfo for details.
The table below specifies the valid members of the mcPrinterInfo object and describes their usage.
Member | Description | Returns |
---|---|---|
Name | Queue Name | Scalar |
Aliases | Queue Aliases | Array |
Descript | Description of queue | Scalar |
Vendor | Printer Vendor | Scalar |
Model | Printer Model | Scalar |
Proto | Communication Protocol | Scalar |
Device | Pathname to printer device | Scalar |
Server | Name of server printer is on | Scalar |
RemoteQueue | Queue name on Server | Scalar |
Langs | Supported printer languages | Array |
SpoolDir | Spool Directory | Scalar |
MaxJobSize | Max size of each job | Scalar |
DescList | Misc descriptions | Array |
The mcSiteInfo object contains site defined information customized by each site. The following are valid members:
Returns a hash of mcSiteInfoEntry objects each of which details a specific site defined data entry. The hash key is a unique SiteInfo variable name defined by the site. The value is an mcSiteInfoEntry object. See OBJECT mcSiteInfoEntry for details.
The table below specifies the valid members of the mcSiteInfoEntry object and describes their usage.
Member | Description | Returns |
---|---|---|
Var | Variable Name | Scalar |
Description | Description of what Variable means | Scalar |
Value | Value for this entry | Scalar |
The mcSoftware object contains data on what software is installed on the system. The following are valid members:
Returns a hash of mcSoftInfo objects each of which details an installed software package. The hash key is a unique package name. The value is an mcSoftInfo object. See OBJECT mcSoftInfo for details.
The table below specifies the valid members of the mcSoftInfo object and describes their usage.
Member | Description | Returns |
---|---|---|
Name | Name of package | Scalar |
EntryType | Entry Type | Scalar |
Version | Version | Scalar |
Revision | Revision | Scalar |
Description | Description | Scalar |
DescVerbose | Description (Verbose) | Scalar |
URL | URL | Scalar |
License | License | Scalar |
Copyright | Copyright | Scalar |
Category | Category | Scalar |
SubCategory | Sub-Category | Scalar |
OSname | Requires OS Name | Scalar |
OSversion | Requires OS Version | Scalar |
Arch | Requires Architecture | Scalar |
ISArch | Requires Inst Set Arch | Scalar |
InstDate | Installation Date | Scalar |
BuildDate | Build Date | Scalar |
ProdStamp | Production Stamp | Scalar |
BaseDir | Base Directory | Scalar |
PkgDeps | List of dependant packages | Array |
DiskUsage | Disk Usage | Scalar |
FileList | File List | Array |
VendorName | Vendor Name | Scalar |
VendorEmail | Vendor Email | Scalar |
VendorPhone | Vendor Phone # | Scalar |
VendorStock | Vendor Stock # | Scalar |
DescList | List of misc description data | Array |
Master | Name of master package | Scalar |
MasterVer | Version of master | Scalar |
MasterRev | Revisionof master | Scalar |
Slaves | List of child packages | Array |
Next | Next peer package | Scalar |
The mcSysConf object contains data on system configuration data obtained via sysconf(3). The following are valid members:
Returns a hash of mcName objects each of which details a SysConf entry. The hash key is a unique SysConf variable name. The value is an mcName object. See OBJECT mcName for details.
For detailed examples please take a look at /opt/sysinfo/lib/ui/uiGUI.pm This is the main module which implements the GUI for mcsysinfo(1) which utilizes the mcSysInfo interface.
The following example displays the hostname and system model:
use lib ('/opt/sysinfo/lib/mcSysInfo'); use mcSysInfo; $si = mcSysInfo->New; # Only retrieve the info we need $si->Class('General'); $si->Retrieve(); printf ("System hostname is %s\n", $si->General->Hostname); printf ("System model is %s\n", $si->General->Model);
The following example displays a list of all device names and their model (if known):
use lib ('/opt/sysinfo/lib/mcSysInfo'); use mcSysInfo; $si = mcSysInfo->New; # Only retrieve the info we need $si->Class('Hardware'); $si->Retrieve(); foreach my $Key (keys %{ $si->Hardware->Entries }) { my $di = $si->Hardware->Entries->{$Key}; printf ("Device %s is a %s\n", $Key, $di->Model); }