Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsUsableDisk ¶
Types ¶
type LsblkBlockDevice ¶
type LsblkOutput ¶
type LsblkOutput struct {
Blockdevices []LsblkBlockDevice `json:"blockdevices"`
}
func GetLsblkOutput ¶
func GetLsblkOutput() (LsblkOutput, error)
func GetLsblkOutputForPath ¶
func GetLsblkOutputForPath(disk_path string) (LsblkOutput, error)
func LoadLsblkFromJson ¶
func LoadLsblkFromJson(jsonInput []byte) (LsblkOutput, error)
type SmartctlOutput ¶
type SmartctlOutput struct {
Device struct {
Name string `json:"name"`
InfoName string `json:"info_name"`
Type string `json:"type"`
Protocol string `json:"protocol"`
} `json:"device"`
DeviceType struct {
ScsiTerminology string `json:"scsi_terminology"`
Name string `json:"name"`
ScsiValue int `json:"scsi_value"`
} `json:"device_type"`
FormFactor struct {
Name string `json:"name"`
AtaValue int `json:"ata_value"`
ScsiValue int `json:"scsi_value"`
} `json:"form_factor"`
ModelFamily string `json:"model_family"`
ModelName string `json:"model_name"`
SerialNumber string `json:"serial_number"`
FirmwareVersion string `json:"firmware_version"`
LogicalUnitID string `json:"logical_unit_id"`
ScsiVendor string `json:"scsi_vendor"`
ScsiProduct string `json:"scsi_product"`
ScsiModelName string `json:"scsi_model_name"`
ScsiRevision string `json:"scsi_revision"`
ScsiVersion string `json:"scsi_version"`
ScsiErrorCounterLog struct {
Read struct {
GigabytesProcessed string `json:"gigabytes_processed"`
ErrorsCorrectedByEccfast int `json:"errors_corrected_by_eccfast"`
ErrorsCorrectedByEccdelayed int `json:"errors_corrected_by_eccdelayed"`
ErrorsCorrectedByRereadsRewrites int `json:"errors_corrected_by_rereads_rewrites"`
TotalErrorsCorrected int `json:"total_errors_corrected"`
CorrectionAlgorithmInvocations int `json:"correction_algorithm_invocations"`
TotalUncorrectedErrors int `json:"total_uncorrected_errors"`
} `json:"read"`
Write struct {
GigabytesProcessed string `json:"gigabytes_processed"`
ErrorsCorrectedByEccfast int `json:"errors_corrected_by_eccfast"`
ErrorsCorrectedByEccdelayed int `json:"errors_corrected_by_eccdelayed"`
ErrorsCorrectedByRereadsRewrites int `json:"errors_corrected_by_rereads_rewrites"`
TotalErrorsCorrected int `json:"total_errors_corrected"`
CorrectionAlgorithmInvocations int `json:"correction_algorithm_invocations"`
TotalUncorrectedErrors int `json:"total_uncorrected_errors"`
} `json:"write"`
Verify struct {
GigabytesProcessed string `json:"gigabytes_processed"`
ErrorsCorrectedByEccfast int `json:"errors_corrected_by_eccfast"`
ErrorsCorrectedByEccdelayed int `json:"errors_corrected_by_eccdelayed"`
ErrorsCorrectedByRereadsRewrites int `json:"errors_corrected_by_rereads_rewrites"`
TotalErrorsCorrected int `json:"total_errors_corrected"`
CorrectionAlgorithmInvocations int `json:"correction_algorithm_invocations"`
TotalUncorrectedErrors int `json:"total_uncorrected_errors"`
} `json:"verify"`
} `json:"scsi_error_counter_log"`
Smartctl struct {
SvnRevision string `json:"svn_revision"`
PlatformInfo string `json:"platform_info"`
BuildInfo string `json:"build_info"`
DriveDatabaseVersion struct {
String string `json:"string"`
} `json:"drive_database_version"`
Argv []string `json:"argv"`
Version []int `json:"version"`
Messages []struct {
String string `json:"string"`
Severity string `json:"severity"`
} `json:"messages"`
ExitStatus int `json:"exit_status"`
PreRelease bool `json:"pre_release"`
} `json:"smartctl"`
ScsiLbProvisioning struct {
Name string `json:"name"`
ManagementEnabled struct {
Name string `json:"name"`
Value int `json:"value"`
} `json:"management_enabled"`
ReadZeros struct {
Name string `json:"name"`
Value int `json:"value"`
} `json:"read_zeros"`
Value int `json:"value"`
} `json:"scsi_lb_provisioning"`
SmartStatus struct {
Scsi struct {
IeString string `json:"ie_string"`
Asc int `json:"asc"`
Ascq int `json:"ascq"`
} `json:"scsi"`
Nvme struct {
Value int `json:"value"`
} `json:"nvme"`
Passed bool `json:"passed"`
} `json:"smart_status"`
NvmeSelfTestLog struct {
CurrentSelfTestOperation struct {
String string `json:"string"`
Value int `json:"value"`
} `json:"current_self_test_operation"`
Table []struct {
SelfTestCode struct {
String string `json:"string"`
Value int `json:"value"`
} `json:"self_test_code"`
SelfTestResult struct {
String string `json:"string"`
Value int `json:"value"`
} `json:"self_test_result"`
PowerOnHours int `json:"power_on_hours"`
} `json:"table"`
} `json:"nvme_self_test_log"`
AtaSmartAttributes struct {
Table []struct {
Raw struct {
String string `json:"string"`
Value int `json:"value"`
} `json:"raw"`
Name string `json:"name"`
WhenFailed string `json:"when_failed"`
Flags struct {
String string `json:"string"`
Value int `json:"value"`
Prefailure bool `json:"prefailure"`
UpdatedOnline bool `json:"updated_online"`
Performance bool `json:"performance"`
ErrorRate bool `json:"error_rate"`
EventCount bool `json:"event_count"`
AutoKeep bool `json:"auto_keep"`
} `json:"flags"`
ID int `json:"id"`
Value int `json:"value"`
Worst int `json:"worst"`
Thresh int `json:"thresh"`
} `json:"table"`
Revision int `json:"revision"`
} `json:"ata_smart_attributes"`
JSONFormatVersion []int `json:"json_format_version"`
LocalTime struct {
Asctime string `json:"asctime"`
TimeT int `json:"time_t"`
} `json:"local_time"`
SataVersion struct {
String string `json:"string"`
Value int `json:"value"`
} `json:"sata_version"`
ScsiTransportProtocol struct {
Name string `json:"name"`
Value int `json:"value"`
} `json:"scsi_transport_protocol"`
NvmeVersion struct {
String string `json:"string"`
Value int `json:"value"`
} `json:"nvme_version"`
NvmeNamespaces []struct {
ID int `json:"id"`
Size struct {
Blocks int `json:"blocks"`
Bytes int64 `json:"bytes"`
} `json:"size"`
Capacity struct {
Blocks int `json:"blocks"`
Bytes int64 `json:"bytes"`
} `json:"capacity"`
Utilization struct {
Blocks int `json:"blocks"`
Bytes int64 `json:"bytes"`
} `json:"utilization"`
FormattedLbaSize int `json:"formatted_lba_size"`
Eui64 struct {
Oui int `json:"oui"`
ExtID int64 `json:"ext_id"`
} `json:"eui64"`
} `json:"nvme_namespaces"`
InterfaceSpeed struct {
Max struct {
String string `json:"string"`
SataValue int `json:"sata_value"`
UnitsPerSecond int `json:"units_per_second"`
BitsPerUnit int `json:"bits_per_unit"`
} `json:"max"`
Current struct {
String string `json:"string"`
SataValue int `json:"sata_value"`
UnitsPerSecond int `json:"units_per_second"`
BitsPerUnit int `json:"bits_per_unit"`
} `json:"current"`
} `json:"interface_speed"`
AtaVersion struct {
String string `json:"string"`
MajorValue int `json:"major_value"`
MinorValue int `json:"minor_value"`
} `json:"ata_version"`
AtaSmartData struct {
OfflineDataCollection struct {
Status struct {
String string `json:"string"`
Value int `json:"value"`
} `json:"status"`
CompletionSeconds int `json:"completion_seconds"`
} `json:"offline_data_collection"`
Capabilities struct {
Values []int `json:"values"`
ExecOfflineImmediateSupported bool `json:"exec_offline_immediate_supported"`
OfflineIsAbortedUponNewCmd bool `json:"offline_is_aborted_upon_new_cmd"`
OfflineSurfaceScanSupported bool `json:"offline_surface_scan_supported"`
SelfTestsSupported bool `json:"self_tests_supported"`
ConveyanceSelfTestSupported bool `json:"conveyance_self_test_supported"`
SelectiveSelfTestSupported bool `json:"selective_self_test_supported"`
AttributeAutosaveEnabled bool `json:"attribute_autosave_enabled"`
ErrorLoggingSupported bool `json:"error_logging_supported"`
GpLoggingSupported bool `json:"gp_logging_supported"`
} `json:"capabilities"`
SelfTest struct {
Status struct {
String string `json:"string"`
Value int `json:"value"`
Passed bool `json:"passed"`
} `json:"status"`
PollingMinutes struct {
Short int `json:"short"`
Extended int `json:"extended"`
} `json:"polling_minutes"`
} `json:"self_test"`
} `json:"ata_smart_data"`
ScsiStartStopCycleCounter struct {
YearOfManufacture string `json:"year_of_manufacture"`
WeekOfManufacture string `json:"week_of_manufacture"`
SpecifiedCycleCountOverDeviceLifetime int `json:"specified_cycle_count_over_device_lifetime"`
AccumulatedStartStopCycles int `json:"accumulated_start_stop_cycles"`
SpecifiedLoadUnloadCountOverDeviceLifetime int `json:"specified_load_unload_count_over_device_lifetime"`
AccumulatedLoadUnloadCycles int `json:"accumulated_load_unload_cycles"`
} `json:"scsi_start_stop_cycle_counter"`
AtaSmartSelfTestLog struct {
Standard struct {
Table []struct {
Type struct {
String string `json:"string"`
Value int `json:"value"`
} `json:"type"`
Status struct {
String string `json:"string"`
Value int `json:"value"`
Passed bool `json:"passed"`
} `json:"status"`
LifetimeHours int `json:"lifetime_hours"`
} `json:"table"`
Revision int `json:"revision"`
Count int `json:"count"`
ErrorCountTotal int `json:"error_count_total"`
ErrorCountOutdated int `json:"error_count_outdated"`
} `json:"standard"`
} `json:"ata_smart_self_test_log"`
AtaSmartSelectiveSelfTestLog struct {
Table []struct {
Status struct {
String string `json:"string"`
Value int `json:"value"`
} `json:"status"`
LbaMin int `json:"lba_min"`
LbaMax int `json:"lba_max"`
} `json:"table"`
Flags struct {
Value int `json:"value"`
RemainderScanEnabled bool `json:"remainder_scan_enabled"`
} `json:"flags"`
Revision int `json:"revision"`
PowerUpScanResumeMinutes int `json:"power_up_scan_resume_minutes"`
} `json:"ata_smart_selective_self_test_log"`
NvmeErrorInformationLog struct {
Table []struct {
StatusField struct {
String string `json:"string"`
Value int `json:"value"`
DoNotRetry bool `json:"do_not_retry"`
StatusCodeType int `json:"status_code_type"`
StatusCode int `json:"status_code"`
} `json:"status_field"`
ErrorCount int `json:"error_count"`
SubmissionQueueID int `json:"submission_queue_id"`
CommandID int `json:"command_id"`
PhaseTag bool `json:"phase_tag"`
ParmErrorLocation int `json:"parm_error_location"`
Lba struct {
Value int `json:"value"`
} `json:"lba"`
Nsid int `json:"nsid"`
} `json:"table"`
Size int `json:"size"`
Read int `json:"read"`
Unread int `json:"unread"`
} `json:"nvme_error_information_log"`
NvmeSmartHealthInformationLog struct {
TemperatureSensors []int `json:"temperature_sensors"`
CriticalWarning int `json:"critical_warning"`
Temperature int `json:"temperature"`
AvailableSpare int `json:"available_spare"`
AvailableSpareThreshold int `json:"available_spare_threshold"`
PercentageUsed int `json:"percentage_used"`
DataUnitsRead int `json:"data_units_read"`
DataUnitsWritten int `json:"data_units_written"`
HostReads int `json:"host_reads"`
HostWrites int `json:"host_writes"`
ControllerBusyTime int `json:"controller_busy_time"`
PowerCycles int `json:"power_cycles"`
PowerOnHours int `json:"power_on_hours"`
UnsafeShutdowns int `json:"unsafe_shutdowns"`
MediaErrors int `json:"media_errors"`
NumErrLogEntries int `json:"num_err_log_entries"`
WarningTempTime int `json:"warning_temp_time"`
CriticalCompTime int `json:"critical_comp_time"`
} `json:"nvme_smart_health_information_log"`
Wwn struct {
Naa int `json:"naa"`
Oui int `json:"oui"`
ID int64 `json:"id"`
} `json:"wwn"`
UserCapacity struct {
Blocks uint `json:"blocks"`
Bytes uint64 `json:"bytes"`
} `json:"user_capacity"`
// Temps & StartStop
Temperature struct {
Current int `json:"current"`
DriveTrip int `json:"drive_trip"`
} `json:"temperature"`
PowerOnTime struct {
Hours int `json:"hours"`
Minutes int `json:"minutes"`
} `json:"power_on_time"`
AtaSctCapabilities struct {
Value int `json:"value"`
ErrorRecoveryControlSupported bool `json:"error_recovery_control_supported"`
FeatureControlSupported bool `json:"feature_control_supported"`
DataTableSupported bool `json:"data_table_supported"`
} `json:"ata_sct_capabilities"`
AtaSmartErrorLog struct {
Summary struct {
Revision int `json:"revision"`
Count int `json:"count"`
} `json:"summary"`
} `json:"ata_smart_error_log"`
NvmePciVendor struct {
ID int `json:"id"`
SubsystemID int `json:"subsystem_id"`
} `json:"nvme_pci_vendor"`
LogicalBlockSize int `json:"logical_block_size"`
PhysicalBlockSize int `json:"physical_block_size"`
RotationRate int `json:"rotation_rate"`
PowerCycleCount int `json:"power_cycle_count"`
ScsiGrownDefectList int `json:"scsi_grown_defect_list"`
NvmeIeeeOuiIdentifier int `json:"nvme_ieee_oui_identifier"`
NvmeTotalCapacity int64 `json:"nvme_total_capacity"`
NvmeUnallocatedCapacity int `json:"nvme_unallocated_capacity"`
NvmeControllerID int `json:"nvme_controller_id"`
NvmeNumberOfNamespaces int `json:"nvme_number_of_namespaces"`
Trim struct {
Supported bool `json:"supported"`
Deterministic bool `json:"deterministic"`
Zeroed bool `json:"zeroed"`
} `json:"trim"`
// SMART
SmartSupport struct {
Available bool `json:"available"`
Enabled bool `json:"enabled"`
} `json:"smart_support"`
SuccessfulQuery bool
InSmartctlDatabase bool `json:"in_smartctl_database"`
TemperatureWarning struct {
Enabled bool `json:"enabled"`
} `json:"temperature_warning"`
}
func SmartctlQueryDisk ¶
func SmartctlQueryDisk(smartctl_path string, disk_type string, disk_path string) (SmartctlOutput, error)
func SmartctlQueryDiskJsonParse ¶
func SmartctlQueryDiskJsonParse(json_string []byte) (SmartctlOutput, error)
Click to show internal directories.
Click to hide internal directories.