#!/usr/bin/env python
# -*- coding: utf-8 -*-

from argparse import ArgumentParser
from mentat import monitor, report

parser = ArgumentParser(add_help=False)
parser.add_argument("-a", "--address", required=True)
parser.add_argument("-s", "--sender", required=True)
parser.add_argument("-r", "--recipient", required=True)
parser.add_argument("-p", "--process", type=int)
parser.add_argument("-i", "--interval", type=float, default=60.0)
parser.add_argument("-d", "--duration", type=float)
parser.add_argument("-t", "--threshold", type=float, nargs=4, default=[])

arguments = parser.parse_args()
address = arguments.address
sender = arguments.sender
recipient = arguments.recipient
threshold = tuple(arguments.threshold)
interval = arguments.interval
duration = arguments.duration
pid = arguments.process

if not threshold:
    if pid: threshold = (95.0, 95.0, 1024.0, 1024.0)
    else: threshold = (95.0, 95.0, 95.0, 95.0)

if duration: report(address, sender, recipient, interval, duration, pid)
else: monitor(address, sender, recipient, threshold, interval, pid)