summaryrefslogtreecommitdiffstats
path: root/extras/configs/http/sample.md
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-01-30 21:18:39 +0100
committerDamjan Marion <dmarion@me.com>2020-01-30 20:24:51 +0000
commitffad890961b7a5809ba08b4ab1c54001d8fd06d3 (patch)
treef9aa9d5153fdbe1c761ea59df9787b287f327dff /extras/configs/http/sample.md
parentd1e6b2937d551b58adf1b89697d7169f4b72bbdc (diff)
misc: move configs to extras/configs
Type: refactor Change-Id: I64665b290e2c42bbd9b0e877e9e4b028090b0ede Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'extras/configs/http/sample.md')
-rw-r--r--extras/configs/http/sample.md82
1 files changed, 82 insertions, 0 deletions
diff --git a/extras/configs/http/sample.md b/extras/configs/http/sample.md
new file mode 100644
index 00000000000..8451cedd8a5
--- /dev/null
+++ b/extras/configs/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 >}}