8 var callKeepalivedStatus
= rpc
.declare({
17 uci
.load('keepalived'),
23 E('table', { 'class': 'table lases' }, [
24 E('tr', { 'class': 'tr table-titles' }, [
25 E('th', { 'class': 'th' }, _('Name')),
26 E('th', { 'class': 'th' }, _('Interface')),
27 E('th', { 'class': 'th' }, _('Active State/State')),
28 E('th', { 'class': 'th' }, _('Probes Sent')),
29 E('th', { 'class': 'th' }, _('Probes Received')),
30 E('th', { 'class': 'th' }, _('Last Transition')),
36 return callKeepalivedStatus().then(function(instancesInfo
) {
37 var targets
= Array
.isArray(instancesInfo
.status
) ? instancesInfo
.status
: [];
38 var instances
= uci
.sections('keepalived', 'vrrp_instance');
40 cbi_update_table(table
,
41 targets
.map(function(target
) {
42 var state
= (target
.stats
.become_master
- target
.stats
.release_master
) ? 'MASTER' : 'BACKUP';
43 if (instances
!= '') {
44 for (var i
= 0; i
< instances
.length
; i
++) {
45 if (instances
[i
]['name'] == target
.data
.iname
) {
46 state
= state
+ '/' + instances
[i
]['state'];
53 target
.data
.ifp_ifname
,
55 target
.stats
.advert_sent
,
56 target
.stats
.advert_rcvd
,
57 new Date(target
.data
.last_transition
* 1000)
60 E('em', _('There are no active instances'))
65 return E('div', {'class': 'cbi-map'}, [
67 E('div', {'class': 'cbi-map-descr'}, _('This overview shows the current status of the VRRP instances on this device.')),
68 E('div', { 'class': 'cbi-section' }, table
)