[collectd] supported regex patterns for extraction from curl response

Dave Cottlehuber dch at skunkwerks.at
Wed Jan 4 12:47:05 CET 2017


Ahoy,

I'm trying to slurp response from curl and capture the value of 2
specific keys in the response:

Here's what I'm interested in:

    db_total_count  19921

Here's a working regex:

          Regex "db_total_count.([0-9]+)"

Here's what I assumed would work, using perl5 regex escape sequences and
regex classes per
http://perldoc.perl.org/perlre.html#Regular-Expressions

    Regex "^db_total_count\s+(\d+)"

- What specific regex escapes are supported?
- Do I need a specific module or compile-time option? 

Here's my collectd.conf snippet:

LoadPlugin logfile
<Plugin logfile>
    LogLevel        info
    File            STDOUT
    Timestamp       true
    PrintSeverity   true
</Plugin>

LoadPlugin csv
<Plugin "csv">
  DataDir "STDOUT"
  StoreRates true
</Plugin>

LoadPlugin curl
<Plugin curl>
  <Page "kyoto-primary">
    URL "http://localhost:1978/rpc/report"
    Timeout 2000
    <Match>
      Regex "db_total_count.([0-9]+)"
      DSType "GaugeLast"
      Type "gauge"
      Instance "records"
    </Match>
  </Page>
</Plugin>

& the curl response - it's from KyotoTycoon via
http://fallabs.com/kyototycoon/ BTW running on FreeBSD 11.0p6 amd64.

$ curl -4vsk localhost:1978/rpc/report
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1978 (#0)
> GET /rpc/report HTTP/1.1
> Host: localhost:1978
> User-Agent: curl/7.50.3
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: KyotoTycoon/0.9.56
< Date: Wed, 04 Jan 2017 10:22:37 GMT
< Content-Length: 590
< Content-Type: text/tab-separated-values
<
cnt_get 0
cnt_get_misses  0
cnt_misc        0
cnt_remove      0
cnt_remove_misses       0
cnt_script      0
cnt_set 0
cnt_set_misses  0
conf_kc_features        (zlib)
conf_kc_version 1.2.76 (16.13)
conf_kt_features        (kqueue)
conf_kt_version 0.9.56 (2.19)
conf_os_name    FreeBSD
db_0    count=0 size=1328904
db_total_count  19921
db_total_size   1328904
serv_conn_count 2
serv_current_time       1483525357.100392
serv_proc_id    52535
serv_running_term       1086.452950
serv_task_count 0
serv_thread_count       16
sys_mem_peak    9977856
sys_mem_rss     9977856
sys_mem_size    9977856
sys_ru_stime    0.855391
sys_ru_utime    0.708283




More information about the collectd mailing list