HP-UX 11i Version 1.5 Kernel Logging

Kernel Logging
Instrumenting Kernel Subsystems for Kernel Logging
Chapter 18
The data passed to the KL infrastructure can be combined with a user-friendly message
describing the event and its implications. These user-friendly messages are composed, stored,
and built by you, in a message catalog file. The steps to complete this task are given below.
But first, a couple of examples.
Suppose a kernel developer instruments some part of the VFS subsystem (subsystem ID
KL_VFS) and wants to log a message when there is something wrong with a file whose name
is specified, for example, through an open() system call. The developer wants the full
message about the event to be “Could not open foo.bar file due to I/O related
error.” Such a message has a static part: Could not open ... file due to I/O related
error”; and a dynamic part:
filename
, in this case, foo.bar. To avoid consuming memory,
the static part of the message is not logged in the kernel. The dynamic part,
filename
, is
logged, however, via the KL_LOG_STR macro with a string pointer pointing to the foo.bar
string. At the same time, the following string is added to the local header file as the static part
of the message associated with this instrumentation point: Could not open %s file due to
I/O related error.
Or, suppose a kernel developer wants to log the following message: “I/O related error
while accessing file, inode is 505, erno is 22.” In this case, the instrumentation
point uses the KL_LOG_INFO macro and the user-friendly message is: I/O related error
while accessing file, inode is %lld, errno is %lld.
NOTE Because the Kernel Logging infrastructure accepts 64-bit integers and the
decoder of the KL files is a 32-bit command, use %lld (or %llx, %llu, etc.)
templates to display the integers.
Step 1. Compose the user-friendly message that will be logged when this instrumentation
point is reached by a running system.
Step 2. Edit the message catalog file,
/us/core/lan/src/NETTRACELOG/format/klfmt.msg, on the view server and
add your message(s). The format of this file is as follows:
$set
N subsystem_ID
n message
.
.
.
where
N
is the number and
subsystem_ID
is the ID assigned to your kernel
subsystem by the KL team;
n
is the number you have assigned to an event ID, and
message
is the user-friendly message you have composed for that event.