script.getscriptsbyhosts

Descripció

object script.getscriptsbyhosts(array hostIds)

Aquest mètode permet recuperar scripts disponibles a l'equip donat.

Aquest mètode és disponible per a qualsevol mena d'usuaris. Els permisos per cridar al mètode es poden revocar a la configuració de rols d'usuaris. Per a més informació, veieu Rols d'usuari.

Paràmetres

(string/array) IDs dels equips dels que es recuperaran els scripts.

Valors de retorn

(object) Retorna un objecte amb ID d'equip com a propietats i matrius d'scripts disponibles com a valors.

El mètode ampliarà automàticament les macros al text de confirmation.

Exemples

Recuperar scripts per ID d'equip

Recuperar tots els scripts disponibles dels equips "30079" i "30073".

Petició:

{
           "jsonrpc": "2.0",
           "method": "script.getscriptsbyhosts",
           "params": [
               "30079",
               "30073"
           ],
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Resposta:

{
           "jsonrpc": "2.0",
           "result": {
               "30079": [
                   {
                       "scriptid": "3",
                       "name": "Detect operating system",
                       "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "7",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "hostid": "10001"
                   },
                   {
                       "scriptid": "1",
                       "name": "Ping",
                       "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "hostid": "10001"
                   },
                   {
                       "scriptid": "2",
                       "name": "Traceroute",
                       "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "hostid": "10001"
                   }
               ],
               "30073": [
                   {
                       "scriptid": "3",
                       "name": "Detect operating system",
                       "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "7",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "hostid": "10001"
                   },
                   {
                       "scriptid": "1",
                       "name": "Ping",
                       "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "hostid": "10001"
                   },
                   {
                       "scriptid": "2",
                       "name": "Traceroute",
                       "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "hostid": "10001"
                   }
               ]
           },
           "id": 1
       }

Font

CScript::getScriptsByHosts() in ui/include/classes/api/services/CScript.php.