Check-task.gmp.py

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
import sys
task_name=sys.argv[4]
portlist="9ddce1ae-57e7-11e1-b13c-406186ea4fc5"
scanconf="698f691e-7489-11df-9d8c-002264764cea"
openvas="08b69003-5fc2-4037-a479-93b440211c73"

def status_task(tname):
 res = gmp.get_tasks()
 for i, task in enumerate(res.xpath('task')):
     id = task.xpath('@id')[0]
     name = task.xpath('name/text()')[0]
     if name == tname:
       status   = task.xpath('status/text()')[0]
       return status

def progress_task(tname):
 res = gmp.get_tasks()
 for i, task in enumerate(res.xpath('task')):
     id = task.xpath('@id')[0]
     name = task.xpath('name/text()')[0]
     if name == tname:
       progress = task.xpath('progress/text()')[0]
       return progress

status = status_task(task_name)
progress = progress_task(task_name)
print(status + " " + progress +"%")