Hello,
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.
https://labs.consol.de/nagios/check_mssql_health/
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
metadata:
created_by: sensu-admin
name: mssql-backup-health-check
namespace: gpcms-managed
spec:
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: ""
proxy_requests:
entity_attributes:
- entity.entity_class == 'proxy'
- entity.labels.proxy_type == 'mssql'
splay: false
splay_coverage: 0
publish: true
round_robin: true
runtime_assets: null
secrets:
- name: MSSQL_PWD
secret: mssql_pwd_sensu_monitoring
stdin: false
subdue: null
subscriptions:
- mssql
timeout: 0
ttl: 0
2 Likes
Hey!
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.