I'm trying to extract specific values from a website using web.page.regexp but have issues matching newline
Using web.page.get here is the complete output
Normally I would easily match this using
Since all the Id's are static and known beforehand I can also write a more specific match for each for those if zabbix doesn't support not stopping after first match.
The issue however is that it doesn't seem to support matching \n as newline.
As you can see the regular expression gives no matches
While if I split it up I get matches for each line
I've tried replacing \n with .*, \s+, \r\n, [\r\n], [\r\n]+, \n+, [[:space:]], [[:cntrl:]], [[:space:]]+ and [[:cntrl:]]+ with no success.
Any idea on how to resolve this?
Rewriting the web response to not have newlines is not an option.
Using web.page.get here is the complete output
Code:
[user@zproxy1]# zabbix_agentd -t 'web.page.get[server,/path/full]'
web.page.get[server,/path/full] [t|HTTP/1.1 200 OK
Content-Type: application/json
Server: Microsoft-IIS/10.0
Referrer-Policy: strict-origin-when-cross-origin
Strict-Transport-Security: max-age=63072000; includeSubDomains
X-Content-Type-Options: nosniff
X-UA-Compatible: IE=edge
X-XSS-Protection: 1; report=https://login.site.domain//restapi/csp/violation/v1;
Date: Thu, 22 Aug 2019 13:17:07 GMT
Connection: close
Content-Length: 878
{
"ApplicationName": "My Application",
"Version": "1.2.3.0.4",
"HealthCheckResults": [
{
"Id": "TypeOfCheck.Target",
"IsHealthy": true
},
{
"Id": "OtherTypeOfCheck.OtherTarget",
"IsHealthy": true
}
]
}]
Code:
\"Id\"\:\s\"(\w+)\.(\w+)\"\,\n\s+"Ishealthy"\:\s(\w+)
The issue however is that it doesn't seem to support matching \n as newline.
As you can see the regular expression gives no matches
Code:
[user@zproxy1]# zabbix_agentd -t 'web.page.regexp[server,/path/full,80,"\"Id\"\:\s\"(\w+)\.(\w+)\"\,\n\s+\"Ishealthy\"\:\s(\w+)",,\1 \2 \3]' web.page.regexp[server,/path/full,80,"\"Id\"\:\s\"(\w+)\.(\w+)\"\,\n\s+\"Ishealthy\"\:\s(\w+)",,\1 \2 \3] [s|]
Code:
[user@zproxy1]# zabbix_agentd -t 'web.page.regexp[server,/path/full,80,"\"Id\"\:\s\"(\w+)\.(\w+)\"\,",,\1 \2]' web.page.regexp[server,/path/full,80,"\"Id\"\:\s\"(\w+)\.(\w+)\"\,",,\1 \2] [s|TypeOfCheck Target] [user@zproxy1]# zabbix_agentd -t 'web.page.regexp[server,/path/full,80,"\"IsHealthy\"\:\s(\w+)",,\1]' web.page.regexp[server,/path/full,80,"\"IsHealthy\"\:\s(\w+)",,\1] [s|true]
Any idea on how to resolve this?
Rewriting the web response to not have newlines is not an option.