1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
| TOKEN="2b5b9618d746e5692bebdd1b5c0da178" URL="http://10.129.1.198/zabbix/api_jsonrpc.php"
# 1. 主机列表 curl -s -X POST -H 'Content-Type: application/json' \ -d "{\"jsonrpc\":\"2.0\",\"method\":\"host.get\",\"params\":{\"output\":\"extend\"},\"auth\":\"$TOKEN\",\"id\":1}" $URL { "jsonrpc": "2.0", "result": [{ "hostid": "10105", "proxy_hostid": "0", "host": "Zabbix", "status": "0", "disable_until": "0", "error": "", "available": "0", "errors_from": "0", "lastaccess": "0", "ipmi_authtype": "-1", "ipmi_privilege": "2", "ipmi_username": "", "ipmi_password": "", "ipmi_disable_until": "0", "ipmi_available": "0", "snmp_disable_until": "0", "snmp_available": "0", "maintenanceid": "0", "maintenance_status": "0", "maintenance_type": "0", "maintenance_from": "0", "ipmi_errors_from": "0", "snmp_errors_from": "0", "ipmi_error": "", "snmp_error": "", "jmx_disable_until": "0", "jmx_available": "0", "jmx_errors_from": "0", "jmx_error": "", "name": "Zabbix", "flags": "0", "templateid": "0", "description": "This host - Zabbix Server", "tls_connect": "1", "tls_accept": "1", "tls_issuer": "", "tls_subject": "", "tls_psk_identity": "", "tls_psk": "" }, { "hostid": "10106", "proxy_hostid": "0", "host": "Zipper", "status": "0", "disable_until": "0", "error": "", "available": "1", "errors_from": "0", "lastaccess": "0", "ipmi_authtype": "-1", "ipmi_privilege": "2", "ipmi_username": "", "ipmi_password": "", "ipmi_disable_until": "0", "ipmi_available": "0", "snmp_disable_until": "0", "snmp_available": "0", "maintenanceid": "0", "maintenance_status": "0", "maintenance_type": "0", "maintenance_from": "0", "ipmi_errors_from": "0", "snmp_errors_from": "0", "ipmi_error": "", "snmp_error": "", "jmx_disable_until": "0", "jmx_available": "0", "jmx_errors_from": "0", "jmx_error": "", "name": "Zipper", "flags": "0", "templateid": "0", "description": "Zipper", "tls_connect": "1", "tls_accept": "1", "tls_issuer": "", "tls_subject": "", "tls_psk_identity": "", "tls_psk": "" }], "id": 1 }
# 2. 可用脚本 curl -s -X POST -H 'Content-Type: application/json' \ -d "{\"jsonrpc\":\"2.0\",\"method\":\"script.get\",\"params\":{\"output\":\"extend\"},\"auth\":\"$TOKEN\",\"id\":1}" $URL { "jsonrpc": "2.0", "result": [{ "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" }, { "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" }, { "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" }], "id": 1 }
|