mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-25 06:10:20 +00:00
new head tail function and get head tail of pihole-FTL.log instead of just head
Signed-off-by: Jacob Salmela <jacob.salmela@pi-hole.net>
This commit is contained in:
parent
7159ecb632
commit
d9d3caec22
1 changed files with 29 additions and 1 deletions
|
@ -958,7 +958,7 @@ list_files_in_dir() {
|
||||||
"${PIHOLE_WEB_SERVER_ERROR_LOG_FILE}") make_array_from_file "${dir_to_parse}/${each_file}" 25
|
"${PIHOLE_WEB_SERVER_ERROR_LOG_FILE}") make_array_from_file "${dir_to_parse}/${each_file}" 25
|
||||||
;;
|
;;
|
||||||
# Same for the FTL log
|
# Same for the FTL log
|
||||||
"${PIHOLE_FTL_LOG}") make_array_from_file "${dir_to_parse}/${each_file}" 25
|
"${PIHOLE_FTL_LOG}") head_tail_log "${dir_to_parse}/${each_file}" 35
|
||||||
;;
|
;;
|
||||||
# parse the file into an array in case we ever need to analyze it line-by-line
|
# parse the file into an array in case we ever need to analyze it line-by-line
|
||||||
*) make_array_from_file "${dir_to_parse}/${each_file}";
|
*) make_array_from_file "${dir_to_parse}/${each_file}";
|
||||||
|
@ -991,6 +991,34 @@ show_content_of_pihole_files() {
|
||||||
show_content_of_files_in_dir "${LOG_DIRECTORY}"
|
show_content_of_files_in_dir "${LOG_DIRECTORY}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
head_tail_log() {
|
||||||
|
# The file being processed
|
||||||
|
local filename="${1}"
|
||||||
|
# The number of lines to use for head and tail
|
||||||
|
local qty="${2}"
|
||||||
|
local head_line
|
||||||
|
local tail_line
|
||||||
|
# Put the current Internal Field Separator into another variable so it can be restored later
|
||||||
|
OLD_IFS="$IFS"
|
||||||
|
# Get the lines that are in the file(s) and store them in an array for parsing later
|
||||||
|
IFS=$'\r\n'
|
||||||
|
local log_head=()
|
||||||
|
log_head=( $(head -n ${qty} ${filename}) )
|
||||||
|
log_write " ${COL_CYAN}-----head of $(basename ${filename})------${COL_NC}"
|
||||||
|
for head_line in "${log_head[@]}"; do
|
||||||
|
log_write " ${head_line}"
|
||||||
|
done
|
||||||
|
log_write ""
|
||||||
|
local log_tail=()
|
||||||
|
log_tail=( $(tail -n ${qty} ${filename}) )
|
||||||
|
log_write " ${COL_CYAN}-----tail of $(basename ${filename})------${COL_NC}"
|
||||||
|
for tail_line in "${log_tail[@]}"; do
|
||||||
|
log_write " ${tail_line}"
|
||||||
|
done
|
||||||
|
# Set the IFS back to what it was
|
||||||
|
IFS="$OLD_IFS"
|
||||||
|
}
|
||||||
|
|
||||||
analyze_gravity_list() {
|
analyze_gravity_list() {
|
||||||
echo_current_diagnostic "Gravity list"
|
echo_current_diagnostic "Gravity list"
|
||||||
local head_line
|
local head_line
|
||||||
|
|
Loading…
Reference in a new issue