Add billing to monitor and status page.
This commit is contained in:
parent
0f00f854ac
commit
585420c768
|
@ -20,7 +20,7 @@ class Container_Collector(threading.Thread):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.thread_stop = False
|
self.thread_stop = False
|
||||||
self.interval = 2
|
self.interval = 2
|
||||||
self.billingtime = 60
|
self.billingtime = 3600
|
||||||
self.test = test
|
self.test = test
|
||||||
self.cpu_last = {}
|
self.cpu_last = {}
|
||||||
self.cpu_quota = {}
|
self.cpu_quota = {}
|
||||||
|
@ -164,14 +164,14 @@ class Container_Collector(threading.Thread):
|
||||||
if cpu_increment == 0.0:
|
if cpu_increment == 0.0:
|
||||||
avemem = 0
|
avemem = 0
|
||||||
else:
|
else:
|
||||||
avemem = cpu_increment*float(increment[container_name]['memincrement'])/3600.0
|
avemem = cpu_increment*float(increment[container_name]['memincrement'])/1800.0
|
||||||
increment[container_name]['lastcputime'] = cpu_val
|
increment[container_name]['lastcputime'] = cpu_val
|
||||||
increment[container_name]['memincrement'] = 0
|
increment[container_name]['memincrement'] = 0
|
||||||
if 'disk_use' in workercinfo[container_name].keys():
|
if 'disk_use' in workercinfo[container_name].keys():
|
||||||
disk_quota = workercinfo[container_name]['disk_use']['total']
|
disk_quota = workercinfo[container_name]['disk_use']['total']
|
||||||
else:
|
else:
|
||||||
disk_quota = 0
|
disk_quota = 0
|
||||||
logger.info("cpu_increment:"+str(cpu_increment)+" avemem:"+str(avemem)+" disk:"+str(disk_quota)+"\n")
|
#logger.info("cpu_increment:"+str(cpu_increment)+" avemem:"+str(avemem)+" disk:"+str(disk_quota)+"\n")
|
||||||
billing = cpu_increment/1000.0 + avemem/500000.0 + float(disk_quota)/1024.0/1024.0/2000
|
billing = cpu_increment/1000.0 + avemem/500000.0 + float(disk_quota)/1024.0/1024.0/2000
|
||||||
basic_info['billing'] += math.ceil(billing)
|
basic_info['billing'] += math.ceil(billing)
|
||||||
workercinfo[container_name]['basic_info'] = basic_info
|
workercinfo[container_name]['basic_info'] = basic_info
|
||||||
|
|
|
@ -206,6 +206,7 @@ function processBasicInfo()
|
||||||
$("#con_ip").html(basic_info.IP);
|
$("#con_ip").html(basic_info.IP);
|
||||||
}
|
}
|
||||||
$("#con_time").html(basic_info.RunningTime+"s");
|
$("#con_time").html(basic_info.RunningTime+"s");
|
||||||
|
$("#con_billing").html(basic_info.billing+" beans");
|
||||||
},"json");
|
},"json");
|
||||||
}
|
}
|
||||||
setInterval(processBasicInfo,1000);
|
setInterval(processBasicInfo,1000);
|
||||||
|
|
|
@ -86,6 +86,7 @@
|
||||||
<th>Cpu Usage</th>
|
<th>Cpu Usage</th>
|
||||||
<th>Mem Usage</th>
|
<th>Mem Usage</th>
|
||||||
<th>Disk Usage</th>
|
<th>Disk Usage</th>
|
||||||
|
<th>Billing</th>
|
||||||
<th>Summary</th>
|
<th>Summary</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -105,6 +106,7 @@
|
||||||
<td id='{{cluster}}_{{ loop.index }}_cpu'>--</td>
|
<td id='{{cluster}}_{{ loop.index }}_cpu'>--</td>
|
||||||
<td id='{{cluster}}_{{ loop.index }}_mem'>--</td>
|
<td id='{{cluster}}_{{ loop.index }}_mem'>--</td>
|
||||||
<td id='{{cluster}}_{{ loop.index }}_disk'>--</td>
|
<td id='{{cluster}}_{{ loop.index }}_disk'>--</td>
|
||||||
|
<td id='{{cluster}}_{{ loop.index }}_billing'>--</td>
|
||||||
<td><a class="btn btn-info btn-xs" href='/vclusters/{{ cluster }}/{{ container['containername'] }}/'>Realtime</a></td>
|
<td><a class="btn btn-info btn-xs" href='/vclusters/{{ cluster }}/{{ container['containername'] }}/'>Realtime</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -135,6 +137,7 @@
|
||||||
$("#"+index+"_disk").html(usedp+"%<br/>"+detail);
|
$("#"+index+"_disk").html(usedp+"%<br/>"+detail);
|
||||||
},"json");
|
},"json");
|
||||||
$("#"+index+"_time").html(data.monitor.basic_info.RunningTime+"s")
|
$("#"+index+"_time").html(data.monitor.basic_info.RunningTime+"s")
|
||||||
|
$("#"+index+"_billing").html(data.monitor.basic_info.billing+" beans")
|
||||||
|
|
||||||
var state = data.monitor.basic_info.State;
|
var state = data.monitor.basic_info.State;
|
||||||
if(state == 'RUNNING')
|
if(state == 'RUNNING')
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
<th>CPU Usage</th>
|
<th>CPU Usage</th>
|
||||||
<th>Mem Usage</th>
|
<th>Mem Usage</th>
|
||||||
<th>Disk Usage</th>
|
<th>Disk Usage</th>
|
||||||
|
<th>Billing</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -60,6 +61,7 @@
|
||||||
<td id='con_cpu'>--</td>
|
<td id='con_cpu'>--</td>
|
||||||
<td id='con_mem'>--</td>
|
<td id='con_mem'>--</td>
|
||||||
<td id='con_disk'>--</td>
|
<td id='con_disk'>--</td>
|
||||||
|
<td id='con_billing'>{{ container['billing'] }} beans</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue