Esempio n. 1
0
def popen(*args, **kwargs):
    """popen(command [, mode='r' [, bufsize]]) -> pipe

    Open a pipe to/from a command returning a file object.
    """
    # allow lazy import of popen2 and javashell
    import popen2
    return popen2.popen(*args, **kwargs)
Esempio n. 2
0
def popen( *args, **kwargs ):
    """popen(command [, mode='r' [, bufsize]]) -> pipe

    Open a pipe to/from a command returning a file object.
    """
    # allow lazy import of popen2 and javashell
    import popen2
    return popen2.popen( *args, **kwargs )
Esempio n. 3
0
def send_email(mem, total_mem, percent):
    import smtplib

    to = "*****@*****.**"
    frm = "*****@*****.**"
    subject = "Garfist memory low"
    msg = """Subject: Garfist memory low

    Status --
    %d / %d (%f%%)
    """ % (
        mem,
        total_mem,
        percent,
    )

    server = smtplib.SMTP("localhost")
    server.sendmail(frm, to, msg)
    server.quit


total_mem = int(popen("free | grep Mem: | awk '{ print $2 }'")[0].read().strip())
mem = int(popen("free | grep buffers/cache | awk '{ print $4; }'")[0].read().strip())

percent = (float(mem) / float(total_mem)) * 100

print mem, "/", total_mem, percent

if percent <= PERCENT_LIMIT:
    send_email(mem, total_mem, percent)
Esempio n. 4
0
def popen( *args, **kwargs ):
    # allow lazy import of popen2 and javashell
    import popen2
    return popen2.popen( *args, **kwargs )