performance questions
I was looking at some strace results from a process using the audit_log_user_message call and I think I see how I can eliminate some ioctls and /proc/self lookups by setting the hostname/tty parameters to non-NULL pointers pointing to NULL values.
But the exename is another story. It does a lookup each time. We have persistent processes each of which submit 100Ks (on the way to 1Ms) of audit_log_user_message events daily, so it would make a difference.
I was thinking about a patch to store off the exename statically if one isn't already in the pipeline. Let me know; I'll submit something if not.
The other question is on the auditd side. IIUC on each event the write_to_log function is checking the logfile size. Seems to me that we could limit the fstat checks to say one every ten events or so. Any problems there?
Thx,
LCB
Signature · 2 lines
LC (Lenny) Bruzenak [email protected]
Quoted 5 lines · LC Bruzenak
I was looking at some strace results from a process using the
audit_log_user_messagecall and I think I see how I can eliminate some ioctls and/proc/selflookups by setting the hostname/tty parameters to non-NULL pointers pointing to NULL values.
Quoted 7 lines
But the exename is another story. It does a lookup each time. We have persistent processes each of which submit 100Ks (on the way to 1Ms) of
audit_log_user_messageevents daily, so it would make a difference.I was thinking about a patch to store off the exename statically if one isn't already in the pipeline. Let me know; I'll submit something if not.
You might try this:
lib/audit_logging.c +3 -2
@@ -240,7 +240,7 @@ int audit_log_user_message(int audit_fd, {char buf[MAX_AUDIT_MESSAGE_LENGTH ];char addrbuf[INET6_ADDRSTRLEN ]; -char exename[PATH_MAX *2 ]; +static char exename[PATH_MAX *2 ]="" ;char ttyname[TTY_PATH ];const char *success;int ret;
@@ -262,7 +262,8 @@ int audit_log_user_message(int audit_fd,else strncat (addrbuf, addr,sizeof (addrbuf)-1 ); -_get_exename (exename,sizeof (exename)); +if (exename[0 ] ==0 ) +_get_exename (exename,sizeof (exename));if (tty ==NULL ) tty =_get_tty (ttyname,TTY_PATH );else if (*tty ==0 )
Quoted 4 lines
The other question is on the auditd side. IIUC on each event the
write_to_logfunction is checking the logfile size. Seems to me that we could limit the fstat checks to say one every ten events or so. Any problems there?
We can probably use the return value of fprintf() +1 (for the NULL byte) and just keep the running total in memory.
-Steve
Quoted 1 line · Steve Grubb
On Thursday, September 29, 2011 11:33:09 AM LC Bruzenak wrote:
...
Quoted 2 lines
You might try this:
...
lib/audit_logging.c int audit_log_user_message(int audit_fd, · line 269
Quoted 7 lines
lib/audit_logging.c +2
-1-_get_exename (exename,sizeof (exename)); +if (exename[0 ] ==0 ) +_get_exename (exename,sizeof (exename));if (tty ==NULL ) tty =_get_tty (ttyname,TTY_PATH );else if (*tty ==0 )
Well, we could (and then it would work like the others) but we really want to store the exename I think. Isn't that what becomes "exe=<EXEPATH>" in the event?
Quoted 3 lines
We can probably use the return value of
fprintf()+1 (for the NULL byte) and just keep the running total in memory.
Oh, right. That would be more precise. Good idea!
Since we're looking, what about the fstatfs in check_disk_space? Any thoughts on that one?
Thanks Steve!
LCB
Signature · 2 lines
LC (Lenny) Bruzenak [email protected]
Quoted 13 lines · LC Bruzenak
Quoted 1 line · Steve Grubb
On Thursday, September 29, 2011 11:33:09 AM LC Bruzenak wrote:
...
Quoted 1 line
You might try this:
...
Quoted 6 lines
lib/audit_logging.c +2
-1-_get_exename (exename,sizeof (exename)); +if (exename[0 ] ==0 ) +_get_exename (exename,sizeof (exename));if (tty ==NULL )
Quoted 7 lines
lib/audit_logging.c int audit_log_user_message(int audit_fd, · line 269
Quoted 3 lines
lib/audit_logging.c +0
-0tty =_get_tty (ttyname,TTY_PATH ); else if (*tty == 0)Well, we could (and then it would work like the others) but we really want to store the exename I think. Isn't that what becomes "exe=<EXEPATH>" in the event?
It does. You can strace it. :)
Quoted 7 lines
Quoted 2 lines
We can probably use the return value of
fprintf()+1 (for the NULL byte) and just keep the running total in memory.Oh, right. That would be more precise. Good idea!
Since we're looking, what about the fstatfs in
check_disk_space? Any thoughts on that one?
Probably can't get rid of that one. Many times people don't separate the audit directory to its own partition. So, we wind up sharing space with /var/log/messages which anyone can write to. Even if we had it exclusively, sometimes there is a cron job that might come and grab files for archiving in which case an internal count would be off.
-Steve