It has been solved in the repo. You can apply the patch [1], or download these files (check the paths before, as they may vary depending on how you installed opennebula):<div><br></div><div>wget <a href="http://dev.opennebula.org/projects/opennebula/repository/revisions/one-3.8/raw/src/cli/oneacct">http://dev.opennebula.org/projects/opennebula/repository/revisions/one-3.8/raw/src/cli/oneacct</a> -O `which oneacct`<br>
<div>wget <a href="http://dev.opennebula.org/projects/opennebula/repository/revisions/one-3.8/raw/src/cli/one_helper/oneacct_helper.rb">http://dev.opennebula.org/projects/opennebula/repository/revisions/one-3.8/raw/src/cli/one_helper/oneacct_helper.rb</a> -O /usr/lib/one/ruby/cli/one_helper/oneacct_helper.rb</div>
<div><br></div><div>I hope that solves the issue</div><div><br></div><div>[1] <a href="http://dev.opennebula.org/projects/opennebula/repository/revisions/af470487098c4228600b36a36bfd2dc8f73435c3">http://dev.opennebula.org/projects/opennebula/repository/revisions/af470487098c4228600b36a36bfd2dc8f73435c3</a><br clear="all">
<div>--<br>Carlos Martín, MSc<br>Project Engineer<br>OpenNebula - The Open-source Solution for Data Center Virtualization<div><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="http://www.OpenNebula.org" target="_blank">www.OpenNebula.org</a> | <a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a> | <a href="http://twitter.com/opennebula" target="_blank">@OpenNebula</a></span><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="mailto:cmartin@opennebula.org" style="color:rgb(42,93,176)" target="_blank"></a></span></div>
</div>
<br><br><div class="gmail_quote">On Thu, Jan 17, 2013 at 3:19 PM, Carlos Martín Sánchez <span dir="ltr"><<a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I forgot to add that meanwhile, you can try to filter records using xpath expressions for HISTORY/STIME and HISTORY/ETIME<div><br></div><div><div class="im">Regards<br clear="all"><div>--<br>Carlos Martín, MSc<br>Project Engineer<br>
OpenNebula - The Open-source Solution for Data Center Virtualization<div>
<span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="http://www.OpenNebula.org" target="_blank">www.OpenNebula.org</a> | <a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a> | <a href="http://twitter.com/opennebula" target="_blank">@OpenNebula</a></span><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="mailto:cmartin@opennebula.org" style="color:rgb(42,93,176)" target="_blank"></a></span></div>
</div>
<br><br></div><div><div class="h5"><div class="gmail_quote">On Thu, Jan 17, 2013 at 3:04 PM, Carlos Martín Sánchez <span dir="ltr"><<a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You are right, that first entry should be filtered out. We'll look into it [1], thanks for reporting.<div><br></div><div>Regards</div><div><br></div><div>[1] <a href="http://dev.opennebula.org/issues/1732" target="_blank">http://dev.opennebula.org/issues/1732</a><div>
<br clear="all">
<div>--<br>Carlos Martín, MSc<br>Project Engineer<br>OpenNebula - The Open-source Solution for Data Center Virtualization<div><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="http://www.OpenNebula.org" target="_blank">www.OpenNebula.org</a> | <a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a> | <a href="http://twitter.com/opennebula" target="_blank">@OpenNebula</a></span><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="mailto:cmartin@opennebula.org" style="color:rgb(42,93,176)" target="_blank"></a></span></div>
</div>
<br><br></div><div><div><div class="gmail_quote">On Thu, Jan 17, 2013 at 1:32 PM, Benadik, Jan <span dir="ltr"><<a href="mailto:jan.benadik@atos.net" target="_blank">jan.benadik@atos.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<br>
<div>Dňa 16.01.2013 14:29, � wrote / napísal(a):<br>
</div><div>
<blockquote type="cite">
Hi,
<div><br>
</div>
<div>On Tue, Jan 15, 2013 at 5:18 PM, Benadik, Jan <span dir="ltr"><<a href="mailto:jan.benadik@atos.net" target="_blank">jan.benadik@atos.net</a>></span> wrote:
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"><small><small><font color="#ff0000"><big><big><font color="#000000"><b>My questions:</b></font></big></big></font></small></small><br>
- how can I limit time frame for oneacct command (i.e. - from 1. 1. 2013 to 31.1.2013 - only running VM's in that only period)?<br>
If I use -s and -e option, it displays all machines without any limitations ...<br>
</div>
</blockquote>
<div><br>
</div>
<div>The -s and -e options will show all the history records that were active during that time interval, but they may start or end outside that interval. Maybe you were expecting records that started and ended within the interval. Can you check if this is the
case, or if you found a bug and there is no filtering at all?</div>
</div>
</blockquote></div>
But there are records in all state (stopped included) - I want to have running state only in that report. That means - If I set exact time frame, I expect records which were in state "Running" inside of that time frame and only number of minutes in "running"
state inside of that time frame. <br>
<br>
I.e. - I have three VM's, all with 4vCPU, 8096MB RAM:<br>
- VM1 started on 12. 24. 2012, stopped on 12. 31. 2012<br>
- VM2 started on 01. 01. 2013, stopped on 01. 15. 2013<br>
- VM3 started on 12. 24. 2012, still running<br>
<br>
If I use (on 02. 01. 2013) command <b><small><small><big><big>bill "01/01/2013" "01/31/2013"</big></big>,
</small></small></b>I expect output like:<br>
oid, vcpus, memory, minutes_running<br>
VM2, 4, 8096, 21600<br>
VM3, 4, 8096, 44640<div><br>
<br>
<blockquote type="cite">
<div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">- how can I display correct figures in minutes for running machines in oneacct output?<span><font color="#888888"><br>
</font></span></div>
</blockquote>
<div><br>
</div>
<div>That depends on how you plan to bill, by the month or waiting after the registry ends.</div>
<div>If you want to get the minutes spent in this month, you need to take into account that STIME and ETIME can be outside the range, you can compute them as:</div>
<br>
bill_start = [$1, h['STIME'].to_i].max</div>
<div><br>
</div>
<div>etime = h['ETIME'].to_i == 0 ? Time.now : h['ETIME'].to_i</div>
<div>
<div>bill_end = [$2, etime].min</div>
<div><br>
</div>
<div><br>
</div>
<div>This is pseudo-ruby, but I hope you get the idea.</div>
</div>
</blockquote>
<br></div>
Thanks - I will try it.<span><font color="#888888"><br>
<br>
Jan</font></span><div><div><br>
<blockquote type="cite">
<div>
<div><br>
</div>
<div>Regards</div>
<div>--<br>
Carlos Martín, MSc<br>
Project Engineer<br>
OpenNebula - The Open-source Solution for Data Center Virtualization
<div><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="http://www.OpenNebula.org" target="_blank">www.OpenNebula.org</a> |
<a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a> |
<a href="http://twitter.com/opennebula" target="_blank">@OpenNebula</a></span><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"></span></div>
</div>
<br>
<br>
<div class="gmail_quote">On Tue, Jan 15, 2013 at 5:18 PM, Benadik, Jan <span dir="ltr">
<<a href="mailto:jan.benadik@atos.net" target="_blank">jan.benadik@atos.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">Hi all,<br>
<br>
<b>I have a script /usr/bin/bill</b><br>
<small><small>#!/usr/bin/env ruby<br>
<br>
require 'json'<br>
<br>
j = JSON.parse(`oneacct -j -s $1 -e $2`)<br>
<br>
puts "oid,vcpus,memory,minutes_running"<br>
<br>
j['HISTORY_RECORDS']['HISTORY'].each do |h|<br>
puts "#{h['OID']},"<<<br>
"#{h['VM']['TEMPLATE']['VCPU']},"<<<br>
"#{h['VM']['TEMPLATE']['MEMORY']},"<<<br>
"#{(h['ETIME'].to_i - h['STIME'].to_i)/60}"<br>
end</small></small><br>
<br>
Output from that command:<br>
<b><small><small>oneadmin@myto-node:~$ bill "01/01/2013" "01/31/2013"</small></small></b><br>
<small><small>oid,vcpus,memory,minutes_running<br>
0,2,1024,0<br>
0,2,1024,0<br>
1,2,1024,0<br>
1,2,1024,32<br>
</small><small><small><small>.<br>
.<br>
.</small></small><br>
110,4,8096,29925<br>
111,4,8096,84<br>
112,4,8096,5939<br>
113,4,8096,22<br>
114,4,8096,<font color="#ff0000">-22637691<br>
<br>
<big><big><font color="#000000">First 4 lines were VM's running in october 2012 (for a while), last line is still running VM.<br>
<br>
<b>My questions:</b></font></big></big></font></small></small><br>
- how can I limit time frame for oneacct command (i.e. - from 1. 1. 2013 to 31.1.2013 - only running VM's in that only period)?<br>
If I use -s and -e option, it displays all machines without any limitations ...<br>
- how can I display correct figures in minutes for running machines in oneacct output?<span><font color="#888888"><br>
<br>
Jan<br>
<div>-- <br>
<font size="3" face="Helvetica"><img alt="" height="15" width="252"><br>
<b>Ján Beňadik</b><br>
<font face="Helvetica">Managed Services - Solution Design Architect<br>
mobile: <a href="tel:%2B421%20903%20691%20634" value="+421903691634" target="_blank">
+421 903 691 634</a><br>
fax: <a href="tel:%2B421%202%206852%208380" value="+421268528380" target="_blank">
+421 2 6852 8380</a><br>
<a href="mailto://jan.benadik@atos.net" target="_blank">jan.benadik@atos.net</a><br>
Vinohradnicka 6, 971 01 Prievidza<br>
<a href="http://www.sk.atos.net" target="_blank">www.sk.atos.net</a><br>
__________________________________<br>
<br>
<img alt="" height="58" width="261"><br>
</font></font></div>
</font></span></div>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org" target="_blank">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
<div>-- <br>
<font size="3" face="Helvetica"><img alt="" src="cid:part14.04020708.04040304@atos.net" height="15" width="252"><br>
<b>Ján Beňadik</b><br>
<font face="Helvetica">Managed Services - Solution Design Architect<br>
mobile: <a href="tel:%2B421%20903%20691%20634" value="+421903691634" target="_blank">+421 903 691 634</a><br>
fax: <a href="tel:%2B421%202%206852%208380" value="+421268528380" target="_blank">+421 2 6852 8380</a><br>
<a href="mailto://jan.benadik@atos.net" target="_blank">jan.benadik@atos.net</a><br>
Vinohradnicka 6, 971 01 Prievidza<br>
<a href="http://www.sk.atos.net" target="_blank">www.sk.atos.net</a><br>
__________________________________<br>
<br>
<img alt="" src="cid:part17.07090906.07070901@atos.net" height="58" width="261"><br>
</font></font></div>
</div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div></div>