commit 33340dc9dd33eed45693bbabf971b8b6b00e32f2 Author: Nis Börge Wechselberg Date: Sat Feb 1 20:56:42 2014 +0100 Initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..aa686c0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +Copyright (c) 2014 Nis Wechselberg + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..b28aa7e --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Prosody-Logwatch + +Scripts to extend logwatch to parse Logfiles from Prosody XMPP-Server. + +## License + +AntennaPod is licensed under the MIT License. You can find the license text in the LICENSE file. diff --git a/conf/logfiles/chatlog.conf b/conf/logfiles/chatlog.conf new file mode 100644 index 0000000..0f5a8dc --- /dev/null +++ b/conf/logfiles/chatlog.conf @@ -0,0 +1,12 @@ +# What actual file? Defaults to LogPath if not absolute path.... +LogFile = prosody/prosody.log +LogFile = prosody/prosody.err +LogFile = prosody/prosody.log.1 +LogFile = prosody/prosody.err.1 + + +# If the archives are searched, here is one or more line +# (optionally containing wildcards) that tell where they are... +#If you use a "-" in naming add that as well -mgt +Archive = prosody/prosody.log.*.gz +Archive = prosody/prosody.err.*.gz diff --git a/conf/services/prosody.conf b/conf/services/prosody.conf new file mode 100644 index 0000000..3040180 --- /dev/null +++ b/conf/services/prosody.conf @@ -0,0 +1,14 @@ +# You can put comments anywhere you want to. They are effective for the +# rest of the line. + +# this is in the format of = . Whitespace at the beginning +# and end of the lines is removed. Whitespace before and after the = sign +# is removed. Everything is case *insensitive*. + +# Yes = True = On = 1 +# No = False = Off = 0 + +Title = "Prosody" + +# Which logfile group... +LogFile = chatlog diff --git a/scripts/services/prosody b/scripts/services/prosody new file mode 100755 index 0000000..8953586 --- /dev/null +++ b/scripts/services/prosody @@ -0,0 +1,78 @@ +#!/usr/bin/perl +my $Debug = $ENV{'PROSODY_DEBUG'} || 0; +my $Detail = $ENV{'prosody_detail'} || $ENV{'PROSODY_DETAIL_LEVEL'} || 0; +my $IgnoreHost = $ENV{'prosody_ignore_host'} || ""; + +if ( $Debug >= 5 ) { + print STDERR "\n\nDEBUG \n\n"; +} + +while (defined($ThisLine = )) { + # remove timestamp. We can't use *RemoveHeaders because we need the + # service name + # $ThisLine =~ s/^\w{3} .\d \d\d:\d\d:\d\d (?:[^\s:]* |)//; + $ThisLine =~ s/^\w{3} .\d \d\d:\d\d:\d\d //; + if ( $ThisLine =~ /Re-opening log files/ or + $ThisLine =~ /^jabber.enbewe.de:saslauth/ or + $ThisLine =~ /^c2s.*?Client connected/ or + $ThisLine =~ /mod_posix.*?Received SIGHUP/ or + $ThisLine =~ /general.*?Reloading configuration file/ or + $ThisLine =~ /c2s.*?Client disconnected/ or + $ThisLine =~ /^s2sin.*?incoming s2s stream (.*?)->jabber.enbewe.de closed/ or + $ThisLine =~ /sent dialback key on outgoing s2s stream/ or + $ThisLine =~ /s2sout.*?outgoing s2s stream jabber.enbewe.de->(.*?) closed/ ) { + # We don't care about these + } elsif ( $ThisLine =~ /^s2sin.*?incoming s2s connection ([^\s]*?)->jabber.enbewe.de complete/ ) { + # Count incoming connections + $IncComplete{$1}++; + } elsif ( $ThisLine =~ /^s2sout.*?Beginning new connection attempt to ([^\s]*?)/ ) { + # Outgoing attempts + $OutAttempt{$1}++; + } elsif ( $ThisLine =~ /^s2sout.*?outgoing s2s connection jabber.enbewe.de->([^\s]*?) complete/ ) { + # Outgoing complete + $OutComplete{$1}++; + } elsif ( $ThisLine =~ /c2s.*?Authenticated as ([^\s]*?)$/ ) { + # Connected users + $Authenticated{$1}++; + } else { + # Report any unmatched entries... + chomp($ThisLine); + $OtherList{$ThisLine}++; + } +} + +################################################ + +if ( ( keys %IncComplete ) or ( keys %OutComplete ) ) { + print "\nS2S Connections:". + "\n====================================". + "\n Incoming:"; + + foreach $Host ( sort keys %IncComplete ) { + print "\n $Host: $IncComplete{$Host}"; + } + + print "\n\n Outgoing:"; + + foreach $Host ( sort keys %OutComplete ) { + print "\n $Host: $OutComplete{$Host}"; + } +} + +if ( keys %Authenticated ) { + print "\n\nUser logins:". + "\n===================================="; + + foreach $User ( sort {$a cmp $b} keys %Authenticated ) { + print "\n $User: $Authenticated{$User}"; + } +} + +if (keys %OtherList) { + print "\n\n**Unmatched Entries**\n"; + foreach $line (sort {$a cmp $b} keys %OtherList) { + print " $line: $OtherList{$line} Time(s)\n"; + } +} + +exit(0);