#!/bin/bash #Roy Cohen :roy@wondercohen.nl #objective :Gluster check OSM server heal for Nagios #First line of code :15/01/2019 #last update :24/01/2019 #version :1.0 ######START OF SCRIPT####### #gluster volume info all | grep "Volume Name:"| cut -d ":" -f2 > /tmp/volume_names for volume in $(gluster volume info all | grep "Volume Name:"| cut -d ":" -f2) do echo "volume, $volume" gluster v heal $volume info |grep entries|cut -d ":" -f2 done #for volume in $(cat /tmp/volume_names) #do # OC="oc rsh -n" # POD=$(oc get pods -n glusterfs | grep Running | grep 'glusterfs-storage' | head -n 1 | cut -d' ' -f1) # VAR1="gluster v heal $volume info |grep entries|cut -d: -f 2" #echo "volume, $volume" # oc rsh -n glusterfs $POD | $VAR1 #done oc rsh -n glusterfs $(oc get pods -n glusterfs | grep Running | grep 'glusterfs-storage' | head -n 1 | cut -d' ' -f1) gluster volume status all oc rsh -n glusterfs $(oc get pods -n glusterfs | grep Running | grep 'glusterfs-storage' | head -n 1 | cut -d' ' -f1) ip -4 addr show POD=$(oc get pods -n glusterfs | grep Running | grep 'glusterfs-storage' | head -n 1 | cut -d' ' -f1) oc rsh -n glusterfs $POD gluster volume info all | grep "Volume Name:"| cut -d ":" -f2 > /tmp/volume_names for volume in $(cat /tmp/volume_names) do OC="oc rsh -n" POD=$(oc get pods -n glusterfs | grep Running | grep 'glusterfs-storage' | head -n 1 | cut -d' ' -f1) VAR1="gluster v heal $volume info |grep entries|cut -d: -f 2" echo "volume, $volume" echo "$OC glusterfs $POD $VAR1" done /tmp/gluster_monitoring_heal oc rsh -n glusterfs $(oc get pods -n glusterfs | grep Running | grep 'glusterfs-storage' | head -n 1 | cut -d' ' -f1) gluster v heal vol_fa562e2cd81f137ccb455633829be163 info|grep entries|cut -d ":" -f2 oc rsh -n glusterfs glusterfs-storage-4jq8n gluster v heal vol_fa562e2cd81f137ccb455633829be163 info|grep entries|cut -d ":" -f2 oc cp /tmp/database.sql mysql:/tmp/ kubectl cp /:/tmp/foo /tmp/bar oc cp glusterfs/glusterfs-storage-4jq8n:gluster_monitoring_heal /tmp