|
|
|
@ -12,6 +12,7 @@ const matchOrError = require("./match-or-error");
|
|
|
|
|
const lsblk = require("./wrappers/lsblk");
|
|
|
|
|
const smartctl = require("./wrappers/smartctl");
|
|
|
|
|
const lvm = require("./wrappers/lvm");
|
|
|
|
|
const upperSnakeCase = require("./upper-snake-case");
|
|
|
|
|
|
|
|
|
|
function gql(strings) {
|
|
|
|
|
return strings.join("");
|
|
|
|
@ -312,6 +313,34 @@ function createDrive({ path }) {
|
|
|
|
|
formFactor: "formFactor",
|
|
|
|
|
ataVersion: "ataVersion",
|
|
|
|
|
sataVersion: "sataVersion"
|
|
|
|
|
},
|
|
|
|
|
smartctlAttributes: {
|
|
|
|
|
[ID]: path,
|
|
|
|
|
smartAttributes: (attributes) => {
|
|
|
|
|
return attributes.map((attribute) => {
|
|
|
|
|
return Object.assign({}, attribute, {
|
|
|
|
|
type: upperSnakeCase(attribute.type),
|
|
|
|
|
updatedWhen: upperSnakeCase(attribute.updatedWhen)
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
smartHealth: (attributes) => {
|
|
|
|
|
let failed = attributes.filter((item) => {
|
|
|
|
|
return (item.failingNow === true || item.failedBefore === true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let deteriorating = attributes.filter((item) => {
|
|
|
|
|
return (item.type === "preFail" && item.worstValueSeen < 100);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (failed.length > 0) {
|
|
|
|
|
return "FAILING";
|
|
|
|
|
} else if (deteriorating.length > 0) {
|
|
|
|
|
return "DETERIORATING";
|
|
|
|
|
} else {
|
|
|
|
|
return "HEALTHY";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -402,25 +431,38 @@ return Promise.try(() => {
|
|
|
|
|
let query = gql`
|
|
|
|
|
# query SomeDrives($drivePaths: [String]) {
|
|
|
|
|
query SomeDrives {
|
|
|
|
|
# hardware {
|
|
|
|
|
# drives(paths: $drivePaths) {
|
|
|
|
|
# path
|
|
|
|
|
# interface
|
|
|
|
|
|
|
|
|
|
# model
|
|
|
|
|
# modelFamily
|
|
|
|
|
# smartAvailable
|
|
|
|
|
# smartEnabled
|
|
|
|
|
# serialNumber
|
|
|
|
|
# wwn
|
|
|
|
|
# firmwareVersion
|
|
|
|
|
# size
|
|
|
|
|
# rpm
|
|
|
|
|
# logicalSectorSize
|
|
|
|
|
# physicalSectorSize
|
|
|
|
|
# formFactor
|
|
|
|
|
# ataVersion
|
|
|
|
|
# sataVersion
|
|
|
|
|
hardware {
|
|
|
|
|
drives {
|
|
|
|
|
path
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
model
|
|
|
|
|
modelFamily
|
|
|
|
|
smartAvailable
|
|
|
|
|
smartEnabled
|
|
|
|
|
serialNumber
|
|
|
|
|
wwn
|
|
|
|
|
firmwareVersion
|
|
|
|
|
size
|
|
|
|
|
rpm
|
|
|
|
|
logicalSectorSize
|
|
|
|
|
physicalSectorSize
|
|
|
|
|
formFactor
|
|
|
|
|
ataVersion
|
|
|
|
|
sataVersion
|
|
|
|
|
|
|
|
|
|
smartHealth
|
|
|
|
|
# smartAttributes {
|
|
|
|
|
# name
|
|
|
|
|
# type
|
|
|
|
|
# value
|
|
|
|
|
# failingNow
|
|
|
|
|
|
|
|
|
|
# flags {
|
|
|
|
|
# affectsPerformance
|
|
|
|
|
# indicatesFailure
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
# blockDevice {
|
|
|
|
|
# removable
|
|
|
|
@ -431,10 +473,10 @@ return Promise.try(() => {
|
|
|
|
|
# size
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resources {
|
|
|
|
|
# resources {
|
|
|
|
|
# blockDevices {
|
|
|
|
|
# name
|
|
|
|
|
# mountpoint
|
|
|
|
@ -455,30 +497,30 @@ return Promise.try(() => {
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
lvm {
|
|
|
|
|
physicalVolumes {
|
|
|
|
|
path
|
|
|
|
|
# lvm {
|
|
|
|
|
# physicalVolumes {
|
|
|
|
|
# path
|
|
|
|
|
|
|
|
|
|
blockDevice {
|
|
|
|
|
name
|
|
|
|
|
deviceNumber
|
|
|
|
|
}
|
|
|
|
|
# blockDevice {
|
|
|
|
|
# name
|
|
|
|
|
# deviceNumber
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
volumeGroup {
|
|
|
|
|
name
|
|
|
|
|
}
|
|
|
|
|
# volumeGroup {
|
|
|
|
|
# name
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
format
|
|
|
|
|
size
|
|
|
|
|
freeSpace
|
|
|
|
|
duplicate
|
|
|
|
|
allocatable
|
|
|
|
|
used
|
|
|
|
|
exported
|
|
|
|
|
missing
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# format
|
|
|
|
|
# size
|
|
|
|
|
# freeSpace
|
|
|
|
|
# duplicate
|
|
|
|
|
# allocatable
|
|
|
|
|
# used
|
|
|
|
|
# exported
|
|
|
|
|
# missing
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|