douzhanjia0773 2019-03-05 17:46
浏览 114

有没有办法使用PHP或任何其他语言从F5 big-ip conf文件中获取数据?

I'm not familiar with networks but I have a requirement where I have to read a big-ip conf file and store the virtual ltm data in a file.

Example of conf file:

> ltm virtual /Common/vs_test {
>     destination /Common/10.01.01.111:80
>     ip-protocol tcp
>     mask 255.255.255.255
>     policies {
>          /Common/adt_vs_test {}
>     }
>     profile {
>        /Common/ADT_DSS_A_G { }
>     }
>     rules {
>        ....
>     }
>     security {
>         ....
>     } 
  }

From this file, I need the

Virtual server name - vs_test

IP:10.01.01.111

Port:80

Security Policy: DSS_A_G

Can someone help me in figuring this out?

  • 写回答

1条回答 默认 最新

  • dtv995719 2019-03-05 23:44
    关注

    You can write a tmsh script to be used locally on the BIG-IP to query that information, or you can use the iControl REST interface to query it as well. You might end up with more than one query to drill down for precisely the correct information as profiles and policies are buried in subcollections of the parent virtual server object. In one query, however, you can pull back the name, destination (IP+port of the virtual server) and the profile collection items like so with curl or a tool like Postman:

    https://ltm3.test.local/mgmt/tm/ltm/virtual?$select=name,destination,profilesReference&expandSubcollections=true
    

    This returns all the virtual servers with only the name, ip+port, and profile information in the following json format (only showing the virtual server with a policy on it for brevity):

    {
        "kind": "tm:ltm:virtual:virtualcollectionstate",
        "selfLink": "https://localhost/mgmt/tm/ltm/virtual?$select=name%2Cdestination%2CprofilesReference&expandSubcollections=true&ver=14.0.0",
        "items": [
            {
                "name": "bigvip_443",
                "destination": "/Common/192.168.102.60:443",
                "profilesReference": {
                    "link": "https://localhost/mgmt/tm/ltm/virtual/~Common~bigvip_443/profiles?ver=14.0.0",
                    "isSubcollection": true,
                    "items": [
                        {
                            "kind": "tm:ltm:virtual:profiles:profilesstate",
                            "name": "ASM_asm_test_policy",
                            "partition": "Common",
                            "fullPath": "/Common/ASM_asm_test_policy",
                            "generation": 569,
                            "selfLink": "https://localhost/mgmt/tm/ltm/virtual/~Common~bigvip_443/profiles/~Common~ASM_asm_test_policy?ver=14.0.0",
                            "context": "all",
                            "nameReference": {
                                "link": "https://localhost/mgmt/tm/security/bot-defense/asm-profile/~Common~ASM_asm_test_policy?ver=14.0.0"
                            }
                        },
                        {
                            "kind": "tm:ltm:virtual:profiles:profilesstate",
                            "name": "clientssl",
                            "partition": "Common",
                            "fullPath": "/Common/clientssl",
                            "generation": 553,
                            "selfLink": "https://localhost/mgmt/tm/ltm/virtual/~Common~bigvip_443/profiles/~Common~clientssl?ver=14.0.0",
                            "context": "clientside",
                            "nameReference": {
                                "link": "https://localhost/mgmt/tm/ltm/profile/client-ssl/~Common~clientssl?ver=14.0.0"
                            }
                        },
                        {
                            "kind": "tm:ltm:virtual:profiles:profilesstate",
                            "name": "http",
                            "partition": "Common",
                            "fullPath": "/Common/http",
                            "generation": 553,
                            "selfLink": "https://localhost/mgmt/tm/ltm/virtual/~Common~bigvip_443/profiles/~Common~http?ver=14.0.0",
                            "context": "all",
                            "nameReference": {
                                "link": "https://localhost/mgmt/tm/ltm/profile/http/~Common~http?ver=14.0.0"
                            }
                        },
                        {
                            "kind": "tm:ltm:virtual:profiles:profilesstate",
                            "name": "tcp",
                            "partition": "Common",
                            "fullPath": "/Common/tcp",
                            "generation": 553,
                            "selfLink": "https://localhost/mgmt/tm/ltm/virtual/~Common~bigvip_443/profiles/~Common~tcp?ver=14.0.0",
                            "context": "all",
                            "nameReference": {
                                "link": "https://localhost/mgmt/tm/ltm/profile/tcp/~Common~tcp?ver=14.0.0"
                            }
                        },
                        {
                            "kind": "tm:ltm:virtual:profiles:profilesstate",
                            "name": "websecurity",
                            "partition": "Common",
                            "fullPath": "/Common/websecurity",
                            "generation": 568,
                            "selfLink": "https://localhost/mgmt/tm/ltm/virtual/~Common~bigvip_443/profiles/~Common~websecurity?ver=14.0.0",
                            "context": "all",
                            "nameReference": {
                                "link": "https://localhost/mgmt/tm/ltm/profile/web-security/~Common~websecurity?ver=14.0.0"
                            }
                        }
                    ]
                }
            },
    

    This is a lot cleaner if you write a script in your language of choice to return only the data you want from your virtual servers, and this can be done from a remote machine against however many big-ip devices you have.

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)