Developer

last person joined: 8 days ago 

Expand all | Collapse all

API to access trail-info on particular MAC

This thread has been viewed 0 times
  • 1.  API to access trail-info on particular MAC

    Posted Aug 27, 2019 10:31 AM

    We are leveraging an Aruba 7205 controller on 8.4.xxx. I would like to display the last 10 or so hops of a device utilizing Aruba's API but just can't seem to figure it out. 

     

    If this is possible, any help would be appreciated.

     

    Thanks!



  • 2.  RE: API to access trail-info on particular MAC
    Best Answer

    EMPLOYEE
    Posted Aug 28, 2019 06:18 PM

    Hello,

     

    Please try out the API mentioned below. The following API is a replication of the show command that is used on CLI for client trail-info. However, the output of this API is json formatted. So you might be able to get some relevant information that you are looking for.

    API Method:
    GET

    API URI:
    https://<controller-ip>:4343/v1/configuration/showcommand?command=show+ap+client+trail-info+<mac-address>&UIDARUBA=<session-id>

    Resoponse
    JSON formated response having the  values  of  the following as lists:

    1) Alerts

    2) Client Trail Info
    3) Deauth Reason
    4) Mobility Trail ( I believe, this is the one you are looking for)

    Let me know if this works.

    Regards,
    Jay

     



  • 3.  RE: API to access trail-info on particular MAC

    Posted Sep 10, 2019 11:56 AM

    Thanks for the quick reply! 

     

    I am able to log in successfully and grab the UIDARUBA code using the following:

    curl --insecure -c "aruba-cookie" -d "username=****&password=****" \
    "https://x.x.x.x:4343/v1/api/login" which spits out the successful message:

    {"_global_result": {"status":"0", "status_str": "You've logged in successfully.", "UIDARUBA":"2e0cacdc-e23b-42e9-a56e-daa384bf8e8b"}}

     

    I follow that up with :

    curl --insecure -X POST --header "Content-Type: application/json" --header "Accept: application/json" "https://x.x.x.x:4343/v1/configuration/showcommand?command=show+ap+client+trail-info+f0-0f-ec-74-de-a5&UIDARUBA=2e0cacdc-e23b-42e9-a56e-daa384bf8e8b"

     

    and receive a bunch of HTML and code:

     

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/>
    <title>Login</title>
    <style type="text/css">
    body {
    font-family: Arial, Helvetica, sans-serif, Tahoma;
    font-size: 11px;
    margin: 0;
    padding: 0;
    background-color: #FFFFFF;
    text-align: center;
    }

    h1 {
    margin: 0;
    padding: 0;
    }

    img {
    border: 0;
    }

    #login-wrapper {
    top: 50%;
    transform: translateY(-50%);
    position: absolute;
    width: 100%;
    }

    .loginbox {
    background-color: #fff;
    color: #646569;
    border: 1px solid #e5e5e5;
    margin: auto;
    position: relative;
    }

    #logincontainer {
    width: 500px;
    }

    #vialogincontainer {
    width: 375px;
    }

    #logoutcontainer {
    width: 375px;
    }

    #aruba-logo {
    margin: 30px auto;
    }

    #loading-icon {
    margin-top: 30px;
    }

    .loginbox h1 {
    font-size: 1.5em;
    margin-bottom: 15px;
    padding: 0px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    }

    .loginbox form {
    text-align: center;
    padding: 15px 0px 10px;
    margin-bottom: 0px;
    }

    #legalcontainer {
    font-size: 9pt;
    padding: 10px 0;
    width: 100%;
    bottom: 0;
    }

    .copyrighttxt {
    text-align: center;
    }

    .inputctrl {
    padding-bottom: 12px;
    }

    .inputctrl input {
    height: 2em;
    font-size: 14px;
    width: 140px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    padding: 0 5px;
    }

    .inputctrl input:hover {
    border: 1px solid rgba(0, 0, 0, 1);
    }

    .inputctrl input:focus {
    border: 1px solid rgba(204, 105, 0, 1);
    outline-style: none;
    }

    #reason {
    color: #cc2b3a;
    font-size: 16px;
    line-height: 30px;
    text-align: left;
    background-color: #ffd7db;
    border-left: 5px solid #ff3649;
    margin: 0px auto 10px;
    padding-left: 10px;
    width: 300px;
    }

    #reason img {
    position: relative;
    top: 2px;
    height: 16px
    }

    .msgtxt {
    height: 2.2em;
    line-height: 1.1em;
    overflow: hidden;
    margin: 0px auto;
    width: 300px;
    text-align: justify;
    font-size: 14pt;
    }

    .info-msg {
    color: #cc9642;
    font-size: 16px;
    text-align: left;
    background-color: #fff1dc;
    border-left: 5px solid #ffbb52;
    margin: 30px auto 10px;
    padding-left: 5px;
    width: 300px;
    }

    .info-icon-cell {
    vertical-align: top;
    }

    .info-icon {
    top: 5px;
    height: 20px;
    position: relative;
    }

    .info-text {
    margin: 5px 5px;
    }

    .error {
    border: 1px solid #B30303;
    }

    a.login {
    text-decoration: none;
    display: inline-block;
    }

    .button {
    background-color: #02a7ec;
    border-radius: 2px 2px 2px 2px;
    color: #FFFFFF;
    font-size: 1.5em;
    font-weight: bold;
    height: 30px;
    padding-top: 3px;
    text-align: center;
    width: 80px;
    cursor: pointer;
    line-height: 27px;
    }

    .button:hover {
    background-color: #0286bd;
    }

    .system-name {
    margin-bottom: 23px;
    }

    ::-webkit-input-placeholder {
    color: #646569;
    opacity: 0.4;
    font-style: italic;
    }

    :-moz-placeholder {
    /* Firefox 18- */
    color: #646569;
    opacity: 0.4;
    font-style: italic;
    }

    ::-moz-placeholder {
    /* Firefox 19+ */
    color: #646569;
    opacity: 0.4;
    font-style: italic;
    }

    :-ms-input-placeholder {
    color: #646569;
    opacity: 0.4;
    font-style: italic;
    }

    .styled-select select {
    background: transparent;
    width: 140px;
    padding: 0 5px;
    font-size: 14px;
    border: 0;
    border-radius: 0;
    height: 2em;
    -webkit-appearance: none;
    }

    .styled-select {
    display: inline-block;
    width: 140px;
    font-size: 14px;
    height: 2em;
    box-sizing: border-box;
    border: 1px solid rgba(0, 0, 0, 0.3);
    background: url(/images/arrow_down.png) no-repeat right 5px center #fff;
    overflow: hidden;
    }

    .styled-select:hover {
    border: 1px solid rgba(0, 0, 0, 1);
    }

    .styled-select select:focus {
    outline-style: none;
    }

    .eula {
    max-height: 300px;
    overflow-y: auto;
    padding-left: 1em;
    padding-right: 1em;
    text-align: left;
    }

    </style>
    <script>
    function init_focus() {
    var f = document.getElementById("login-form");
    if (!f) return;
    var x;
    if ((x = f.elements["uid"])) {
    x.disabled = false;
    x.focus();
    }
    if ((x = f.elements["passwd"])) x.disabled = false;
    if ((x = f.elements["login"])) x.disabled = false;
    var ua = "", bneedxml = false;
    if (window && window.navigator) {
    ua = window.navigator.userAgent.toLowerCase();
    }
    if (ua.indexOf("windows") >= 0 && ua.indexOf("mozilla/") >= 0 && ua.indexOf("(compatible; msie") >= 0) {
    try {
    var x = new ActiveXObject("MsXML2.XMLHTTP.4.0");
    var y = new ActiveXObject("MsXml2.DOMDocument");
    if (x && y) {
    bneedxml = false;
    }
    else {
    bneedxml = true;
    }
    }
    catch (e) {
    bneedxml = true;
    }
    }
    if ((x = f.elements["needxml"])) {
    x.value = bneedxml ? "1" : "0";
    }
    }
    function set_action() {
    var f = document.getElementById("login-form");
    if (!f) return;
    f.action = f.elements["realaction"].value;
    }
    function checkError() {
    var f = document.getElementById("reason");
    if (!f) return;
    if("" != f.innerHTML)
    f.style.display = "";
    }
    function loginValidation(){
    var LoginForm = document.getElementById("login-form");
    if("" == LoginForm.uid.value)
    {
    alert("Please provide User Name");
    document.forms[1].uid.focus();
    return;
    }
    else if("" == LoginForm.passwd.value)
    {
    alert("Please provide Password");
    document.forms[1].passwd.focus();
    return;
    }
    LoginForm.submit();
    window.sessionStorage.removeItem('prevSearch');
    }
    function convertHTMLTag(s) {
    return s == null ? "" : s.replace(/\&/g, "&amp;").replace(/\</g, "&lt;").replace(/\>/g, "&gt;").replace(/\"/g, "&quot;").replace(/\'/g, "&#39;");
    }
    </script>
    </head>
    <body onload="init_focus()">
    <div id="login-wrapper">
    <div id="logincontainer" class="loginbox">
    <img id="aruba-logo" src="/images/aruba-hpe-logo.png" width="175" alt="Aruba Networks" title="Aruba Networks"/>
    <h1 id="system-name"></h1>
    <div class="eula">

    </div>
    <form id="eula-accept" style="display: none">
    <div>
    <a class="login" href="javascript&colon;void(0);" onclick="acceptEula();return false;">
    <div class="button">I Accept</div>
    </a>
    </div>
    </form>

    <form id="login-form" method="post" autocomplete="off" action="/screens/wms/wms.login" style="display: none">
    <input type="hidden" name="opcode" value="login"/>
    <input type="hidden" name="url" value="/v1/configuration/showcommand?command=show+ap+client+trail-info+f0-0f-ec-74-de-a5&amp;UIDARUBA=2e0cacdc-e23b-42e9-a56e-daa384bf8e8b"/>
    <input type="hidden" name="needxml"/>
    <div class="inputctrl">
    <input type="text" name="uid" class="errornone" placeholder="Username" onKeyPress="if(event && event.keyCode == 13){loginValidation();return false;}"></input>
    </div>
    <div class="inputctrl">
    <input type="password" name="passwd" placeholder="Password" onKeyPress="if(event && event.keyCode == 13){loginValidation();return false;}"></input>
    </div>
    <div>
    <a class="login" href="javascript&colon;void(0);" onclick="loginValidation();return false;"><div name="login" class="button">Log in</div></a>
    </div>
    </form>
    <div id="reason">
    <img src="/images/alert-login-page.png"/>
    <span id="failreason"></span>
    </div>
    <noscript>
    <div>
    JavaScript is disabled on your browser.<br>
    Please try again after enabling JavaScript support.
    </div>
    </noscript>
    <div id="legalcontainer" >
    <div class="copyrighttxt">Copyright &#169; <span id=currentYear>2019</span> Aruba, a Hewlett Packard Enterprise company.</div>
    </div>
    </div>
    </div>
    <script>
    var systemName = "wa-ar7205-1";
    systemName = convertHTMLTag(systemName);
    document.getElementById("system-name").innerHTML = systemName;

    var reasonDisplay = 'none';
    if (reasonDisplay === 'none') {
    document.getElementById("reason").style.display = 'none';
    }

    var dataFailure=document.getElementById("failreason").innerHTML;
    if (dataFailure === "Login failed.") {
    document.getElementById("failreason").innerHTML="Invalid password or username.";
    } else if (dataFailure === "Login max failed.") {
    document.getElementById("failreason").innerHTML="Maximum number of concurrent sessions reached";
    } else if (dataFailure === "Session is invalid.") {
    document.getElementById("reason").style.display = 'none';
    }
    try {
    /* Encapsulate sys-banner-display into a "eval" such that any syntax error gets trapped by the catch */
    var mustAcceptEula = window.Function("return false")();
    if(mustAcceptEula) {
    document.getElementById("eula-accept").style.display = "block";
    } else {
    document.getElementById("login-form").style.display = "block";
    }
    }
    catch(error) {
    document.getElementById("login-form").style.display = "block";
    }

    function acceptEula() {
    document.getElementById("eula-accept").style.display = "none";
    document.getElementsByClassName("eula")[0].style.display = "none";
    document.getElementById("login-form").style.display = "block";
    return false;
    }

    </script>

    </body>
    </html>

     

    I feel like we are getting close though!

     



  • 4.  RE: API to access trail-info on particular MAC
    Best Answer

    EMPLOYEE
    Posted Sep 10, 2019 02:27 PM

    Hi Robinson,

     

    There are two errors in the way you are making the API call.
    1) The method should be GET
    2) Missing header Cookie (Cookie: SESSION=<uidaruba_token>)

    Try curl using the following and it should work:

     

    curl --insecure -X GET \ "https://10.88.1.111:4343/v1/configuration/showcommand?command=show+ap+client+trail-info+f0:0f:ec:74:de:a5&UIDARUBA=<uidaruba_token>" \

    --header "Accept: application/json" \
    --header "Cookie: SESSION=<uidaruba_token>"


    Let me know if this works for you.

    Thanks,
    Jay



  • 5.  RE: API to access trail-info on particular MAC

    Posted Sep 10, 2019 07:11 PM

    OutputTrail.PNG

     

    When I go to the controllers API (https://10.x.x.x:4343/api/) and use this command in "Show Command"
    show ap client trail-info fc:25:3f:b1:24:85

    This is the output:

    {
    "Alerts": [
    {
    "Reason": "STA has roamed to another AP",
    "Timestamp": "Sep 10 13:42:34"
    }
    ],
    "Client Trail Info": [
    {
    "AP-name": "TS 141 Hall",
    "Alert": "STA has roamed to another AP",
    "BSSID": "f4:2e:7f:05:8a:71",
    "Deauth Reason": "STA has left and is disassociated",
    "ESSID": "XXX",
    "MAC": "fc:25:3f:b1:24:85",
    "VLAN": "259"
    }
    ],
    "Deauth Reason": [
    {
    "Reason": "STA has left and is disassociated",
    "Timestamp": "Sep 10 18:43:17"
    },
    {
    "Reason": "STA has left and is disassociated",
    "Timestamp": "Sep 10 18:42:54"
    },
    {
    "Reason": "STA has left and is disassociated",
    "Timestamp": "Sep 10 18:13:25"
    },
    {
    "Reason": "STA has left and is disassociated",
    "Timestamp": "Sep 10 17:43:09"
    },
    {
    "Reason": "STA has left and is disassociated",
    "Timestamp": "Sep 10 17:13:28"
    },
    {
    "Reason": "STA has left and is disassociated",
    "Timestamp": "Sep 10 16:43:25"
    },
    {
    "Reason": "STA has left and is disassociated",
    "Timestamp": "Sep 10 16:13:22"
    },
    {
    "Reason": "STA has left and is disassociated",
    "Timestamp": "Sep 10 16:12:56"
    },
    {
    "Reason": "STA has left and is disassociated",
    "Timestamp": "Sep 10 15:43:27"
    },
    {
    "Reason": "STA has left and is disassociated",
    "Timestamp": "Sep 10 15:13:19"
    }
    ],
    "Mobility Trail": [
    {
    "AP-name": "TS 141 Hall",
    "BSSID": "f4:2e:7f:05:8a:71",
    "ESSID": "XXX",
    "Timestamp": "Sep 10 18:43:17",
    "VLAN": "259"
    },
    {
    "AP-name": "TS 141 Hall",
    "BSSID": "f4:2e:7f:05:8a:71",
    "ESSID": "XXX1",
    "Timestamp": "Sep 10 18:43:12",
    "VLAN": "259"
    },
    {
    "AP-name": "TS 141 Hall",
    "BSSID": "f4:2e:7f:05:8a:71",
    "ESSID": "XXX1",
    "Timestamp": "Sep 10 18:43:12",
    "VLAN": "259"
    },
    {
    "AP-name": "TS 141 Hall",
    "BSSID": "f4:2e:7f:05:8a:71",
    "ESSID": "XXX1",
    "Timestamp": "Sep 10 18:42:54",
    "VLAN": "259"
    },
    {
    "AP-name": "TS 141 Hall",
    "BSSID": "f4:2e:7f:05:8a:71",
    "ESSID": "XXX1",
    "Timestamp": "Sep 10 18:42:48",
    "VLAN": "259"
    },
    {
    "AP-name": "TS 141 Hall",
    "BSSID": "f4:2e:7f:05:8a:71",
    "ESSID": "XXX1",
    "Timestamp": "Sep 10 18:42:48",
    "VLAN": "259"
    },
    {
    "AP-name": "TS 141 Hall",
    "BSSID": "f4:2e:7f:05:8a:71",
    "ESSID": "XXX1",
    "Timestamp": "Sep 10 18:13:25",
    "VLAN": "259"
    },
    {
    "AP-name": "TS 141 Hall",
    "BSSID": "f4:2e:7f:05:8a:71",
    "ESSID": "XXX1",
    "Timestamp": "Sep 10 18:13:12",
    "VLAN": "259"
    },
    {
    "AP-name": "TS 141 Hall",
    "BSSID": "f4:2e:7f:05:8a:71",
    "ESSID": "XXX1",
    "Timestamp": "Sep 10 18:13:12",
    "VLAN": "259"
    },
    {
    "AP-name": "TS 141 Hall",
    "BSSID": "f4:2e:7f:05:8a:71",
    "ESSID": "XXX1",
    "Timestamp": "Sep 10 17:43:09",
    "VLAN": "259"
    }
    ],
    "_data": [
    "10",
    "1",
    "10"
    ],
    "_meta": [
    "BSSID",
    "ESSID",
    "AP-name",
    "VLAN",
    "Timestamp"]
    }

     

    When I send the commands to log in and trail from the CLI:

     

    [root@WCS-snipeIT-01 xmlApiScripts]# ./xml_user_login.sh
    {"_global_result": {"status":"0", "status_str": "You've logged in successfully.", "UIDARUBA":"7273b388-211c-44f6-bdb2-be68bf982697"}}


    [root@WCS-snipeIT-01 xmlApiScripts]# nano trail.sh


    [root@WCS-snipeIT-01 xmlApiScripts]# ./trail.sh > output.txt
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0

     

    This is the trail.sh script
    curl --insecure -X GET "https://10.x.x.x:4343/v1/configuration/showcommand?command=show+ap+client+trail-info+fc-25-3f-b1-24-85&UIDARUBA=7273b388-211c-44f6-bdb2-be68bf982697" \
    --header "Accept: application/json" \
    --header "Cookie: SESSION=7273b388-211c-44f6-bdb2-be68bf982697"

     

    I feel like we are getting close, it is connecting now successfully but I am not sure what that output is from?

     

    Thanks for all of the help. We are trying to figure out a cheap way to track lost devices within our school and get them back to their rightful owners!



  • 6.  RE: API to access trail-info on particular MAC

    MVP GURU
    Posted Sep 11, 2019 05:16 AM

    Hi,

     

    Don't missing : for mac address ?



  • 7.  RE: API to access trail-info on particular MAC

    Posted Sep 11, 2019 08:17 AM

    I want to thank both you guys for your help. The final solution was the following:

     

    curl --insecure -X GET "https://x.x.x.x:4343/v1/configuration/showcommand?command=show+ap+client+trail-info+fc:25:3f:b1:24:85&UIDARUBA=38a0211f-7947-4949-941a-860d7dcefd8c" \
    --header "Accept: application/json" \
    --header "Cookie: SESSION=38a0211f-7947-4949-941a-860d7dcefd8c"

     

    Which produced the same output as my previous post using the API show command within the controller. 


    Thanks guys!