This one is a one liner to collect memory info from a set of servers.
Uses the command seq -w which pads the numbers with leading 0 to follow naming convention.
is simpler than the form for ((i=1;i<16;i++)) which will not pad the numbers.
for i in `seq -w 01 16`;do echo "sheif_prd${i} Mem= `ssh -q sherif@sheif_prd$i free|grep Mem|tr -s " " |cut -d " " -f2`" ; done
This uses to be useful to collect simple info like memory or CPU or such things.
Another one is for fixing SQLFire backups taken by sqlf -file option.
the backup is done using this script:
RunSQLFire_sqlscript.sh:
source ${HOME}/.bash_profile
if [ "x${1}" = "x" ]
then
echo "missing SQL script"
exit 1
fi
${HOME}/sqlfire/current/bin/sqlf run -client-bind-address=${HOSTNAME} -client-port=1527 -user=prd -password=prd -file=${1}
Then backup is taken in the following format:
PRMPT-$ head table_data
sqlf> SELECT * FROM "PRD"."TABLE";
Part_number |Serial |Type |ALLOWED
----------------------------------------------------------------------------------------------------
4028227 |6542883 |E |1
11256276 |14533312 |P |0
3798130 |18648804 |C |0
14000630 |574577 |E |1
2059762 |18986693 |E |1
The below AWK one liners converts the above into SQL inserts:
cat table_data |tr -s " " |awk -F"|" '{print("\x27" $1 "\x27" "," "\x27" $2 "\x27" "," "\x27" $3 "\x27" "," $4 "," "{ts \x27" $5 "\x27 }");}' |sed -e "s/ '/'/g" >table_data_fixed
Note the use of ASCII for " ' " as it was difficult to print it from within AWK.
cat table_data_fixed |sed -e's/^/INSERT INTO TABLE (Part_number,Serial,Type,ALLOWED) VALUES (/g' |sed -e 's/$/);/g' >table_data_inserts.sql
Uses the command seq -w which pads the numbers with leading 0 to follow naming convention.
is simpler than the form for ((i=1;i<16;i++)) which will not pad the numbers.
for i in `seq -w 01 16`;do echo "sheif_prd${i} Mem= `ssh -q sherif@sheif_prd$i free|grep Mem|tr -s " " |cut -d " " -f2`" ; done
This uses to be useful to collect simple info like memory or CPU or such things.
Another one is for fixing SQLFire backups taken by sqlf -file option.
the backup is done using this script:
RunSQLFire_sqlscript.sh:
source ${HOME}/.bash_profile
if [ "x${1}" = "x" ]
then
echo "missing SQL script"
exit 1
fi
${HOME}/sqlfire/current/bin/sqlf run -client-bind-address=${HOSTNAME} -client-port=1527 -user=prd -password=prd -file=${1}
Then backup is taken in the following format:
PRMPT-$ head table_data
sqlf> SELECT * FROM "PRD"."TABLE";
Part_number |Serial |Type |ALLOWED
----------------------------------------------------------------------------------------------------
4028227 |6542883 |E |1
11256276 |14533312 |P |0
3798130 |18648804 |C |0
14000630 |574577 |E |1
2059762 |18986693 |E |1
The below AWK one liners converts the above into SQL inserts:
cat table_data |tr -s " " |awk -F"|" '{print("\x27" $1 "\x27" "," "\x27" $2 "\x27" "," "\x27" $3 "\x27" "," $4 "," "{ts \x27" $5 "\x27 }");}' |sed -e "s/ '/'/g" >table_data_fixed
Note the use of ASCII for " ' " as it was difficult to print it from within AWK.
cat table_data_fixed |sed -e's/^/INSERT INTO TABLE (Part_number,Serial,Type,ALLOWED) VALUES (/g' |sed -e 's/$/);/g' >table_data_inserts.sql
No comments:
Post a Comment