File: sssd

package info (click to toggle)
logwatch 7.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,572 kB
  • sloc: perl: 8,290; sh: 354; makefile: 38
file content (178 lines) | stat: -rw-r--r-- 6,516 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178

########################################################
# Please file all bug reports, patches, and feature
# requests under:
#      https://sourceforge.net/p/logwatch/_list/tickets
# Help requests and discusion can be filed under:
#      https://sourceforge.net/p/logwatch/discussion/
########################################################

########################################################
## Copyright (c) 2014 Orion Poplawski
## Covered under the included MIT/X-Consortium License:
##    http://www.opensource.org/licenses/mit-license.php
## All modifications and contributions by other persons to
## this script are assumed to have been donated to the
## Logwatch project and thus assume the above copyright
## and licensing terms.  If you want to make contributions
## under your own copyright or a different license this
## must be explicitly stated in the contribution an the
## Logwatch project reserves the right to not accept such
## contributions.  If you have made significant
## contributions to this script and want to claim
## copyright please contact logwatch-devel@lists.sourceforge.net.
#########################################################

use strict;
my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
my $IgnoreBackendStatus = $ENV{'ignore_backend_status'} || 0;
my $IgnoreEnumerationRequested = $ENV{'ignore_enumeration_requested'} || 0;
my $OfflineOkay = $ENV{'offline_okay'} || 0;
my %CannotContactKDC;
my $Domain;
my %Errors;
my $Realm;
my $Service;
my %Starts;
my %Stops;
my %OtherList;
my %BackendStatus;
my %BackendOffline;
my $EnumerationRequested = 0;
my $ignore_p11_child_error = 0;

# Lines are of the form:
# sssd[service]:
while (defined(my $ThisLine = <STDIN>)) {
   next unless $ThisLine =~ /^sssd/;
   chomp($ThisLine);

   # Default service, domain
   $Service = "Daemon";
   $Domain = "unknown";

   # Strip off pid:
   $ThisLine =~ s/\[\d+\]: /: /;

   # Strip off and record the service if any
   if ($ThisLine =~ s/^sssd\[([^]]+)(?:\[\d+\])?\]: // or $ThisLine =~ s/^sssd_([^:[]+): //) {
     $Service = ($1 eq "be") ? "Backend[$Domain]" : $1;
   }

   # Strip off and record the backend domain if any
   if ($ThisLine =~ s/^sssd\[be\[([^]]+)\](?:\[\d+\])?\]: //) {
     $Service = "Backend[$1]";
     $Domain = $1;
   }

   # Strip off leading sssd:
   $ThisLine =~ s/^sssd: //;

   # Strip off duplicate timestamp if present
   $ThisLine =~ s/^\(... ... .\d \d\d:\d\d:\d\d \d\d\d\d\) //;

   # Remove []s from debug messages if any
   $ThisLine =~ s/^\[(\S+)\] /$1 /;
   $ThisLine =~ s/^\[(\S+)\] /$1 /;

   # Remove pids from debug messages if any
   $ThisLine =~ s/\[\d+\]//;

   # Ignore debug messages
   my ($debuglevel) = ($ThisLine =~ /\s\((0x[0-9a-f]{4})\):\s/);

   next if defined($debuglevel) && hex($debuglevel) > 16;
   if ($ThisLine =~ /Starting up/) {
      $Starts{$Service}++;
   } elsif ($ThisLine =~ /^Shutting down/) {
      $Stops{$Service}++;
   } elsif ($ThisLine =~ /error/i) {
      $Errors{$Service}->{$ThisLine}++;
   } elsif (my ($status) = ($ThisLine =~ /Backend is (.*)/)) {
      $BackendStatus{$Domain} = $status;
      $BackendOffline{$Domain}++ if $BackendStatus{$Domain} eq "offline";
   } elsif ($ThisLine =~ /^Enumeration requested but not enabled/) {
      $EnumerationRequested++ unless $IgnoreEnumerationRequested;
   } elsif ($Service eq "Daemon" && $ThisLine =~ /exec_child_ex command:/) {
      # Ignore - https://github.com/SSSD/sssd/issues/7778
   } elsif ($Service eq "Daemon" && $ThisLine =~ /Keytab successfully retrieved and stored in:/) {
      # Ignore
   } elsif ($Service eq "krb5_child" && (
              $ThisLine =~ "Preauthentication failed" or
              $ThisLine =~ "Client's credentials have been revoked")) {
      # Ignore - these will generate a pam auth failed message
   } elsif ($Service eq "p11_child" && $ThisLine =~ /Certificate .* not valid .*Certificate key usage inadequate for attempted operation/) {
      # sssd ssh does not ignore certificates of different types - ignore the errors generated by it
      $ignore_p11_child_error = 1;
   } elsif ($Service eq "p11_child" && $ThisLine =~ /do_work failed/ && $ignore_p11_child_error) {
   } elsif ($Service eq "p11_child" && $ThisLine =~ /p11_child failed/ && $ignore_p11_child_error) {
      $ignore_p11_child_error = 0;
   } elsif (($Realm) = ($ThisLine =~ /Cannot contact any KDC for realm '(.*)'/)) {
      $CannotContactKDC{$Realm}++ unless $OfflineOkay;
   } else {
      $OtherList{$Service}{$ThisLine}++;
   }
}

if (keys %Errors) {
   print "\nSSSD ERRORS:\n";
   foreach my $Service (sort {$a cmp $b} keys %Errors) {
      print "   $Service:\n";
      foreach my $Error (sort {$a cmp $b} keys %{$Errors{$Service}}) {
         print "      $Error: " . $Errors{$Service}->{$Error} . " Time(s)\n";
      }
   }
}

# sssd will generally start in offline mode, so don't alert if we've just started up
foreach $Domain (keys(%BackendOffline)) {
   if ($BackendOffline{$Domain} and (($Starts{"Backend[$Domain]"} < $BackendOffline{$Domain}) or ($BackendStatus{$Domain} ne "online")) and not $IgnoreBackendStatus) {
      print "\nSSSD Backend $Domain went offline $BackendOffline{$Domain} Time(s),";
      print " and started " . $Starts{"Backend[$Domain]"} . " Time(s),";
      print " last status was $BackendStatus{$Domain}\n";
   }
}

if (keys %CannotContactKDC) {
   print "\nCannot contact any KDC for realm:\n";
   foreach my $Realm (sort {$a cmp $b} keys %CannotContactKDC) {
      print "   $Realm: " . $CannotContactKDC{$Realm} . " Time(s)\n";
   }
}

if (keys %Starts and $Detail) {
   print "\nSSSD Services Started:\n";
   foreach my $Service (sort {$a cmp $b} keys %Starts) {
      print "   $Service: " . $Starts{$Service} . " Time(s)\n";
   }
}

if (keys %Stops and $Detail) {
   print "\nSSSD Services Stopped:\n";
   foreach my $Service (sort {$a cmp $b} keys %Stops) {
      print "   $Service: " . $Stops{$Service} . " Time(s)\n";
   }
}

if ($EnumerationRequested) {
   print "\nEnumeration requested but not enabled: $EnumerationRequested Time(s)\n";
}

if (keys %OtherList) {
   print "\n\n**Unmatched Entries**\n";
   foreach my $service (sort {$a cmp $b} keys %OtherList) {
      print "   $service:\n";
      foreach my $line (sort {$a cmp $b} keys %{$OtherList{$service}}) {
         print "      $line: $OtherList{$service}{$line} Time(s)\n";
      }
   }
}

exit(0);

# vi: shiftwidth=3 tabstop=3 syntax=perl et
# Local Variables:
# mode: perl
# perl-indent-level: 3
# indent-tabs-mode: nil
# End: