Reply
Highlighted

use wapi to create/download traffic captures on ha pair

leifeste
Techie
Posts: 10
228     0

i am trying to automate traffic captures from an ha pair, and thought i would do it via the wapi. i've done this on the cli with set_traffic_capture, for both the active and passive nodes.  i did find the perl script uploaded by jim mozley, which i'm using as a touchpoint while i do this via simple curl commands.  so i can get the member id via the member host_name object, which gives me access to the active node of the ha pair.  my question is, is there a way to use the wapi to run capture_traffic_control (and fileop to pull the file) on the passive node of an ha pair?  i looked at the read_token option, hoping that might do it, but i'm not sure that's what that is for (and it came back as an empty array when i tried it). i apologize if i've missed something obvious.

 

thanks!

 

curl examples with output...

 

$ curl -s --tlsv1 --insecure --user '<username>' 'https://<grid_master>/wapi/v2.7/member?host_name~=<host_name>&_return_fields=host_name'

[
{
"_ref": "member/<member_id_hash>:<host_name>",
"host_name": "<host_name>"
}
]

 

$ curl -s --tlsv1 --insecure --user '<username>' -X POST https://<grid_master>/wapi/v2.7/member/<member_id_hash>:<host_name>?_function=capture_traffic_status
Enter host password for user '<username>':
{
"file_exists": true,
"file_size": 972201826,
"status": "STOPPED"

}

 

$ curl -s --tlsv1 --insecure --user '<username>' -X POST 'https://<grid_master>/wapi/v2.7/member/<member_id_hash>:<host_name>?_function=read_token'
Enter host password for user '<username>':
{
"pnode_tokens": []

}

Re: use wapi to create/download traffic captures on ha pair

leifeste
Techie
Posts: 10
229     0

well, after two weeks of no responses on here to this question, i finally broke down and created a support ticket a few days ago.  i'll update here once i get a final verdict and/or more info from them.

Re: use wapi to create/download traffic captures on ha pair

MRichard Community Manager
Community Manager
Posts: 101
229     0

First get the ref for the member, if you don't know it.

 

 

curl -k -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.7/member?host_name=gm.example.net'
[ { "_ref": "member/m99x1234567890rx7Qw:gm.example.net", "config_addr_type": "BOTH", "host_name": "gm.example.net", "platform": "VNIOS", "service_type_configuration": "ALL_V4" } ]

 

 

returns:

 

 

[
    {
        "_ref": "member/m99x1234567890rx7Qw:gm.example.net",
        "config_addr_type": "BOTH",
        "host_name": "gm.example.net",
        "platform": "VNIOS",
        "service_type_configuration": "ALL_V4"
    }
]

 

 

 

This is the call to poll the capture status:

 

 

curl -k -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.9/member/m99x1234567890rx7Qw:gm.example.net?_function=capture_traffic_status'

 

 

which returns:

 

{
    "file_exists": false,
    "file_size": 0,
    "status": "STOPPED"
} 

 

 

 

Here's the call to start the capture:

 

 

curl -k -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.9/member/m99x1234567890rx7Qw:gm.example.net?_function=capture_traffic_control&action=START&interface=ALL'

 

 

 

Now I can poll the status to see it running:

 

 

curl -k -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.9/member/m99x1234567890rx7Qw:gm.example.net?_function=capture_traffic_status'

{
    "file_exists": true,
    "file_size": 81920,
    "status": "RUNNING"
}

 

 

 

To download, the capture must be stopped.  Either stop it manually (as below) or wait for the timer to expire.

 

 

curl -k -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.9/member/m99x1234567890rx7Qw:gm.example.net?_function=capture_traffic_control&action=STOP&interface=ALL'

 

 

 

Here's the call to generate the capture file.

 

 

curl -k -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.9/fileop?_function=getmemberdata&member=gm.example.net&type=TRAFFIC_CAPTURE_FILE'

which returns a token and a URL.

 

{
    "token": "eJy9kTF...",
    "url": "https://192.168.1.2/http_direct_file_io/req_id-DOWNLOAD-12345/gm.example.net_0_2019-10-28-13-05-10_tcpdumpLog.tar.gz"
}

Download the file using the URL:

 

curl -k -u admin:infoblox -H "Content-type:application/force-download" -O 'https://192.168.1.2/http_direct_file_io/req_id-DOWNLOAD-12345/gm.richard.netwo_0_2019-10-28-13-05-10_tcpdumpLog.tar.gz'

And then close the generated file using the token:

 

curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.9/fileop?_function=downloadcomplete' \
-H "Content-Type: application/json" -d \
'{
  "token": "eJy9kTF..."
}'
Showing results for 
Search instead for 
Do you mean 

Recommended for You