Changes between Version 1 and Version 2 of CheckFile2


Ignore:
Timestamp:
09/10/09 23:16:45 (4 years ago)
Author:
mickem
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CheckFile2

    v1 v2  
    1 [NSClientSample test=foo,test,bar] 
     1[[TracNav(TracNav/CC)]] 
     2= CheckFile2 =  
     3A command to check aspects on several files it can be used to check one file but that is not the goal. 
     4The core scenario is: "do I have more then x files matching this criteria?" but it is flexible enough to be applicable in many other scenarios as well. 
     5 
     6The main concept is much like the eventlog checks where you have a data-set which you want to "filter" and then check the resulting number of lines against a criteria. 
     7 
     8The CheckFile2 command Uses [wiki:filters] to define the "interesting" files. 
     9 
     10== Syntax == 
     11A filter is made up of three things: 
     12 * Filter mode 
     13   Determines what happens when the filter is matched. 
     14 * Filter type 
     15   What the filter will match (ie. which field). 
     16 * An Expression 
     17   What to check for. 
     18 
     19The syntax of a filter is: ''filter'''<mode><type>'''='''<expression>'''''  
     20 
     21== Order == 
     22Order is important, as soon as a positive (+) or negative (-) rule is matched it is either discarded or included and the entry is "finished" and it will continue with the next entry. The best way here is to have an "idea" either remove all entries first or include all required ones first (depending on what you want to do). You can mix and such but this will probably complicate things for you unless you actually need to. 
     23 
     24== Filter modes == 
     25Capturing files (or discarding them) are done with filters. There are three kinds of filters. 
     26 
     27||'''<filter mode>'''||'''title'''||'''description''' 
     28||+||positive requirements||All these filters must match or the row is discarded. 
     29||.||potential matches||If this matches the line is included (unless another lines overrides). 
     30||-||negative requirements||None of these filters can match (if any do the row is discarded). 
     31 
     32Thus if you want to have: all files from the last month but not the ones smaller then 5kbI would break this down as such: (notice there are other options). 
     33- date=older than 2 months 
     34+ size=larget then 5k 
     35This would discard all files older then 2 month and then include all files larger then 5kb. 
     36 
     37== Filter Types == 
     38||'''<filter type>'''||'''Values'''||'''Description''' 
     39 
     40=== time expression === 
     41A '''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). A few examples of time expression are: filter+generated=>2d means filter will match any records older than 2 days, filter+generated=<2h means match any records newer then 2 hours. Warning, the bash interprets the "<,>,!". Use the "\" to avoid this. e.g. filter+generated=\>2d . On the Client activate the "Nasty Metachars" Option, to allow the \. 
     42 
     43=== string expression === 
     44A '''string expression''' is a key followed by a string that specifies a string expression. Currently substr and regexp are supported. Thus you enter filter.message=regexp:(foo|bar) to enter a regular expression and filter-message=substr:foo to enter a substring patter match. 
     45 
     46== Filter in/out == 
     47There are two basic ways to filter: 
     48 * in 
     49   When you filter in it means all records matching your filter will be returned (the "simplest way") 
     50 * out 
     51   When you filter out it means all records matching your filter will be discarded. 
     52 
     53So: 
     54{{{ 
     55filter=in filter+size==5k 
     56... 
     57filter=out filter-size=ne:5k 
     58}}} 
     59Will both have the same effect as the first one filters "in" and matches all siles with 5kb and the second one filters out and discards all files not 5kb. 
     60 
     61[[NSClientCommand(CheckFile2,path=c:\test pattern=*.txt MaxCrit=1 filter+written=gt:2h)]] 
     62[[NSClientResult(ok,CheckFile ok,'no files found'=0;0;1;)]] 
     63