Package oshi.hardware.platform.linux
Class LinuxHWDiskStore
- java.lang.Object
-
- oshi.hardware.common.AbstractHWDiskStore
-
- oshi.hardware.platform.linux.LinuxHWDiskStore
-
- All Implemented Interfaces:
HWDiskStore
@ThreadSafe public final class LinuxHWDiskStore extends AbstractHWDiskStore
Linux hard disk implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classLinuxHWDiskStore.UdevStat
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringBLOCKprivate longcurrentQueueLengthprivate static java.lang.StringDISKprivate static java.lang.StringDM_LV_NAMEprivate static java.lang.StringDM_UUIDprivate static java.lang.StringDM_VG_NAMEprivate static java.lang.StringID_FS_TYPEprivate static java.lang.StringID_FS_UUIDprivate static java.lang.StringID_MODELprivate static java.lang.StringID_SERIAL_SHORTprivate static org.slf4j.LoggerLOGprivate static java.lang.StringLOGICAL_VOLUME_GROUPprivate static java.lang.StringMAJORprivate static java.lang.StringMINORprivate static java.lang.StringPARTITIONprivate java.util.List<HWPartition>partitionListprivate longreadBytesprivate longreadsprivate static intSECTORSIZEprivate static java.lang.StringSIZEprivate static java.lang.StringSTATprivate longtimeStampprivate longtransferTimeprivate static intUDEV_STAT_LENGTHprivate static int[]UDEV_STAT_ORDERSprivate longwriteBytesprivate longwrites
-
Constructor Summary
Constructors Modifier Constructor Description privateLinuxHWDiskStore(java.lang.String name, java.lang.String model, java.lang.String serial, long size)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidcomputeDiskStats(LinuxHWDiskStore store, java.lang.String devstat)longgetCurrentQueueLength()The length of the disk queue (#I/O's in progress).private static java.lang.StringgetDependentNamesFromHoldersDirectory(java.lang.String sysPath)static java.util.List<HWDiskStore>getDisks()Gets the disks on this machineprivate static java.util.List<HWDiskStore>getDisks(LinuxHWDiskStore storeToUpdate)private static java.lang.StringgetMountPointOfDmDevice(java.lang.String vgName, java.lang.String lvName)private static java.lang.StringgetPartitionNameForDmDevice(java.lang.String vgName, java.lang.String lvName)java.util.List<HWPartition>getPartitions()The partitions on this disk.longgetReadBytes()The number of bytes read from the disklonggetReads()The number of reads from the disklonggetTimeStamp()The time this disk's statistics were updated.longgetTransferTime()The time spent reading or writing, in milliseconds.longgetWriteBytes()The number of bytes written to the disklonggetWrites()The number of writes to the diskprivate static java.util.Map<java.lang.String,java.lang.String>readMountsMap()booleanupdateAttributes()Make a best effort to update all the statistics about the drive without needing to recreate the drive list.
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
BLOCK
private static final java.lang.String BLOCK
- See Also:
- Constant Field Values
-
DISK
private static final java.lang.String DISK
- See Also:
- Constant Field Values
-
PARTITION
private static final java.lang.String PARTITION
- See Also:
- Constant Field Values
-
STAT
private static final java.lang.String STAT
- See Also:
- Constant Field Values
-
SIZE
private static final java.lang.String SIZE
- See Also:
- Constant Field Values
-
MINOR
private static final java.lang.String MINOR
- See Also:
- Constant Field Values
-
MAJOR
private static final java.lang.String MAJOR
- See Also:
- Constant Field Values
-
ID_FS_TYPE
private static final java.lang.String ID_FS_TYPE
- See Also:
- Constant Field Values
-
ID_FS_UUID
private static final java.lang.String ID_FS_UUID
- See Also:
- Constant Field Values
-
ID_MODEL
private static final java.lang.String ID_MODEL
- See Also:
- Constant Field Values
-
ID_SERIAL_SHORT
private static final java.lang.String ID_SERIAL_SHORT
- See Also:
- Constant Field Values
-
DM_UUID
private static final java.lang.String DM_UUID
- See Also:
- Constant Field Values
-
DM_VG_NAME
private static final java.lang.String DM_VG_NAME
- See Also:
- Constant Field Values
-
DM_LV_NAME
private static final java.lang.String DM_LV_NAME
- See Also:
- Constant Field Values
-
LOGICAL_VOLUME_GROUP
private static final java.lang.String LOGICAL_VOLUME_GROUP
- See Also:
- Constant Field Values
-
SECTORSIZE
private static final int SECTORSIZE
- See Also:
- Constant Field Values
-
UDEV_STAT_ORDERS
private static final int[] UDEV_STAT_ORDERS
-
UDEV_STAT_LENGTH
private static final int UDEV_STAT_LENGTH
-
reads
private long reads
-
readBytes
private long readBytes
-
writes
private long writes
-
writeBytes
private long writeBytes
-
currentQueueLength
private long currentQueueLength
-
transferTime
private long transferTime
-
timeStamp
private long timeStamp
-
partitionList
private java.util.List<HWPartition> partitionList
-
-
Method Detail
-
getReads
public long getReads()
Description copied from interface:HWDiskStoreThe number of reads from the disk- Returns:
- the reads
-
getReadBytes
public long getReadBytes()
Description copied from interface:HWDiskStoreThe number of bytes read from the disk- Returns:
- the bytes read
-
getWrites
public long getWrites()
Description copied from interface:HWDiskStoreThe number of writes to the disk- Returns:
- the writes
-
getWriteBytes
public long getWriteBytes()
Description copied from interface:HWDiskStoreThe number of bytes written to the disk- Returns:
- the bytes written
-
getCurrentQueueLength
public long getCurrentQueueLength()
Description copied from interface:HWDiskStoreThe length of the disk queue (#I/O's in progress). Includes I/O requests that have been issued to the device driver but have not yet completed. Not supported on macOS.- Returns:
- the current disk queue length
-
getTransferTime
public long getTransferTime()
Description copied from interface:HWDiskStoreThe time spent reading or writing, in milliseconds.- Returns:
- the transfer time
-
getTimeStamp
public long getTimeStamp()
Description copied from interface:HWDiskStoreThe time this disk's statistics were updated.- Returns:
- the timeStamp, in milliseconds since the epoch.
-
getPartitions
public java.util.List<HWPartition> getPartitions()
Description copied from interface:HWDiskStoreThe partitions on this disk.- Returns:
- an
UnmodifiableListof the partitions on this drive.
-
getDisks
public static java.util.List<HWDiskStore> getDisks()
Gets the disks on this machine- Returns:
- a list of
HWDiskStoreobjects representing the disks
-
getDisks
private static java.util.List<HWDiskStore> getDisks(LinuxHWDiskStore storeToUpdate)
-
updateAttributes
public boolean updateAttributes()
Description copied from interface:HWDiskStoreMake a best effort to update all the statistics about the drive without needing to recreate the drive list. This method provides for more frequent periodic updates of individual drive statistics but may be less efficient to use if updating all drives. It will not detect if a removable drive has been removed and replaced by a different drive in between method calls.- Returns:
- True if the update was (probably) successful, false if the disk was not found
-
readMountsMap
private static java.util.Map<java.lang.String,java.lang.String> readMountsMap()
-
computeDiskStats
private static void computeDiskStats(LinuxHWDiskStore store, java.lang.String devstat)
-
getPartitionNameForDmDevice
private static java.lang.String getPartitionNameForDmDevice(java.lang.String vgName, java.lang.String lvName)
-
getMountPointOfDmDevice
private static java.lang.String getMountPointOfDmDevice(java.lang.String vgName, java.lang.String lvName)
-
getDependentNamesFromHoldersDirectory
private static java.lang.String getDependentNamesFromHoldersDirectory(java.lang.String sysPath)
-
-