How to use check_uptime method in autotest

Best Python code snippet using autotest_python

uptime.py

Source:uptime.py Github

copy

Full Screen

1# /usr/bin/python2#3# Dieser Check überprüft die Uptime, errecnet daraus den Reload zeitpunkt und speichert den in die Datenbank.4# Wenn sich die Uptime Ändert kommt eine Warnung! Beispiel: zur vollen Stunde:5#6# crontab -e7#8# 0 */1 * * * /usr/bin/python /var/www/IOT-Heizung/checks/uptime.py >> /var/www/IOT-Heizung/checks/logs/uptime.log9# 10#11import json12import requests13import os14from datetime import datetime15from datetime import timedelta16import check as common17def resetTime(uptime):18 time = datetime.now() - timedelta(seconds=uptime)19 return time.strftime("%Y-%m-%d %H:%M")20# Create Check Class21check = common.Check("uptime")22# URL23url = "http://heizung/api/reset"24response = requests.get(url, auth=(check.username, check.password))25print("REST API Status Code:\t" + str(response.status_code))26# JSON Parse. Fully decoded27reset = response.json()28# time variables29tc_dead_zone = "TIME('00:03')"30#31# Reference https://www.techonthenet.com/mariadb32#33# select * from check_uptime where ABS(TIMEDIFF('2022-05-15 16:36', reload)) <= TIME('00:03');34# Building SQL35reset_time = resetTime(reset["uptime"])36sql = "select count(1) as existing from check_uptime where ABS(TIMEDIFF('"37sql += reset_time38sql += "', reload)) <= "39sql += tc_dead_zone40sql += ";"41print(sql)42reloadfound = False43check.cursor.execute(sql)44for row in check.cursor.fetchall():45 reloadfound = row[0] > 046del row47if(reloadfound):48 print("No Record found. OK")49 check.status = common.CheckStatus.OK50else:51 print("New Reload. WARNING")52 sql = "insert into check_uptime (reload,reason,ref) values ('"53 sql += reset_time54 sql += "','"55 sql += reset["reason"]56 sql += "',false);"57 print(sql)58 check.execDML(sql)59 check.status = common.CheckStatus.WARNING60#delete check...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3##4## Author: Adriano Monteiro Marques <adriano@umitproject.org>5##6## Copyright (C) 2011 S2S Network Consultoria e Tecnologia da Informacao LTDA7##8## This program is free software: you can redistribute it and/or modify9## it under the terms of the GNU Affero General Public License as10## published by the Free Software Foundation, either version 3 of the11## License, or (at your option) any later version.12##13## This program is distributed in the hope that it will be useful,14## but WITHOUT ANY WARRANTY; without even the implied warranty of15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16## GNU Affero General Public License for more details.17##18## You should have received a copy of the GNU Affero General Public License19## along with this program. If not, see <http://www.gnu.org/licenses/>.20##21from django.conf.urls.defaults import *22urlpatterns = patterns('',23 url('^report_status/?$', 'status_api.views.report_status', name='report_status'),24 url('^check_status/?$', 'status_api.views.check_status', name='check_status'),25 url('^check_incidents/?$', 'status_api.views.check_incidents', name='check_incidents'),26 url('^check_downtime/?$', 'status_api.views.check_downtime', name='check_downtime'),27 url('^check_uptime/?$', 'status_api.views.check_uptime', name='check_uptime'),28 url('^check_availability/?$', 'status_api.views.check_availability', name='check_availability'),...

Full Screen

Full Screen

test_main.py

Source:test_main.py Github

copy

Full Screen

1#!/usr/bin/env python2import sys3import unittest4from mock import patch5import check_uptime6class MainTestCase(unittest.TestCase):7 def setUp(self):8 pass9 @patch("check_uptime.get_uptime")10 def test_main(self, mock_get_uptime):11 #12 # Test with no issues13 #14 with patch.object(sys, "argv", ["check_uptime.py"]):15 mock_get_uptime.return_value = 116 self.assertEqual(check_uptime.main(), 0)17 #18 # Test with min-days failure19 #20 with patch.object(sys, "argv", ["check_uptime.py", "--min-days", "2"]):21 mock_get_uptime.return_value = 100.222 self.assertEqual(check_uptime.main(), 1)23 #24 # Test with max-days failure25 #26 with patch.object(sys, "argv", ["check_uptime.py", "--max-days", "2"]):27 mock_get_uptime.return_value = 172801.2...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful