Howdy, Stranger!

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


OpenVZ IO accounting spreadsheet
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

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?

  • jhjh Member

    It's in bytes

  • Mistook the tittle for a certain high RAM brand

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

    hehe :P

  • RadiRadi Host Rep, Veteran

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

    So did I :D.

  • 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.