Taking data from all blades to active blade without doing ssh to individual slot.
Problem this snippet solves:
This code is useful when you want to take (compress, copy, qkview etc.) data from all blades/slots in one shot, whether it is active blade or not you can perform it from your primary/Active blade without doing ssh to individual slot and running the command in all blades.
How to use this snippet:
You have to change the command or can say code in line where I've , like here I have written the code to take RRD data from all the blades and make it compress and finally copy them to my primary blade. No need to do ssh on all the blades. The final output will be copied to /var/tmp of active/primary.
Code :
#!/bin/sh clear i=1 tmsh show sys cluster | grep "Primary Slot ID" > /var/tmp/Primary_Slot_ID.txt #pri_bld will give the Slot ID of the Primary or Active blade pri_bld=$(awk 'NR == 1 {print $4}' /var/tmp/Primary_Slot_ID.txt) echo "Primary blade is: $pri_bld" tmsh show sys hardware | grep "powered-up" > /var/tmp/total_bld.txt #tot_bld will give the value of how many blades are there, which are powered-up currently tot_bld=$(cat /var/tmp/total_bld.txt | wc -l) echo "Total blades are: $tot_bld" echo while [[ $i -le $tot_bld ]] do if [ "$i" = "$pri_bld" ] then echo "Inside Slot$i" echo echo # Here, change the command you want to use like taking qkview or logs etc. Use $HOSTNAME and $i (Slot ID) wherever required. tar zcvf /var/tmp/$HOSTNAME-rrd-slot$i.tar.gz /var/rrd/* else echo "Inside Slot$i" echo echo # Here, replace the command you want to use like taking qkview or logs etc. Use $HOSTNAME and $i (Slot ID) wherever required. tar zcvf /var/tmp/$HOSTNAME-rrd-slot$i.tar.gz /var/rrd/* | ssh root@slot$i # Copy the output data, mean change the location of the required data and it will copy it in active blade from all other blades. ssh root@slot$i 'scp -v /var/tmp/$HOSTNAME-rrd-slot$i.tar.gz root@slot$pri_bld:/var/tmp/' echo echo "rrd data compressed and copied to Slot$pri_bld" echo fi ((i = i + 1)) done while [[ $i -eq $tot_bld ]] do rm -f /var/tmp/Primary_Slot_ID.txt echo "Deleting Primary_Slot_ID.txt" rm -f /var/tmp/total_bld.txt echo "Deleting total_bld.txt" done
Published Oct 24, 2017
Version 1.0bhatt_bhuvan_29
Nimbostratus
Joined May 05, 2019
bhatt_bhuvan_29
Nimbostratus
Joined May 05, 2019
- bhatt_bhuvan_29Nimbostratus
you can write back to me, if you need some custom code with problem and desired solution.