Пример #1
0
timestamp_now = datetime.obtain_timestamp(now)

five_minutes = int(timestamp_now) - 300

five_minutes_date = datetime.timestamp_to_datetime(five_minutes)

server.set_conditions('WHERE date<%s', [five_minutes_date])

arr_server = []

with server.select(['hostname']) as cur:
    for s in cur:
        arr_server.append(s['hostname'])

if len(arr_server) > 0:

    send_mail = SendMail()

    content_mail = "THE NEXT SERVERS ARE DOWN: " + ", ".join(
        arr_server) + "\n\n"

    content_mail = 'Please, click in this link for view the servers down; ' + config.domain_url + make_url(
        'pastafari/servers', {'type': 'down'})

    if not send_mail.send(
            email_address, config.email_notification,
            I18n.lang('pastafari', 'servers_down',
                      'WARNING:  SERVERS ARE DOWN!'), content_mail):
        print('Sended email with notification')