in reply to (OT) Get the number of blocks per second by reading the proc diskstats file

Asserting that you're "writing a perl script" doesn't make your actual question a Perl question.

Use a search engine and the keywords "proc diskstats" if you want answers about the content of /proc/diskstats.

Helpful addendum: /proc is NOT where disk statistics live on every distro of Linux, so you may wish to consult the docs for your flavor and/or use "diskstats Linux"as your SE keywords.

  • Comment on Re: (OT) Get the number of blocks per second by reading the proc diskstats file

Replies are listed 'Best First'.
Re^2: (OT) Get the number of blocks per second by reading the proc diskstats file
by haavard82 (Initiate) on Nov 13, 2011 at 15:33 UTC
    Thank you for your answer. I agree that the question might not be an actual Perl question, but since I'm scripting with Perl I had some hopes that someone had some experience to share. I already used Google for tons of searches without any luck. If someone knows how to create some snippets of code and perhaps share some ideas of which values to use from the diskstats file, and also how to do the actual calculation, it would be very helpful. I'm sorry if my question is slightly non-Perl, but this place is one of my last hopes at the moment.

      "if my question is slightly non-Perl....

      No, your question is entirely non-Perl; in fact, somewhat akin to:

      "I'm cooking a turkey for dinner. Please provide a synopsis of Turkish history"

      As to "tons of searchs," didn't you find man proc referenced somewhere... or the documentation itself, http://linux.die.net/man/5/proc?

      man proc will tell you, among other things:

      /proc/pid/stat
      Status information about the process. This is used by ps(1). It is defined in /usr/src/linux/fs/proc/array.c.
      The fields, in order, with their proper scanf(3) format specifiers, are:
      ....

      Update: If you don't Read The Fine Manual, you really shouldn't expect the Monks to do your reading, interpretation and coding for you. See On asking for help and How do I post a question effectively?

        Please realize many newbies don't always know what they're supposed to know ahead of time. (hence the term 'newbie') Instead of this habit you seem to have developed to 'welcome' many new members to our site with a RTFM-type answer, why not assume best intentions were made and just stick to pointing them in the right direction.

        I have no problem calling someone out on trying to use the site as a coding service but I don't see that here and, frankly, I don't see it in a lot of the threads you respond to with your well thought out snarky remarks.

        Last time I checked, this site was a community that encourages sharing and learning. One that welcomes it's new members. If that is difficult for you to do in a non-abusive way then maybe consider sticking to threads from more experienced members.