在阅读了几个主题后,我设法让我的简单smartctl脚本用于显示有关3WARE RAID控制器背后的硬盘的SMART信息。
感谢Emily E.它现在以红色输出破碎的硬盘。但是,它会将阵列中的所有驱动器(损坏的驱动器)变为红色,而不是仅仅挑出损坏的硬盘。
到目前为止,这是我在脚本中的内容(感谢Emily E。):
bold=$(tput bold)
red=$(tput setaf 1)
green=$(tput setaf 2)
normal=$(tput sgr0)
echo "${green}${bold}:: CONTROLLER POORT 0 - HARDDISK ARRAY A (22x) ::${normal}"
out0=$(
for i in {0..21}; do
echo -en '\n'
echo "HARDDISK $i" $SN $MD
smartctl -i -A /dev/twa0 -d 3ware,$i |grep -E "^ "5"|^"197"|^"198"|"FAILING_NOW"|"Serial"|"Smartctl""
done
)
if echo "$out0" | grep -q "Device Read Identity Failed"; then
echo "$red$out0"
else
echo "$out0"
fi
echo -en '\n'
echo -en '\n'
echo "${green}${bold}:: CONTROLLER POORT 1 - HARDDISK ARRAY B (22x) :::${normal}"
out1=$(
for i in {0..21}; do
echo -en '\n'
echo "HARDDISK $i" $SN $MD
smartctl -i -A /dev/twa1 -d 3ware,$i |grep -E "^ "5"|^"197"|^"198"|"FAILING_NOW"|"Serial"|"Smartctl""
done
)
if echo "$out1" | grep -q "Device Read Identity Failed"; then
echo "$red$out1"
else
echo "$out1"
fi
echo -en '\n'
echo -en '\n'
echo "${green}${bold}:: CONTROLLER POORT 1 - HARDDISK ARRAY OS (2x) :::${normal}"
out2=$(
for i in {0..1}; do
echo -en '\n'
echo "HARDDISK $i" $SN $MD
smartctl -i -A /dev/twa2 -d 3ware,$i |grep -E "^ "5"|^"197"|^"198"|"FAILING_NOW"|"Serial"|"Smartctl""
done
)
if echo "$out2" | grep -q "Device Read Identity Failed"; then
echo "$red$out2"
else
echo "$out2"
fi
echo -en '\n'
使用新的/更新的代码,它现在将颜色设置为红色,但也是整个数组,而不是仅仅一个驱动器。也许有一个解决方法呢?
如果没有,我会保持原样。但是当只有破碎的磁盘被涂成红色而不是整个阵列时,会更容易注意到。
答案 0 :(得分:1)
像这样写
class Test {
constructor() {
this.childObject = new Child(this);
}
parentHello() {
console.log("Parent Hello World!");
}
}
class Child {
constructor(parent) {
this.parent = parent;
}
childHello() {
this.parent.parentHello();
}
}
const obj = new Test();
obj.childObject.childHello();