summaryrefslogtreecommitdiffstats
path: root/extras/configs/http/sample.md
blob: 8451cedd8a5669e6e2b3dd7da890c0cc0a08ae24 (plain)
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
---
title: Home
---

# VPP Status

### Here's the version...

VPP version: <div id="VPPversion"></div>

build date: <div id="VPPbuilddate"></div>

<div id="like_button_container"></div>

### Show Interface

<p>Enter the interface name, then click "Submit" to display interface stats:</p>

<input id="ifacename" type="text"></input>
<button onclick="getStats()">Get Stats</button>

<div id="ifacestats"></div>

{{< rawhtml >}}

<script>
function getStats() {
    var url="http://192.168.10.1:1234/interface_stats.json?";
    var iface=document.getElementById("ifacename").value;
    url=url.concat(iface);
    fetch(url, {
        method: 'POST',
        mode: 'no-cors',
        cache: 'no-cache',
        headers: {
                 'Content-Type': 'application/json',
        },
})
.then((response) => response.json())
.then(function(obj) {
      console.log(obj)
      var result=obj.interface_stats.name;
      result = result.concat(": rx-pkts: ");
      result = result.concat(obj.interface_stats.rx_packets);
      result = result.concat(" rx-bytes: ");
      result = result.concat(obj.interface_stats.rx_bytes);
      result = result.concat(": tx-pkts: ");
      result = result.concat(obj.interface_stats.tx_packets);
      result = result.concat(" tx-bytes: ");
      result = result.concat(obj.interface_stats.tx_bytes);
      result = result.concat(" drops: ");
      result = result.concat(obj.interface_stats.drops);
      result = result.concat(" ip4: ");
      result = result.concat(obj.interface_stats.ip4);
      result = result.concat(" ip6: ");
      result = result.concat(obj.interface_stats.ip6);

      document.getElementById("ifacestats").innerHTML=result;
})
.catch(function(error) {
      console.log(error);
})}
// unconditionally populate vpp version info ->
fetch('http://192.168.10.1:1234/version.json', {
    method: 'GET',
    mode: 'no-cors',
    cache: 'no-cache',
    headers: {
         'Content-Type': 'application/json',
    },
})
.then((response) => response.json())
.then(function(obj) {
      document.getElementById("VPPbuilddate").innerHTML=obj.vpp_details.build_date;
      document.getElementById("VPPversion").innerHTML=obj.vpp_details.version;
})
.catch(function(error) {
      console.log(error);
});
</script>

{{< /rawhtml >}}