Tuesday, February 9, 2016

Script - check pool size

Checking size of zfs pool. Please note, if the size is over TB, this script does not work.

#!/bin/bash
# Tue Aug 4 09:14:09 EDT 2015
# File
# Copy authorized key to remove host
# Sam Bhusalsystem check on remote server
# OS: Solaris 10
#

LOGFILE="logs/POOL_SIZE_`date "+%m%d%y_time.%H-%M-%S.log`"

# using for to loop through, you may find better option
for i in `cat ../etc/hosts.ip | grep -v "#" | awk '{print $1}'`
do
echo "Checking $i"
echo "Checking $i" >> $LOGFILE
#ssh -q $i /usr/sbin/zpool list | grep -vi size | awk '{print $2}' >>$LOGFILE
# ssh -q $i echo "Checking `hostname`:$i"; echo; zpool list | awk '{print $1 "\t" $2}' >>$LOGFILE
ssh -q $i /usr/sbin/zpool list | grep -vi size | awk '{print $2}'| sed -e 's/G//g' | paste -sd+ - | bc >> $LOGFILE
echo "" >> $LOGFILE
echo "-------------------------------------" >> $LOGFILE

done
more $LOGFILE
# EOF

--------------------------------
$ cd etc
$ cat hosts.ip

192.168.10.200 dnsserv1
192.168.10.130 appserv1
# 192.168.10.20 dnsserv1
192.168.10.210 dnsserv2
192.168.10.140 appserv2

No comments:

Post a Comment