Ticket #269 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

Update time-expression to not require allow_nasty_meta_chars=1

Reported by: sttanner Owned by: mickem
Priority: 5 Milestone: 0.3.6
Component: Core Version: 0.3.5
Severity: Feature Requests Keywords: time expression nasty metachars
Cc:

Description (last modified by mickem) (diff)

Update time-expression to not require allow_nasty_meta_chars=1

According to

 http://nsclient.org/nscp/wiki/time-expression

A time expression is a date/time interval as a number prefixed by a filter prefix (<, >, =, !=) and followed by a unit postfix (m, s, h, d, w).

...

<keyword>=<operator><value><unit-postfix>

If the time expression definition was updated to allow the additional operators

'lt:' to be equivalent to '<'

'gt:' to be equivalent to '>'

'eq:' to be equivalent to '='

'ne:' to be equivalent to '<>', '!=', and '!'

allow_nasty_meta_chars=1 would not be required to define a time expression.

 http://nsclient.org/nscp/wiki/doc/Configuration

Examples:

foo=lt:1d would be equivalent to foo=<1d

bar=gt:4h would be equivalent to bar=>4h

foo=eq:5m would be equivalent to foo==5m

bar=ne:3s would be equivalent to bar=<>3s (or bar=!=3s, or bar=!3s)

I believe that adding support for these additional operators could be done by changing the following lines in filter_framework.hpp from

322                     const filter_all_numeric& operator=(std::wstring value) {
323                             value_ = value;
324                             if (value.substr(0,1) == _T(">")) {
325                                     max = value.substr(1);
326                             } else if (value.substr(0,2) == _T("<>")) {
327                                     neq = value.substr(2);
328                             } else if (value.substr(0,1) == _T("<")) {
329                                     min = value.substr(1);
330                             } else if (value.substr(0,1) == _T("=")) {
331                                     eq = value.substr(1);
332                             } else if (value.substr(0,2) == _T("!=")) {
333                                     neq = value.substr(2);
334                             } else if (value.substr(0,1) == _T("!")) {
335                                     neq = value.substr(1);
336                             } else if (value.substr(0,3) == _T("in:")) {
337                                     inList = value.substr(3);
338                             } else {
339                                     throw parse_exception(_T("Unknown filter key: ") + value + _T(" (numeric filters have to have an operator as well ie. foo=>5 or bar==5)"));
340                             }

to

322                     const filter_all_numeric& operator=(std::wstring value) {
323                             value_ = value;
324                             if (value.substr(0,1) == _T(">")) {
325                                     max = value.substr(1);
326                             } else if (value.substr(0,2) == _T("<>")) {
327                                     neq = value.substr(2);
328                             } else if (value.substr(0,1) == _T("<")) {
329                                     min = value.substr(1);
330                             } else if (value.substr(0,1) == _T("=")) {
331                                     eq = value.substr(1);
332                             } else if (value.substr(0,2) == _T("!=")) {
333                                     neq = value.substr(2);
334                             } else if (value.substr(0,1) == _T("!")) {
335                                     neq = value.substr(1);
336                             } else if (value.substr(0,3) == _T("in:")) {
337                                     inList = value.substr(3);
338                             } else if (value.substr(0,3) == _T("gt:")) {
339                                     max = value.substr(3);
340                             } else if (value.substr(0,3) == _T("ne:")) {
341                                     neq = value.substr(3);
342                             } else if (value.substr(0,3) == _T("lt:")) {
343                                     min = value.substr(3);
344                             } else if (value.substr(0,3) == _T("eq:")) {
345                                     eq = value.substr(3);
346                             } else {




347                                     throw parse_exception(_T("Unknown filter key: ") + value + _T(" (numeric filters have to have an operator as well ie. foo=>5 or bar==5)"));
348                             }

Change History

comment:1 Changed 3 years ago by mickem

  • Owner changed from MickeM to mickem
  • Status changed from new to assigned
  • Description modified (diff)

good idea!!! will add...

comment:2 Changed 3 years ago by mickem

  • Description modified (diff)
  • Milestone changed from 0.4.0 to 0.3.6

comment:3 Changed 3 years ago by mickem

  • Status changed from assigned to closed
  • Resolution set to fixed
  • Description modified (diff)

Fixed in the next build...

Note: See TracTickets for help on using tickets.