Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
346 views
in Technique[技术] by (71.8m points)

bash - FreeNAS检查IP和Scrub然后关闭(FreeNAS check IP & Scrub then shutdown)

I have FreeNAS 11.2 installed and run a cronjob every evening to check if any of my ip's are still online.

(我已经安装了FreeNAS 11.2,并每天晚上运行cronjob来检查我的IP是否仍然在线。)

If yes it shuts down if not it repeats the check every 15 minutes.

(如果是,它将关闭,否则将每15分钟重复一次检查。)

#!/bin/bash

hosts=(
  10.10.0.100 #Client 1
  10.10.0.101 #Client 2 
  10.10.0.102 #Client 3 
  10.10.0.103 #Client 4
  10.10.0.104 #Client 5
)

for host in "${hosts[@]}"; do
  if ping -c 1 -i 1 "$host" >/dev/null; then
    echo "No Shutdown - At least one PC ($host) is online"
    exit 0
  fi
done

echo "No PC is online - Shutdown"
shutdown -p now

Now i want to extend my script to check if a scrub or resilver (zfs) is still in progress or not.

(现在,我想扩展我的脚本,以检查清理还是重新编译(zfs)仍在进行中。)

I thought of something like this:

(我想到了这样的事情:)

for host in "${hosts[@]}"; do
  if ping -c 1 -i 1 "$host" >/dev/null; then
    exit 0
  fi
 if zpool xyz status | grep -q 'scrub in progress'; then
    exit 0
  fi
done
shutdown -p now

But this didn't work so i wanted to know if some could help me with this?

(但这没有用,所以我想知道是否有人可以帮助我?)

  ask by AlphaInc. translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...