是否存在curl命令以获取虚拟服务器详细信息?

时间:2019-04-11 15:16:56

标签: curl f5 big-ip

我在寻找一个curl命令,该命令实际上可以为我提供虚拟服务器的详细信息,例如池名称,IP,HTTP代码等。我查看了f5devcentral页面,但没有解决。

2 个答案:

答案 0 :(得分:1)

iControl Rest API与以下内容一起使用:

curl -k -u admin:pw -H "Content-Type: application/json" https://bigip.example.com/mgmt/tm/ltm/virtual/

对于特定的虚拟服务器,请使用https://bigip.example.com/mgmt/tm/ltm/virtual/{VS_NAME}作为API端点

输出(被截断):

{
  "kind": "tm:ltm:virtual:virtualstate",
  "name": "vs.example.com",
  "fullPath": "vs.example.com",
  "generation": 111111,
  "selfLink": "https://localhost/mgmt/tm/ltm/virtual/vs.example.com?ver=13.1.1.2",
  "addressStatus": "yes",
  "autoLasthop": "default",
  "cmpEnabled": "yes",
  "connectionLimit": 0,
  "destination": "/Common/10.1.1.1:80",
  "enabled": true,
  "gtmScore": 0,
  "ipProtocol": "tcp",
  "mask": "255.255.255.255",
  "mirror": "disabled",
  "mobileAppTunnel": "disabled",
  "nat64": "disabled",
  "pool": "/Common/test",
  "poolReference": {
    "link": "https://localhost/mgmt/tm/ltm/pool/~Common~test?ver=13.1.1.2"
  },
...
}

答案 1 :(得分:0)

您可以将curl与jq一起用于JSON过滤。获取所有虚拟服务器详细信息:

curl -sk -u user:pass GET https://www.example.com/mgmt/tm/ltm/virtual/ | jq -r

使用jq通过嵌套的JSON key:value字段进一步选择所需的信息。要列出.items下的所有嵌套值:

curl -sk -u user:pass GET https://www.example.com/mgmt/tm/ltm/virtual/ | jq -r '.items'

并进一步深入研究。如果需要VIP名称和IP地址:

curl -sk -u user:pass GET https://www.example.com/mgmt/tm/ltm/virtual/ |  jq -r '.items[] .name, .items[] .destination'