blob: 53591421b858119bded5ab302062504177ec4f72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/usr/bin/env bash
scriptlocalpath="";
dbpass='';
PrepareInputFiles() {
local sincedate=$1;
local untildate=$2;
local inputfilename=$3;
journalctl -u ssh -S "${sincedate}" -U "${untildate}" > "${scriptlocalpath}/${inputfilename}";
}
ClearTempFiles() {
local UpperRangeShort=$(date '+%Y-%m' --date 'today');
local inputfilename=$1;
if [ -f "${scriptlocalpath}/${inputfilename}" ]; then
mv "${scriptlocalpath}/${inputfilename}" "${scriptlocalpath}/backup/${UpperRangeShort}${inputfilename}";
else
echo "did not find ${inputfilename} file";
fi
}
main() {
local UpperRangeShort=$(date '+%Y-%m' --date 'today');
local LowerRangeShort=$(date '+%Y-%m' --date '1 week ago');
local UpperRange="${UpperRangeShort}-01";
local LowerRange="${LowerRangeShort}-01";
local logfilename='sshlogs';
PrepareInputFiles ${LowerRange} ${UpperRange} ${logfilename};
python3 "${scriptlocalpath}/ssh_login_parser.py" ${LowerRange} ${UpperRange} ${logfilename} ${dbpass};
ClearTempFiles ${logfilename};
}
main;
|