[Orca-dev] orcallator.se patches

Blair Zajac blair at orcaware.com
Thu May 27 22:18:27 PDT 2004


Dmitry Berezin wrote:

> Blair,
> 
>  
> 
> Here are some orcallator.se patches that I was talking about previously.
> 
>  
> 
> Two small patches – logfile compression and timestamp do not need any 
> further explanation.

Dmitry,

In the future, let's have separate emails for each patch, otherwise it 
gets hard to reply to each one specifically.

Can you try this patch to fix the log file compression problem.  This 
one makes me feel much better in the way the code is written.

I don't have a Solaris box to try this on.  Right now I'm just looking 
to make sure it "compiles" with SE.  I'm pretty certain the logic is 
correct.

--- data_gatherers/orcallator/orcallator.se     (revision 326)
+++ data_gatherers/orcallator/orcallator.se     (working copy)
@@ -699,7 +699,8 @@
    char   tm_buf[32];
    int    file_number;
    int    need_new_log_file;
-  int    exists;
+  int    exists_uncompressed;
+  int    exists_compressed;
    int    result;
    int    i;

@@ -744,32 +745,52 @@

      // Get the new filename.  Check for already existing uncompressed
      // log filenames and compressed log filenames.
-    file_number = 0;
      strftime(tm_buf, sizeof(tm_buf), "%Y-%m-%d", now);
+
+    // If the previous log filename has the same date, then increment
+    // the file number, otherwise reset it to 0.  The first time
+    // through, output_filename will be nil.
+    if (nil != output_filename && output_filename =~ tm_buf) {
+      file_number++;
+    } else {
+      file_number = 0;
+    }
+
      while (1 == 1) {
-      exists          = 0;
+
+      // Check for the existence of an uncompressed and compressed
+      // versions of the output log file.  If there is an uncompressed
+      // one but not a compressed once, then compress it in
+      // background.  If either an uncompressed or compressed file
+      // exist, then go to the next file number.
        output_filename = sprintf("%s/orcallator-%s-%03d", output_directory,
                                                           tm_buf,
                                                           file_number);
        result          = stat(output_filename, log_file_stat);
        if (result != -1) {
-        exists = 1;
-        if (compress != nil) {
-          system(sprintf(compress, output_filename));
-        }
+        exists_uncompressed = 1;
        } else {
-        for (i=0; i<NUMBER_COMPRESS_SUFFIXES; ++i) {
-          compressed_filename = sprintf("%s%s", output_filename,
-                                                compression_suffixes[i]);
-          result              = stat(compressed_filename, log_file_stat);
-          if (result != -1) {
-            exists = 1;
-            break;
-          }
+        exists_uncompressed = 0;
+      }
+
+      exists_compressed = 0;
+      for (i=0; i<NUMBER_COMPRESS_SUFFIXES; ++i) {
+        compressed_filename = sprintf("%s%s", output_filename,
+                                              compression_suffixes[i]);
+        result              = stat(compressed_filename, log_file_stat);
+        if (result != -1) {
+          exists_compressed = 1;
+          break;
          }
        }

-      if (exists != 0) {
+      if (nil != compress &&
+          0 != exists_uncompressed &&
+          0 == exists_compressed) {
+        system(sprintf(compress, output_filename));
+      }
+
+      if (0 != exists_uncompressed && 0 != exists_compressed) {
          file_number++;
        } else {
          break;

Best,
Blair

-- 
Blair Zajac <blair at orcaware.com>
Plots of your system's performance - http://www.orcaware.com/orca/



More information about the Orca-dev mailing list