One line helpers

# Analyze all but INSERTS from mysql’s general log
grep -E ‘^.*[0-9]{1,}\sQuery’ /your-path/to/file.log | awk ‘{$1=$2=””; print toupper($0)}’ | sed ‘s/\s+/ /g’ | grep -Ev “^\s*INSERT” | sed -r ‘s/^(.*)(\sSET\s).*(\sWHERE.*)/\1\3/g’ | sed -r ‘s/^(.*SELECT).*(\sFROM)(\s.*)/\1\3/g’ | sed “s/’//g” | sed -r ‘s/=\s\w+/ /g’ | sort | uniq -c

# Change ls result and execute it.
ls -1 | grep -v “bz2” | xargs -n 1 -I'{}’ echo mv “{}” /dockers_persistent/binlog/mms_av_1/

# Change df result, replace some character and execute it as a parameter in the middle of the instruction.
# get some volumes, umount, repair and mount’em.

docker_name=mysql_server_1
df -h | grep $docker_name | awk  '{print "umount " $6 " && xfs_repair -t 15 " $1 " > ./" gensub("/", "-", "g",$1) " 2> ./" gensub("/", "-", "g",$1) ".err && mount " $6  " &"}'
# Observe CPU frequency
watch "cat /proc/cpuinfo | grep MHz | awk -F":" '{print $2'} | sort -n | uniq -c "
# Change devices from mapper into uuid
grep "/dev/mapper/[a-z\-]\{1,\}\s" -o /tmp/fstab | while read line ; do blkid -s UUID "$line" | sed 's/"/\\"/g' |  eval$(awk -F": " '{print  " sed -i \"s#"$1"#"$2"#\" /tmp/fstab2" }'); done
# get all config lines but commented
grep -v "^#\|^$" ./106/etc/elasticsearch/elasticsearch.yml
# reroute all shards from one node into another.
curl  -XGET 'http://localhost:9200/_cat/shards?v' -s  | grep "NODE_NAME\s*$" | awk -v NEW_NODE="es00.6" ' {print "{\"commands\":[{ \"move\": {\"index\":\""$1"\",\"shard\": "$2",\"from_node\": \""$8"\",\"to_node\":\""NEW_NODE"\" }}]}" }' | sed "s/^\|$/'/g" | xargs curl -XPOST "http://localhost:9201/_cluster/reroute" -d  
# get plugins whithin whole cluster
curl -XGET 'http://localhost:9200/_nodes/*/_all' | jq-linux64 .nodes | jq-linux64 '.[] |  [ .version ], [.settings.name], {plugins}'
  1. No comments yet.

  1. No trackbacks yet.