|
|
@ -12,6 +12,7 @@ const matchOrError = require("./match-or-error");
|
|
|
|
const lsblk = require("./wrappers/lsblk");
|
|
|
|
const lsblk = require("./wrappers/lsblk");
|
|
|
|
const smartctl = require("./wrappers/smartctl");
|
|
|
|
const smartctl = require("./wrappers/smartctl");
|
|
|
|
const lvm = require("./wrappers/lvm");
|
|
|
|
const lvm = require("./wrappers/lvm");
|
|
|
|
|
|
|
|
const upperSnakeCase = require("./upper-snake-case");
|
|
|
|
|
|
|
|
|
|
|
|
function gql(strings) {
|
|
|
|
function gql(strings) {
|
|
|
|
return strings.join("");
|
|
|
|
return strings.join("");
|
|
|
@ -312,6 +313,34 @@ function createDrive({ path }) {
|
|
|
|
formFactor: "formFactor",
|
|
|
|
formFactor: "formFactor",
|
|
|
|
ataVersion: "ataVersion",
|
|
|
|
ataVersion: "ataVersion",
|
|
|
|
sataVersion: "sataVersion"
|
|
|
|
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`
|
|
|
|
let query = gql`
|
|
|
|
# query SomeDrives($drivePaths: [String]) {
|
|
|
|
# query SomeDrives($drivePaths: [String]) {
|
|
|
|
query SomeDrives {
|
|
|
|
query SomeDrives {
|
|
|
|
# hardware {
|
|
|
|
hardware {
|
|
|
|
# drives(paths: $drivePaths) {
|
|
|
|
drives {
|
|
|
|
# path
|
|
|
|
path
|
|
|
|
# interface
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
# model
|
|
|
|
model
|
|
|
|
# modelFamily
|
|
|
|
modelFamily
|
|
|
|
# smartAvailable
|
|
|
|
smartAvailable
|
|
|
|
# smartEnabled
|
|
|
|
smartEnabled
|
|
|
|
# serialNumber
|
|
|
|
serialNumber
|
|
|
|
# wwn
|
|
|
|
wwn
|
|
|
|
# firmwareVersion
|
|
|
|
firmwareVersion
|
|
|
|
# size
|
|
|
|
size
|
|
|
|
# rpm
|
|
|
|
rpm
|
|
|
|
# logicalSectorSize
|
|
|
|
logicalSectorSize
|
|
|
|
# physicalSectorSize
|
|
|
|
physicalSectorSize
|
|
|
|
# formFactor
|
|
|
|
formFactor
|
|
|
|
# ataVersion
|
|
|
|
ataVersion
|
|
|
|
# sataVersion
|
|
|
|
sataVersion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
smartHealth
|
|
|
|
|
|
|
|
# smartAttributes {
|
|
|
|
|
|
|
|
# name
|
|
|
|
|
|
|
|
# type
|
|
|
|
|
|
|
|
# value
|
|
|
|
|
|
|
|
# failingNow
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# flags {
|
|
|
|
|
|
|
|
# affectsPerformance
|
|
|
|
|
|
|
|
# indicatesFailure
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
# blockDevice {
|
|
|
|
# blockDevice {
|
|
|
|
# removable
|
|
|
|
# removable
|
|
|
@ -431,10 +473,10 @@ return Promise.try(() => {
|
|
|
|
# size
|
|
|
|
# size
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
}
|
|
|
|
# }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
resources {
|
|
|
|
# resources {
|
|
|
|
# blockDevices {
|
|
|
|
# blockDevices {
|
|
|
|
# name
|
|
|
|
# name
|
|
|
|
# mountpoint
|
|
|
|
# mountpoint
|
|
|
@ -455,30 +497,30 @@ return Promise.try(() => {
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
lvm {
|
|
|
|
# lvm {
|
|
|
|
physicalVolumes {
|
|
|
|
# physicalVolumes {
|
|
|
|
path
|
|
|
|
# path
|
|
|
|
|
|
|
|
|
|
|
|
blockDevice {
|
|
|
|
# blockDevice {
|
|
|
|
name
|
|
|
|
# name
|
|
|
|
deviceNumber
|
|
|
|
# deviceNumber
|
|
|
|
}
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
volumeGroup {
|
|
|
|
# volumeGroup {
|
|
|
|
name
|
|
|
|
# name
|
|
|
|
}
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
format
|
|
|
|
# format
|
|
|
|
size
|
|
|
|
# size
|
|
|
|
freeSpace
|
|
|
|
# freeSpace
|
|
|
|
duplicate
|
|
|
|
# duplicate
|
|
|
|
allocatable
|
|
|
|
# allocatable
|
|
|
|
used
|
|
|
|
# used
|
|
|
|
exported
|
|
|
|
# exported
|
|
|
|
missing
|
|
|
|
# missing
|
|
|
|
}
|
|
|
|
# }
|
|
|
|
}
|
|
|
|
# }
|
|
|
|
}
|
|
|
|
# }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|