1 Star 0 Fork 3

镇痛片/shell脚本

forked from xxxx/shell脚本 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
smart_ssd_discovery.sh 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
xxxx 提交于 2021-04-07 14:15 . add smart_ssd_discovery.sh.
#!/bin/bash
sudo omreport storage vdisk controller=0 |grep -i ssd &> /dev/null
if [[ $? -eq 0 ]]
then
mkdir -p /tmp/zabbix_ssd_monitor
sudo omreport storage vdisk controller=0 |egrep 'Name|Device Name|Media'|grep -B2 -i ssd |grep -v -i ssd |sed 's/.*Name.*: //g' |sed 's/ //g'|xargs -l2 |sed 's/\/dev\///g' > /tmp/zabbix_ssd_monitor/device_list
sudo megacli -cfgdsply –aALL |egrep '^Name|^Slot Number' |sed 's/ //g' |sed 's/:/ /g' > /tmp/zabbix_ssd_monitor/slot_list
while read name device; do sed -i "s/${name}/${device}/g" /tmp/zabbix_ssd_monitor/slot_list ; done < /tmp/zabbix_ssd_monitor/device_list
while read name device; do if [[ $name == 'Name' ]]; then device_new="$device"; else echo $name $device |sed "s/^/${device_new} /"; fi; done < /tmp/zabbix_ssd_monitor/slot_list > /tmp/zabbix_ssd_monitor/slot_list.last
for device in `awk '{print $NF}' |xargs`; do grep $device /tmp/zabbix_ssd_monitor/slot_list.last |awk '{print $1,$NF}' >> /tmp/zabbix_ssd_monitor/ssd_list; done < /tmp/zabbix_ssd_monitor/device_list
length=`wc -l /tmp/zabbix_ssd_monitor/ssd_list |awk '{print $1}'`
printf "{\n"
printf '\t'"\"data\":["
while read ssd_name ssd_slot
do
printf '\n\t\t{'
printf "\"{#SSD_NAME}\":\"${ssd_name}\",\"{#SSD_SLOT}\":\"${ssd_slot}\"}"
length=$(($length-1))
if [ $length -gt 0 ]
then
printf ','
fi
done < /tmp/zabbix_ssd_monitor/ssd_list
printf "\n\t]\n"
printf "}\n"
fi
#smartctl -H -d megaraid,3 /dev/sdc
#smartctl -A -d megaraid,3 /dev/sdc
#Wear_Leveling_Count
#Runtime_Bad_Block
rm -rf /tmp/zabbix_ssd_monitor
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/itboge/shell-script.git
[email protected]:itboge/shell-script.git
itboge
shell-script
shell脚本
master

搜索帮助