creating sensu checks using sensu-puppet

I’m trying out sensu and i ran into an issue using the puppet module. I would like to monitor 20 printers using sensu, and i tried creating the following check:

#collect printer metrics and send to graphite
class monitoring::sensu::checks::metrics_printers {
  $printer = hiera('printer')
  $printer_snmp_community = hiera('printer_snmp_community')
  $pagecount_OID = '1.3.6.1.2.1.43.10.2.1.4.1.1 '
  sensu::check {$printer:
    command => "snmp-metrics.rb -h ${printer} -C ${printer_snmp_community} \
                    -O ${pagecount_OID} -s pages -p printer",
    type => 'metric',
    handlers => 'graphite',
    subscribers => 'snmp-metrics',
  }
}


It didn't work, because the array of $printers was all merged into a string...

the alternative is to create a unique check for each printer, but i don't think that's a good solution. Any suggestions?

I think having individual checks for printers makes sense. Here is how
I would do it in puppet:

  # Custom define so we define multiple instances
  define sensu_printer_check ( $community, $page_count ) {
    sensu::check {name:     command => "snmp\-metrics\.rb \-h {name} -C \{community\} \\                     \-O {pagecount} -s pages -p printer",
    type => 'metric',
    handlers => 'graphite',
    subscribers => 'snmp-metrics',
  }

  # Now make lots of them from the array
$printer_array = hiera('printer')
sensu_printer_check { $printer_array:
    community => hiera('printer_snmp_community')
    page_count => '1.3.6.1.2.1.43.10.2.1.4.1.1 '
  }

It allows you to easily add more with the array, and handle each
printer individually in sensu (pages, resolving, silencing.)

After all, if you silenced one printer, you would still probably want
to get alerted if a different printer started failing? Having
individual checks enables this.
And of course with the custom define you could go crazy with hiera if
different printers have different thresholds, handlers, etc.

···

On Sat, Dec 14, 2013 at 7:06 PM, Victor Vrancean <vrancean@gmail.com> wrote:

I'm trying out sensu and i ran into an issue using the puppet module. I
would like to monitor 20 printers using sensu, and i tried creating the
following check:

#collect printer metrics and send to graphite
class monitoring::sensu::checks::metrics_printers {
  $printer = hiera('printer')
  $printer_snmp_community = hiera('printer_snmp_community')
  $pagecount_OID = '1.3.6.1.2.1.43.10.2.1.4.1.1 '
  sensu::check {printer: &nbsp;&nbsp;&nbsp;&nbsp;command =&gt; &quot;snmp\-metrics\.rb \-h {printer} -C
\{printer\_snmp\_community\} \\ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\-O {pagecount_OID} -s pages -p printer",
    type => 'metric',
    handlers => 'graphite',
    subscribers => 'snmp-metrics',
  }
}

It didn't work, because the array of $printers was all merged into a
string...

the alternative is to create a unique check for each printer, but i don't
think that's a good solution. Any suggestions?