]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/ceph/StatusDetail.js
1 Ext
.define('PVE.ceph.StatusDetail', {
2 extend
: 'Ext.panel.Panel',
3 alias
: 'widget.pveCephStatusDetail',
10 bodyPadding
: '0 5 20',
26 html
: '<h3>' + gettext('Monitors') + '</h3>'
40 '<h3>' + gettext('OSDs') + '</h3>',
41 '<table class="osds">',
43 '<td><i class="fa fa-fw good fa-circle"></i>',
46 '<td><i class="fa fa-fw warning fa-circle-o"></i>',
51 '<td><i class="fa fa-fw good fa-arrow-circle-up"></i>',
58 '<td><i class="fa fa-fw critical fa-arrow-circle-down"></i>',
79 '<h3>' + gettext('PGs') + '</h3>',
80 '<tpl for="monitors">',
81 '<div class="left-aligned">{state_name}:</div>',
82 '<div class="right-aligned">{count}</div><br />',
83 '<div style="clear:both"></div>',
88 updateAll: function(record
) {
90 me
.suspendLayout
= true;
92 if (!record
.data
.pgmap
||
93 !record
.data
.osdmap
||
94 !record
.data
.osdmap
.osdmap
||
95 !record
.data
.health
||
96 !record
.data
.health
.timechecks
||
97 !record
.data
.monmap
||
98 !record
.data
.monmap
.mons
) {
99 // only continue if we have all the data
104 var pgs_by_state
= record
.data
.pgmap
.pgs_by_state
|| [];
105 pgs_by_state
.sort(function(a
,b
){
106 return (a
.state_name
< b
.state_name
)?-1:(a
.state_name
=== b
.state_name
)?0:1;
108 me
.getComponent('pgs').update({monitors
: pgs_by_state
});
110 // update osds counts
111 // caution: this code is not the nicest,
112 // but since the status call only gives us
113 // the total, up and in value,
114 // we parse the health summary and look for the
115 // x/y in osds are down message
116 // to get the rest of the numbers
118 // the alternative would be to make a second api call,
119 // as soon as not all osds are up, but those are costly
121 var total_osds
= record
.data
.osdmap
.osdmap
.num_osds
|| 0;
122 var in_osds
= record
.data
.osdmap
.osdmap
.num_in_osds
|| 0;
123 var up_osds
= record
.data
.osdmap
.osdmap
.num_up_osds
|| 0;
124 var out_osds
= total_osds
- in_osds
;
125 var down_osds
= total_osds
- up_osds
;
127 var downinregex
= /(\d+)\/(\d+) in osds are down/;
128 Ext
.Array
.some(record
.data
.health
.summary
, function(item
) {
129 var found
= item
.summary
.match(downinregex
);
131 if (found
!== null) {
132 // sanity check, test if the message is
133 // consistent with the direct value
135 if (found
[2] == in_osds
) {
136 downin_osds
= parseInt(found
[1],10);
144 var downout_osds
= down_osds
- downin_osds
;
145 var upin_osds
= in_osds
- downin_osds
;
146 var upout_osds
= up_osds
- upin_osds
;
152 downout
: downout_osds
154 me
.getComponent('osds').update(osds
);
156 // update the monitors
157 var mons
= record
.data
.monmap
.mons
.sort(function(a
,b
) {
158 return (a
.name
< b
.name
)?-1:(a
.name
> b
.name
)?1:0;
161 var monTimes
= record
.data
.health
.timechecks
.mons
|| [];
163 var monContainer
= me
.getComponent('monitors');
165 for (i
= 0; i
< mons
.length
&& i
< monTimes
.length
; i
++) {
166 timechecks
[monTimes
[i
].name
] = monTimes
[i
].health
;
169 for (i
= 0; i
< mons
.length
; i
++) {
170 var monitor
= monContainer
.getComponent('mon.' + mons
[i
].name
);
172 // since mons are already sorted, and
173 // we always have a sorted list
174 // we can add it at the mons+1 position (because of the title)
175 monitor
= monContainer
.insert(i
+1, {
176 xtype
: 'pveCephMonitorWidget',
177 itemId
: 'mon.' + mons
[i
].name
180 monitor
.updateMonitor(timechecks
[mons
[i
].name
], mons
[i
], record
.data
.quorum_names
);
182 me
.suspendLayout
= false;
187 Ext
.define('PVE.ceph.MonitorWidget', {
188 extend
: 'Ext.Component',
189 alias
: 'widget.pveCephMonitorWidget',
191 userCls
: 'monitor inline-block',
194 health
: 'HEALTH_ERR',
195 iconCls
: PVE
.Utils
.get_health_icon(),
201 '<i class="fa fa-fw {iconCls}"></i>'
204 // expects 3 variables which are
205 // timestate: the status from timechecks.mons
206 // data: the monmap.mons data
207 // quorum_names: the quorum_names array
208 updateMonitor: function(timestate
, data
, quorum_names
) {
210 var state
= 'HEALTH_ERR';
212 // if the monitor is part of the quorum
213 // and has a timestate, get the timestate,
214 // otherwise the state is ERR
215 if (timestate
&& quorum_names
&&
216 quorum_names
.indexOf(data
.name
) !== -1) {
220 me
.update(Ext
.apply(me
.data
, {
224 iconCls
: PVE
.Utils
.get_health_icon(PVE
.Utils
.map_ceph_health
[state
])
231 fn: function(events
, element
) {
232 var me
= this.component
;
237 me
.tooltip
= Ext
.create('Ext.tip.ToolTip', {
240 renderTo
: Ext
.getBody(),
241 html
: gettext('Monitor') + ': ' + me
.data
.name
+ '<br />' +
242 gettext('Address') + ': ' + me
.data
.addr
+ '<br />' +
243 gettext('Health') + ': ' + me
.data
.health
251 fn: function(events
, element
) {
252 var me
= this.component
;