Menu

#5 logging failure Proc Trigger contains /

open
nobody
Server (2)
5
2001-10-20
2001-10-20
No

The logging code would fail if the Proc entity trigger
contains `/' For example when you're matching a path
and process name.

Attached is a patch to get around it, but ideally
should be modified to work around all characters
illegal to be in path/filenames.

(side note, monitoring still works, but no log is ever
written)

---- begin patch ----
> diff -u DataLogFile.py.orig DataLogFile.py
--- DataLogFile.py.orig Sat Oct 20 11:38:54 2001
+++ DataLogFile.py Sat Oct 20 11:42:47 2001
@@ -16,7 +16,7 @@
''' # '

import os, sys, socket, string
-import time
+import time, re

class DataLogFile:
def __init__ (self, report, moduleVersion,
fields):
@@ -61,8 +61,13 @@
if not
os.path.exists('CollectedData/%s%02d/%02d/%s' %(year,
month, day, self.host)):
os.mkdir('CollectedData/%s%02d/%02d/%s'
%(year, month, day, self.host))

+ # Replace any `/' in subentity (e.g. path and
process name match in
+ # Proc module) Otherwise, the process will be
monitored, but no logs
+ # will ever be written.
+ newsubentity = re.sub('/', '%2F',
self.subentity)
+
# Define the filename for convenience
- z =
'CollectedData/%s%02d/%02d/%s/%s%02d%02d.%s_%s_%s'
%(year, month, day, self.host, year, month, day,
self.host, self.entity, self.subentity)
+ z =
'CollectedData/%s%02d/%02d/%s/%s%02d%02d.%s_%s_%s'
%(year, month, day, self.host, year, month, day,
self.host, self.entity, newsubentity)

# If the file doesn't exist
if not os.path.exists('%s.data' %(z)):

Discussion


Log in to post a comment.