How to use update_watchdog method in autotest

Best Python code snippet using autotest_python

watchdog.py

Source:watchdog.py Github

copy

Full Screen

...42 if triggers["above"] is not None:43 if isinstance(new, (float, int)):44 if new > triggers["above"]:45 self.log("{} is above {} for {}".format(new, triggers["above"], entity))46 self.update_watchdog(watchdog, entity, "add")47 continue48 if triggers["below"] is not None:49 if isinstance(new, (float, int)):50 if new < triggers["below"]:51 self.log("{} is below {} for {}".format(new, triggers["below"], entity))52 self.update_watchdog(watchdog, entity, "add")53 continue54 if new is None and triggers["state"].lower() == "unknown":55 self.update_watchdog(watchdog, entity, "add")56 continue57 elif isinstance(new, str) and triggers["state"].lower() == new.lower():58 self.update_watchdog(watchdog, entity, "add")59 continue60 self.update_watchdog(watchdog, entity, "remove")61 def update_watchdog(self, watchdog, entity, add_or_remove):62 """Update watchdog info."""63 attributes = {64 "icon": self.watchdog_config[watchdog]["icon"],65 "friendly_name": self.watchdog_config[watchdog]["friendly_name"],66 67 }68 watchdog_state = self.get_state("watchdog.{}".format(watchdog), attribute="all")69 if watchdog_state is None:70 self.set_state("watchdog.{}".format(watchdog),71 state=self.state_normal,72 attributes={"entities": attributes})73 watchdog_state = self.get_state("watchdog.{}".format(watchdog), attribute="all")74 watchdog_attributes = watchdog_state.get("attributes", {})75 watchdog_entities = watchdog_attributes.get("entities", [])...

Full Screen

Full Screen

watchdog2.py

Source:watchdog2.py Github

copy

Full Screen

...12 charset='utf8'13)14cursor = sieve_db.cursor(pymysql.cursors.DictCursor)15HOST = "165.132.105.40"16def update_watchdog(timestamp, lis_port, cpu_usage, mem_usage) :17 sql = 'UPDATE job_tasks SET cpu_usage=' + str(cpu_usage) + ' WHERE ec_id=' + str(ec_id) + ' AND listening_port=' + str(lis_port)18 cursor.execute(sql)19 sieve_db.commit()20sql = 'SELECT id FROM engine_computer where ip_address="' + HOST + '"'21cursor.execute(sql)22ec_id = (cursor.fetchall())[0]['id']23while True :24 pids = []25 pair = {}26 for proc in psutil.process_iter() :27 try :28 if proc.name() == "python3" or proc.name() == "python3.6":29 port = proc.cmdline()[3]30 pids.append(proc.pid)31 pair[proc.pid] = port32 except :33 pass34 print("pids : ", pids)35 print("pair : ", pair)36 for pid in pids :37 cmd = ['ps', '-p', str(pid), '-o', '%cpu'] 38 fd_popen = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout 39 data = fd_popen.read().strip() 40 fd_popen.close()41 data = data.decode('utf-8')42 data = data.split('\n')43 lis_port = pair[pid]44 cpu_usage = data[1]45 print(pid, lis_port, cpu_usage)46 update_watchdog(1, lis_port, cpu_usage, 10)...

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