Changeset 75d5e70 in nscp


Ignore:
Timestamp:
08/15/05 18:48:14 (8 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
89f1a84
Parents:
e26cfe0
Message:

Alot of fixes and some changes (se changelog for details)

Files:
25 edited

Legend:

Unmodified
Added
Removed
  • NSCPlugin.cpp

    re26cfe0 r75d5e70  
    121121  if (!fGetVersion) 
    122122    throw NSPluginException(file_, "Critical error (fGetVersion)"); 
    123   return fGetVersion(major, minor, revision); 
     123  return fGetVersion(major, minor, revision)?true:false; 
    124124} 
    125125/** 
  • NSClient++.cpp

    re26cfe0 r75d5e70  
    4444      try { 
    4545        serviceControll::Install(SZSERVICENAME, SZSERVICEDISPLAYNAME, SZDEPENDENCIES); 
     46        serviceControll::SetDescription(SZSERVICENAME, SZSERVICEDESCRIPTION); 
    4647      } catch (const serviceControll::SCException& e) { 
    4748        LOG_MESSAGE_STD("Service installation failed: " + e.error_); 
     
    8586 
    8687    } else if ( _stricmp( "listpdh", argv[1]+1 ) == 0 ) { 
    87       PDH::Enumerations::str_lst lst = PDH::Enumerations::EnumObjects(); 
    88       for (PDH::Enumerations::str_lst::iterator it = lst.begin();it!=lst.end();++it) { 
    89         PDH::Enumerations::str_lst lst = PDH::Enumerations::EnumObjectItems(*it); 
    90         for (PDH::Enumerations::str_lst::iterator it2 = lst.begin();it2!=lst.end();++it2) { 
    91           std::cout << "\\" << *it <<"\\" << *it2 << std::endl;; 
     88      PDH::Enumerations::Objects lst = PDH::Enumerations::EnumObjects(); 
     89      for (PDH::Enumerations::Objects::iterator it = lst.begin();it!=lst.end();++it) { 
     90        if ((*it).instances.size() > 0) { 
     91          for (PDH::Enumerations::Instances::const_iterator it2 = (*it).instances.begin();it2!=(*it).instances.end();++it2) { 
     92            for (PDH::Enumerations::Counters::const_iterator it3 = (*it).counters.begin();it3!=(*it).counters.end();++it3) { 
     93              std::cout << "\\" << (*it).name << "(" << (*it2).name << ")\\" << (*it3).name << std::endl;; 
     94            } 
     95          } 
     96        } else { 
     97          for (PDH::Enumerations::Counters::const_iterator it2 = (*it).counters.begin();it2!=(*it).counters.end();++it2) { 
     98            std::cout << "\\" << (*it).name << "\\" << (*it2).name << std::endl;; 
     99          } 
    92100        } 
    93101      } 
  • NSClient++.vcproj

    re26cfe0 r75d5e70  
    333333      </File> 
    334334      <File 
     335        RelativePath=".\include\PDHCounter.h"> 
     336      </File> 
     337      <File 
    335338        RelativePath=".\Settings.h"> 
    336339      </File> 
     
    439442      </File> 
    440443      <File 
     444        RelativePath=".\NSC.dist"> 
     445        <FileConfiguration 
     446          Name="Distribution|Win32"> 
     447          <Tool 
     448            Name="VCCustomBuildTool" 
     449            CommandLine="echo Copying $(InputFileName)... 
     450cmd /c &quot;copy $(InputDir)\$(InputFileName) $(InputDir)\Dist\$(InputName).ini&quot; 
     451" 
     452            Outputs="$(InputDir)\Dist\$(InputName).ini"/> 
     453        </FileConfiguration> 
     454      </File> 
     455      <File 
    441456        RelativePath=".\NSC.ini"> 
    442457        <FileConfiguration 
     
    460475        </FileConfiguration> 
    461476        <FileConfiguration 
    462           Name="Distribution|Win32"> 
     477          Name="Distribution|Win32" 
     478          ExcludedFromBuild="TRUE"> 
    463479          <Tool 
    464480            Name="VCCustomBuildTool" 
  • changelog

    re26cfe0 r75d5e70  
     12005-07-31 MickeM 
     2 + /install now sets the serive to autostart 
     3 * Did some cleanup of minor code sctions 
     4 * (done before but not repported i think) /listpdh option added to list all pdh counters (nsclient++ /listpdh) 
     5 + Added service description 
     6 * Eventlog reworked (again) this time I hope it is better (and even usefull, but syntax has changed) 
     7 
     82005-07-26 MickeM 
     9 + Added support for ShowAll=long (to show long and short info, only applies to some areas, but avalible everywhere) 
     10 + Extended Drive and memory check syntax to facilitate both Free and Used space checks: MaxWarnFree / MaxWarnUsed etc) 
     11 
     122005-07-19 MickeM 
     13 * Changed thread API to use _creatthreadex as opposed to _creatthread (works better now!) 
     14 * Fixed UNKNOWN return code (was 4 should have been 3) 
     15 
     162005-07-16 MickeM 
     17 * Fixed drivechecks from NSClient 
     18 
    1192005-07-11 MickeM 
    220 * *ALOT* of bugfixes and enhancements all checking code has been centralzed and rewritten also my nternal check scripts  
  • docs/CheckDisk/index.html

    r6654022 r75d5e70  
    156156      <th valign="top">Option </th> 
    157157      <th valign="top">Values </th> 
    158       <th valign="top">Description </td> 
     158      <th valign="top" width="690">Description </td> 
    159159      </th> 
    160160    </tr> 
    161161    <tr> 
    162       <td valign="top">MaxWarn&lt; </td> 
     162      <td valign="top">MaxWarnFree</td> 
    163163      <td valign="top">Size with optional postfix (g, m, k, b, %)</td> 
    164       <td valign="top">The maximum size the directory is allowed before a  
    165       warning state is returned.</td> 
    166     </tr> 
    167     <tr> 
    168       <td valign="top">MaxCrit </td> 
    169       <td valign="top">Size with optional postfix (g, m, k, b, %) </td> 
    170       <td valign="top">The maximum size the directory is allowed before a  
    171       critical state is returned. </td> 
    172     </tr> 
    173     <tr> 
    174       <td valign="top">MinWarn </td> 
    175       <td valign="top">Size with optional postfix (g, m, k, b, %) </td> 
    176       <td valign="top">The minimum size the directory is allowed before a  
    177       warning state is returned. </td> 
    178     </tr> 
    179     <tr> 
    180       <td valign="top">MinCrit </td> 
    181       <td valign="top">Size with optional postfix (g, m, k, b, %) </td> 
    182       <td valign="top">The minimum size the directory is allowed before a  
    183       critical state is returned. </td> 
     164      <td valign="top" width="690">The maximum allowed free space for the  
     165      drive(s).</td> 
     166    </tr> 
     167    <tr> 
     168      <td valign="top">MaxCritFree</td> 
     169      <td valign="top">Size with optional postfix (g, m, k, b, %) </td> 
     170      <td valign="top" width="690">The maximum allowed free space for the  
     171      drive(s).</td> 
     172    </tr> 
     173    <tr> 
     174      <td valign="top">MinWarnFree</td> 
     175      <td valign="top">Size with optional postfix (g, m, k, b, %) </td> 
     176      <td valign="top" width="690">The minimum allowed free space for the  
     177      drive(s).</td> 
     178    </tr> 
     179    <tr> 
     180      <td valign="top">MinCritFree</td> 
     181      <td valign="top">Size with optional postfix (g, m, k, b, %) </td> 
     182      <td valign="top" width="690">The minimum allowed free space for the  
     183      drive(s).</td> 
     184    </tr> 
     185    <tr> 
     186      <td valign="top">MaxWarnUsed</td> 
     187      <td valign="top">Size with optional postfix (g, m, k, b, %)</td> 
     188      <td valign="top" width="690">The maximum allowed used space for the  
     189      drive(s).</td> 
     190    </tr> 
     191    <tr> 
     192      <td valign="top">MaxCritUsed</td> 
     193      <td valign="top">Size with optional postfix (g, m, k, b, %) </td> 
     194      <td valign="top" width="690">The maximum allowed used space for the  
     195      drive(s).</td> 
     196    </tr> 
     197    <tr> 
     198      <td valign="top">MinWarnUsed</td> 
     199      <td valign="top">Size with optional postfix (g, m, k, b, %) </td> 
     200      <td valign="top" width="690">The minimum allowed used space for the  
     201      drive(s).</td> 
     202    </tr> 
     203    <tr> 
     204      <td valign="top">MinCritUsed</td> 
     205      <td valign="top">Size with optional postfix (g, m, k, b, %) </td> 
     206      <td valign="top" width="690">The minimum allowed used space for the  
     207      drive(s).</td> 
    184208    </tr> 
    185209    <tr> 
    186210      <td valign="top">ShowAll </td> 
    187       <td valign="top"><i>None</i> </td> 
    188       <td valign="top"> 
    189       <p>A Boolean flag to show size of directories that are not in an alarm  
    190       state. If this is not specified only drives with an alarm state will  
    191       be listed in the resulting string.</p> 
     211      <td valign="top">Emtpy, long</td> 
     212      <td valign="top" width="690"> 
     213      <p>If present will display information even if an item is not  
     214      reporting a state. If set to long will display more information.</p> 
    192215      </td> 
    193216    </tr> 
     
    195218      <td valign="top">Drive </td> 
    196219      <td valign="top">A Drive letter or the path of a mounted Volume </td> 
    197       <td valign="top">The letter of the drive to check. Notice that the drive  
    198       has to be a fixed drive. </td> 
     220      <td valign="top" width="690">The letter of the drive to check.</td> 
    199221    </tr> 
    200222    <tr> 
    201223      <td valign="top">FilterType</td> 
    202       <td valign="top">FIXED, CDROM, REMOVABLE</td> 
    203       <td valign="top">Filter for drive type to prevent checking drives of  
     224      <td valign="top">FIXED, CDROM, REMOVABLE, REMOTE</td> 
     225      <td valign="top" width="690">Filter for drive type to prevent checking drives of  
    204226      certain kinds (most useful when using CheckAll). The default is FIXED</td> 
    205227    </tr> 
     
    207229      <td valign="top">CheckAll</td> 
    208230      <td valign="top"><i>None</i></td> 
    209       <td valign="top">Check all available drives</td> 
     231      <td valign="top" width="690">Check all available drives</td> 
    210232    </tr> 
    211233  </table> 
     
    217239    <ul> 
    218240      <li> 
    219       <p><b>Check the size of C:\ and make sure it has 50% free space:</b></p> 
    220       <p><code>CheckDriveSize ShowAll MaxWarn=50% MaxCrit=75% Drive=c:\</code></p> 
    221       <p><code>OK: c:: 63G (68374007808B)|c:=85% 50;75;</code></p> 
     241      <p><b>Check the size of C:\ and make sure it has 10% free space:</b></p> 
     242      <p><code>CheckDriveSize ShowAll MinWarnFree=10% MinCritFree=5% Drive=c:\</code></p> 
     243      <p><code>CRITICAL: C:: Total: 74.5G - Used: 71.2G (95%) - Free: 3.28G (5%) < critical|C:;5%;10;5;</code></p> 
    222244      <div class="config"> 
    223245        <p>define command { </p> 
     
    241263      <li> 
    242264      <p><b>To check the size of all fixed and network drives and make sure they  
    243       are at least 50% full</b></p> 
     265      have atleast 1gig free space</b></p> 
    244266      <p><code>CheckDriveSize -a MinWarn=50% MinCrit=25% CheckAll FilterType=FIXED  
    245267      FilterType=REMOTE</code></p> 
    246       <p><code>WARNING: X:\: 28% &lt; warning|C:\=84% 50%;25%; X:\=28% 50%;25%;  
    247       Y:\=98% 50%;25%;</code></p> 
     268      <p><code>CRITICAL: D:\: Total: 186G - Used: 186G (99%) - Free: 709M (1%) < warning, Y:\: Total: 279G - Used: 279G (99%) - Free: 384M (1%) < critical|C:\;76514398208;1073741824;536870912; D:\;199303897088;1073741824;536870912; X:\;35467034624;1073741824;536870912; Y:\;299649466368;1073741824;536870912; 
     269</code></p> 
    248270      <div class="config"> 
    249271        <p>define command { </p> 
    250272        <p>&nbsp;&nbsp;&nbsp; command_name CheckAllDrives </p> 
    251273        <p>&nbsp;&nbsp;&nbsp; command_line check_nrpe -H $HOSTADDRESS$ -p  
    252         5666 -c CheckDriveSize -a Drive=$ARG1$ CheckAll FilterType=FIXED  
     274        5666 -c CheckDriveSize -a CheckAll FilterType=FIXED  
    253275      FilterType=REMOTE MinWarn=$ARG1$ MinCrit=$ARG2$ </p> 
    254276        <p>}</p> 
  • docs/CheckEventLog/index.html

    re26cfe0 r75d5e70  
    4141    <tr> 
    4242      <td valign="top">filter</td> 
    43       <td valign="top">in, out</td> 
    44       <td valign="top">Specify if you want to filter out or in records.</td> 
     43      <td valign="top">in, out, any, all</td> 
     44      <td valign="top">Specify the way you want to filter things.<p><b>in</b>  
     45      means any thing matching this filter will be included in the result.</p> 
     46      <p><b>out</b> means any thing matching this filter will be excluded  
     47      from the result.</p> 
     48      <p><b>any</b> means any of the filter rules has to match.</p> 
     49      <p><b>all</b> means all of the filter rules have to match.</p> 
     50      <p>Thus filter=all filter=in and filter=any filter=out is the  
     51      combinations that makes the most sence depending on your filter  
     52      concept.</td> 
    4553    </tr> 
    4654    <tr> 
     
    4856      <td valign="top"><i>None</i></td> 
    4957      <td valign="top">Flag to specify if you want to include string  
    50       representationof the error messages.</td> 
     58      representation of the error messages.</td> 
    5159    </tr> 
    5260    <tr> 
    5361      <td valign="top">truncate</td> 
    5462      <td valign="top">length of the returned set</td> 
    55       <td valign="top">This wil ltruncate the output after the specified  
     63      <td valign="top">This will truncate the output after the specified  
    5664      length. As NRPE can only handle 1024 chars you need to truncate the  
    5765      output.</td> 
    5866    </tr> 
    5967    <tr> 
    60       <td valign="top">warning-count</td> 
     68      <td valign="top">MaxWarn</td> 
    6169      <td valign="top">number of records</td> 
    6270      <td valign="top">The maximum records to allow before reporting a  
     
    6472    </tr> 
    6573    <tr> 
    66       <td valign="top">critical-count</td> 
     74      <td valign="top">MaxCrit</td> 
    6775      <td valign="top">number of records</td> 
    6876      <td valign="top">The maximum records to allow before reporting a  
     
    8290      filter-eventSource</td> 
    8391      <td valign="top"> 
    84       regexp</td> 
     92      string expression</td> 
    8593      <td valign="top"> 
    86       The name of the source of the event.</td> 
     94      The name of the source of the event. Can be a substring or  
     95      regularexpression</td> 
    8796    </tr> 
    8897    <tr> 
     
    9099      filter-generated</td> 
    91100      <td valign="top"> 
    92       Time with optional postfix</td> 
     101      time expression</td> 
    93102      <td valign="top"> 
    94103      Time ago the message was generated</td> 
     
    98107      filter-written</td> 
    99108      <td valign="top"> 
    100       Time with optional postfix</td> 
     109      time expression</td> 
    101110      <td valign="top"> 
    102111      Time ago the message was written to the log</td> 
     
    106115      filter-message</td> 
    107116      <td valign="top"> 
    108       regexp</td> 
     117      string expression</td> 
    109118      <td valign="top"> 
    110       Filter strings in the message.</td> 
     119      Filter strings in the message. Can be a substring or  
     120      regularexpression</td> 
    111121    </tr> 
    112122  </table> 
    113   <p>The “Time with optional postfix” is a way to simply specify large times by  
    114   adding unit postfix. The available postfixes are S for Second, M for Minute,  
    115   H for Hour, D for Day and W for week. </p> 
     123  <p>&nbsp;</p> 
     124  <p>A time expression is a date/time intervall as a number prefixed by a  
     125  filter prefix (&lt;, &gt;, =, !=) and followed by a unit postfix (m, s, h, d, w).  
     126  A few examples of time expression are: filter-generated=&gt;2d means filter  
     127  will match any records older than 2 days, filter-generated=&lt;2h means match  
     128  any records newver then 2 hours.</p> 
     129  <p>A string expression is a key followed by a string that specifies a string  
     130  expression. Currently substr and regexp are supported. Thus you enter  
     131  filter-message=regexp:(foo|bar) to enter a regular expression and  
     132  filter-message=substr:foo to enter a substring patter match.</p> 
    116133  <h3>Examples</h3> 
    117134  <div class="example"> 
     
    122139      all warnings. Allow 3 errors before a warning is issued and 7 before  
    123140      a critical state.</b></p> 
    124       <p><code>checkEventLog file=system file=application filter-eventType=warning filter-generated=1d filter-eventSource=Cdrom filter-eventSource=NSClient warning-count=3 critical-count=7</code></p> 
     141      <p><code>checkEventLog file=system file=application  
     142      MaxWarn=1 MaxCrit=1 filter-generated=&gt;2d filter-eventSource=substr:Service  
     143      filter-eventSource=substr:Tcpip filter=out filter=any</code></p> 
    125144      <p><code>CRITICAL: 27 > critical: ESENT, ESENT, ESENT, ESENT,...</code></p> 
    126145      <div class="config"> 
     
    128147        <p>&nbsp;&nbsp;&nbsp; command_name check_event_log </p> 
    129148        <p>&nbsp;&nbsp;&nbsp; command_line check_nrpe -H $HOSTADDRESS$ -p  
    130         5666 -c checkEventLog -a file=system file=application filter-eventType=warning filter-generated=1d filter-eventSource=Cdrom filter-eventSource=NSClient warning-count=3 critical-count=7 </p> 
     149        5666 -c checkEventLog -a file=system file=application MaxWarn=1 MaxCrit=1  
     150      filter-generated=&gt;2d filter-eventSource=substr:Service  
     151      filter-eventSource=substr:Tcpip filter=out filter=any</p> 
    131152        <p>}</p> 
    132153        <p>&nbsp;&nbsp;&nbsp; check_command check_event_log 
  • docs/CheckSystem/index.html

    re26cfe0 r75d5e70  
    152152    </tr> 
    153153    <tr> 
    154       <td valign="top">warn</td> 
    155       <td valign="top">time</td> 
    156       <td valign="top">Minimum uptime time to not generate a warning state.</td> 
    157     </tr> 
    158     <tr> 
    159       <td valign="top">crit</td> 
    160       <td valign="top">time</td> 
    161       <td valign="top">Minimum uptime time to not generate a critical state.</td> 
     154      <td valign="top">MaxCrit</td> 
     155      <td valign="top">time</td> 
     156      <td valign="top">Maximum time the system is allowed to be up</td> 
     157    </tr> 
     158    <tr> 
     159      <td valign="top">MinCrit</td> 
     160      <td valign="top">time</td> 
     161      <td valign="top">Minimum time the system is allowed to be up</td> 
     162    </tr> 
     163    <tr> 
     164      <td valign="top">MaxWarn</td> 
     165      <td valign="top">time</td> 
     166      <td valign="top">Maximum time the system is allowed to be up</td> 
     167    </tr> 
     168    <tr> 
     169      <td valign="top">MinWarn</td> 
     170      <td valign="top">time</td> 
     171      <td valign="top">Minimum time the system is allowed to be up</td> 
    162172    </tr> 
    163173    <tr> 
     
    173183      <li> 
    174184      <p>Check that the system has been running for at least a day:</p> 
    175       <p><code>checkUpTime warn=1d crit=12h</code></p> 
     185      <p><code>checkUpTime MinWarn=1d MinWarn=12h</code></p> 
    176186      <p><code>Client has uptime (19h) &lt; warning (24h)</code></p> 
    177187      </li> 
     
    316326  can be check as there are a lot of performance counter. To find performance  
    317327  counters use the program perfmon that is shipped with windows. An important  
    318   note is that performance counters are language and version specific.</p> 
    319   <p><i><b>This is currently broken and will be fixed in the next version.</b></i></p> 
     328  note is that performance counters are language and version specific. You can  
     329  list all avalible performance counters using the /listpdh command line  
     330  option.</p> 
    320331  <table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" id="table16"> 
    321332    <tr> 
     
    326337    <tr> 
    327338      <td valign="top">MaxWarn</td> 
    328       <td valign="top">Size GMKB%</td> 
    329       <td valign="top">The maximum size allowed before a warning state is  
    330       returned.</td> 
     339      <td valign="top">Number</td> 
     340      <td valign="top">Maximum allowed number</td> 
    331341    </tr> 
    332342    <tr> 
    333343      <td valign="top">MaxCrit</td> 
    334       <td valign="top">Size GMKB%</td> 
    335       <td valign="top">The maximum size allowed before a critical state is  
    336       returned.</td> 
     344      <td valign="top">Number</td> 
     345      <td valign="top">Maximum allowed number</td> 
    337346    </tr> 
    338347    <tr> 
    339348      <td valign="top">MinWarn</td> 
    340       <td valign="top">Size GMKB%</td> 
    341       <td valign="top">The minimum size allowed before a warning state is  
    342       returned.</td> 
     349      <td valign="top">Number</td> 
     350      <td valign="top">Minimum allowed number</td> 
    343351    </tr> 
    344352    <tr> 
    345353      <td valign="top">MinCrit</td> 
    346       <td valign="top">Size GMKB%</td> 
    347       <td valign="top">The minimum size allowed before a critical state is  
    348       returned.</td> 
     354      <td valign="top">Number</td> 
     355      <td valign="top">Minimumallowed number</td> 
    349356    </tr> 
    350357    <tr> 
    351358      <td valign="top">ShowAll</td> 
    352359      <td valign="top"><i>None</i></td> 
    353       <td valign="top">A Boolean flag to show size even if no state is returned  
    354       (?).</td> 
     360      <td valign="top">A Boolean flag to show value even if no state is returned.</td> 
    355361    </tr> 
    356362    <tr> 
     
    372378      <p>Check that mutex count (on WinXP) is below 500:</p> 
    373379      <p><code>checkCounter "Counter:mutex=\\Objects\\Mutexes" ShowAll MaxWarn=500 MaxCrit=1000</code></p> 
    374       <p><code>WARNING: mutex: 673 > warning|page=673;500;1000;</code></p> 
     380      <p><code>WARNING: mutex: 673 > warning|mutex=673;500;1000;</code></p> 
    375381      </li> 
    376382    </ul> 
  • docs/welcome.html

    re26cfe0 r75d5e70  
    3333  <table id="table17" border="0" cellspacing="0" cellpadding="0" class="MsoNormalTable"> 
    3434    <tr> 
    35       <td valign="top">2005-06-09</td> 
    36       <td>Update with a lot of nice things that will simplify  
    37       configuration (I hope).<p>Enhances/Fixes:</p> 
    38       <ul> 
    39         <li>Autodecteds windows version and language. Hopefully this  
    40         will reduce configuration problems.</li> 
    41         <li>Fixed &quot; escapes in nsc.ini (NRPE Copmmands section)</li> 
    42       </ul> 
    43       <p>Added:</p> 
    44       <ul> 
    45         <li>A decent CheckEventLog (it can now be used, and I think as  
    46         soon as I have time to update the docs a bit more might be a  
    47         nice and usable addition.</li> 
    48       </ul> 
    49       </td> 
    50     </tr> 
    51     <tr> 
    52       <td valign="top">2005-05-29</td> 
    53       <td>Minor update that fixes a few bugs.<p>Enhances/Fixes:</p> 
    54       <ul> 
    55         <li>Fixed PROCSTATE and SERVICESTATE return state.</li> 
    56         <li>Fixed performance data for drives (and possibly other places)</li> 
    57       </ul> 
    58       <p>Added:</p> 
    59       <ul> 
    60         <li>Added support for individual size in CheckDriveSize and CheckFileSize  
    61         (size has to be specified before a drive/path).</li> 
    62       </ul> 
     35      <td valign="top">2005-07-31</td> 
     36      <td>Mainly fixes some minor issues, also adds support for FreeSpace  
     37      checks (in addition to UsedSpace check) as well as &quot;long description  
     38      support&quot; and a reworked EventLog checker.<br> 
     39      <br> 
     40      No updated documentation yet but hopefully all outstanding issues  
     41      has been fixed.<br> 
     42      <br> 
     43      Extract from change log:<br> 
     44      + /install now sets the serivice to autostart<br> 
     45      + Added service description<br> 
     46      * added /listpdh option added to list all pdh counters<br> 
     47      * Eventlog reworked (again) this time I hope it is better <br> 
     48      + Added support for ShowAll=long (to show more information)<br> 
     49      + Extended Drive and memory check syntax to facilitate both Free and  
     50      Used space checks: MaxWarnFree / MaxWarnUsed etc)<br> 
     51      * Changed thread API to use _creatthreadex as opposed to _creatthread  
     52      (works better now!)<br> 
     53      * Fixed UNKNOWN return code (was 4 should have been 3)<br> 
     54      * Fixed drivechecks from NSClient<br> 
     55&nbsp;</td> 
     56    </tr> 
     57    <tr> 
     58      <td valign="top">2005-07-12</td> 
     59      <td>Update with a lot bugfixes 
    6360      </td> 
    6461    </tr> 
     
    6865  <a href="http://nscplus.sf.net" target="_top">http://nscplus.sf.net</a></p> 
    6966  <p>Latest version is 
    70   <a href="http://prdownloads.sourceforge.net/nscplus/NSClient++-0.2.2.zip?download"> 
    71   NSClient++ 0.2.2.zip</a></p> 
     67  <a href="http://prdownloads.sourceforge.net/nscplus/NSClient++-0.2.4d.zip?download"> 
     68  NSClient++ 0.2.4.zip</a></p> 
    7269  <h1>Modules</h1> 
    7370  <p>NSClient++ comes with a few modules out of the box that does various checks.  
  • include/NSCAPI.h

    r1d9338a r75d5e70  
    88    returnOK = 0, 
    99    returnWARN = 1, 
    10     returnUNKNOWN = 4, 
     10    returnUNKNOWN = 3, 
    1111    returnInvalidBufferLen = -2, 
    1212    returnIgnored = -1 
     
    2525  const int returnWARN = 1; 
    2626  const int returnCRIT = 2; 
    27   const int returnUNKNOWN = 4; 
     27  const int returnUNKNOWN = 3; 
    2828  const int returnInvalidBufferLen = -2; 
    2929  const int returnIgnored = -1; 
  • include/PDHCounter.h

    re26cfe0 r75d5e70  
    262262  class Enumerations { 
    263263  public: 
    264     typedef std::list<std::string> str_lst; 
    265     static str_lst EnumObjects() { 
     264 
     265    struct Counter { 
     266      std::string name; 
     267    }; 
     268    typedef std::list<Counter> Counters; 
     269    struct Instance { 
     270      std::string name; 
     271    }; 
     272    typedef std::list<Instance> Instances; 
     273    struct Object { 
     274      std::string name; 
     275      Instances instances; 
     276      Counters counters; 
     277    }; 
     278 
     279    typedef std::list<Object> Objects; 
     280    static Objects EnumObjects(DWORD dwDetailLevel = PERF_DETAIL_WIZARD) { 
     281      Objects ret; 
     282 
     283      DWORD dwObjectBufLen = 0; 
     284      LPTSTR szObjectBuffer = NULL; 
     285      PDH_STATUS status = PdhEnumObjects(NULL, NULL, szObjectBuffer, &dwObjectBufLen, dwDetailLevel, FALSE); 
     286      if (status != PDH_MORE_DATA) 
     287        throw PDHException("PdhEnumObjects failed when trying to retrieve size of object buffer", status); 
     288 
     289      szObjectBuffer = new char[dwObjectBufLen+1024]; 
     290      status = PdhEnumObjects(NULL, NULL, szObjectBuffer, &dwObjectBufLen, dwDetailLevel, FALSE); 
     291      if (status != ERROR_SUCCESS) 
     292        throw PDHException("PdhEnumObjects failed when trying to retrieve object buffer", status); 
     293 
     294      char *cp=szObjectBuffer; 
     295      while(*cp != '\0') { 
     296        Object o; 
     297        o.name = cp; 
     298        ret.push_back(o); 
     299        cp += lstrlen(cp)+1; 
     300      } 
     301      delete [] szObjectBuffer; 
     302 
     303      for (Objects::iterator it = ret.begin(); it != ret.end(); ++it) { 
     304        DWORD dwCounterBufLen = 0; 
     305        LPTSTR szCounterBuffer = NULL; 
     306        DWORD dwInstanceBufLen = 0; 
     307        LPTSTR szInstanceBuffer = NULL; 
     308        status = PdhEnumObjectItems(NULL, NULL, (*it).name.c_str(), szCounterBuffer, &dwCounterBufLen, szInstanceBuffer, &dwInstanceBufLen, dwDetailLevel, 0); 
     309        if (status != PDH_MORE_DATA) 
     310          throw PDHException("PdhEnumObjectItems failed when trying to retrieve size for " + (*it).name, status); 
     311        szCounterBuffer = new char[dwCounterBufLen+1024]; 
     312        szInstanceBuffer = new char[dwInstanceBufLen+1024]; 
     313        status = PdhEnumObjectItems(NULL, NULL, (*it).name.c_str(), szCounterBuffer, &dwCounterBufLen, szInstanceBuffer, &dwInstanceBufLen, dwDetailLevel, 0); 
     314        if (status != ERROR_SUCCESS) 
     315          throw PDHException("PdhEnumObjectItems failed when trying to retrieve buffer for " + (*it).name, status); 
     316 
     317        if (dwCounterBufLen > 0) { 
     318          cp=szCounterBuffer; 
     319          while(*cp != '\0') { 
     320            Counter o; 
     321            o.name = cp; 
     322            (*it).counters.push_back(o); 
     323            cp += lstrlen(cp)+1; 
     324          } 
     325        } 
     326        if (dwInstanceBufLen > 0) { 
     327          cp=szInstanceBuffer; 
     328          while(*cp != '\0') { 
     329            Instance o; 
     330            o.name = cp; 
     331            (*it).instances.push_back(o); 
     332            cp += lstrlen(cp)+1; 
     333          } 
     334        } 
     335        delete [] szCounterBuffer; 
     336        delete [] szInstanceBuffer; 
     337      } 
     338      return ret; 
     339    } 
     340    /* 
     341    static str_lst EnumObjectItems(std::string object) { 
    266342      str_lst ret; 
    267343      DWORD bufLen = 4096; 
     344      DWORD bufLen2 = 0; 
    268345      LPTSTR buf = new char[bufLen+1]; 
    269       PDH_STATUS status = PdhEnumObjects(NULL, NULL, buf, &bufLen, PERF_DETAIL_EXPERT, FALSE); 
     346      PDH_STATUS status = PdhEnumObjectItems(NULL, NULL, object.c_str(), buf, &bufLen, NULL, &bufLen2, PERF_DETAIL_WIZARD, 0); 
    270347      if (status == ERROR_SUCCESS) { 
    271348        char *cp=buf; 
     
    277354      return ret; 
    278355    } 
    279     static str_lst EnumObjectItems(std::string object) { 
     356    static str_lst EnumObjectInstances(std::string object) { 
    280357      str_lst ret; 
    281358      DWORD bufLen = 4096; 
    282359      DWORD bufLen2 = 0; 
    283360      LPTSTR buf = new char[bufLen+1]; 
    284       PDH_STATUS status = PdhEnumObjectItems(NULL, NULL, object.c_str(), buf, &bufLen, NULL, &bufLen2, PERF_DETAIL_EXPERT, 0); 
     361      PDH_STATUS status = PdhEnumObjectItems(NULL, NULL, object.c_str(), NULL, &bufLen2, buf, &bufLen, PERF_DETAIL_WIZARD, 0); 
    285362      if (status == ERROR_SUCCESS) { 
    286363        char *cp=buf; 
     
    292369      return ret; 
    293370    } 
     371    */ 
    294372    static bool validate(std::string counter, std::string &error) { 
    295373      PDH_STATUS status = PdhValidatePath(counter.c_str()); 
  • include/ServiceCmd.cpp

    r1e62ed5 r75d5e70  
    4747      SERVICE_ALL_ACCESS,         // desired access 
    4848      SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS ,  // service type 
    49       SERVICE_DEMAND_START,       // start type 
     49      SERVICE_AUTO_START,       // start type 
    5050      SERVICE_ERROR_NORMAL,       // error control type 
    5151      szPath,                     // service's binary 
     
    187187    CloseServiceHandle(schSCManager); 
    188188  } 
     189 
     190  void SetDescription(std::string name, std::string desc) { 
     191    SERVICE_DESCRIPTION descr; 
     192    SC_HANDLE schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 
     193    if (!schSCManager) 
     194      throw SCException("OpenSCManager failed."); 
     195    SC_HANDLE schService = OpenService(schSCManager, TEXT(name.c_str()), SERVICE_ALL_ACCESS); 
     196    if (!schService) { 
     197      CloseServiceHandle(schSCManager); 
     198      throw SCException("OpenService failed."); 
     199    } 
     200 
     201    LPSTR d = new char[desc.length()+1]; 
     202    strncpy(d, desc.c_str(), desc.length()); 
     203    descr.lpDescription = d; 
     204    BOOL bResult = ChangeServiceConfig2(schService, SERVICE_CONFIG_DESCRIPTION, &descr); 
     205    delete [] d; 
     206    CloseServiceHandle(schService); 
     207    CloseServiceHandle(schSCManager); 
     208    if (!bResult) 
     209      throw SCException("ChangeServiceConfig2 failed."); 
     210  } 
    189211} 
  • include/ServiceCmd.h

    ra0528c4 r75d5e70  
    1212  void Start(std::string); 
    1313  void Stop(std::string); 
     14  void SetDescription(std::string,std::string); 
    1415} 
  • include/checkHelpers.hpp

    re26cfe0 r75d5e70  
    3535    return str + " (unknown)"; 
    3636  } 
    37  
     37  std::string formatNotFound(std::string str, ResultType what) { 
     38    if (what == warning) 
     39      return str + "not found (warning)"; 
     40    else if (what == critical) 
     41      return str + "not found (critical)"; 
     42    return str + "not found (unknown)"; 
     43  } 
     44 
     45  typedef enum {showLong, showShort, showProblems, showUnknown} showType; 
    3846  template <class TContents> 
    3947  struct CheckConatiner { 
     
    4351    std::string data; 
    4452    std::string alias; 
    45     CheckConatiner()  
     53 
     54    showType show; 
     55 
     56 
     57    CheckConatiner() : show(showUnknown) 
    4658    {} 
    4759    CheckConatiner(std::string data_, TContents warn_, TContents crit_)  
    48       : data(data_), warn(warn_), crit(crit_)  
     60      : data(data_), warn(warn_), crit(crit_), show(showUnknown)  
    4961    {} 
    5062    CheckConatiner(std::string name_, std::string alias_, TContents warn_, TContents crit_)  
    51       : data(data_), alias(alias_), warn(warn_), crit(crit_)  
     63      : data(data_), alias(alias_), warn(warn_), crit(crit_), show(showUnknown)  
     64    {} 
     65    CheckConatiner(const TThisType &other)  
     66      : data(other.data), alias(other.alias), warn(other.warn), crit(other.crit), show(other.show)  
    5267    {} 
    5368    std::string getAlias() { 
     
    6176      if (!crit.hasBounds()) 
    6277        crit = def.crit; 
    63     } 
    64     void formatString(std::string &message, typename TContents::TValueType &value) { 
    65       crit.formatString(message, value); 
    66       message = getAlias() + ": " + message; 
     78      if (show == showUnknown) 
     79        show = def.show; 
     80    } 
     81    bool showAll() { 
     82      return show != showProblems; 
    6783    } 
    6884    std::string gatherPerfData(typename TContents::TValueType &value) { 
    6985      return crit.gatherPerfData(getAlias(), value, warn, crit); 
    7086    } 
    71     void runCheck(typename TContents::TValueType &value, NSCAPI::nagiosReturn &returnCode, std::string &message, std::string &perf, bool bShowAll) { 
     87    void runCheck(typename TContents::TValueType &value, NSCAPI::nagiosReturn &returnCode, std::string &message, std::string &perf) { 
    7288      std::string tstr; 
    7389      if (crit.check(value, getAlias(), tstr, critical)) { 
     
    7591      } else if (warn.check(value, getAlias(), tstr, warning)) { 
    7692        NSCHelper::escalteReturnCodeToWARN(returnCode); 
    77       }else if (bShowAll) { 
    78         formatString(tstr, value); 
     93      }else if (show == showLong) { 
     94        tstr = getAlias() + ": " + TContents::toStringLong(value); 
     95      }else if (show == showShort) { 
     96        tstr = getAlias() + ": " + TContents::toStringShort(value); 
    7997      } 
    8098      perf += gatherPerfData(value); 
     
    90108  class disk_size_handler { 
    91109  public: 
     110    static std::string print(TType value) { 
     111      return strEx::itos_as_BKMG(value); 
     112    } 
    92113    static TType parse(std::string s) { 
    93114      return strEx::stoi64_as_BKMG(s); 
     
    96117      return strEx::stoi64(s); 
    97118    } 
    98     static std::string print(TType value) { 
    99       return strEx::itos_as_BKMG(value); 
    100     } 
    101119    static std::string print_percent(TType value) { 
    102120      return strEx::itos(value) + "%"; 
     
    104122    static std::string print_unformated(TType value) { 
    105123      return strEx::itos(value); 
     124    } 
     125 
     126    static std::string key_total() { 
     127      return "Total: "; 
     128    } 
     129    static std::string key_lower() { 
     130      return "Used: "; 
     131    } 
     132    static std::string key_upper() { 
     133      return "Free: "; 
    106134    } 
    107135  }; 
     
    239267    } 
    240268 
    241     std::string toString(TType value) const { 
     269    static std::string toStringLong(TType value) { 
     270      return THandler::print(value); 
     271    } 
     272    static std::string toStringShort(TType value) { 
    242273      return THandler::print(value); 
    243274    } 
     
    246277    } 
    247278 
    248     inline bool isAbove(TType value) const { 
    249       return check(value)==above; 
    250     } 
    251     inline bool isBelow(TType value) const { 
    252       return check(value)==below; 
    253     } 
    254279    const NumericBounds & operator=(std::string value) { 
    255280      set(value); 
     
    274299  }; 
    275300 
     301 
     302  template <typename TTypeValue, typename TTypeTotal = TTypeValue> 
     303  struct PercentageValueType { 
     304    typedef TTypeValue TValueType; 
     305    TTypeValue value; 
     306    TTypeTotal total; 
     307 
     308    TTypeValue getUpperPercentage() { 
     309      return 100-(value*100/total); 
     310    } 
     311    TTypeValue getLowerPercentage() { 
     312      return (value*100)/total; 
     313    } 
     314  }; 
     315 
    276316  template <typename TType = int, class THandler = int_handler > 
    277317  class NumericPercentageBounds { 
    278318  public: 
    279319    typedef enum { 
    280       none, 
    281       percentage, 
    282       size, 
     320      none = 0, 
     321      percentage_upper = 1, 
     322      percentage_lower = 2, 
     323      value_upper = 3, 
     324      value_lower = 4, 
    283325    } checkTypes; 
    284326 
     327    class InternalValue { 
     328      NumericPercentageBounds *pParent_; 
     329      bool isUpper_; 
     330    public: 
     331 
     332      InternalValue(bool isUpper) : pParent_(NULL), isUpper_(isUpper) {} 
     333      void setParent(NumericPercentageBounds *pParent) { 
     334        pParent_ = pParent; 
     335      } 
     336      const InternalValue & operator=(std::string value) { 
     337        std::cout << "Setting value: " << value << std::endl; 
     338        std::string::size_type p = value.find_first_of('%'); 
     339        if (p != std::string::npos) { 
     340          if (isUpper_) 
     341            pParent_->setPercentageUpper(value); 
     342          else 
     343            pParent_->setPercentageLower(value); 
     344        } else { 
     345          if (isUpper_) 
     346            pParent_->setUpper(value); 
     347          else 
     348            pParent_->setLower(value); 
     349        } 
     350        return *this; 
     351      } 
     352 
     353    }; 
     354 
    285355    checkTypes type_; 
    286     TType value_; 
    287     TType max_; 
     356    typename TType::TValueType value_; 
    288357    typedef typename TType TValueType; 
    289358    typedef THandler TFormatType; 
    290359    typedef NumericPercentageBounds<TType, THandler> TMyType; 
    291  
    292     NumericPercentageBounds() : type_(none), value_(0), max_(0) {} 
     360    InternalValue upper; 
     361    InternalValue lower; 
     362 
     363    NumericPercentageBounds() : type_(none), upper(true), lower(false) { 
     364      upper.setParent(this); 
     365      lower.setParent(this); 
     366    } 
    293367 
    294368    NumericPercentageBounds(const NumericPercentageBounds &other) { 
    295369      type_ = other.type_; 
    296370      value_ = other.value_; 
    297       max_ = other.max_; 
    298     } 
    299     void setMax(TType max) { max_ = max; } 
    300  
     371    } 
    301372    checkResultType check(TType value) const { 
    302       if (type_ == percentage) { 
    303         if (((value*100)/max_) == value_) 
     373      if (type_ == percentage_lower) { 
     374        std::cout << "Checking: percentage_lower " << value.getLowerPercentage() << " < " << value_ << std::endl; 
     375        if (value.getLowerPercentage() == value_) 
    304376          return same; 
    305         else if (((value*100)/max_) > value_) 
     377        else if (value.getLowerPercentage() > value_) 
    306378          return above; 
    307         else 
    308           return below; 
     379      } else if (type_ == percentage_upper) { 
     380        std::cout << "Checking: percentage_upper " << value.getUpperPercentage() << " < " << value_ << std::endl; 
     381        if (value.getUpperPercentage() == value_) 
     382          return same; 
     383        else if (value.getUpperPercentage() > value_) 
     384          return above; 
     385      } else if (type_ == value_lower) { 
     386        std::cout << "Checking: value_lower " << value.total << " < " << value_ << std::endl; 
     387        if (value.value == value_) 
     388          return same; 
     389        else if (value.value > value_) 
     390          return above; 
     391      } else if (type_ == value_upper) { 
     392        std::cout << "Checking: value_upper " << (value.total-value.value) << " < " << value_ << std::endl; 
     393        if ((value.total-value.value) == value_) 
     394          return same; 
     395        else if ((value.total-value.value) > value_) 
     396          return above; 
    309397      } else { 
    310         if (value == value_) 
    311           return same; 
    312         else if (value > value_) 
    313           return above; 
    314         return below; 
    315       } 
    316     } 
    317     std::string toString(TType value) const { 
    318       if (type_ == percentage) 
    319         return THandler::print_percent((value*100)/max_); 
    320       return THandler::print(value); 
     398        std::cout << "Damn...: " << type_ << std::endl; 
     399        throw "Damn..."; 
     400      } 
     401      return below; 
     402    } 
     403    static std::string toStringShort(TType value) { 
     404      return THandler::print(value.value); 
     405 
     406    } 
     407    static std::string toStringLong(TType value) { 
     408      return  
     409        THandler::key_total() + THandler::print(value.total) +  
     410        " - " + THandler::key_lower() + THandler::print(value.value) +  
     411          " (" + THandler::print_percent(value.getLowerPercentage()) + ")" + 
     412        " - " + THandler::key_upper() + THandler::print(value.total-value.value) +  
     413          " (" + THandler::print_percent(value.getUpperPercentage()) + ")"; 
    321414    } 
    322415    inline bool hasBounds() const { 
    323416      return type_ != none; 
    324417    } 
    325     inline bool isPercentage() const { 
    326       return type_ == percentage; 
    327     } 
    328     inline bool isAbove(TType value, TType max) const { 
    329       return check(value, max)==above; 
    330     } 
    331     inline bool isBelow(TType value, TType max) const { 
    332       return check(value, max)==below; 
    333     } 
    334     TType getPerfBound(TType value) { 
     418    typename TType::TValueType getPerfBound(TType value) { 
    335419      return value_; 
    336420    } 
    337     std::string gatherPerfData(std::string alias, TType &value, TType warn, TType crit) { 
    338       if (isPercentage()) { 
     421    std::string gatherPerfData(std::string alias, TType &value, typename TType::TValueType warn, typename TType::TValueType crit) { 
     422      if (type_ == percentage_upper) { 
    339423        return alias + ";" 
    340           + THandler::print_unformated((value*100)/max_) + "%;" 
     424          + THandler::print_unformated(value.getUpperPercentage()) + "%;" 
    341425          + THandler::print_unformated(warn) + ";" 
    342426          + THandler::print_unformated(crit) + "; "; 
     427      } else if (type_ == percentage_lower) { 
     428          return alias + ";" 
     429            + THandler::print_unformated(value.getLowerPercentage()) + "%;" 
     430            + THandler::print_unformated(warn) + ";" 
     431            + THandler::print_unformated(crit) + "; "; 
    343432      } else { 
    344433        return alias + ";" 
    345           + THandler::print_unformated(value) + ";" 
    346           + THandler::print_unformated((warn*max_)/100) + ";" 
    347           + THandler::print_unformated((crit*max_)/100) + "; "; 
    348       } 
    349     } 
    350     const NumericPercentageBounds & operator=(std::string value) { 
    351       set(value); 
    352       return *this; 
     434          + THandler::print_unformated(value.value) + ";" 
     435          + THandler::print_unformated(warn) + ";" 
     436          + THandler::print_unformated(crit) + "; "; 
     437      } 
    353438    } 
    354439  private: 
    355     void set(std::string s) { 
    356       std::string::size_type p = s.find_first_of('%'); 
    357       if (p == std::string::npos) { 
    358         value_ = THandler::parse(s); 
    359         type_ = size; 
    360       } else { 
    361         value_ = THandler::parse_percent(s); 
    362         type_ = percentage; 
    363       } 
     440    void setUpper(std::string s) { 
     441      std::cout << "Setting value:U " << s << std::endl; 
     442      value_ = THandler::parse(s); 
     443      type_ = value_upper; 
     444    } 
     445    void setLower(std::string s) { 
     446      std::cout << "Setting value:L " << s << std::endl; 
     447      value_ = THandler::parse(s); 
     448      type_ = value_lower; 
     449    } 
     450    void setPercentageUpper(std::string s) { 
     451      value_ = THandler::parse_percent(s); 
     452      type_ = percentage_upper; 
     453    } 
     454    void setPercentageLower(std::string s) { 
     455      value_ = THandler::parse_percent(s); 
     456      type_ = percentage_lower; 
    364457    } 
    365458  }; 
     
    379472      return (value & value_) != 0; 
    380473    } 
    381     std::string toString(TType value) const { 
     474    static std::string toStringLong(TType value) { 
     475      return THandler::print(value); 
     476    } 
     477    static std::string toStringShort(TType value) { 
    382478      return THandler::print(value); 
    383479    } 
     
    427523      return state.hasBounds() ||  max.hasBounds() || min.hasBounds(); 
    428524    } 
     525 
     526    static std::string toStringLong(typename TValueType &value) { 
     527      return TNumericHolder::toStringLong(value.count) + ", " + TStateHolder::toStringLong(value.state); 
     528    } 
     529    static std::string toStringShort(typename TValueType &value) { 
     530      return TNumericHolder::toStringShort(value.count); 
     531    } 
     532/* 
    429533    void formatString(std::string &message, typename TValueType &value) { 
    430534      if (state.hasBounds()) 
     
    435539        message = max.toString(value.count); 
    436540    } 
     541    */ 
    437542    std::string gatherPerfData(std::string alias, typename TValueType &value, TMyType &warn, TMyType &crit) { 
    438543      if (state.hasBounds()) { 
     
    447552    bool check(typename TValueType &value, std::string lable, std::string &message, ResultType type) { 
    448553      if ((state.hasBounds())&&(!state.check(value.state))) { 
    449         message = lable + ": " + formatState(state.toString(value.state), type); 
     554        message = lable + ": " + formatState(TStateHolder::toStringShort(value.state), type); 
    450555        return true; 
    451556      } else if ((max.hasBounds())&&(max.check(value.count) != below)) { 
    452         message = lable + ": " + formatAbove(max.toString(value.count), type); 
     557        message = lable + ": " + formatAbove(TNumericHolder::toStringShort(value.count), type); 
    453558        return true; 
    454559      } else if ((min.hasBounds())&&(min.check(value.count) != above)) { 
    455         message = lable + ": " + formatBelow(min.toString(value.count), type); 
     560        message = lable + ": " + formatBelow(TNumericHolder::toStringShort(value.count), type); 
    456561        return true; 
    457562      } else { 
     
    478583      return state.hasBounds(); 
    479584    } 
    480     void formatString(std::string &message, typename TValueType &value) { 
    481       message = state.toString(value); 
     585    static std::string toStringLong(typename TValueType &value) { 
     586      return TStateHolder::toStringLong(value); 
     587    } 
     588    static std::string toStringShort(typename TValueType &value) { 
     589      return TStateHolder::toStringShort(value); 
    482590    } 
    483591    std::string gatherPerfData(std::string alias, typename TValueType &value, TMyType &warn, TMyType &crit) { 
     
    489597    bool check(typename TValueType &value, std::string lable, std::string &message, ResultType type) { 
    490598      if ((state.hasBounds())&&(!state.check(value))) { 
    491         message = lable + ": " + formatState(state.toString(value), type); 
     599        message = lable + ": " + formatState(TStateHolder::toStringLong(value), type); 
    492600        return true; 
    493601      } else { 
     
    517625      return max.hasBounds() || min.hasBounds(); 
    518626    } 
    519     void formatString(std::string &message, typename THolder::TValueType &value) { 
    520       message = max.toString(value); 
     627    static std::string toStringLong(typename THolder::TValueType &value) { 
     628      return THolder::toStringLong(value); 
     629    } 
     630    static std::string toStringShort(typename THolder::TValueType &value) { 
     631      return THolder::toStringShort(value); 
    521632    } 
    522633    std::string gatherPerfData(std::string alias, typename THolder::TValueType &value, TMyType &warn, TMyType &crit) { 
     
    530641    bool check(typename THolder::TValueType &value, std::string lable, std::string &message, ResultType type) { 
    531642      if ((max.hasBounds())&&(max.check(value) != below)) { 
    532         message = lable + ": " + formatAbove(max.toString(value), type); 
     643        message = lable + ": " + formatAbove(THolder::toStringLong(value), type); 
    533644        return true; 
    534645      } else if ((min.hasBounds())&&(min.check(value) != above)) { 
    535         message = lable + ": " + formatBelow(min.toString(value), type); 
     646        message = lable + ": " + formatBelow(THolder::toStringLong(value), type); 
    536647        return true; 
    537648      } else { 
     
    545656  typedef MaxMinBounds<NumericBounds<__int64, int64_handler> > MaxMinBoundsInt64; 
    546657  typedef MaxMinBounds<NumericBounds<int, int_handler> > MaxMinBoundsInteger; 
     658  typedef MaxMinBounds<NumericBounds<unsigned int, int_handler> > MaxMinBoundsUInteger; 
    547659  typedef MaxMinBounds<NumericBounds<disk_size_type, disk_size_handler<disk_size_type> > > MaxMinBoundsDiscSize; 
    548660  typedef MaxMinBounds<NumericBounds<time_type, time_handler<time_type> > > MaxMinBoundsTime; 
    549661 
    550662 
    551   typedef MaxMinBounds<NumericPercentageBounds<int, int_handler> > MaxMinPercentageBoundsInteger; 
    552   typedef MaxMinBounds<NumericPercentageBounds<__int64, int64_handler> > MaxMinPercentageBoundsInt64; 
    553   typedef MaxMinBounds<NumericPercentageBounds<double, double_handler> > MaxMinPercentageBoundsDouble; 
    554   typedef MaxMinBounds<NumericPercentageBounds<disk_size_type, disk_size_handler<> > > MaxMinPercentageBoundsDiskSize; 
     663  //typedef MaxMinBounds<NumericPercentageBounds<PercentageValueType<int ,int>, int_handler> > MaxMinPercentageBoundsInteger; 
     664  //typedef MaxMinBounds<NumericPercentageBounds<PercentageValueType<__int64, __int64>, int64_handler> > MaxMinPercentageBoundsInt64; 
     665  //typedef MaxMinBounds<NumericPercentageBounds<PercentageValueType<double, double>, double_handler> > MaxMinPercentageBoundsDouble; 
     666  typedef MaxMinBounds<NumericPercentageBounds<PercentageValueType<disk_size_type, disk_size_type>, disk_size_handler<> > > MaxMinPercentageBoundsDiskSize; 
     667  typedef MaxMinBounds<NumericPercentageBounds<PercentageValueType<__int64, __int64>, disk_size_handler<__int64> > > MaxMinPercentageBoundsDiskSizei64; 
    555668 
    556669  typedef MaxMinStateBounds<MaxMinStateValueType<int, state_type>, NumericBounds<int, int_handler>, StateBounds<state_type, state_handler> > MaxMinStateBoundsStateBoundsInteger; 
  • include/config.h

    re26cfe0 r75d5e70  
    99// internal name of the service 
    1010#define SZSERVICENAME        "NSClient++" 
     11 
     12// Description of service 
     13#define SZSERVICEDESCRIPTION "Nagios Windows Agent (Provides performance data for Nagios server)" 
    1114 
    1215// displayed name of the service 
     
    8386#define MAIN_SECTION_TITLE "Settings" 
    8487#define MAIN_MASTERKEY "master_key"  
    85 #define MAIN_MASTERKEY_DEFAULT "This is a secret key thet you should change" 
     88#define MAIN_MASTERKEY_DEFAULT "This is a secret key that you should change" 
    8689#define MAIN_OBFUSCATED_PASWD "obfuscated_password" 
    8790#define MAIN_OBFUSCATED_PASWD_DEFAULT "" 
  • include/strEx.h

    re26cfe0 r75d5e70  
    1111 
    1212namespace strEx { 
     13 
     14  inline void append_list(std::string &lst, std::string &append) { 
     15    if (!lst.empty()) 
     16      lst += ", "; 
     17    lst += append; 
     18  } 
     19 
    1320 
    1421  inline void replace(std::string &string, std::string replace, std::string with) { 
     
    8188    return value * smallest_unit; 
    8289  } 
     90 
    8391  inline unsigned long long stoi64_as_time(std::string time, unsigned int smallest_unit = 1000) { 
    8492    std::string::size_type p = time.find_first_of("sSmMhHdDwW"); 
  • include/thread.h

    r1d9338a r75d5e70  
    4040  HANDLE hThread_;    // Thread handle 
    4141  T* pObject_;      // Wrapped object 
    42   HANDLE hStopEvent_;   // Event to signal that the thread has stopped 
    4342  HANDLE hMutex_;     // Mutex to protect internal data 
     43  unsigned uThreadID;   // THe thread ID 
     44 
     45 
     46  bool bThreadHasTerminated; 
     47  bool bThreadHasBeenClosed; 
     48 
    4449 
    4550 
    4651  typedef struct thread_param { 
    47     HANDLE hStopEvent;  // The stop event to signal when thread dies 
    4852    T *instance;    // The thread instance object 
    4953    LPVOID lpParam;   // The optional argument to the thread 
     
    5660   * Sets up default values 
    5761   */ 
    58   Thread() : hThread_(NULL), pObject_(NULL), hStopEvent_(NULL) { 
     62  Thread() : hThread_(NULL), pObject_(NULL), uThreadID(-1), bThreadHasTerminated(false), bThreadHasBeenClosed(false) { 
    5963    hMutex_ = CreateMutex(NULL, FALSE, NULL); 
    6064    assert(hMutex_ != NULL); 
     
    6771  virtual ~Thread() { 
    6872    { 
     73      if (bThreadHasBeenClosed && bThreadHasTerminated) 
     74        ; 
     75      else if (bThreadHasBeenClosed||bThreadHasTerminated) 
     76        std::cout << "Thread has not terminated correctly..." << std::endl; 
     77      /* 
    6978      MutexLock mutex(hMutex_, 5000L); 
    7079      if (!mutex.hasMutex()) { 
     
    7685      hStopEvent_ = NULL; 
    7786      delete pObject_; 
    78       pObject_ = NULL; 
     87      */ 
     88//      pObject_ = NULL; 
     89//      CloseHandle(hThread_); 
    7990    } 
    8091    if (hMutex_) 
     
    91102   * @return exit status 
    92103   */ 
    93   static void threadProc(LPVOID lpParameter) { 
     104  static unsigned __stdcall threadProc(void* lpParameter) { 
    94105    thread_param* param = static_cast<thread_param*>(lpParameter); 
    95106    T* instance = param->instance; 
    96     HANDLE hStopEvent = param->hStopEvent; 
    97107    LPVOID lpParam = param->lpParam; 
    98108    Thread *pCore = param->pCore; 
    99109    delete param; 
    100110 
    101     instance->threadProc(lpParam); 
     111    unsigned returnCode = instance->threadProc(lpParam); 
    102112    pCore->terminate(); 
    103     SetEvent(hStopEvent); 
    104     _endthread(); 
     113    _endthreadex( 0 ); 
     114    return returnCode; 
     115 
     116//    _endthread(); 
    105117  } 
    106118 
     
    125137        throw ThreadException("Thread already started, thread not started..."); 
    126138      } 
    127       assert(hStopEvent_ == NULL); 
     139//      assert(hStopEvent_ == NULL); 
    128140      param = new thread_param; 
    129141      param->instance = pObject_ = new T; 
    130       param->hStopEvent = hStopEvent_ = CreateEvent(NULL, TRUE, FALSE, NULL); 
     142//      param->hStopEvent = hStopEvent_ = CreateEvent(NULL, TRUE, FALSE, NULL); 
    131143      param->lpParam = lpParam; 
    132144      param->pCore = this; 
    133145    } 
    134     hThread_ = reinterpret_cast<HANDLE>(::_beginthread(threadProc, 0, reinterpret_cast<VOID*>(param))); 
     146    //hThread_ = reinterpret_cast<HANDLE>(::_beginthreadex(threadProc, 0, reinterpret_cast<VOID*>(param))); 
     147    //hThread = (HANDLE)_beginthreadex( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID ); 
     148    hThread_ = reinterpret_cast<HANDLE>(::_beginthreadex(NULL, 0, threadProc, reinterpret_cast<VOID*>(param), 0, &uThreadID)); 
    135149  } 
    136150  /** 
     
    139153   * @return true if the thread has terminated 
    140154   */ 
    141   bool exitThread(const unsigned int delay = 5000L) { 
     155  bool exitThread(const unsigned int delay = 20000L) { 
    142156    DWORD dwWaitResult = -1; 
    143157    { 
    144       MutexLock mutex(hMutex_, 5000L); 
     158      MutexLock mutex(hMutex_, delay); 
    145159      if (!mutex.hasMutex()) { 
    146160        throw ThreadException("Could not retrieve mutex, thread not stopped..."); 
     
    148162      if (!pObject_) 
    149163        return true; 
    150       assert(hStopEvent_ != NULL); 
    151164      pObject_->exitThread(); 
    152165    } 
    153     dwWaitResult = WaitForSingleObject(hStopEvent_, delay); 
    154     switch (dwWaitResult) { 
    155       // The thread got mutex ownership. 
    156       case WAIT_OBJECT_0: 
    157         return true; 
    158         // Did not get a signal due to time-out. 
    159       case WAIT_TIMEOUT:  
    160         return false;  
    161         // Never got a signal. 
    162       case WAIT_ABANDONED:  
    163         return false;  
    164     } 
     166    dwWaitResult = WaitForSingleObject(hThread_, delay); 
     167    if (dwWaitResult == WAIT_OBJECT_0) { 
     168      bThreadHasBeenClosed = true; 
     169      CloseHandle(hThread_); 
     170      delete pObject_; 
     171      pObject_ = NULL; 
     172      return true; 
     173    } 
     174    std::cout << "Failed to terminate thread..." << std::endl; 
     175    assert(false); 
    165176    return false; 
    166177  } 
     
    188199private: 
    189200  void terminate() { 
    190     MutexLock mutex(hMutex_, 5000L); 
    191     if (!mutex.hasMutex()) { 
    192       throw ThreadException("Could not retrieve mutex, thread not stopped..."); 
    193     } 
    194     delete pObject_; 
    195     pObject_ = NULL; 
    196     hThread_ = NULL; 
     201    bThreadHasTerminated = true; 
    197202  } 
    198203}; 
  • include/utils.h

    re26cfe0 r75d5e70  
    3030} 
    3131 
    32  
    33  
    34  
    35  
    36  
    37  
    3832#define MAP_OPTIONS_BEGIN(args) \ 
    3933  for (std::list<std::string>::const_iterator cit__=args.begin();cit__!=args.end();++cit__) { \ 
    4034  std::pair<std::string,std::string> p__ = strEx::split(*cit__,"="); if (false) {} 
     35 
     36#define MAP_OPTIONS_SHOWALL(obj) \ 
     37      else if (p__.first == SHOW_ALL) { if (p__.second == "long") obj.show = checkHolders::showLong; else obj.show = checkHolders::showShort; } \ 
     38      else if (p__.first == SHOW_FAIL) { obj.show = checkHolders::showProblems; } 
     39 
     40#define MAP_OPTIONS_DISK_ALL(obj, postfix, pfUpper, pfLower) \ 
     41      else if (p__.first == "MaxWarn" pfUpper) { obj.warn.max.upper = p__.second; } \ 
     42      else if (p__.first == "MaxCrit" pfUpper) { obj.crit.max.upper = p__.second; } \ 
     43      else if (p__.first == "MinWarn" pfUpper) { obj.warn.min.upper = p__.second; } \ 
     44      else if (p__.first == "MinCrit" pfUpper) { obj.crit.min.upper = p__.second; } \ 
     45      else if (p__.first == "MaxWarn" pfLower) { obj.warn.max.lower = p__.second; } \ 
     46      else if (p__.first == "MaxCrit" pfLower) { obj.crit.max.lower = p__.second; } \ 
     47      else if (p__.first == "MinWarn" pfLower) { obj.warn.min.lower = p__.second; } \ 
     48      else if (p__.first == "MinCrit" pfLower) { obj.crit.min.lower = p__.second; } \ 
     49      else if (p__.first == "MaxWarn" postfix) { obj.warn.max.lower = p__.second; } \ 
     50      else if (p__.first == "MaxCrit" postfix) { obj.crit.max.lower = p__.second; } \ 
     51      else if (p__.first == "MinWarn" postfix) { obj.warn.min.upper = p__.second; } \ 
     52      else if (p__.first == "MinCrit" postfix) { obj.crit.min.upper = p__.second; } 
     53 
     54#define MAP_OPTIONS_NUMERIC_ALL(obj, postfix) \ 
     55      else if (p__.first == ("MaxWarn" postfix)) { obj.warn.max = p__.second; } \ 
     56      else if (p__.first == ("MaxCrit" postfix)) { obj.crit.max = p__.second; } \ 
     57      else if (p__.first == ("MinWarn" postfix)) { obj.warn.min = p__.second; } \ 
     58      else if (p__.first == ("MinCrit" postfix)) { obj.crit.min = p__.second; } 
     59 
     60#define MAP_OPTIONS_PUSH(value, list) \ 
     61      else if (p__.first == value) { list.push_back(p__.second); } 
     62#define MAP_OPTIONS_DO(action) \ 
     63      else if (p__.first == value) { action; } 
    4164#define MAP_OPTIONS_STR(value, obj) \ 
    4265      else if (p__.first == value) { obj = p__.second; } 
     66#define MAP_OPTIONS_STR2INT(value, obj) \ 
     67      else if (p__.first == value) { obj = atoi(p__.second.c_str()); } 
    4368#define MAP_OPTIONS_STR_AND(value, obj, extra) \ 
    4469      else if (p__.first == value) { obj = p__.second; extra;} 
     
    4772#define MAP_OPTIONS_BOOL_FALSE(value, obj) \ 
    4873      else if (p__.first == value) { obj = false; } 
     74#define MAP_OPTIONS_BOOL_VALUE(value, obj, tStr) \ 
     75      else if ((p__.first == value)&&(p__.second == tStr)) { obj = true; }  
    4976#define MAP_OPTIONS_BOOL_EX(value, obj, tStr, fStr) \ 
    5077      else if ((p__.first == value)&&(p__.second == tStr)) { obj = true; } \ 
    5178      else if ((p__.first == value)&&(p__.second == fStr)) { obj = false; } 
    5279#define MAP_OPTIONS_MISSING(arg, str) \ 
    53     else { arg = str + p__.first; return NSCAPI::returnUNKNOWN; } 
     80      else { arg = str + p__.first; return NSCAPI::returnUNKNOWN; } 
     81#define MAP_OPTIONS_FALLBACK_AND(obj, extra) \ 
     82      else { obj = p__.first; extra;} 
    5483#define MAP_OPTIONS_END() } 
    5584 
  • modules/CheckDisk/CheckDisk.cpp

    re26cfe0 r75d5e70  
    8787 
    8888  DriveConatiner tmpObject; 
    89   bool bShowAll = false; 
    9089  bool bFilter = false; 
    9190  bool bFilterRemote = false; 
     
    9998  MAP_OPTIONS_BEGIN(args) 
    10099    MAP_OPTIONS_STR_AND("Drive", tmpObject.data, drives.push_back(tmpObject)) 
    101     MAP_OPTIONS_STR("MaxWarn", tmpObject.warn.max) 
    102     MAP_OPTIONS_STR("MinWarn", tmpObject.warn.min) 
    103     MAP_OPTIONS_STR("MaxCrit", tmpObject.crit.max) 
    104     MAP_OPTIONS_STR("MinCrit", tmpObject.crit.min) 
    105     else if (p__.first == "FilterType") { 
    106       bFilter = true; 
    107       if (p__.second == "FIXED") { 
    108         bFilterFixed = true; 
    109       } else if (p__.second == "CDROM") { 
    110         bFilterCDROM = true; 
    111       } else if (p__.second == "REMOVABLE") { 
    112         bFilterRemovable = true; 
    113       } else if (p__.second == "REMOTE") { 
    114         bFilterRemote= true; 
    115       } 
    116     } 
     100    MAP_OPTIONS_DISK_ALL(tmpObject, "", "Free", "Used") 
     101    MAP_OPTIONS_SHOWALL(tmpObject) 
     102    MAP_OPTIONS_BOOL_VALUE("FilterType", bFilterFixed, "FIXED") 
     103    MAP_OPTIONS_BOOL_VALUE("FilterType", bFilterCDROM, "CDROM") 
     104    MAP_OPTIONS_BOOL_VALUE("FilterType", bFilterRemovable, "REMOVABLE") 
     105    MAP_OPTIONS_BOOL_VALUE("FilterType", bFilterRemote, "REMOTE") 
    117106    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
    118     MAP_OPTIONS_BOOL_TRUE(SHOW_ALL, bShowAll) 
    119107    MAP_OPTIONS_BOOL_TRUE(CHECK_ALL, bCheckAll) 
    120108    MAP_OPTIONS_SECONDARY_BEGIN(":", p2) 
     
    126114      MAP_OPTIONS_MISSING_EX(p2, message, "Unknown argument: ") 
    127115    MAP_OPTIONS_SECONDARY_END() 
    128     MAP_OPTIONS_MISSING(message, "Unknown argument: ") 
     116  MAP_OPTIONS_FALLBACK_AND(tmpObject.data, drives.push_back(tmpObject)) 
    129117  MAP_OPTIONS_END() 
     118  bFilter = bFilterFixed || bFilterCDROM  || bFilterRemote || bFilterRemovable; 
    130119 
    131120  if (bCheckAll) { 
     
    182171      message += strEx::itos(totalNumberOfBytes.QuadPart); 
    183172    } else { 
     173      checkHolders::PercentageValueType<checkHolders::disk_size_type, checkHolders::disk_size_type> value; 
    184174      std::string tstr; 
    185       checkHolders::disk_size_type size = totalNumberOfBytes.QuadPart-totalNumberOfFreeBytes.QuadPart; 
     175      value.value = totalNumberOfBytes.QuadPart-totalNumberOfFreeBytes.QuadPart; 
     176      value.total = totalNumberOfBytes.QuadPart; 
    186177      drive.setDefault(tmpObject); 
    187       drive.warn.max.setMax(totalNumberOfBytes.QuadPart); 
    188       drive.warn.min.setMax(totalNumberOfBytes.QuadPart); 
    189       drive.crit.max.setMax(totalNumberOfBytes.QuadPart); 
    190       drive.crit.min.setMax(totalNumberOfBytes.QuadPart); 
    191       drive.runCheck(size, returnCode, message, perf, bShowAll); 
     178      drive.runCheck(value, returnCode, message, perf); 
    192179    } 
    193180  } 
     
    209196  } 
    210197  PathConatiner tmpObject; 
    211   bool bShowAll = false; 
    212198  std::list<PathConatiner> paths; 
    213199 
    214200  MAP_OPTIONS_BEGIN(args) 
    215201    MAP_OPTIONS_STR_AND("File", tmpObject.data, paths.push_back(tmpObject)) 
     202    MAP_OPTIONS_SHOWALL(tmpObject) 
    216203    MAP_OPTIONS_STR("MaxWarn", tmpObject.warn.max) 
    217204    MAP_OPTIONS_STR("MinWarn", tmpObject.warn.min) 
    218205    MAP_OPTIONS_STR("MaxCrit", tmpObject.crit.max) 
    219206    MAP_OPTIONS_STR("MinCrit", tmpObject.crit.min) 
    220     MAP_OPTIONS_BOOL_TRUE(SHOW_ALL, bShowAll) 
    221207    MAP_OPTIONS_SECONDARY_BEGIN(":", p2) 
    222208    else if (p2.first == "File") { 
     
    239225 
    240226    checkHolders::disk_size_type size = sizeFinder.getSize(); 
    241     path.runCheck(size, returnCode, message, perf, bShowAll); 
     227    path.runCheck(size, returnCode, message, perf); 
    242228  } 
    243229  if (message.empty()) 
  • modules/CheckDisk/CheckDisk.vcproj

    rcea178b r75d5e70  
    228228      </File> 
    229229      <File 
     230        RelativePath="..\..\include\checkHelpers.hpp"> 
     231      </File> 
     232      <File 
    230233        RelativePath="..\..\include\NSCHelper.h"> 
    231234      </File> 
  • modules/CheckEventLog/CheckEventLog.cpp

    re26cfe0 r75d5e70  
    66#include <strEx.h> 
    77#include <time.h> 
     8#include <utils.h> 
    89 
    910CheckEventLog gCheckEventLog; 
     
    3940class EventLogRecord { 
    4041  EVENTLOGRECORD *pevlr_; 
     42  DWORD currentTime_; 
    4143public: 
    42   EventLogRecord(EVENTLOGRECORD *pevlr) : pevlr_(pevlr) { 
     44  EventLogRecord(EVENTLOGRECORD *pevlr, DWORD currentTime) : pevlr_(pevlr), currentTime_(currentTime) { 
    4345  } 
    4446  inline DWORD timeGenerated() const { 
    45     return pevlr_->TimeGenerated; 
     47    return (currentTime_-pevlr_->TimeGenerated)*1000; 
    4648  } 
    4749  inline DWORD timeWritten() const { 
    48     return pevlr_->TimeWritten; 
     50    return (currentTime_-pevlr_->TimeWritten)*1000; 
    4951  } 
    5052  inline std::string eventSource() const { 
     
    121123 
    122124 
    123 struct searchQuery { 
    124     struct searchQueryItem { 
    125  
    126       typedef enum { 
    127         eventType,  
    128         eventSource,  
    129         timeWritten, 
    130         timeGenerated, 
    131         message, 
    132         none 
    133       } queryType; 
    134  
    135       typedef enum { out, in, undefined } filterType; 
    136  
    137       filterType filter_; 
    138       queryType queryType_; 
    139       DWORD dwValue_; 
    140       boost::regex regexp_; 
    141        
    142  
    143       searchQueryItem()  
    144         : queryType_(none), dwValue_(0), filter_(out)  
    145       {} 
    146       searchQueryItem(filterType filter, queryType type, std::string str)  
    147         : queryType_(type), dwValue_(0), filter_(filter) 
    148       { 
    149         switch (queryType_ ) { 
    150         case eventType: 
    151           dwValue_ = EventLogRecord::translateType(str); 
    152           break; 
    153  
    154         case timeGenerated: 
    155           dwValue_ = strEx::stoui_as_time(str)/1000; 
    156           break; 
    157  
    158         case eventSource: 
    159         case message: 
    160           try { 
    161             regexp_ = str; 
    162           } catch (const boost::bad_expression e) { 
    163             throw (std::string)"Invalid syntax in regular expression:" + str; 
    164           } 
    165           break; 
    166         } 
    167       } 
    168  
    169       searchQueryItem& operator=(const searchQueryItem &other) { 
    170         queryType_ = other.queryType_; 
    171         dwValue_ = other.dwValue_; 
    172         filter_ = other.filter_; 
    173         try { 
    174           regexp_ = other.regexp_; 
    175         } catch (const boost::bad_expression e) { 
    176           throw (std::string)"Invalid syntax in regular expression:" + other.toString(); 
    177         } 
    178         return *this; 
    179       } 
    180  
    181       bool match(DWORD now, const EventLogRecord &record) const { 
    182         switch (queryType_) { 
    183         case eventType: 
    184           return record.eventType() & dwValue_; 
    185  
    186         case eventSource: 
    187           if (regexp_.empty()) 
    188             return false; 
    189           return boost::regex_match(record.eventSource(), regexp_); 
    190  
    191         case timeWritten: 
    192           return record.timeWritten() < (now-dwValue_); 
    193  
    194         case timeGenerated: 
    195           return record.timeGenerated() < (now-dwValue_); 
    196  
    197         case message: 
    198           if (regexp_.empty()) 
    199             return false; 
    200           return boost::regex_match(record.enumStrings(), regexp_); 
    201  
    202         default: 
    203           return false; 
    204         } 
    205       } 
    206       std::string queryType2String(queryType query) const { 
    207         switch (queryType_) { 
    208         case eventType: 
    209           return "eventType"; 
    210         case eventSource: 
    211           return "eventSource"; 
    212         case timeWritten: 
    213           return "timeWritten"; 
    214         case timeGenerated: 
    215           return "timeGenerated"; 
    216         case message: 
    217           return "message"; 
    218         default: 
    219           return "unknown"; 
    220         } 
    221  
    222       } 
    223  
    224       std::string toString() const { 
    225         std::stringstream ss; 
    226         ss << " Type: " << queryType2String(queryType_) << " = " << dwValue_ << ", '" << regexp_ << "'"; 
    227         return ss.str(); 
    228       } 
    229     }; 
    230  
    231  
    232  
    233   unsigned int truncate; 
    234   unsigned warning_count; 
    235   unsigned critical_count; 
    236   bool descriptions; 
    237   std::list<searchQueryItem> queries; 
    238  
    239   searchQuery() : truncate(0), descriptions(false), warning_count(0), critical_count(0) {} 
    240  
    241   std::string toString() { 
    242     std::string ret; 
    243     for (std::list<searchQuery::searchQueryItem>::const_iterator cit = queries.begin(); cit != queries.end(); ++cit ) { 
    244       ret += (*cit).toString(); 
    245     } 
    246     return ret; 
    247   } 
    248  
     125struct eventlog_filter { 
     126  filters::filter_all_strings eventSource; 
     127  filters::filter_all_numeric<unsigned int, filters::handlers::eventtype_handler> eventType; 
     128  filters::filter_all_strings message; 
     129  filters::filter_all_times timeWritten; 
     130  filters::filter_all_times timeGenerated; 
     131 
     132  inline bool hasFilter() { 
     133    return eventSource.hasFilter() || eventType.hasFilter() || message.hasFilter() ||  
     134      timeWritten.hasFilter() || timeGenerated.hasFilter(); 
     135  } 
     136  bool matchFilter(const EventLogRecord &value) const { 
     137    if ((eventSource.hasFilter())&&(eventSource.matchFilter(value.eventSource()))) 
     138      return true; 
     139    else if ((eventType.hasFilter())&&(eventType.matchFilter(value.eventType()))) 
     140      return true; 
     141    else if ((message.hasFilter())&&(message.matchFilter(value.enumStrings()))) 
     142      return true; 
     143    else if ((timeWritten.hasFilter())&&(timeWritten.matchFilter(value.timeWritten()))) 
     144      return true; 
     145    else if ((timeGenerated.hasFilter())&&(timeGenerated.matchFilter(value.timeGenerated()))) 
     146      return true; 
     147    return false; 
     148  } 
    249149}; 
    250150 
    251 // checkEventLog file=application truncate=1024 descriptions filter=[out|in] 
    252 //          warning-count=3 critical-count=10 
    253 // filter type = warning AND generated > 1d 
    254 // 
    255 // match (type, "warning") && match(generated, "1d") 
    256 //          filer-eventType=warning  
    257 //          filer-eventSource= 
    258 //          filer-date=4d 
    259 // 
    260 // CheckEventLog 
    261 // request: CheckEventLog&<logfile>&<Query strings> 
    262 // Return: <return state>&<log entry 1> - <log entry 2>... 
    263 // <return state> 0 - No errors 
    264 //          1 - Unknown 
    265 //          2 - Errors 
    266  
    267 // ./nrpe-2.0/src/check_nrpe -H 192.168.167 -p 5666 -c checkEventLog -a file=system file=application filter-eventType=warning filter-generated=1d descriptions filter-eventSource=Cdrom filter-eventSource=NSClient warning-count=3 critical-count=7 filter=in truncate=512 
    268 // 
    269 // Examples: 
    270 // CheckEventLog&Application&1&<type>&<query>&huffa... 
    271 // CheckEventLog&Application&warn.require.eventType=warning&critical.require.eventType=error&truncate=1024&descriptions&all.exclude.eventSourceRegexp=^(Win|Msi|NSClient\+\+|Userenv|ASP\.NET|LoadPerf|Outlook|Application E|NSClient).* 
     151 
     152#define MAP_FILTER(value, obj) \ 
     153      else if (p__.first == value) { eventlog_filter filter; filter.obj = p__.second; filter_chain.push_back(filter); } 
     154 
     155 
    272156#define BUFFER_SIZE 1024*64 
    273157NSCAPI::nagiosReturn CheckEventLog::handleCommand(const strEx::blindstr command, const unsigned int argLen, char **char_args, std::string &message, std::string &perf) { 
    274158  if (command != "CheckEventLog") 
    275159    return NSCAPI::returnIgnored; 
    276   NSCAPI::nagiosReturn rCode = NSCAPI::returnOK; 
    277   std::list<std::string> args = arrayBuffer::arrayBuffer2list(argLen, char_args); 
    278  
    279   std::string ret; 
    280   searchQuery query; 
     160  typedef checkHolders::CheckConatiner<checkHolders::MaxMinBoundsUInteger> EventLogQueryConatiner; 
     161  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
     162  std::list<std::string> stl_args = arrayBuffer::arrayBuffer2list(argLen, char_args); 
     163 
    281164  std::list<std::string> files; 
    282   searchQuery::searchQueryItem::filterType filter = searchQuery::searchQueryItem::out; 
    283  
    284   for (std::list<std::string>::const_iterator it = args.begin(); it!=args.end(); ++it) { 
    285     try { 
    286       if ((*it) == "descriptions") { 
    287         query.descriptions = true; 
    288       } else { 
    289         std::pair<std::string,std::string> p = strEx::split((*it), "="); 
    290         if (p.first == "truncate") { 
    291           query.truncate = strEx::stoi(p.second); 
    292         } else if (p.first == "file") { 
    293           files.push_back(p.second); 
    294         } else if (p.first == "filter") { 
    295           if (p.second == "in") 
    296             filter = searchQuery::searchQueryItem::in; 
    297           else 
    298             filter = searchQuery::searchQueryItem::out; 
    299         } else if (p.first == "warning-count") { 
    300           query.warning_count = strEx::stoi(p.second); 
    301         } else if (p.first == "critical-count") { 
    302           query.critical_count = strEx::stoi(p.second); 
    303  
    304         } else if (p.first == "filter-eventType") { 
    305           query.queries.push_back(searchQuery::searchQueryItem(filter, searchQuery::searchQueryItem::eventType, p.second)); 
    306         } else if (p.first == "filter-eventSource") { 
    307           query.queries.push_back(searchQuery::searchQueryItem(filter, searchQuery::searchQueryItem::eventSource, p.second)); 
    308         } else if (p.first == "filter-generated") { 
    309           query.queries.push_back(searchQuery::searchQueryItem(filter, searchQuery::searchQueryItem::timeGenerated, p.second)); 
    310         } else if (p.first == "filter-written") { 
    311           query.queries.push_back(searchQuery::searchQueryItem(filter, searchQuery::searchQueryItem::timeWritten, p.second)); 
    312         } else if (p.first == "filter-message") { 
    313           query.queries.push_back(searchQuery::searchQueryItem(filter, searchQuery::searchQueryItem::message, p.second)); 
    314         } 
    315       } 
    316     } catch (std::string s) { 
    317       if (message.empty()) 
    318         message += "UNKNOWN: "; 
    319       else 
    320         message += ", "; 
    321       message += s; 
    322     } 
    323   } 
    324   if (!message.empty()) { 
     165  std::list<eventlog_filter> filter_chain; 
     166  EventLogQueryConatiner query; 
     167 
     168  bool bFilterIn = true; 
     169  bool bFilterAll = false; 
     170  bool bShowDescriptions = false; 
     171  unsigned int truncate = 0; 
     172 
     173  try { 
     174    MAP_OPTIONS_BEGIN(stl_args) 
     175      MAP_OPTIONS_NUMERIC_ALL(query, "") 
     176      MAP_OPTIONS_STR2INT("truncate", truncate) 
     177      MAP_OPTIONS_BOOL_TRUE("descriptions", bShowDescriptions) 
     178      MAP_OPTIONS_PUSH("file", files) 
     179      MAP_OPTIONS_BOOL_EX("filter", bFilterIn, "in", "out") 
     180      MAP_OPTIONS_BOOL_EX("filter", bFilterAll, "all", "any") 
     181      MAP_FILTER("filter-eventType", eventType) 
     182      MAP_FILTER("filter-eventSource", eventSource) 
     183      MAP_FILTER("filter-generated", timeGenerated) 
     184      MAP_FILTER("filter-written", timeWritten) 
     185      MAP_FILTER("filter-message", message) 
     186      MAP_OPTIONS_MISSING(message, "Unknown argument: ") 
     187    MAP_OPTIONS_END() 
     188  } catch (filters::parse_exception e) { 
     189    message = e.getMessage(); 
     190    return NSCAPI::returnUNKNOWN; 
     191  } catch (filters::filter_exception e) { 
     192    message = e.getMessage(); 
    325193    return NSCAPI::returnUNKNOWN; 
    326194  } 
     
    352220      while (dwRead > 0)  
    353221      {  
    354         bool match = false; 
    355         bool undefined = true; 
    356         searchQuery::searchQueryItem::filterType tFilter = searchQuery::searchQueryItem::out; 
    357         EventLogRecord record(pevlr); 
    358  
    359         for (std::list<searchQuery::searchQueryItem>::const_iterator cit3 = query.queries.begin(); cit3 != query.queries.end(); ++cit3 ) { 
    360           if ((*cit3).match(currentTime, record)) { 
    361             if ((*cit3).filter_ == searchQuery::searchQueryItem::in) 
    362               match = true; 
    363             else { 
    364               match = false; 
     222        bool bMatch = bFilterAll; 
     223        EventLogRecord record(pevlr, currentTime); 
     224 
     225        for (std::list<eventlog_filter>::const_iterator cit3 = filter_chain.begin(); cit3 != filter_chain.end(); ++cit3 ) { 
     226          bool bTmpMatched = (*cit3).matchFilter(record); 
     227          if (bFilterAll) { 
     228            if (!bTmpMatched) { 
     229              bMatch = false; 
     230              break; 
     231            } 
     232          } else { 
     233            if (bTmpMatched) { 
     234              bMatch = true; 
     235              break; 
    365236            } 
    366237          } 
    367238        } 
    368239 
    369         if (match) { 
    370           if (!ret.empty()) 
    371             ret += ", "; 
    372           ret += record.eventSource(); 
    373           if (query.descriptions) { 
    374             ret += "(" + EventLogRecord::translateType(record.eventType()) + ")"; 
    375             ret += "[" + record.enumStrings() + "]"; 
     240        if ((bFilterIn&&bMatch)||(!bFilterIn&&!bMatch)) { 
     241          strEx::append_list(message, record.eventSource()); 
     242          if (bShowDescriptions) { 
     243            message += "(" + EventLogRecord::translateType(record.eventType()) + ")"; 
     244            message += "[" + record.enumStrings() + "]"; 
    376245          } 
    377246          hit_count++; 
    378247        } 
    379  
    380248        dwRead -= pevlr->Length;  
    381249        pevlr = (EVENTLOGRECORD *) ((LPBYTE) pevlr + pevlr->Length);  
    382250      }  
    383  
    384251      pevlr = (EVENTLOGRECORD *) &bBuffer;  
    385252    }  
    386  
    387253    CloseEventLog(hLog); 
    388254  } 
    389  
    390   if ((query.critical_count > 0) && (hit_count > query.critical_count)) { 
    391     ret = "CRITICAL: " + strEx::itos(hit_count) + " > critical: " + ret; 
    392     rCode = NSCAPI::returnCRIT; 
    393   } else if ((query.warning_count > 0) && (hit_count > query.warning_count)) { 
    394     ret = "WARNING: " + strEx::itos(hit_count) + " > warning: " + ret; 
    395     rCode = NSCAPI::returnWARN; 
    396   } else { 
    397     ret = "OK: " + strEx::itos(hit_count) + ": " + ret; 
    398   } 
    399   if (query.truncate != 0) 
    400     ret = ret.substr(0, query.truncate); 
    401   if ((query.truncate > 0) && (ret.length() > query.truncate)) 
    402     ret = ret.substr(0, query.truncate); 
    403   message = ret; 
    404   return rCode; 
     255  query.runCheck(hit_count, returnCode, message, perf); 
     256  if ((truncate > 0) && (message.length() > (truncate-4))) 
     257    message = message.substr(0, truncate-4) + "..."; 
     258  if (message.empty()) 
     259    message = "Eventlog check ok"; 
     260  return returnCode; 
    405261} 
    406262 
  • modules/CheckEventLog/CheckEventLog.h

    re26cfe0 r75d5e70  
    22 
    33#include <strEx.h> 
     4#include <checkHelpers.hpp> 
     5#include <filter_framework.hpp> 
    46 
    57class CheckEventLog { 
  • modules/CheckSystem/CheckSystem.cpp

    re26cfe0 r75d5e70  
    148148  std::list<CPULoadConatiner> list; 
    149149  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    150   bool bShowAll = false; 
    151150  bool bNSClient = false; 
    152151  CPULoadConatiner tmpObject; 
     
    155154 
    156155  MAP_OPTIONS_BEGIN(stl_args) 
    157     MAP_OPTIONS_STR("MaxWarn", tmpObject.warn.max) 
     156    MAP_OPTIONS_NUMERIC_ALL(tmpObject, "") 
    158157    MAP_OPTIONS_STR("warn", tmpObject.warn.max) 
    159     MAP_OPTIONS_STR("MinWarn", tmpObject.warn.min) 
    160     MAP_OPTIONS_STR("MaxCrit", tmpObject.crit.max) 
    161158    MAP_OPTIONS_STR("crit", tmpObject.crit.max) 
    162     MAP_OPTIONS_STR("MinCrit", tmpObject.crit.min) 
    163159    MAP_OPTIONS_STR_AND("time", tmpObject.data, list.push_back(tmpObject)) 
    164160    MAP_OPTIONS_STR_AND("Time", tmpObject.data, list.push_back(tmpObject)) 
    165     MAP_OPTIONS_BOOL_TRUE(SHOW_ALL, bShowAll) 
     161    MAP_OPTIONS_SHOWALL(tmpObject) 
    166162    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
    167163      MAP_OPTIONS_SECONDARY_BEGIN(":", p2) 
     
    173169      MAP_OPTIONS_MISSING_EX(p2, msg, "Unknown argument: ") 
    174170      MAP_OPTIONS_SECONDARY_END() 
    175     else { tmpObject.data = p__.first, list.push_back(tmpObject); } 
     171    MAP_OPTIONS_FALLBACK_AND(tmpObject.data, list.push_back(tmpObject)) 
    176172  MAP_OPTIONS_END() 
    177173 
     
    198194      } else { 
    199195        load.setDefault(tmpObject); 
    200         load.runCheck(value, returnCode, msg, perf, bShowAll); 
     196        load.runCheck(value, returnCode, msg, perf); 
    201197      } 
    202198    } 
     
    220216  } 
    221217  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    222   bool bShowAll = false; 
    223218  bool bNSClient = false; 
    224219  UpTimeConatiner bounds; 
     
    227222 
    228223  MAP_OPTIONS_BEGIN(stl_args) 
    229     MAP_OPTIONS_STR("MaxWarn", bounds.warn.max) 
     224    MAP_OPTIONS_NUMERIC_ALL(bounds, "") 
    230225    MAP_OPTIONS_STR("warn", bounds.warn.min) 
    231     MAP_OPTIONS_STR("MinWarn", bounds.warn.min) 
    232     MAP_OPTIONS_STR("MaxCrit", bounds.crit.max) 
    233226    MAP_OPTIONS_STR("crit", bounds.crit.min) 
    234     MAP_OPTIONS_STR("MinCrit", bounds.crit.min) 
    235227    MAP_OPTIONS_STR("Alias", bounds.data) 
    236     MAP_OPTIONS_BOOL_TRUE(SHOW_ALL, bShowAll) 
     228    MAP_OPTIONS_SHOWALL(bounds) 
    237229    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
    238230    MAP_OPTIONS_MISSING(msg, "Unknown argument: ") 
     
    250242  } else { 
    251243    value *= 1000; 
    252     bounds.runCheck(value, returnCode, msg, perf, bShowAll); 
     244    bounds.runCheck(value, returnCode, msg, perf); 
    253245  } 
    254246 
     
    296288  std::list<StateConatiner> list; 
    297289  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    298   bool bShowAll = false; 
    299290  bool bNSClient = false; 
    300291  StateConatiner tmpObject; 
     
    304295 
    305296  MAP_OPTIONS_BEGIN(stl_args) 
    306     /* 
    307     MAP_OPTIONS_STR("MaxWarn", tmpObject.warn.max) 
    308     MAP_OPTIONS_STR("warn", tmpObject.warn.min) 
    309     MAP_OPTIONS_STR("MinWarn", tmpObject.warn.min) 
    310     MAP_OPTIONS_STR("MaxCrit", tmpObject.crit.max) 
    311     MAP_OPTIONS_STR("crit", tmpObject.crit.min) 
    312     MAP_OPTIONS_STR("MinCrit", tmpObject.crit.min) 
    313     */ 
     297    MAP_OPTIONS_SHOWALL(tmpObject) 
    314298    MAP_OPTIONS_STR("Alias", tmpObject.data) 
    315     MAP_OPTIONS_BOOL_TRUE(SHOW_ALL, bShowAll) 
    316     MAP_OPTIONS_BOOL_FALSE(SHOW_FAIL, bShowAll) 
    317299    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
    318300    MAP_OPTIONS_SECONDARY_BEGIN(":", p2) 
     
    345327        continue; 
    346328      } 
    347       if ((info.m_dwCurrentState == SERVICE_RUNNING) && (bShowAll)) { 
     329      if ((info.m_dwCurrentState == SERVICE_RUNNING) && (*it).showAll()) { 
    348330        if (!msg.empty()) msg += " - "; 
    349331        msg += (*it).data + ": Started"; 
     
    373355      else 
    374356        value = checkHolders::state_none; 
    375       (*it).runCheck(value, returnCode, msg, perf, bShowAll); 
     357      (*it).runCheck(value, returnCode, msg, perf); 
    376358    } 
    377359 
     
    398380NSCAPI::nagiosReturn CheckSystem::checkMem(const unsigned int argLen, char **char_args, std::string &msg, std::string &perf) 
    399381{ 
    400   typedef checkHolders::CheckConatiner<checkHolders::MaxMinPercentageBoundsInt64 > MemoryConatiner; 
     382  typedef checkHolders::CheckConatiner<checkHolders::MaxMinPercentageBoundsDiskSizei64 > MemoryConatiner; 
    401383  std::list<std::string> stl_args = arrayBuffer::arrayBuffer2list(argLen, char_args); 
    402384  if (stl_args.empty()) { 
     
    412394 
    413395  MAP_OPTIONS_BEGIN(stl_args) 
    414     MAP_OPTIONS_STR("MaxWarn", bounds.warn.max) 
    415     MAP_OPTIONS_STR("MinWarn", bounds.warn.min) 
    416     MAP_OPTIONS_STR("MaxCrit", bounds.crit.max) 
    417     MAP_OPTIONS_STR("MinCrit", bounds.crit.min) 
     396    MAP_OPTIONS_DISK_ALL(bounds, "", "Free", "Used") 
    418397    MAP_OPTIONS_STR("Alias", bounds.data) 
    419     MAP_OPTIONS_BOOL_TRUE(SHOW_ALL, bShowAll) 
     398    MAP_OPTIONS_SHOWALL(bounds) 
    420399    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
    421400    MAP_OPTIONS_MISSING(msg, "Unknown argument: ") 
     
    427406    return NSCAPI::returnUNKNOWN; 
    428407  } 
    429   long long pageCommit = pObject->getMemCommit();  
    430   long long pageCommitLimit = pObject->getMemCommitLimit();  
     408  checkHolders::PercentageValueType<long long, long long> value; 
     409  value.value = pObject->getMemCommit(); 
     410  value.total = pObject->getMemCommitLimit(); 
    431411  if (bNSClient) { 
    432     msg = strEx::itos(pageCommitLimit) + "&" + strEx::itos(pageCommit); 
     412    msg = strEx::itos(value.total) + "&" + strEx::itos(value.value); 
    433413    return NSCAPI::returnOK; 
    434414  } else { 
    435     bounds.warn.max.setMax(pageCommitLimit); 
    436     bounds.warn.min.setMax(pageCommitLimit); 
    437     bounds.crit.max.setMax(pageCommitLimit); 
    438     bounds.crit.min.setMax(pageCommitLimit); 
    439     bounds.runCheck(pageCommit, returnCode, msg, perf, bShowAll); 
     415    bounds.runCheck(value, returnCode, msg, perf); 
    440416  } 
    441417  if (msg.empty()) 
     
    500476  std::list<StateConatiner> list; 
    501477  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    502   bool bShowAll = false; 
    503478  bool bNSClient = false; 
    504479  StateConatiner tmpObject; 
     
    508483 
    509484  MAP_OPTIONS_BEGIN(stl_args) 
    510     MAP_OPTIONS_STR("MaxWarnCount", tmpObject.warn.max) 
    511     MAP_OPTIONS_STR("MinWarnCount", tmpObject.warn.min) 
    512     MAP_OPTIONS_STR("MaxCritCount", tmpObject.crit.max) 
    513     MAP_OPTIONS_STR("MinCritCount", tmpObject.crit.min) 
     485    MAP_OPTIONS_NUMERIC_ALL(tmpObject, "Count") 
    514486    MAP_OPTIONS_STR("Alias", tmpObject.alias) 
    515     MAP_OPTIONS_BOOL_TRUE(SHOW_ALL, bShowAll) 
    516     MAP_OPTIONS_BOOL_FALSE(SHOW_FAIL, bShowAll) 
     487    MAP_OPTIONS_SHOWALL(tmpObject) 
    517488    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
    518489    MAP_OPTIONS_SECONDARY_BEGIN(":", p2) 
     
    550521    TNtServiceInfo info; 
    551522    if (bNSClient) { 
    552       if (bFound && bShowAll) { 
     523      if (bFound && (*it).showAll()) { 
    553524        if (!msg.empty()) msg += " - "; 
    554525        msg += (*it).data + ": Started"; 
     
    568539        value.state = checkHolders::state_stopped; 
    569540      } 
    570       (*it).runCheck(value, returnCode, msg, perf, bShowAll); 
     541      (*it).runCheck(value, returnCode, msg, perf); 
    571542    } 
    572543 
     
    603574  std::list<CounterConatiner> counters; 
    604575  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    605   bool bShowAll = false; 
    606576  bool bNSClient = false; 
    607577  /* average maax */ 
     
    617587    MAP_OPTIONS_STR("MinCrit", tmpObject.crit.min) 
    618588    MAP_OPTIONS_STR("Alias", tmpObject.data) 
    619     MAP_OPTIONS_BOOL_TRUE(SHOW_ALL, bShowAll) 
    620     MAP_OPTIONS_BOOL_FALSE(SHOW_FAIL, bShowAll) 
     589    MAP_OPTIONS_SHOWALL(tmpObject) 
    621590    MAP_OPTIONS_BOOL_EX("Averages", bCheckAverages, "true", "false") 
    622591    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
     
    629598      MAP_OPTIONS_MISSING_EX(p2, msg, "Unknown argument: ") 
    630599    MAP_OPTIONS_SECONDARY_END() 
    631     else { 
    632       tmpObject.data = p__.first; 
    633       counters.push_back(tmpObject); 
    634     } 
     600    MAP_OPTIONS_FALLBACK_AND(tmpObject.data, counters.push_back(tmpObject)) 
    635601  MAP_OPTIONS_END() 
    636602 
     
    657623      } else { 
    658624        counter.setDefault(tmpObject); 
    659         counter.runCheck(value, returnCode, msg, perf, bShowAll); 
     625        counter.runCheck(value, returnCode, msg, perf); 
    660626      } 
    661627    } catch (const PDH::PDHException e) { 
  • modules/CheckSystem/PDHCollector.cpp

    re26cfe0 r75d5e70  
    133133  }while (((waitStatus = WaitForSingleObject(hStopEvent_, checkIntervall_*100)) == WAIT_TIMEOUT)); 
    134134  if (waitStatus != WAIT_OBJECT_0) { 
    135     NSC_LOG_ERROR("Something odd happend, terminating PDH collection thread!"); 
     135    NSC_LOG_ERROR("Something odd happened, terminating PDH collection thread!"); 
    136136  } 
    137137 
     
    142142    } 
    143143 
    144     if (!CloseHandle(hStopEvent_)) 
     144    if (!CloseHandle(hStopEvent_)) { 
    145145      NSC_LOG_ERROR_STD("Failed to close stopEvent handle: " + strEx::itos(GetLastError())); 
    146     else 
     146    } else 
    147147      hStopEvent_ = NULL; 
    148148    try { 
     
    160160*/ 
    161161void PDHCollector::exitThread(void) { 
    162   MutexLock mutex(mutexHandler); 
    163   if (!mutex.hasMutex()) { 
    164     NSC_LOG_ERROR("Failed to get Mute when trying to close thread!"); 
    165     return; 
    166   } 
    167162  if (hStopEvent_ == NULL) 
    168     NSC_LOG_ERROR("Failed to get stop event!"); 
     163    NSC_LOG_ERROR("Stop event is not created!"); 
    169164  else 
    170165    if (!SetEvent(hStopEvent_)) { 
  • modules/SysTray/TrayIcon.cpp

    re26cfe0 r75d5e70  
    55#include <ShellAPI.h> 
    66 
    7 void IconWidget_::threadProc(LPVOID lpParameter) 
     7unsigned IconWidget_::threadProc(LPVOID lpParameter) 
    88{ 
    99  createDialog(); 
     10  return 0; 
    1011} 
    1112 
  • modules/SysTray/TrayIcon.h

    re26cfe0 r75d5e70  
    88class IconWidget_ { 
    99public: 
    10   void threadProc(LPVOID lpParameter); 
     10  unsigned threadProc(LPVOID lpParameter); 
    1111  void exitThread(void); 
    1212 
Note: See TracChangeset for help on using the changeset viewer.