The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:

Feature #2066

Make units optional

Added by Sam Quigley about 7 years ago. Updated almost 3 years ago.

Status:Merged - Pending ReleaseStart date:03/10/2009
Priority:NormalDue date:
Assignee:Ruth Linehan% Done:

0%

Category:library
Target version:1.7.0
Keywords:intern Affected Facter version:
Branch:https://github.com/puppetlabs/facter/pull/237

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com


Description

For memory facts (and maybe other stuff?), Facter currently uses the largest unit it can (kb/mb/gb/tb), and only prints two decimal places of accuracy. On some of my systems, this means that the facts reported by facter are slightly wrong — and it also introduces a bit of complexity into any program that wants to make use of these facts, since they have to translate back into machine-readable units…

It’d be nice if there were an option to make facter report bytes instead…

-sq

History

#1 Updated by James Turnbull about 7 years ago

  • Category set to library
  • Status changed from Unreviewed to Accepted
  • Assignee set to Puppet Community
  • Target version set to 30
  • 3 changed from Unknown to Easy

#2 Updated by James Turnbull almost 7 years ago

  • Assignee deleted (Puppet Community)

#3 Updated by Paul Nasrat over 6 years ago

  • Target version changed from 30 to 14

#4 Updated by Anonymous about 6 years ago

We should add the new unitless versions as something like ‘memory_mb’ to avoid breaking backwards compatibility.

#5 Updated by Dominic Cleal over 5 years ago

I’ve posted a patch for this to puppet-dev, which adds mb and b versions of the memorysize, memoryfree, swapsize and swapfree facts. The units we choose to display can easily be changed in lib/facter/util/memory.rb, but I figure these two should allow people enough flexibility without creating excessive variations.

http://groups.google.com/group/puppet-dev/browse_thread/thread/d8bf869d97148590

https://github.com/domcleal/facter/tree/tickets/master/2066

Tested them from Puppet and it works well, making it much easier to calculate memory limits etc.

#6 Updated by Jacob Helwig about 5 years ago

From the discussion on the mailing list between Paul Nasrat and Dominic Cleal, it looks like the originally submitted patch is is going to wait until after some further refactoring in Facter.

#7 Updated by Theo Cabrerizo Diem over 4 years ago

Is there any update on this issue ? I’m running puppet 2.7.9 and facter 1.6.4 and such facts with units are quite useless as they are :(

#puppet apply -e 'notice($::memorysize)' -v
notice: Scope(Class[main]): 989.92 MB
# puppet apply -e 'notice($::memorysize / 2)' -v
left operand of / is not a number at line 1 on node blabla.mydomain

#8 Updated by Anonymous over 4 years ago

Theo Cabrerizo Diem wrote:

Is there any update on this issue ? I’m running puppet 2.7.9 and facter 1.6.4 and such facts with units are quite useless as they are :(

#puppet apply -e 'notice($::memorysize)' -v
notice: Scope(Class[main]): 989.92 MB
# puppet apply -e 'notice($::memorysize / 2)' -v
left operand of / is not a number at line 1 on node blabla.mydomain

Well, you can write Puppet code to reverse the calculation and get a useful number, but that really sucks.

If someone gets the proposed change into decent shape and sends a pull request we would probably merge it; adding more facts is safe inside a stable series, and I am absolutely inclined to accept this into core in the form that is proposed without waiting for any more central or standard way to have this happen.

Changing the central fact definition to have a fixed unit is useful, but not something we can do without a major release around it, to avoid breaking things for people who do depend on the current version. Like my code that did the reversing and all. :)

#9 Updated by eric sorenson over 4 years ago

I have a really dead-simple fact that has no units whatsoever, making it very easy to do inline arithmetic on the memory size. This lets us, for example, size memcache as a percentage of the fact value directly.

https://gist.github.com/1202271

#10 Updated by Ken Barber about 4 years ago

  • Target version changed from 14 to 186

#11 Updated by Anonymous about 4 years ago

  • Target version deleted (186)

#12 Updated by Jeff Weiss almost 4 years ago

  • Keywords set to intern

#13 Updated by Jeff Weiss almost 4 years ago

  • Assignee set to Anonymous
  • Target version set to 2.1.0

#14 Updated by Jeff Weiss almost 4 years ago

  • Tracker changed from Bug to Feature

#15 Updated by Anonymous almost 4 years ago

  • Assignee changed from Anonymous to Ruth Linehan

A month here and I’m already delegating.

#16 Updated by Ruth Linehan almost 4 years ago

Made the decision to make units MB, since this is the smallest reasonable unit to be useful to work from.

#17 Updated by Anonymous almost 4 years ago

  • Branch set to https://github.com/puppetlabs/facter/pull/237

#18 Updated by Anonymous almost 4 years ago

  • Status changed from Accepted to In Topic Branch Pending Review

#19 Updated by Anonymous almost 4 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release

#20 Updated by Anonymous almost 4 years ago

  • Target version changed from 2.1.0 to 2.0.0

#21 Updated by Chris Couples over 3 years ago

Ruth Linehan wrote:

Made the decision to make units MB, since this is the smallest reasonable unit to be useful to work from.

Given that many system configuration files specify values in KB, rather than MB (I’m thinking of sysctls and /etc/security/limits.conf, off the top of my head), maybe that’s a better default than MB(?)

#22 Updated by Anonymous almost 3 years ago

  • Target version changed from 2.0.0 to 1.7.0

This was actually released in 1.7.0

Also available in: Atom PDF