Fedora35:ログ解析設定

Webアクセスログ解析(AWStats)のインストール

AWstatsをインストールします。

[root@www ~]# dnf -y install awstats

自動作成されているawstats.fedoraserver.jp.conf を設定します。

[root@www ~]# vi /etc/awstats/awstats.fedoraserver.jp.conf 

126行目:変更します。

LogFormat=

157行目:ホスト名を設定します。

SiteDomain="fedoraserver.jp"

172行目:除外したいドメイン名やIPアドレスを追記します。

HostAliases="localhost 127.0.0.1 REGEX[^.*fedoraserver\.jp$] REGEX[^192\.168\.1\.]"

awstats.confを設定します。

[root@www ~]# vi /etc/httpd/conf.d/awstats.conf

30行目:アクセス許可IPを追記します。

        Require ip 192.168.1.1/24

再起動します。

[root@www ~]# systemctl restart httpd

1時間毎に自動更新する設定をします。

[root@www ~]# /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=fedoraserver.jp -update

Web ブラウザを起動し、「http://fedoraserver.jp/awstats/awstats.pl」にアクセスして、作動確認します。

awstats

メールログ解析(Pfiogsumm)のインストール

pflogsumm をインストールします。

[root@www ~]# dnf -y install postfix-perl-scripts

メールログのサマリーを出力します。

[root@www ~]# perl /usr/sbin/pflogsumm -d yesterday /var/log/maillog
Postfix log summaries for Jul 29

Grand Totals
------------
messages

      8   received
      8   delivered
      2   forwarded
      1   deferred  (1  deferrals)
      0   bounced
      0   rejected (0%)
      0   reject warnings
      0   held
      0   discarded (0%)

   2428k  bytes received
   2429k  bytes delivered
      3   senders
      2   sending hosts/domains
      2   recipients
      2   recipient hosts/domains


Per-Hour Traffic Summary
------------------------
    time          received  delivered   deferred    bounced     rejected
    --------------------------------------------------------------------
    0000-0100           0          0          0          0          0
    0100-0200           0          0          0          0          0
    0200-0300           0          0          0          0          0
…

root宛てにメール送信する設定をします。

[root@www ~]# crontab -e

毎日午前1時にメール送信する設定をします。

[root@www ~]# 00 01 * * * perl /usr/sbin/pflogsumm -e -d yesterday /var/log/maillog | mail -s 'Logwatch for Postfix' root

コメント

タイトルとURLをコピーしました