[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ossec-cvs] ossec-hids: run_check.c (HEAD) [dcid]



Module name:	ossec-hids
Changes by:	dcid	07/08/09 22:43:16

Modified files:
	run_check.c

Log message:
Description: Commiting Jeff Schroeder patch for syscheckd. His comments:
SCHED_BATCH is a Linux process scheduler added in 2.6.16 designed to
improve interactivity by giving lower priority to non-interactive and
cpu intensive processes. There is a brief description of SCHED_BATCH
here: http://kernelnewbies.org/Linux_2_6_16
Reviewed by: dcid, jeff
Bug:

Index: run_check.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/syscheckd/run_check.c,v
diff -u -r1.28 -r1.29
--- run_check.c	10 Aug 2007 00:56:23 -0000	1.28
+++ run_check.c	10 Aug 2007 01:43:16 -0000	1.29
@@ -5,11 +5,17 @@
  *
  * This program is a free software; you can redistribute it
  * and/or modify it under the terms of the GNU General Public
- * License (version 2) as published by the FSF - Free Software
+ * License (version 3) as published by the FSF - Free Software
  * Foundation
  */
 
 
+/* SCHED_BATCH is Linux specific and is only picked up with _GNU_SOURCE */
+#ifdef __linux__
+	#define _GNU_SOURCE
+	#include <sched.h>
+#endif
+
 #include "shared.h"
 #include "syscheck.h"
 #include "os_crypto/md5/md5_op.h"
@@ -89,6 +95,20 @@
     time_t prev_time_rk = 0;
     time_t prev_time_sk = 0;
     
+    /*
+     * SCHED_BATCH forces the kernel to assume this is a cpu intensive process
+     * and gives it a lower priority. This keeps ossec-syscheckd from reducing
+     * the interactity of an ssh session when checksumming large files.
+     * This is available in kernel flavors >= 2.6.16
+     */
+    #ifdef SCHED_BATCH
+    struct sched_param pri;
+    pri.sched_priority = 0;
+    
+    int status = sched_setscheduler(0, SCHED_BATCH, &pri);
+    
+    debug1("%s: Setting SCHED_BATCH returned: %d", ARGV0, status);
+    #endif
             
     #ifdef DEBUG
     verbose("%s: Starting daemon ..",ARGV0);


OSSEC home | Main Index | Thread Index


OSSEC project: www.ossec.net.
Mailling list information: http://www.ossec.net/en/mailing_lists.html.