Extending Statistics

I would like to modify the statistics page to show additional graphs.
In particular, I'd like to create a couple of graphs showing groupings
of hosts of low, medium, and high load, available disk space,
available memory, etc.

For example, a load pie graph would have 3 slices: the number of
hosts with a load < 0.5, hosts with a load >= 0.5 and < 1.0, and those
with a load >= 1.0.

I've added the facts to report the system load in Facter, and I've
found the various ruby files in /controllers, /helpers, and /views for
displaying statistics and also the fact_values.rb in /modules, but I'm
not sure how to query the facts database for conditionals like this?
I'm no Ruby guru, and I didn't recognize the query format in
fact_values.rb.

It would actually be very nice to have a general method in
fact_values.rb to query facts by more than just name. Here is what I
was hoping to accomplish in statistics_controller.rb:

@load_low = FactValue.count_each &quot;load_average_5m &lt; 0.5&quot;
@load_med = FactValue.count_each &quot;(load_average_5m &gt;= 0.5) &amp;&amp;

(load_average_5m < 1.0)"
@load_high = FactValue.count_each "load_average_5m >= 1.0"

Where then I could graph these in the helper app.

I would appreciate any help.

Thanks,

I am doing something similar to what you are asking. I'm basically
adding charts to the statistics page. My charts will show a
distribution of UNIQUE values for a given fact. So for what I am
doing to work for you I think that first you would need to create a
fact that reports load as of string of the following values: "< 0.5",
">= 0.5", "< 1.0" and ">= 1.0" … except some of those seem to
conflict … so maybe: "< 0.5", "0.5-1.0", and "> 1.0"? So again,
fact "my_load" would report for a system with load of 0.2 a value for
that fact of "< 0.5" … not actually "0.2". This then puts the logic
of the groupings into the fact code and takes it out of the foreman
code, making changes to foreman simpler.

Here is what I do (for 0.4):

Edit app/helpers/statistics_helper.rb

Add something like the following to the 'charts' array:

pie_chart("load_dist" ,"System Load Distribution",
FactValue.count_each("my_load")),

I would also edit app/views/statistics/index.html.erb and change

<% charts.in_groups(3,nil) do |ch| -%>

to

<% charts.in_groups(5,nil) do |ch| -%>

Otherwise you get some weird looking pages

Hopefully this is something that can help you get started. Would be
nice to have a settings page to define extra charts to generate on
that page after pointing to a fact … but I guess that is sort of
what the dynamic pie chart graphs on the facts page is for.

Regards,
Jake

··· On Dec 12, 1:52 pm, Kyle Mallory wrote: > I would like to modify the statistics page to show additional graphs. > In particular, I'd like to create a couple of graphs showing groupings > of hosts of low, medium, and high load, available disk space, > available memory, etc. > > For example, a load pie graph would have 3 slices: the number of > hosts with a load < 0.5, hosts with a load >= 0.5 and < 1.0, and those > with a load >= 1.0. > > I've added the facts to report the system load in Facter, and I've > found the various ruby files in /controllers, /helpers, and /views for > displaying statistics and also the fact_values.rb in /modules, but I'm > not sure how to query the facts database for conditionals like this? > I'm no Ruby guru, and I didn't recognize the query format in > fact_values.rb. > > It would actually be very nice to have a general method in > fact_values.rb to query facts by more than just name. Here is what I > was hoping to accomplish in statistics_controller.rb: > > @load_low = FactValue.count_each "load_average_5m < 0.5" > @load_med = FactValue.count_each "(load_average_5m >= 0.5) && > (load_average_5m < 1.0)" > @load_high = FactValue.count_each "load_average_5m >= 1.0" > > Where then I could graph these in the helper app. > > I would appreciate any help. > > Thanks,

> I would like to modify the statistics page to show additional graphs.
> In particular, I'd like to create a couple of graphs showing groupings
> of hosts of low, medium, and high load, available disk space,
> available memory, etc.
>
> For example, a load pie graph would have 3 slices: the number of
> hosts with a load < 0.5, hosts with a load >= 0.5 and < 1.0, and those
> with a load >= 1.0.
>
> I've added the facts to report the system load in Facter, and I've
> found the various ruby files in /controllers, /helpers, and /views for
> displaying statistics and also the fact_values.rb in /modules, but I'm
> not sure how to query the facts database for conditionals like this?
> I'm no Ruby guru, and I didn't recognize the query format in
> fact_values.rb.
>
> It would actually be very nice to have a general method in
> fact_values.rb to query facts by more than just name. Here is what I
> was hoping to accomplish in statistics_controller.rb:
>
> @load_low = FactValue.count_each "load_average_5m < 0.5"
> @load_med = FactValue.count_each "(load_average_5m >= 0.5) &&
> (load_average_5m < 1.0)"
> @load_high = FactValue.count_each "load_average_5m >= 1.0"
>
> Where then I could graph these in the helper app.

sadly, facts are always strings, so you would need to parse the values
first, sadly i had to do something very similar for the memory usage
facts.

Ohad

··· On Mon, Dec 12, 2011 at 9:52 PM, Kyle Mallory wrote: > > I would appreciate any help. > > Thanks, > > -- > You received this message because you are subscribed to the Google Groups "Foreman users" group. > To post to this group, send email to foreman-users@googlegroups.com. > To unsubscribe from this group, send email to foreman-users+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/foreman-users?hl=en. >

Corey Osman
corey@logicminds.biz
678-348-0582 Pacific Time

Green I.T and Datacenter Automation Specialist

>> I would like to modify the statistics page to show additional graphs.
>> In particular, I'd like to create a couple of graphs showing groupings
>> of hosts of low, medium, and high load, available disk space,
>> available memory, etc.
>>
>> For example, a load pie graph would have 3 slices: the number of
>> hosts with a load < 0.5, hosts with a load >= 0.5 and < 1.0, and those
>> with a load >= 1.0.
>>
>> I've added the facts to report the system load in Facter, and I've
>> found the various ruby files in /controllers, /helpers, and /views for
>> displaying statistics and also the fact_values.rb in /modules, but I'm
>> not sure how to query the facts database for conditionals like this?
>> I'm no Ruby guru, and I didn't recognize the query format in
>> fact_values.rb.
>>
>> It would actually be very nice to have a general method in
>> fact_values.rb to query facts by more than just name. Here is what I
>> was hoping to accomplish in statistics_controller.rb:
>>
>> @load_low = FactValue.count_each "load_average_5m < 0.5"
>> @load_med = FactValue.count_each "(load_average_5m >= 0.5) &&
>> (load_average_5m < 1.0)"
>> @load_high = FactValue.count_each "load_average_5m >= 1.0"
>>
>> Where then I could graph these in the helper app.
>
> sadly, facts are always strings, so you would need to parse the values
> first, sadly i had to do something very similar for the memory usage
> facts.

What about trying to ask ruby what kind of type the value is and then type casting the value so that floats, string, integers could be used instead in the graphs?

value.to_i
value.to_f
value.to_s

··· On Dec 13, 2011, at 5:02 AM, Ohad Levy wrote: > On Mon, Dec 12, 2011 at 9:52 PM, Kyle Mallory wrote:

Ohad

I would appreciate any help.

Thanks,


You received this message because you are subscribed to the Google Groups “Foreman users” group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups “Foreman users” group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/foreman-users?hl=en.