Microsoft SQL Server tsql checks?


is there a way to do a simple tsql check against a Microsoft SQL Server using Sensu Go Agent ?
Did not find anything on bonsai or might have searched for the wrong thing … Goal would be to run a SQL Query against a Microsoft SQL Server from a local or remote Sensu Agent.

Thanks in advance !

Found a way to do this by using a nagios check plugin from ConsolLabs.

Plugin is based on perl therefore needs some config to successfully run before Sensu can use it.
Also using sensu env secret provider and labels to run this from a proxy entity.

type: CheckConfig
api_version: core/v2
  created_by: sensu-admin
  name: mssql-backup-health-check
  namespace: gpcms-managed
  check_hooks: null
  command: /opt/nagios/libexec/check_mssql_health --hostname {{ .labels.hostname }} --port {{ .labels.port }} --username "{{ .labels.sqluser }}" --password="$MSSQL_PWD" --mode=database-backup-age --name {{ .labels.database }} --multiline
  env_vars: null
  handlers: []
  high_flap_threshold: 0
  interval: 900
  low_flap_threshold: 0
  output_metric_format: nagios_perfdata
  output_metric_handlers: null
  proxy_entity_name: ""
    - entity.entity_class == 'proxy'
    - entity.labels.proxy_type == 'mssql'
    splay: false
    splay_coverage: 0
  publish: true
  round_robin: true
  runtime_assets: null
  - name: MSSQL_PWD
    secret: mssql_pwd_sensu_monitoring
  stdin: false
  subdue: null
  - mssql
  timeout: 0
  ttl: 0

You might find this post interesting if you find yourself using a lot of perl based checks.

Todd’s Odds & Ends: A pattern for Perl based plugin assets

Sensu agents will always be able to run Nagios check plugins as Sensu check commands, but turning those perl Nagios plugins into Sensu assets can be a little harder, due to the perl interpreter requirement. So if the self-executing perl pattern from that post works for you, great! If it doesn’t you can use configuration management to make sure that Nagios plugin is pre-installed for the Sensu agent to run, instead of using it as a Sensu asset.