Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Advertise on LowEndTalk.com
OpenVZ IO accounting spreadsheet
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

OpenVZ IO accounting spreadsheet

jhjh Member

I wrote a little script which is so little and so useful I thought it should be shared :)

This is to gather the IO reads and writes by container ID and put them in an Excel-friendly format. Just copy and paste the script in and copy and paste the results into Excel.

for CT in $(vzlist -H -o veid) 
do
    reads=$(cat /proc/bc/${CT}/ioacct | sed 's/\t//g' | grep ^read | awk '{ print $2 }')
    writes=$(cat /proc/bc/${CT}/ioacct | sed 's/\t//g' | grep ^write | awk '{ print $2 }')
    echo -e "${CT}\t${reads}\t${writes}"
done

Comments

  • DamianDamian Member

    Hey that's pretty cool.. is this in bytes or in I/O operations?

  • Mistook the tittle for a certain high RAM brand

    I'm here to collect your heart

  • @DalComp said:
    Mistook the tittle for a certain high RAM brand

    hehe :P

    Patrick | INIZ
  • RadiRadi Member, Provider

    @DalComp said:
    Mistook the tittle for a certain high RAM brand

    So did I :D.

    4 GB RAM/90 GB SSD/4 TB Traffic/KVM/1 IPv4 for $7/mo only here with coupon code "LET-It-GO".

  • dannixdannix Member

    @jhadley said:

    for CT in $(vzlist -H -o veid) 
    > do
    >   reads=$(cat /proc/bc/${CT}/ioacct | sed 's/\t//g' | grep ^read | awk '{ print $2 }')
    >   writes=$(cat /proc/bc/${CT}/ioacct | sed 's/\t//g' | grep ^write | awk '{ print $2 }')
    >   echo -e "${CT}\t${reads}\t${writes}"
    > done

    You could optimize it a little bit and get rid of grep by using:

    awk '/^read/ { print $2 }' awk '/^write/ { print $2 }'

    I'm not sure why you need sed, awk can deal with '\t'

    And the dead cat is most probably also not needed.

    I have no way of testing it now, but there is high chance that this will give you the same results:

    for CT in $(vzlist -H -o veid) do reads=$(awk '/^read/ { print $2 }' /proc/bc/${CT}/ioacct) writes=$(awk '^/write/ { print $2 }' /proc/bc/${CT}/ioacct) echo -e "${CT}\t${reads}\t${writes}" done

  • can someone take this one step further and run it 10 seconds apart and compare the results so we could see who are io hogs?

Sign In or Register to comment.