mirror of
https://github.com/clearlinux/telemetrics-client.git
synced 2026-09-01 11:15:51 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3b8d81b6d | ||
|
|
f4f012af7b | ||
|
|
9db4e1d8c9 |
+1
-1
@@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([telemetrics-client], [2.3.4], [https://clearlinux.org/])
|
||||
AC_INIT([telemetrics-client], [2.3.5], [https://clearlinux.org/])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AM_INIT_AUTOMAKE([1.14 -Wall -Werror -Wno-extra-portability foreign subdir-objects])
|
||||
AM_SILENT_RULES([yes])
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[Unit]
|
||||
Description=Telemetrics Kernel Log Scanner
|
||||
ConditionVirtualization=!container
|
||||
Requires=telemprobd.socket
|
||||
After=telemprobd.socket
|
||||
|
||||
|
||||
+15
-12
@@ -490,7 +490,7 @@ static bool deliver_record(TelemPostDaemon *daemon, char *headers[], char *body,
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool process_staged_record(char *filename, bool is_retry, TelemPostDaemon *daemon)
|
||||
bool process_staged_record(char *filename, TelemPostDaemon *daemon)
|
||||
{
|
||||
int k;
|
||||
bool ret = false;
|
||||
@@ -530,20 +530,12 @@ bool process_staged_record(char *filename, bool is_retry, TelemPostDaemon *daemo
|
||||
goto end_processing_file;
|
||||
}
|
||||
|
||||
/* Retries should not be recorded */
|
||||
if (is_retry == false) {
|
||||
/** Journal entry **/
|
||||
save_entry_to_journal(daemon, current_time, headers);
|
||||
/** Record retention **/
|
||||
apply_retention_policies(daemon, body);
|
||||
}
|
||||
|
||||
/** Record delivery **/
|
||||
if (!daemon->record_server_delivery_enabled) {
|
||||
telem_log(LOG_INFO, "record server delivery disabled\n");
|
||||
// Not an error condition
|
||||
ret = true;
|
||||
goto end_processing_file;
|
||||
goto end_record_delivery;
|
||||
}
|
||||
|
||||
/** Spool policies **/
|
||||
@@ -571,6 +563,17 @@ bool process_staged_record(char *filename, bool is_retry, TelemPostDaemon *daemo
|
||||
/** Deliver or spool **/
|
||||
ret = deliver_record(daemon, headers, body, cfg_file);
|
||||
|
||||
end_record_delivery:
|
||||
/** Save record once it is properly delivered, if record
|
||||
* is spooled the record is not saved to journal until
|
||||
* delievered on a re-try **/
|
||||
if (ret) {
|
||||
/** Save to journal **/
|
||||
save_entry_to_journal(daemon, current_time, headers);
|
||||
/** Record retention **/
|
||||
apply_retention_policies(daemon, body);
|
||||
}
|
||||
|
||||
end_processing_file:
|
||||
/** Update spool size if record will be removed **/
|
||||
if (ret) {
|
||||
@@ -625,7 +628,7 @@ int staging_records_loop(TelemPostDaemon *daemon)
|
||||
telem_log(LOG_ERR, "Failed to allocate memory for staging record full path\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (process_staged_record(record_path, true, daemon)) {
|
||||
if (process_staged_record(record_path, daemon)) {
|
||||
unlink(record_path);
|
||||
processed++;
|
||||
}
|
||||
@@ -721,7 +724,7 @@ void run_daemon(TelemPostDaemon *daemon)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* Process inotify event */
|
||||
if (process_staged_record(record_name, false, daemon)) {
|
||||
if (process_staged_record(record_name, daemon)) {
|
||||
unlink(record_name);
|
||||
}
|
||||
free(record_name);
|
||||
|
||||
@@ -85,11 +85,9 @@ void close_daemon(TelemPostDaemon *daemon);
|
||||
* Processed record written on disk
|
||||
*
|
||||
* @param filename a pointor to record on disk
|
||||
* @param is_retry a boolean value that indicates if
|
||||
* the record has been previously processed.
|
||||
* @param daemon post to telemetry post daemon
|
||||
*/
|
||||
bool process_staged_record(char *filename, bool is_retry, TelemPostDaemon *daemon);
|
||||
bool process_staged_record(char *filename, TelemPostDaemon *daemon);
|
||||
|
||||
/**
|
||||
* Scans staging directory to process files that were
|
||||
@@ -107,6 +105,7 @@ int staging_records_loop(TelemPostDaemon *daemon);
|
||||
* @param body a pointer to the payload
|
||||
* @param cfg_file a pointer to a non-default configuration
|
||||
* file to be used.
|
||||
* @return true if successful, false otherwise
|
||||
*/
|
||||
bool post_record_http(char *headers[], char *body, char *cfg_file);
|
||||
|
||||
|
||||
+4
-4
@@ -62,7 +62,7 @@ START_TEST(check_handle_client_with_no_data)
|
||||
bool success;
|
||||
char *filename = ABSTOPSRCDIR "/tests/telempostd/empty_message";
|
||||
|
||||
success = process_staged_record(filename, false, &tdaemon);
|
||||
success = process_staged_record(filename, &tdaemon);
|
||||
// Return true to remove corrupted record
|
||||
ck_assert(success == true);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ START_TEST(check_handle_client_with_incorrect_data)
|
||||
bool success;
|
||||
char *filename = ABSTOPSRCDIR "/tests/telempostd/incorrect_message";
|
||||
|
||||
success = process_staged_record(filename, false, &tdaemon);
|
||||
success = process_staged_record(filename, &tdaemon);
|
||||
// Return true to remove corrupted record
|
||||
ck_assert(success == true);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ START_TEST(check_process_record_with_correct_size_and_data)
|
||||
bool success;
|
||||
char *filename = ABSTOPSRCDIR "/tests/telempostd/correct_message";
|
||||
|
||||
success = process_staged_record(filename, false, &tdaemon);
|
||||
success = process_staged_record(filename, &tdaemon);
|
||||
ck_assert(success == true);
|
||||
}
|
||||
END_TEST
|
||||
@@ -100,7 +100,7 @@ START_TEST(check_process_record_with_incorrect_headers)
|
||||
bool success;
|
||||
char *filename = ABSTOPSRCDIR "/tests/telempostd/incorrect_headers";
|
||||
|
||||
success = process_staged_record(filename, false, &tdaemon);
|
||||
success = process_staged_record(filename, &tdaemon);
|
||||
// Return true to remove corrupted record
|
||||
ck_assert(success == true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user