[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: motd handling in jessie



Riley Baird <BM-2cVqnDuYbAU5do2DfJTrN7ZbAJ246S4Xix@bitmessage.ch> writes:

> Sort of off topic, but as far as I can tell, the historical purpose of
> MOTD was to send a message to all users of a system. Is it still used
> for this?

Yes.  Stanford used, and presumably still uses, this pretty regularly for
head nodes of compute environments to alert users about upcoming downtime
and similar issues.

> Are there other uses of it?

The most common use of MOTD in large data centers is to provide a succinct
snapshot of relevant information about a system when an administrator logs
in.  When you have access to 30,000 machines, it's nice to not have to
remember exactly what hardware class or kernel a particular server has and
instead be reminded when you log in.

For example, here's the ERB template we used to generate the MOTD at
Stanford (this is neither good Puppet ERB syntax nor good Ruby, but you'll
get the idea):

<%  os = lsbdistdescription.gsub(/Debian GNU\/Linux/, "Debian")
    os.gsub!(/Red Hat Enterprise Linux/i, 'RHEL')
    os.gsub!(/RHEL (\w+) release (\d+) \(.* (\d+)\)/i, 'RHEL \1 \2u\3')
    os.gsub!(/RHEL (\w+) release ([\d\.]+) \(.*\)/i, 'RHEL \1 \2')

    processor = processor0.strip.gsub(/\s+/, " ")
    processor = processor.strip.gsub(/\(R\)|\(TM\)/i, '')
    processor = processor.strip.gsub(/(\w+-Core|Processor|CPU) /i, '')
    processor = processor.strip.gsub(/(Intel|AMD) /i, '')

    host = fqdn.downcase

    product = productname rescue nil
    if product.nil?
      product = "unknown"
    else
      product.strip!
      product.gsub!(/VMware Virtual Platform/i, 'vmware')
      product.gsub!(/ Server/i, '')
      product.gsub!(/SUN BLADE /i, 'SB ')
      product.gsub!(/Precision WorkStation /i, '')
      product.gsub!(/ MODULE/i, '')
    end
    sn = serialnumber rescue nil
    if virtual == 'physical' and (! sn.nil?)
      product += ", " + serialnumber
    end

    memory = memorysize
    if memory.match(/\./)
      memory.sub!(/0+ /, ' ')
      memory.sub!(/\. /, ' ')
    end
    memory.gsub!(/\s+/, '')

    swap = swapsize
    if swap.match(/\./)
      swap.sub!(/0+ /, ' ')
      swap.sub!(/\. /, ' ')
    end
    swap.gsub!(/\s+/, '')
-%>
<%= host %> - <%= os %>, <%= architecture %>
<%= processorcount %>-core <%= processor %> (<%= product %>); <%= memory %> RAM, <%= swap %> swap
Puppet environment: <%= environment %>; kernel <%= kernelrelease %> (<%= hardwaremodel %>)
<%= text -%>

-- 
Russ Allbery (rra@debian.org)               <http://www.eyrie.org/~eagle/>


Reply to: