Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37409640
en ru br
Репозитории ALT
S:0.9.2-alt1
5.1: 0.8-alt2.M51.1
4.1: 0.4-alt2.M41.3
4.0: 0.1-alt2.M40.1
www.altlinux.org/Changes

Группа :: Система/Настройка/Прочее
Пакет: alterator-logs

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

alterator-logs-0.8/000075500000000000000000000000001152651523500143235ustar00rootroot00000000000000alterator-logs-0.8/Makefile000064400000000000000000000003701152651523500157630ustar00rootroot00000000000000NAME=logs
DESCRIPTION="System logs"

INSTALL=/usr/bin/install

all:
clean:
install: install-module install-data

include /usr/share/alterator/build/module.mak

install-data:
install -d $(sysconfdir)/alterator
cp -a logs $(sysconfdir)/alterator
alterator-logs-0.8/applications/000075500000000000000000000000001152651523500170115ustar00rootroot00000000000000alterator-logs-0.8/applications/logs.desktop000064400000000000000000000004501152651523500213470ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-System
Icon=logs
Terminal=false
Name=System logs
X-Alterator-URI=/logs
X-Alterator-Help=logs
Name[ru]=п║п╦я│я┌п╣п╪п╫я▀п╣ п╤я┐я─п╫п╟п╩я▀
Name[uk]=п║п╦я│я┌п╣п╪п╫я√ п╤я┐я─п╫п╟п╩п╦
Name[pt_BR]=Registros do sistema
Name[es]=Usuц║rio del Sistema
alterator-logs-0.8/backend3/000075500000000000000000000000001152651523500157755ustar00rootroot00000000000000alterator-logs-0.8/backend3/logs000075500000000000000000000132441152651523500166730ustar00rootroot00000000000000#!/bin/sh

alterator_api_version=1

data_dir=/etc/alterator/logs
order_file="$data_dir/.order"
cache_dir=/var/cache/alterator/logs

mkdir -p -- "$cache_dir"

. alterator-sh-functions
. shell-quote

qdata_dir=
quote_sed_regexp_variable qdata_dir "$data_dir"

log_list()
{
# ordered list
local ordered_list="$(sed "s/.*/$qdata_dir\/&.desktop/" "$order_file")"
for i in $ordered_list;do
[ ! -s "$i" ] || echo "$i"
done

local sorted_list=" $(echo "$ordered_list"|tr '\n' ' ') "
local f
find "$data_dir" -name '*.desktop'|
while read f;do
[ -z "${sorted_list##* $f *}" ] || echo "$f"
done
}

log_basename()
{
local n=${1##*/}
echo "${n%%.desktop}"
}

log_cat()
{
local f="$1";shift
local t="$(file -b "$f")"
if [ -z "${t##bzip2 compressed data*}" ]; then
bzcat "$f" 2>/dev/null
elif [ -z "${t##gzip compressed data*}" ]; then
zcat "$f" 2>/dev/null
else
cat "$f" 2>/dev/null
fi
}

__make_timestamp()
{
path="$1";shift
find "$(dirname $path)" -type f -name "$(basename $path).*"|
LANG=C LC_ALL=C LC_COLLATE=C sort -r|
xargs -r stat -c '%n %Y'
}

# log_line_dump <log_name> <log_file>
# dump line database
log_line_dump()
{
local log_name="$1";shift
local log_file="$1";shift

#rotated path, has caching
local new_timestamp_file="$cache_dir/$log_name.newtimestamp"
local old_timestamp_file="$cache_dir/$log_name.timestamp"
local line_file="$cache_dir/$log_name.lines"

__make_timestamp "$log_file" >"$new_timestamp_file"

if cmp -- "$old_timestamp_file" "$new_timestamp_file" 2>/dev/null;then
cat "$line_file" 2>/dev/null
else
local total="0"
cut -f1 "$new_timestamp_file"|
while read f;do
local size="$(log_cat "$f"|wc -l)"
total="$(($total + $size))"
printf '%s\t%s\n' "$total" "$f"
done|
tee "$line_file"
fi
mv -f -- "$new_timestamp_file" "$old_timestamp_file"
}

# log_line_count <log_name> <log_file>
# return total number of log lines
log_line_count()
{
local log_name="$1";shift
local log_file="$1";shift

local tail_wc="$(cat "$log_file"|wc -l)"
local head_wc="$(log_line_dump "$log_name" "$log_file"|tail -n1|cut -f1)"
[ -n "$head_wc" ] || head_wc=0

echo "$(($tail_wc + $head_wc))"
}

# log_line_range <log_name> <log_file> <start> <stop>
# dump line ranges inside fileset
log_line_range()
{
local log_name="$1";shift
local log_file="$1";shift

local start="$1";shift
local stop="$1";shift

log_line_dump "$log_name" "$log_file"|
awk -v "start=$start" \
-v "stop=$stop" \
-v "log_file=$log_file" \
'BEGIN {
lo=-1; prev1=0
}
{
if (start > $1) { prev1=$1; next; }

lo=(lo == -1)?(start - prev1):1;
hi=(stop <= $1)?(stop - prev1):"$";
printf "%s\t%s\t%s\n",lo,hi,$2;
prev1=$1;
if (stop <= $1) exit;
}
END {
lo=(lo == -1)?(start - prev1):1;
hi=stop - prev1;
if (stop > prev1) printf "%s\t%s\t%s\n",lo,hi,log_file;
}'
}

# usage: log_dump <log_name> <log_file> <start> <stop>
# print page from log file
log_dump_range()
{
local log_name="$1";shift
local log_file="$1";shift
local start="$1";shift
local stop="$1";shift

log_line_range "$log_name" "$log_file" "$start" "$stop"|
while read start stop path;do
log_cat "$path"|
sed -n \
-e "$start,$stop p" \
-e "$stop q"
done
}

desktop_awk()
{
[ ! -f "$1" ] ||
alterator-dump-desktop \
-v lang="$in_language" \
-v out="X-Alterator-URI;Name" \
-v def="/notfound;" \
$1
}

on_message()
{
case "$in_action" in
read)
[ -n "$in_name" ] || return

local name="$in_name"
local desktopfile="$data_dir/$name.desktop"

#dump + total size
local path="$(desktop_awk "$desktopfile"|cut -f1)"
local total="$(log_line_count "$name" "$path")"
[ "$total" -gt 1 ] || total=1

#main data: page size and start shift
local start="${in_start:-1}"
local size="${in_size:-20}"
local old_start="$start"
local stop=

#change size: back to first page
if [ -n "$in_new_size" -a "$in_new_size" != "$in_size" ];then
size="$in_new_size"
start=1
fi

#next/back/first/last
if [ -n "$in_next" ]; then
start="$(($start + $size))"
[ "$start" -lt "$total" ] || start="$old_start"
fi

if [ -n "$in_back" ]; then
start="$(($start - $size))"
[ "$start" -ge 0 ] || start="$old_start"
fi

if [ -n "$in_first" ]; then
start=1
fi

if [ -n "$in_last" ]; then
start="$(( ( $total / $size ) * $size ))"
[ "$start" -lt 1 -o "$start" -ne "$total" ] || start="$(($start - $size))"
stop="$total"
else
stop="$(($start + $size))"
fi
[ "$start" -gt 1 ] || start=1
[ "$stop" -le "$total" ] || stop="$total"

write_string_param text "$(log_dump_range "$name" "$path" "$start" "$stop")"

local format="`_ "Lines %s-%s of %s"`"
write_string_param range "$(printf "$format" "$start" "$stop" "$total")"

write_string_param name "$name"
write_string_param start "$start"
write_string_param size "$size"
write_string_param new_size "$size"

rm -f -- "$cachefile"
;;
list)
case "$in__objects" in
avail_size)
write_enum_item "10" "`_ "10 lines"`"
write_enum_item "20" "`_ "20 lines"`"
write_enum_item "50" "`_ "50 lines"`"
write_enum_item "100" "`_ "100 lines"`"
;;
avail_log)
log_list|
while read n;do
printf '%s\t' "$(log_basename "$n")"
desktop_awk "$n"
done|
while read desktopfile path description;do
[ -f "$path" ] || continue
write_enum_item "$desktopfile" "$description"
done
;;
esac
;;
esac
}

message_loop
alterator-logs-0.8/logs/000075500000000000000000000000001152651523500152675ustar00rootroot00000000000000alterator-logs-0.8/logs/alteratord.desktop000064400000000000000000000003171152651523500210240ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-Xorg
Icon=configd
Terminal=false
Name=System configurator
Name[ru]=п║п╦я│я┌п╣п╪п╫я▀п╧ п╨п╬п╫я└п╦пЁя┐я─п╟я┌п╬я─
X-Alterator-URI=/var/log/alteratord.log
alterator-logs-0.8/logs/bacula.desktop000064400000000000000000000003211152651523500201050ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-Xorg
Icon=secure
Terminal=false
Name=Backup server
X-Alterator-URI=/var/log/bacula/log
Name[ru]=п║п╣я─п╡п╣я─ я─п╣п╥п╣я─п╡п╫п╬пЁп╬ п╨п╬п©п╦я─п╬п╡п╟п╫п╦я▐
alterator-logs-0.8/logs/iptables.desktop000064400000000000000000000002751152651523500204710ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-Xorg
Icon=configd
Terminal=false
Name=Network firewall
Name[ru]=п▒я─п╟п╫п╢п╪п╟я┐я█я─
X-Alterator-URI=/var/log/alterator-net-iptables
alterator-logs-0.8/logs/kernel.desktop000064400000000000000000000002331152651523500201400ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-Xorg
Icon=secure
Terminal=false
Name=Kernel
Name[ru]=п╞п╢я─п╬
X-Alterator-URI=/var/log/kernel/info
alterator-logs-0.8/logs/mail.desktop000064400000000000000000000002611152651523500176030ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-Xorg
Icon=secure
Terminal=false
Name=E-mail
Name[ru]=п╜п╩п╣п╨я┌я─п╬п╫п╫п╟я▐ п©п╬я┤я┌п╟
X-Alterator-URI=/var/log/mail/all
alterator-logs-0.8/logs/messages.desktop000064400000000000000000000003061152651523500204700ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-Xorg
Icon=configd
Terminal=false
Name=System messages
Name[ru]=п║п╦я│я┌п╣п╪п╫я▀п╣ я│п╬п╬п╠я┴п╣п╫п╦я▐
X-Alterator-URI=/var/log/syslog/messages
alterator-logs-0.8/logs/secure.desktop000064400000000000000000000002551152651523500201520ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-Xorg
Icon=secure
Terminal=false
Name=Security
Name[ru]=п▒п╣п╥п╬п©п╟я│п╫п╬я│я┌я▄
X-Alterator-URI=/var/log/auth/secure
alterator-logs-0.8/ui/000075500000000000000000000000001152651523500147405ustar00rootroot00000000000000alterator-logs-0.8/ui/logs/000075500000000000000000000000001152651523500157045ustar00rootroot00000000000000alterator-logs-0.8/ui/logs/ajax.scm000064400000000000000000000033761152651523500173440ustar00rootroot00000000000000(define-module (ui logs ajax)
:use-module (alterator ajax)
:use-module (alterator algo)
:use-module (alterator woo)
:export (init))

;;; Functions
(define (do-apply data)
(form-update-value-list '("start" "size" "text" "range") data))

(define (do-update . args)
(catch/message
(lambda()
(do-apply (apply woo-read-first "/logs"
'start (form-value "start")
'size (form-value "size")
'name (form-value "name")
'language (form-value "language")
args)))))

(define (do-select)
(do-apply (woo-read-first "/logs"
'name (form-value "name")
'language (form-value "language")
'last #t)))

(define (do-size)
(do-update 'new_size (form-value "new_size")))

(define (do-back)
(do-update 'back #t))

(define (do-next)
(do-update 'next #t))

(define (do-first)
(do-update 'first #t))

(define (do-last)
(do-update 'last #t))

(define (on-load)
(catch/message
(lambda()
(form-update-enum "new_size" (woo-list "/logs/avail_size" 'language (form-value "language")))
(let* ((log-list (woo-list "/logs/avail_log" 'language (form-value "language")))
(log-first (or (cond-car log-list) (woo-error (_ "No logs available"))))
(log-name (woo-get-option log-first 'name))
(log-data (woo-read-first "/logs" 'last #t 'name log-name 'language (form-value "language"))))

(form-update-enum "name" log-list)
(form-update-value-list '("name" "new_size") log-data)
(do-apply log-data))

(form-bind "name" "change" do-select)
(form-bind "new_size" "change" do-size)
(form-bind "back_button" "click" do-back)
(form-bind "next_button" "click" do-next)
(form-bind "first_button" "click" do-first)
(form-bind "last_button" "click" do-last))))
alterator-logs-0.8/ui/logs/index.html000064400000000000000000000021601152651523500177000ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<!-- log viewer module -->
<html wf="none">
<body>
<form method="POST">
<input type="hidden" name="start"/>
<input type="hidden" name="size"/>
<table style="width:100%">
<tr>
<td colspan="2">
<span translate="_">Logs:</span>&nbsp;<select name="name"/>
</td>
</tr>
<tr>
<td colspan="2" style="width:100%">
<textarea name="text" style="width:99%;height:350px" readonly="yes"></textarea>
</td>
</tr>
<tr>
<td>
<img src="/design/images/null.gif" class="first-page-button" name="first_button"/>
<img src="/design/images/null.gif" class="prev-page-button" name="back_button"/>
<img src="/design/images/null.gif" class="next-page-button" name="next_button"/>
<img src="/design/images/null.gif" class="last-page-button" name="last_button"/>
</td>
<td style="text-align:right">
<span class="alterator-label" name="range"/>&nbsp;|&nbsp;<span translate="_">Show:</span><select name="new_size"/>
</td>
</tr>
</table>
</form>
</body>
</html>
alterator-logs-0.8/ui/logs/index.scm000064400000000000000000000011641152651523500175210ustar00rootroot00000000000000(document:surround "/std/frame")

;; UI

(edit name "start" visibility #f)
(edit name "size" visibility #f)
margin "10"
(hbox align "left"
(label text (_ "Logs:"))
(label text " ")
(combobox name "name"))
(textbox name "text")
(hbox align "left"
(label name "range")
(button text (_ "Previous") name "back_button")
(button text (_ "Next") name "next_button")
(label)
(button text (_ "First page") name "first_button")
(button text (_ "Last page") name "last_button")
(label text "|")
(label text (_ "Show:"))
(label " ")
(combobox name "new_size"))
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin