]>
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>',
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 !record
.data
.health
.health
||
100 !record
.data
.health
.health
.health_services
||
101 !record
.data
.health
.health
.health_services
[0]) {
102 // only continue if we have all the data
107 var pgs_by_state
= record
.data
.pgmap
.pgs_by_state
|| [];
108 pgs_by_state
.sort(function(a
,b
){
109 return (a
.state_name
< b
.state_name
)?-1:(a
.state_name
=== b
.state_name
)?0:1;
111 me
.getComponent('pgs').update({states
: pgs_by_state
});
113 // update osds counts
114 // caution: this code is not the nicest,
115 // but since the status call only gives us
116 // the total, up and in value,
117 // we parse the health summary and look for the
118 // x/y in osds are down message
119 // to get the rest of the numbers
121 // the alternative would be to make a second api call,
122 // as soon as not all osds are up, but those are costly
124 var total_osds
= record
.data
.osdmap
.osdmap
.num_osds
|| 0;
125 var in_osds
= record
.data
.osdmap
.osdmap
.num_in_osds
|| 0;
126 var up_osds
= record
.data
.osdmap
.osdmap
.num_up_osds
|| 0;
127 var out_osds
= total_osds
- in_osds
;
128 var down_osds
= total_osds
- up_osds
;
130 var downinregex
= /(\d+) osds down/;
131 Ext
.Array
.some(record
.data
.health
.summary
, function(item
) {
132 var found
= item
.summary
.match(downinregex
);
134 if (found
!== null) {
135 downin_osds
= parseInt(found
[1],10);
142 var downout_osds
= down_osds
- downin_osds
;
143 var upin_osds
= in_osds
- downin_osds
;
144 var upout_osds
= up_osds
- upin_osds
;
150 downout
: downout_osds
152 me
.getComponent('osds').update(osds
);
154 // update the monitors
155 var mons
= record
.data
.monmap
.mons
.sort(function(a
,b
) {
156 return (a
.name
< b
.name
)?-1:(a
.name
> b
.name
)?1:0;
159 var monTimes
= record
.data
.health
.timechecks
.mons
|| [];
160 var monHealth
= record
.data
.health
.health
.health_services
[0].mons
|| [];
162 var healthchecks
= {};
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 if (mons
.length
=== 1) {
170 timechecks
[mons
[0].name
] = "HEALTH_OK";
173 for (i
= 0; i
< mons
.length
&& i
< monHealth
.length
; i
++) {
174 healthchecks
[monHealth
[i
].name
] = monHealth
[i
].health
;
177 for (i
= 0; i
< mons
.length
; i
++) {
178 var monitor
= monContainer
.getComponent('mon.' + mons
[i
].name
);
180 // since mons are already sorted, and
181 // we always have a sorted list
182 // we can add it at the mons+1 position (because of the title)
183 monitor
= monContainer
.insert(i
+1, {
184 xtype
: 'pveCephMonitorWidget',
185 itemId
: 'mon.' + mons
[i
].name
188 monitor
.updateMonitor(timechecks
[mons
[i
].name
], mons
[i
], record
.data
.quorum_names
, healthchecks
[mons
[i
].name
]);
190 me
.suspendLayout
= false;
195 Ext
.define('PVE.ceph.MonitorWidget', {
196 extend
: 'Ext.Component',
197 alias
: 'widget.pveCephMonitorWidget',
199 userCls
: 'monitor inline-block',
202 health
: 'HEALTH_ERR',
203 iconCls
: PVE
.Utils
.get_health_icon(),
209 '<i class="fa fa-fw {iconCls}"></i>'
212 // expects 3 variables which are
213 // timestate: the status from timechecks.mons
214 // data: the monmap.mons data
215 // quorum_names: the quorum_names array
216 updateMonitor: function(timestate
, data
, quorum_names
, health
) {
218 var state
= 'HEALTH_ERR';
225 // if the monitor is part of the quorum
226 // and has a timestate, get the timestate,
227 // otherwise the state is ERR
228 if (timestate
&& health
&& quorum_names
&&
229 quorum_names
.indexOf(data
.name
) !== -1) {
230 state
= (healthstates
[health
] < healthstates
[timestate
])?
234 me
.update(Ext
.apply(me
.data
, {
238 iconCls
: PVE
.Utils
.get_health_icon(PVE
.Utils
.map_ceph_health
[state
])
245 fn: function(events
, element
) {
246 var me
= this.component
;
251 me
.tooltip
= Ext
.create('Ext.tip.ToolTip', {
254 renderTo
: Ext
.getBody(),
255 html
: gettext('Monitor') + ': ' + me
.data
.name
+ '<br />' +
256 gettext('Address') + ': ' + me
.data
.addr
+ '<br />' +
257 gettext('Health') + ': ' + me
.data
.health
265 fn: function(events
, element
) {
266 var me
= this.component
;