Results 1 to 6 of 6

Thread: Python Code to Show Free Memory

  1. #1
    Join Date
    Sep 2007
    Beans
    219
    Distro
    Ubuntu 11.04 Natty Narwhal

    Python Code to Show Free Memory

    Hi,

    I would like to create Python code to monitor the amount of free memory or swap space. Is there any way to do this?

    Thanks
    Mick

  2. #2
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: Python Code to Show Free Memory

    Define "monitor".

  3. #3
    Join Date
    Sep 2009
    Location
    Canada, Montreal QC
    Beans
    1,809
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Python Code to Show Free Memory

    Look at the code of other programs. They sure must be using an API.
    I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
    Freedom is measured in Stallmans.
    Projects: gEcrit

  4. #4
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Python Code to Show Free Memory

    Quote Originally Posted by MickSulley View Post
    Hi,

    I would like to create Python code to monitor the amount of free memory or swap space. Is there any way to do this?

    Thanks
    Mick
    Read the pseudo-file /proc/meminfo

  5. #5
    Join Date
    Sep 2007
    Beans
    219
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Python Code to Show Free Memory

    Read the pseudo-file /proc/meminfo
    Brilliant! Just what I wanted.

    The background is that I had an unfortunate incident with a server recently when it ran out of swap space. I am looking for a way to send me an email before things get that bad.

    Thanks for your help
    Mick

  6. #6
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Python Code to Show Free Memory

    Quote Originally Posted by MickSulley View Post
    Brilliant! Just what I wanted.

    The background is that I had an unfortunate incident with a server recently when it ran out of swap space. I am looking for a way to send me an email before things get that bad.

    Thanks for your help
    Mick
    Usually you have just a handful of suspects (server processes) and you can also get info about them in /proc/{pid}

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •