This change contains:
* New configuration keys: record_retention_enabled and
record_server_delivery_enabled. These keys are needed to control
remote delivery of records and record retention. These keys are
optional to preserve backward compatibility with existing custom
configurations.
* Record copy implementation. This change allows to save copies of
records locally when feature is enabled in configuration. This
operation is independent of record spooling and record reporting
to remote server.
* New telem_journal argument to allow record payload print from
local copy (if it exists).
Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
This change fixes memory leaks present in journal printing command line
interface and journal printing api.
Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
Random id generation function in telemetry.c is equivalent to function
in util.c, this change reuses the function defined in util.c in
telemetry.c and removes the no longer needed function.
Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
Addressing comments from first code review and fixing travis-ci
check_journal error in prune test.
Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
This change adds a logging mechanism for records submitted to telemetry
client. A basic journal is added to keep track of the last 100 valid
records that the daemon processed.
This journal can be queried by a new command line interface that was
added as part of the change 'telem_journal'.
Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
* An event_id header is needed to group records when multiple records
are generated by same event.
* Adding new available parameter to telem_record_gen, making possible
for this utility to tag multiple records with same event_id.
Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
Because telemd does not restart when an update is installed the daemon
could get out of sync with probes if a new version of a probe requires a
new version of telemd. This change will trigger a restart when an update
takes place.
The call to "fprint()" is a typo and should be "fprintf()".
Also, the "error->message" string is an artifact from the time when
telemetrics-client used glib. Now it uses libnica, which propogates
errors differently. Simply remove the format specifier for now.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Additional headers added: board_name, cpu_model, and bios_version.
* Board name is a combination of board_name and board_vendor from
dmi file system.
* CPU model is read from /proc/cpuinfo.
* BIOS version is taken from dmi file system.
Because log messages from services contain arbitrary data, and sometimes
this data is privacy sensitive, only enable the log level filters when
the privacy filter override is in effect.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
The current behavior of the configuration code is to print a generic
error message and exit if configuration parsing fails.
To clarify the reason for exiting, and thus make the error message more
actionable, print an additional error message that describes which key
from the config is affected and the type of value it accepts.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
When a key from a INI file is missing, libnica returns NULL, so we need
to properly check for a non-NULL return value before passing it to
strdup().
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Since strlen(opt_class) is already called before this for loop, there is
no need to call it again. It also avoids repeatedly calling strlen() as
part of the for-loop conditional check.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Since the code repeats the same logic in several places, it is
convenient to split the routine into a helper function, startswith().
This also fixes a bug with the earlier port to libnica: in the
in_clr_build() function, strstr() was chosen as the replacement function
instead of strncmp(), which means a match will be found in any part of
the string. However, a match should only be found when it is a prefix.
To fix, switch the strstr() in that function to use startswith() as
well.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
During the processing of a core file or sending telemetry, any numbers
of errors may occur. Make sure the core file is not unlinked under these
conditions.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
When the path filters for privacy are in effect, backtraces are scrubbed
from records, and this results in the core files being unlinked.
However, this is not friendly behavior for the developer. A common
situation that triggers the path filters is installing custom binaries
on the system (say, under /usr/local/bin or /opt/bin) for testing
purposes. To better enable developers to debug their programs, having
the core files available to process with gdb is very valuable.
Eventually, I would like to add an opt-in to keep all core files, but
I'll wait until the configuration code is refactored.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
When the daemon is sitting idle, we are seeing libcurl consume around
2MB of memory, which had been previously allocated on-the-fly for its
global environment.
To have more control over this memory consumption, making sure the
daemon uses as little memory as possible when doing no work, explicitly
allocate the libcurl global environment before each POST and deallocate
it afterwards.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
In case the value returned by SYSLOG_ACTION_SIZE_BUFFER exceeds MAX_BUF,
the buffer later allocated has size MAX_BUF, but SYSLOG_ACTION_READ may
read more than MAX_BUF bytes to store in the buffer, leading to a buffer
overrun.
Fix the issue by ensuring SYSLOG_ACTION_READ reads at most "buflen"
bytes, the size of the allocated buffer.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Since loopsize is initialized to 0, the conditional statement where
loopsize increments led to the buffer size check not being executed the
first time through the loop.
Simply remove the counter variable to fix the issue.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This completes the glib dependency removal work. The next commit will
clean up the makefiles and documentation.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
The checks in is_banned_path() for a path prefix not under /usr needed
to be connected with a logical AND, not OR, as implied by the recent
changes.
Also, use an explicit logical OR for the other two groups of
conditionals so that they are grouped similarly to the checks that
required an AND.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
As far as I can tell, the standard library doesn't have a function to
check for an ASCII string. Equivalently, we can iterate over each
character in the string, byte by byte, and verify that only 7-bit
characters are present.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
One more binary was using GOptionContext: telem-record-gen. Convert it
to use getopt_long() as well.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Continuing the removal of dependency on glib, switch to use
getopt_long() instead of the GOptionContext API for the crash probe.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>