![]() |
Icinga-core 1.4.0
next gen monitoring
|
functions to read and filter log files in normal and reverse order More...
#include "../include/cgiutils.h"
#include "../include/readlogs.h"
Go to the source code of this file.
Functions | |
log reading | |
int | add_log_filter (int requested_filter, int include_exclude) |
Add Filter to the list of log filters. | |
int | get_log_entries (char *log_file, char *search_string, int reverse, time_t ts_start, time_t ts_end) |
Read's a defined log file and stores the entries into entry list struct. | |
void | free_log_filters (void) |
frees all memory allocated to list of log filters in memory | |
void | free_log_entries (void) |
frees all memory allocated to list of log entries in memory | |
log archive determination | |
void | get_log_archive_to_use (int archive, char *file_name, int file_name_length) |
returns the file name of a log file depending on archive number and log_rotation_method | |
int | determine_archive_to_use_from_time (time_t target_time) |
returns an archive number for a given timestamp corresponding to log_rotation_method | |
void | determine_log_rotation_times (int archive) |
determines the log rotation times | |
Variables | |
initializing lists | |
logfilter * | filter_list = NULL |
logentry * | entry_list = NULL |
logentry * | last_entry = NULL |
external vars | |
int | log_rotation_method |
char | log_file [MAX_FILENAME_LENGTH] |
char | log_archive_path [MAX_FILENAME_LENGTH] |
vars for log archive determination | |
time_t | this_scheduled_log_rotation = 0L |
time_t | last_scheduled_log_rotation = 0L |
time_t | next_scheduled_log_rotation = 0L |
functions to read and filter log files in normal and reverse order
Definition in file readlogs.c.
int add_log_filter | ( | int | requested_filter, |
int | include_exclude | ||
) |
Add Filter to the list of log filters.
[in] | requested_filter | the id of the log entry you want to filter for |
[in] | include_exclude | type of filter
|
READLOG_OK | |
READLOG_ERROR | |
READLOG_ERROR_MEMORY |
With this function you can add filters before reading the actual log entries from file. This will prevent allocating memory for log entries we don't need anyway. Be aware that you can use only one type of filtering (include or exclude). If you want to have all entries except a view, then use the filter with exclude. If you need just a few defined ones (like in notifications.c) then use include.
Definition at line 83 of file readlogs.c.
int determine_archive_to_use_from_time | ( | time_t | target_time | ) |
returns an archive number for a given timestamp corresponding to log_rotation_method
[in] | target_time | the timestamp for which the archive number should be returned for |
target_time
This function determines log archive to use, given a specific time. The log archive number represents the log file.
In case the log_rotation_method
would be daily then this archive numbers would return:
Definition at line 471 of file readlogs.c.
void determine_log_rotation_times | ( | int | archive | ) |
determines the log rotation times
[in] | archive | number of archive to determine the log rotation times for |
determines the log rotation times - past, present, future - depending on archive
number and log_rotation_method
Definition at line 506 of file readlogs.c.
void free_log_entries | ( | void | ) |
frees all memory allocated to list of log entries in memory
Definition at line 387 of file readlogs.c.
void free_log_filters | ( | void | ) |
frees all memory allocated to list of log filters in memory
Definition at line 369 of file readlogs.c.
void get_log_archive_to_use | ( | int | archive, |
char * | file_name, | ||
int | file_name_length | ||
) |
returns the file name of a log file depending on archive
number and log_rotation_method
[in] | archive | number of log archive to return file name for |
[out] | file_name | returns the file name corresponding to archive |
[in] | file_name_length | the maximum length of the char in file_name |
This function determines the log file we should use (from current time). Depending which archive number given it returns the full file name of the log file we can read. (get_log_entries)
Definition at line 417 of file readlogs.c.
int get_log_entries | ( | char * | log_file, |
char * | search_string, | ||
int | reverse, | ||
time_t | ts_start, | ||
time_t | ts_end | ||
) |
Read's a defined log file and stores the entries into entry list struct.
[in] | log_file | the full path of the log file to read |
[in] | search_string | a string you are searching for. Set to NULL to disable search function |
[in] | reverse | this bool defines which order the log entries should return |
[in] | ts_start | defines the start timestamp for log entries
|
[in] | ts_end | defines the end timestamp for log entries
|
READLOG_OK | |
READLOG_ERROR | |
READLOG_ERROR_MEMORY | |
READLOG_ERROR_NOFILE | |
READLOG_ERROR_FILTER |
This functions reads a log_file
and and try's (if set) to filter for a search string. This search string uses regular expressions. The reverse option defines if you want have your log entries returned in normal or revers order. Normal order for returning would be from the newest entry to the oldest. You can also set a time "window". This defines if you want to exclude entries which are outside of these "window". Then only entries will be returned which are between start and end. Very useful if user has all entries in one log file.
Definition at line 142 of file readlogs.c.
logentry* entry_list = NULL |
the list with all current logentries
Definition at line 36 of file readlogs.c.
logfilter* filter_list = NULL |
list of filters which should applyed during log reading
Definition at line 35 of file readlogs.c.
logentry* last_entry = NULL |
the last used log entry element
Definition at line 37 of file readlogs.c.
time_t last_scheduled_log_rotation = 0L |
timestamp of last log rotation
Definition at line 52 of file readlogs.c.
char log_archive_path[MAX_FILENAME_LENGTH] |
char log_file[MAX_FILENAME_LENGTH] |
the log rotation method of the main Icinga log file see common.h
time_t next_scheduled_log_rotation = 0L |
timestamp of next log rotation
Definition at line 53 of file readlogs.c.
time_t this_scheduled_log_rotation = 0L |
timestamp of current log rotation
Definition at line 51 of file readlogs.c.