summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include
diff options
context:
space:
mode:
authorJaymin Patel <jem.patel@gmail.com>2022-09-08 10:05:13 +0530
committerJaymin Patel <jem.patel@gmail.com>2022-10-23 16:19:33 +0530
commitd1a82d28868678716f16472f70b46557ba99f8df (patch)
tree488200d40fbc8a6b0515ad7e3adeb93fb622ed89 /applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include
parent3e9d9a9dbb045c24eb93643838f8e8e3b9074e4b (diff)
luci-app-keepalived: Add LuCI for keepalived
LuCI Support for Keepalived Signed-off-by: Jaymin Patel <jem.patel@gmail.com>
Diffstat (limited to 'applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include')
-rw-r--r--applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include/35_keepalived.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include/35_keepalived.js b/applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include/35_keepalived.js
new file mode 100644
index 0000000000..4f47d14980
--- /dev/null
+++ b/applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include/35_keepalived.js
@@ -0,0 +1,65 @@
+'use strict';
+'require baseclass';
+'require uci';
+'require rpc';
+
+var callKeepalivedStatus = rpc.declare({
+ object: 'keepalived',
+ method: 'dump',
+ expect: { },
+});
+
+return baseclass.extend({
+ title: _('Keepalived Instances'),
+
+ load: function() {
+ return Promise.all([
+ callKeepalivedStatus(),
+ uci.load('keepalived'),
+ ]);
+ },
+
+ render: function(data) {
+ var targets = (data[0].status) ? data[0].status : [];
+ var instances = uci.sections('keepalived', 'vrrp_instance');
+
+ var table =
+ E('table', { 'class': 'table lases' }, [
+ E('tr', { 'class': 'tr table-titles' }, [
+ E('th', { 'class': 'th' }, _('Name')),
+ E('th', { 'class': 'th' }, _('Interface')),
+ E('th', { 'class': 'th' }, _('Active State/State')),
+ E('th', { 'class': 'th' }, _('Probes Sent')),
+ E('th', { 'class': 'th' }, _('Probes Received')),
+ E('th', { 'class': 'th' }, _('Last Transition')),
+ E([])
+ ])
+ ]);
+
+ cbi_update_table(table,
+ targets.map(function(target) {
+ var state = (target.stats.become_master - target.stats.release_master) ? 'MASTER' : 'BACKUP';
+ if (instances != '') {
+ for (var i = 0; i < instances.length; i++) {
+ if (instances[i]['name'] == target.data.iname) {
+ state = state + '/' + instances[i]['state'];
+ break;
+ }
+ }
+ }
+ return [
+ target.data.iname,
+ target.data.ifp_ifname,
+ state,
+ target.stats.advert_sent,
+ target.stats.advert_rcvd,
+ new Date(target.data.last_transition * 1000)
+ ];
+ }, this), E('em', _('There are no active instances')));
+
+
+ return E([
+ table
+ ]);
+ },
+});