mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			703 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			703 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env bash
 | 
						|
# $Id: iscsimon.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/storage/iscsi/iscsimon.sh $
 | 
						|
#
 | 
						|
# iscsimon.sh
 | 
						|
#
 | 
						|
# Monitor iscsi connections for failures, and stop vm's if necessary
 | 
						|
#
 | 
						|
 | 
						|
err=0
 | 
						|
for sid in `iscsiadm -m session | awk '{print $2}' | tr -d '[]'`
 | 
						|
do
 | 
						|
  state=`iscsiadm -m session -r $sid -P 1 | grep "iSCSI Session State:" | awk '{print $NF}'`
 | 
						|
  if [ $state == "FREE" -o $state == "FAILED" ]
 | 
						|
  then
 | 
						|
    echo "DOWN" $sid `iscsiadm -m session -r $sid -P 1 | grep Target | awk '{print $2}'` `iscsiadm -m session -r $sid -P 1 | grep "Current Portal" | awk '{print $3}'`
 | 
						|
    err=1
 | 
						|
  fi
 | 
						|
done
 | 
						|
 | 
						|
if [ $err -eq 0 ] 
 | 
						|
then
 | 
						|
  echo "OK"
 | 
						|
fi
 |