Code Monkey home page Code Monkey logo

puppet-smartd's Introduction

Puppet smartd Module

Build Status

Table of Contents

  1. Overview
  2. Description
  3. Usage
  4. Limitations
  5. Versioning
  6. Support
  7. See Also

Overview

Manages the smartmontools package including the smartd daemon

Description

Installs the smartmontools package and enables the smartd service.

If your hardware supports it, smartd can automatically probe for the drives, but if they are hidden behind a RAID controller, it will need additional help. The module includes a facter plugin to identify drives hiding behind an LSI MegaRAID/Dell PERC/Supermicro controller on Linux systems if you have the LSI proprietary MegaCli tool installed; we don't have any FreeBSD machines with this controller so haven't written the necessary code to use FreeBSD's standard mfiutil(8) utility instead.

Currently, drives behind an LSI MegaRAID controller will be automatically probed and added to the smartd configuration file, if the MegaCli utility is installed. There is no way to turn this behavior off. This is arguably a bug.

It is planned that in a future release the megaraid specific facts will be migrated into the puppet-megaraid module.

Forked

This is a fork of csail/smartd that was initially made primarily to fix support of probing SATA drives behind a LSI Megaraid controllers. The author has been aware of the fork and it's hoped that the two modules can be merged. Since the initial fork, a number of small API changes have been made to improve usage.

Usage

Version 2.x.x incompatible API change

The v2 API merges the v1 API's devices and device_options parameters into a single parameter named devices, but with incompatible semantics to the v1 API.

devices now accepts an Array of Hash. This is to allow multiple smartd.conf entries for the same blockdev as is typically required for probing through to individual disks behind a block device presented by a RAID controller.

Old v1 API

Note that devices used to accept a flat Array.

    class{ 'smartd':
      devices        => [ '/dev/sg1', '/dev/sg2' ],
      device_options => { '/dev/sg1' => '-o on -S on -a', '/dev/sg2' => '-o on -S on -a' },
    }

New v2 API

devices now accepts an Array of Hash.

    class{ 'smartd':
      devices => [
        { device => '/dev/sg1', options => '-o on -S on -a' },
        { device => '/dev/sg2', options => '-o on -S on -a' },
      ],
    }

Simple Usage

    include smartd
    class{ 'smartd': }

Parameters

All parameters are optional.

ensure

String defaults to: present

Standard Puppet ensure semantics (and supports purged state if your package provider does). Valid values are: present,latest,absent,purged

package_name

String defaults to: smartmontools

Name of the smartmontools package.

service_name

String defaults to: smartd

Name of the smartmontools monitoring daemon.

service_ensure

String defaults to: running

State of the smartmontools monitoring daemon. Valid values are: running,stopped

config_file

String defaults to: (OS-specific)

Path to the configuration file for the monitoring daemon.

devicescan

Bool defaults to: true

Sets the DEVICESCAN directive in the smart daemon config file. Tells the smart daemon to automatically detect all of the SMART-capable drives in the system.

devicescan_options

String defaults to: undef

Passes options to the DEVICESCAN directive. devicescan must equal true for this to have any effect.

devices

Array of Hash defaults to: []

Explicit list of raw block devices to check. Eg.

    [{ device => '/dev/sda', options => '-I 194' }]

mail_to

String defaults to: root

Smart daemon notification email address.

warning_schedule

String defaults to: daily

Smart daemon problem mail notification frequency. Valid values are: daily,once,diminishing, exec

If exec is selected, a value must be provided to exec_script.

exec_script

String defaults to: false

Path to the script that should be executed when problem mail notification should be sent. This parameter should only be set if warning_schedule is set to exec.

enable_default

Bool defaults to: true if $::smartmontools_version >= 5.43, otherwise false

Enables/disables the DEFAULT directive in the smartd.conf file. This directive was added in the 5.43 release of smartmontools and is unsupported in previous versions.

If enable_default is set to false the the values from the mail_to and warning_schedule parameters are set on the DEVICESCAN directive (if enabled) instead of the [absent] DEFAULT directive.

Example smartd.conf content based on this setting:

enable_default => true

# Managed by Puppet -- do not edit!
DEFAULT -m root -M daily
DEVICESCAN

enable_default => false

# Managed by Puppet -- do not edit!
DEVICESCAN -m root -M daily

Here is an example of the error message generated by the DEFFAULT directive appearing in the configuration file of 5.42.

smartd 5.42 2011-10-20 r3458 [i686-linux-2.6.18-371.6.1.el5PAE] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
Opened configuration file /etc/smartd.conf
Drive: DEFAULT, implied '-a' Directive on line 2 of file /etc/smartd.conf
Drive: DEVICESCAN, implied '-a' Directive on line 3 of file /etc/smartd.conf
Configuration file /etc/smartd.conf was parsed, found DEVICESCAN, scanning devices
Device: DEFAULT, unable to autodetect device type

This option could not be named default to be consistent with the naming convention of the other parameters in this module due to this bug PUP-2244 that affects puppet 2.7.x.

Note that RHEL5 ships with 5.42 while RHEL6 ships with 5.43.

default_options

String defaults to: undef

Additional arguments to be set on the DEFAULT directive.

If default is set to false, this parameter's value will be set on the DEVICESCAN directive (if enabled) instead of the [absent] DEFAULT directive.

Pedantic Example

    class{ 'smartd':
      ensure             => 'present',
      package_name       => 'smartmontools',
      service_name       => 'smartd',
      service_ensure     => 'running',
      config_file        => '/etc/smartd.conf',
      devicescan         => true,
      devicescan_options => '-H -m [email protected]',
      devices            => [
        { device => '/dev/sg1', options => '-o on -S on -a' },
        { device => '/dev/sg2', options => '-o on -S on -a' },
      ],
      mail_to            => 'root',
      warning_schedule   => 'diminishing',
      default            => 'false',
      default_options    => '-H',
    }

Hiera Data Bindings

---
smartd::mail_to: "root@%{::domain}"
smartd::devicescan: false
smartd::devices:
  -
    device: '/dev/cciss/c0d0'
    options: '-d cciss,0 -a -o on -S on -s (S/../.././19|L/../../3/21)'
  -
    device: '/dev/cciss/c0d0'
    options: '-d cciss,1 -a -o on -S on -s (S/../.././18|L/../../3/20)'
  -
    device: '/dev/sda'
    options: '-a -o on -S on -s (S/../.././18|L/../../3/20|C/../.././19)'

Facts

megacli

Path to the MegaCli executable. Example:

megacli => /usr/bin/MegaCli

megacli_version

Version string of the MegaCli executable. Example:

megacli_version => 8.07.07

megaraid_adapters

The count of LSI MegaRAID adapters detected in the system. Note that this module presently only supports a single adapter per system. Example:

megaraid_adapters => 1

megaraid_fw_package_build

The LSI MegaRAID adapter firmware package string. Example:

megaraid_fw_package_build => 23.22.0-0012

megaraid_fw_version

The LSI MegaRAID adapter firmware version string. Example:

megaraid_fw_version => 3.340.05-2939

megaraid_physical_drives

The LSI MegaRAID unique device ID(s) for all attached disks. Example:

megaraid_physical_drives => 116,117,120,121,122,123,124,125,126,127,128,129,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,200,201,202,203,204,205,206,207

megaraid_physical_drives_sas

The LSI MegaRAID unique device ID(s) for only attached SAS disks. Example:

megaraid_physical_drives_sas => 116,117,120,121,122,123,124,125,126,127,128,129,131,132,133,134,135,136,137,138,139,140,187,188,189,190,191,192,193,194,195,196,197,198,200,201,202,203,204,205,206,207

megaraid_physical_drives_sata

The LSI MegaRAID unique device ID(s) for only attached SATA disks. Example:

megaraid_physical_drives_sata => 141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186

megaraid_product_name

The LSI MegaRAID product name string. Example:

megaraid_product_name => LSI MegaRAID SAS 9286CV-8e

megaraid_serial

The LSI MegaRAID serial number string. Example:

megaraid_serial => SV22925366

megaraid_virtual_drives

A listing of /dev/<foo> devices exported by a LSI MegaRAID controller. Example:

megaraid_virtual_drives => sda,sdb,sdc,sdd,sde,sdf,sdg,sdh,sdk,sdl

smartd

Path to the smartd executable. Example:

smartd => /usr/sbin/smartd

smartmontools_version

Version of the install smartmontools package. Example:

smartmontools_version => 5.43

Limitations

Tested Platforms

These are the platforms that have had integration testing since the fork.

  • el6.x
  • el5.x

Versioning

This module is versioned according to the Semantic Versioning 2.0.0 specification.

Support

Please log tickets and issues at github

See Also

puppet-smartd's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

puppet-smartd's Issues

HP SmartArray adapters should be treated similar to MegaRaid

This is the desired config in /etc/smartd.conf:

/dev/cciss/c0d0 -d cciss,0 -a -o on -S on
/dev/cciss/c0d0 -d cciss,1 -a -o on -S on
/dev/cciss/c0d0 -d cciss,2 -a -o on -S on
/dev/cciss/c0d0 -d cciss,3 -a -o on -S on
/dev/cciss/c0d0 -d cciss,4 -a -o on -S on
/dev/cciss/c0d0 -d cciss,5 -a -o on -S on

This does not appear to work.

class { 'smartd':
  devices        => [
    '/dev/cciss/c0d0',
    '/dev/cciss/c0d0',
    '/dev/cciss/c0d0',
    '/dev/cciss/c0d0',
    '/dev/cciss/c0d0',
    '/dev/cciss/c0d0',
  ],
  device_options => {
    '/dev/cciss/c0d0' => '-d cciss,0 -a -o on -S on',
    '/dev/cciss/c0d0' => '-d cciss,1 -a -o on -S on',
    '/dev/cciss/c0d0' => '-d cciss,2 -a -o on -S on',
    '/dev/cciss/c0d0' => '-d cciss,3 -a -o on -S on',
    '/dev/cciss/c0d0' => '-d cciss,4 -a -o on -S on',
    '/dev/cciss/c0d0' => '-d cciss,5 -a -o on -S on',
  },
}

The result is this in /etc/smartd.conf:

/dev/cciss/c0d0 -d cciss,5 -a -o on -S on

-n option is not set by default

smartd.conf option "-n" makes smartd avoid spinning up disks in some inactive states. if unused, smartd might cause disk spin-ups when polling them.

it's possible to activate this option with default_options, but it would be a better default if the module would activate "-n standby" by default.

Auto-generating the devices array programmatically

What do you think of this?

https://gist.github.com/solarkennedy/7606943

I think the template approach is pretty good, but I find it difficult to read, and as you said, it is arguably a bug that it is not disable-able. But could be?

With this function:

class { 'smartd':
  devices     => hiera('smartd::devices', smartd_guess() ),
  devicescan  => hiera('smartd::devicescan', false),
}

Obviously this doesn't account for raid controllers yet, but it does skip the right things and disables devicescan so that smartd can actually run on mixed environments. (wouldn't it be nice if DEVICESCAN would gracefully skip things it didn't understand?)

I also like how this function can increment smart scan hours, this is probably also possible with the erb.

I don't know how to best reconcile different other behaviors, like I suppose there could be arguments to this function that alter the scan pattern and behavior, but then it gets all pretty confusing....

In the end, I don't want to have to hand-configure anything. I want puppet to do its best to do this for me.

Either way, more facts are needed to do raid controllers. I can volunteer to write them for others (I feel like I have every kind over here), do you want me to follow the megaraid fact patterns that you have laid out?

And, do you think this function based approach has merit? Should I focus my effort into the template method instead?

megacli_legacy.rb: cannot load such file -- semver

I get the following error every run:

Error: Facter: error while resolving custom facts in /opt/puppetlabs/puppet/cache/lib/facter/megacli_legacy.rb: cannot load such file -- semver
# cat /opt/puppetlabs/puppet/cache/lib/facter/megacli_legacy.rb
require 'semver'

# Legacy versions of MegaCLI require different arguments to determine certain
# software and firmware versions.
Facter.add(:megacli_legacy) do
  megacli = Facter.value(:megacli)
  megacli_version = Facter.value(:megacli_version)

  setcode do
    next if megacli.nil?
    next if megacli_version.nil?

    # Modern version assumed from changelog at
    # http://www.lsi.com/downloads/Public/RAID%20Controllers/RAID%20Controllers%20Common%20Files/Linux%20MegaCLI%208.07.10.txt
    actual_version = SemVer.new(megacli_version)
    modern_version = SemVer.new('8.02.16')

    actual_version < modern_version
  end
end

We don't use megaraid / megacli anywhere so I'm a little surprised it even tries to load this custom fact actually?

megaraid_virtual_drives: undefined method `map'

I am seeing this output when running puppet agent --test and do not have the megaraid_virtual_drives fact .

Could not retrieve megaraid_virtual_drives: undefined method `map' for "/dev/sda\n/dev/sdb":String

This is on PE 3.0.1 with (I think) ruby 1.9.3.

Invalid relationship: File[/etc/smartd.conf] when ensure is changed from present to (absent|purged)

Hello,
I am getting following error :
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid relationship: File[/etc/smartd.conf] { notify => Service[smartd] }, because Service[smartd] doesn't seem to be in the catalog
Warning: Not using cache on failed catalog

When
class{'smartd': ensure => 'present'; }
is changed to ensure absent or purged.
Module version is 2.5.1
puppet is 3.8.4

Use -NoLog for all megacli commands

Additions in #23 run megacli without the '-NoLog' arguement. This leads to MegaSAS.log files being generated on the system.

The following is output from my systems, in case you need more samples to test against.

# megacli -Version -Ctrl -aALL -NoLog

        CTRL VERSION:
        ================

Product Name : Supermicro SMC2208
Serial No : 
Fw Package Build : 23.9.0-0015
FW Version : 3.220.05-1881

Exit Code: 0x00

facts are undocumented

Several facts have recently been added to this module and they should be documented in the README.md.

New release?

Hey!

The last release has been out for quite some time. Could you release a 2.6.1 with the latest commit? Thanks!

-M exec not supported

smartd.conf man page details a "-M exec" mode that can be used to run a shell script when an email should be sent. This is used by default in debian with "/usr/share/smartmontools/smartd-runner" to run all scripts dropped in a .d directory.

It would be nice to be able to set value of -M to exec with a script path in order to recreate debian's default behaviour, or implement something else with own script.

Error in megaraid_serial

It looks like my RAID controllers do not have serial numbers. This results in several errors output by facter during a Puppet run.

Could not retrieve megaraid_serial: undefined method `size' for nil:NilClass
Could not retrieve megaraid_serial: undefined method `size' for nil:NilClass
Could not retrieve megaraid_serial: undefined method `size' for nil:NilClass
# facter -dp megaraid_serial
Could not retrieve megaraid_serial: undefined method `size' for nil:NilClass
value for megaraid_serial is still nil
# MegaCli -Version -Ctrl -aALL -NoLog

        CTRL VERSION:
        ================

Product Name : Supermicro SMC2208
Serial No : 
Fw Package Build : 23.9.0-0015
FW Version : 3.220.05-1881

Exit Code: 0x00

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.