Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Sensu-Go ::: Set handler for keepalive check with puppet #1330

Open
icalvete opened this issue Jan 30, 2023 · 0 comments
Open

[question] Sensu-Go ::: Set handler for keepalive check with puppet #1330

icalvete opened this issue Jan 30, 2023 · 0 comments

Comments

@icalvete
Copy link

icalvete commented Jan 30, 2023

[QUESTION]

I want to be able to get notified when a server is down.

Puppet: sensu/sensu-puppet v5.9.0

Based on sensu/sensu-go#1960, I tried this code without success.

Since there is a special static handler called "keepalive", I create a set handler "keepalive" and include my telegram handler (telegram_ops) in it.

BACKEND Code

class { 'sensu':
  api_host                     => 'sensu3.mydomain.com',
  password                     => '****',
  agent_password               => '****',
  agent_entity_config_password => '****',
  ssl_ca_source => 'puppet:///modules/common/ssl/ca.crt',
}

include sensu::cli

class { 'sensu::backend':
  ssl_cert_source => 'puppet:///modules/common/ssl/my.crt',
  ssl_key_source  => 'puppet:///modules/common/ssl/my.key',
  config_hash     => {
    'deregistration-handler' => 'deregistration',
    'event-log-file'         => '/var/log/sensu/events.log'
  }
}

sensu_bonsai_asset { 'sensu/check-cpu-usage':
  ensure  => 'present',
  version => 'latest',
  }
sensu_check { 'check-cpu':
  ensure         => 'present',
  labels         => {'contacts' => 'ops'},
  handlers       => ['telegram_ops'],
  command        => 'check-cpu-usage -w 75 -c 85',
  interval       => 60, 
  subscriptions  => 'linux',
  publish        => true,
  runtime_assets => ['sensu/check-cpu-usage']
}

sensu_bonsai_asset { 'sensu/sensu-go-has-contact-filter':
  ensure  => 'present',
  version => '0.2.0',
}
sensu_filter { 'contact_ops':
  ensure         => 'present',
  action         => 'allow',
  runtime_assets => ['sensu/sensu-go-has-contact-filter'],
  expressions    => ['has_contact(event, "ops")'],
}

sensu_filter { 'first_occurrence':
  ensure         => 'present',
  action         => 'allow',
  expressions    => ['event.check.occurrences == 1'],
}

sensu_bonsai_asset { 'Thor77/sensu-telegram-handler':
  ensure  => 'present'
}
sensu_handler { 'telegram_ops':
  ensure          => 'present',
  type            => 'pipe',
  command         => 'sensu-telegram-handler --api-token **** --chatid -****',
  timeout         => 10, 
  runtime_assets  => ['Thor77/sensu-telegram-handler'],
  filters         => [
    'is_incident',
    'not_silenced',
    'contact_ops',
    'first_occurrence'
  ],
}
sensu_handler { 'keepalive':
  ensure    => 'present',
  type      => 'set',
  handlers  => ['telegram_ops'],
}

AGENT Code (Very simple code.)

class { 'sensu::agent':
  subscriptions => ['default', 'linux', $hostname, 'nuc']
}

It does not work. If I suddenly shutdown a server, nothing happeds.

What is the proper way to do this?

It is posible any other aproach?

Long time ago there was another solution, class sensu had the parameter client_keepalive but it is not available anymore.

Thanks.

@icalvete icalvete changed the title Sensu-Go ::: Set handler for keepalive check with puppet [question] Sensu-Go ::: Set handler for keepalive check with puppet Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant