
I was checking the memory on approximately 140 servers using ansible:
1 |
ansible --user root -k -i servers.list -m shell -a "free -h; mysql" test |
but the output appears over several lines e.g.
1 2 3 4 5 |
server103.domain.dev | SUCCESS | rc=0 >> total used free shared buffers cached Mem: 94G 44G 49G 59M 203M 4.6G -/+ buffers/cache: 39G 54G Swap: 0B 0B 0B |
but what I wanted was the server name and the total memory available. So I first grepped the output to remove the lines I didn’t want e.g.
1 |
grep -A3 "domain.dev" | egrep -v "^--|Swap|total|buffer" |
leaving me with two lines of… Read more »