Hello,
i`m creating an script that collect`s data from virtual machines about cpu usage and store that data into RRD.
so everything now works fine, but it takes long time if in machine is a lot of virtual`s.
so i want to make my script to collect information with 1 request. at this time i`m collecting data like this:
cpu=`vzctl exec $veid top -bn2 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%\id.*/\1/" | tail -n1 | \
awk '{print 100-$1}'`
wa=`vzctl exec $veid top -bn2 | grep "Cpu(s)" | awk '{print $6/1}' | tail -n1`
i use top -bn2 so it takes second line from top ( because the first line do not show proper value ) and if there is about 30 virtual machines to go all script around it takes some time, becose there are 2 requests: 1 for cpu ( us+sy+ni+hi+si+st ) and second to get wa
so if there is posible to get with 1 request those 2 variables then script would run twice faster
thanks for any advice and sorry for my bad english .