File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
This CHANGELOG follows the format listed [ here] ( https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md ) .
5
5
6
6
## [ Unreleased]
7
+ ### Added
8
+ - ` check-postgres-query.rb ` : Add ` -r ` , ` --regex-pattern ` to match query result against (@jindraj )
9
+
7
10
### Changes
8
11
- Updated development dependency to bundler ~ > 2.1
9
12
- Updated development dependency to rake ~ > 13.0
Original file line number Diff line number Diff line change @@ -75,6 +75,11 @@ class CheckPostgresQuery < Sensu::Plugin::Check::CLI
75
75
long : '--query QUERY' ,
76
76
required : true
77
77
78
+ option :regex_pattern ,
79
+ description : 'Regex pattern to match on query results and alert on if it does not match' ,
80
+ short : '-r REGEX' ,
81
+ long : '--regex-pattern REGEX'
82
+
78
83
option :check_tuples ,
79
84
description : 'Check against the number of tuples (rows) returned by the query' ,
80
85
short : '-t' ,
@@ -127,6 +132,8 @@ def run
127
132
critical "Results: #{ res . values } "
128
133
elsif config [ :warning ] && calc . evaluate ( config [ :warning ] , value : value )
129
134
warning "Results: #{ res . values } "
135
+ elsif config [ :regex_pattern ] && ( res . getvalue ( 0 , 0 ) !~ /#{ config [ :regex_pattern ] } / )
136
+ critical "Query result #{ res . getvalue ( 0 , 0 ) } doesn't match configured regex #{ config [ :regex_pattern ] } "
130
137
else
131
138
ok 'Query OK'
132
139
end
You can’t perform that action at this time.
0 commit comments