summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-09-17 09:47:35 -0400
committerFlorin Coras <florin.coras@gmail.com>2019-09-18 14:26:59 +0000
commit43765e2b4eaa8e1f2a5f1562414e04962c777ff3 (patch)
treee5a18e7ba42c4c7fb962d034e22a79d9beb89288 /extras
parent4bf849043d6ffc1d3d43e65f381e310f425d01f7 (diff)
builtinurl: initial working attempt
Note that the builtin URLs are disabled by default. To activate, "builtinurl enable" or use the builtinurl_enable API. See .../extras/http/sample.md for some Hugo-friendly .md w/ embedded Javascript that accesses the builtin URLs. Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I6d82d9292c41d6d2d90be73ba8a1a043fb20c986
Diffstat (limited to 'extras')
-rw-r--r--extras/http/sample.md82
-rw-r--r--extras/http/setup.http3
2 files changed, 84 insertions, 1 deletions
diff --git a/extras/http/sample.md b/extras/http/sample.md
new file mode 100644
index 00000000000..8451cedd8a5
--- /dev/null
+++ b/extras/http/sample.md
@@ -0,0 +1,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 >}}
diff --git a/extras/http/setup.http b/extras/http/setup.http
index 3b8da575a98..78b7a2f19e8 100644
--- a/extras/http/setup.http
+++ b/extras/http/setup.http
@@ -3,4 +3,5 @@ create tap host-if-name lstack host-ip4-addr 192.168.10.2/24
set int ip address tap0 192.168.10.1/24
set int state tap0 up
-http static server www-root /scratch/fdio-site-fork/public uri tls://0.0.0.0/1234 cache-size 10m fifo-size 2048
+http static server www-root <path> uri tcp://0.0.0.0/1234 cache-size 10m fifo-size 2048
+builtinurl enable