System tasks

Get all tasks without log

Request Structure:

http://<cluster>:<port>/api/system/tasks/get

Post data:

access_token = <access_token>

The response from the server:

{
 "msg": [
  {
   "id": "ntmjhibjazlkmlrmbwpgdgeilcwyvf",
   "node": "PC-ruslan",
   "user": "ruslan",
   "description": "Set /etc/hosts",
   "module": "system",
   "method": "hostsset",
   "queue": true,
   "status": "error",
   "process_id": "60480",
   "start": "09-05-2022 19:34:58",
   "end": "09-05-2022 19:35:02",
   "duration": "3"
  },
  {
   "id": "svipiesvlrplfuvbgcilcvimotekqz",
   "node": "node-2.docluster.com",
   "user": "ruslan",
   "description": "Set /etc/hosts",
   "module": "system",
   "method": "hostsset",
   "queue": true,
   "status": "success",
   "process_id": "79574",
   "start": "09-05-2022 19:34:58",
   "end": "09-05-2022 19:35:02",
   "duration": "3"
  },
  {
   "id": "cavohdzoqabtmqaofmdgtskggdwjne",
   "node": "PC-ruslan",
   "user": "ruslan",
   "description": "Set /etc/hosts",
   "module": "system",
   "method": "hostsset",
   "queue": true,
   "status": "error",
   "process_id": "60558",
   "start": "09-05-2022 19:36:07",
   "end": "09-05-2022 19:36:11",
   "duration": "4"
  },
  {
   "id": "hvrombzgewntoyewhywgseldmwywmo",
   "node": "node-2.docluster.com",
   "user": "ruslan",
   "description": "Set /etc/hosts",
   "module": "system",
   "method": "hostsset",
   "queue": true,
   "status": "success",
   "process_id": "79623",
   "start": "09-05-2022 19:36:08",
   "end": "09-05-2022 19:36:11",
   "duration": "3"
  }
 ],
 "status": "success",
 "error": ""
}

Errors:

-no tasks in the system

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/tasks/get'
data = {
        'ip': '1.2.3.4',
}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)

 

Get all task data per id

Request Structure:

http://<cluster>:<port>/api/system/tasks/get

Post data:

access_token = <access_token>
id = <task id>

The response from the server:

{
 "msg": [
  {
   "id": "ntmjhibjazlkmlrmbwpgdgeilcwyvf",
   "node": "PC-ruslan",
   "user": "ruslan",
   "description": "Set /etc/hosts",
   "module": "system",
   "method": "hostsset",
   "arg": {
    "192.168.129.198": [
     "PC-ruslan"
    ],
    "192.168.129.81": [
     "node-1.docluster.com"
    ],
    "192.168.129.82": [
     "node-2.docluster.com"
    ],
    "192.168.129.83": [
     "node-3.docluster.com"
    ],
    "192.168.129.84": [
     "node-4.docluster.com"
    ],
    "192.168.129.85": [
     "node-5.docluster.com"
    ],
    "192.168.129.86": [
     "node-6.docluster.com"
    ],
    "192.168.129.87": [
     "node-7.docluster.com"
    ],
    "192.168.129.88": [
     "node-8.docluster.com"
    ],
    "192.168.129.89": [
     "node-9.docluster.com"
    ],
    "192.168.129.90": [
     "node-10.docluster.com",
     "node-10.docluster.comq"
    ]
   },
   "queue": true,
   "status": "error",
   "process_id": "60480",
   "start": "09-05-2022 19:34:58",
   "end": "09-05-2022 19:35:02",
   "duration": "3",
   "log": "Task: ntmjhibjazlkmlrmbwpgdgeilcwyvf\nModule: system\nMethod: hostsset\nDescription: Set /etc/hosts\nUser: ruslan\n-------------------------------------\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\nTask: error\n"
  }
 ],
 "status": "success",
 "error": ""
}

Errors:

-no tasks in the system

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/tasks/get'
data = {
        'id': <task id>
}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)

 

 

Stop task per id

Request Structure:

http://<cluster>:<port>/api/system/tasks/stop

Post data:

access_token = <access_token>
id = <task id>

The response from the server:

{
 "msg": [],
 "status": "success",
 "error": ""
}

Errors:

-no tasks in the system

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/tasks/stop'
data = {
        'id': <task id>,
}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)

 

 

 


Revision #2
Created 10 May 2022 06:39:14 by Ruslan
Updated 10 May 2022 11:58:50 by Ruslan