diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-02-10 16:52:16 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-02-10 17:10:58 +0200 |
commit | 8a916702efcd22685b02d7dd2760de8e55a2868b (patch) | |
tree | 3a6c172468f16096a236483f78df0221922bd40e | |
parent | b90b1590c9f1575b2f8ca2da8e993661ea16abb3 (diff) | |
download | syslogck-8a916702efcd22685b02d7dd2760de8e55a2868b.tar.gz syslogck-8a916702efcd22685b02d7dd2760de8e55a2868b.tar.bz2 |
Add documentation
-rw-r--r-- | syslogck | 124 |
1 files changed, 120 insertions, 4 deletions
@@ -7,8 +7,6 @@ use Pod::Usage; | |||
7 | use Pod::Man; | 7 | use Pod::Man; |
8 | use Getopt::Long qw(:config gnu_getopt no_ignore_case); | 8 | use Getopt::Long qw(:config gnu_getopt no_ignore_case); |
9 | 9 | ||
10 | use Data::Dumper; | ||
11 | |||
12 | use constant { | 10 | use constant { |
13 | EX_OK => 0, | 11 | EX_OK => 0, |
14 | EX_USAGE => 64, | 12 | EX_USAGE => 64, |
@@ -19,8 +17,126 @@ use constant { | |||
19 | EX_NOPERM => 77 | 17 | EX_NOPERM => 77 |
20 | }; | 18 | }; |
21 | 19 | ||
20 | =head1 NAME | ||
21 | |||
22 | syslogck - check if syslog properly delivers messages | ||
23 | |||
24 | =head1 SYNOPSIS | ||
25 | |||
26 | B<syslogck> [OPTIONS] [FILE...] | ||
27 | |||
28 | =head1 DESCRIPTION | ||
29 | |||
30 | Sends a test message via syslog and checks if it appears in the destination | ||
31 | log file. By default, the message is sent via the B<user.notice> syslog | ||
32 | facility. The log file is determined by analyzing the syslog configuration | ||
33 | file. If several logs are configured to receive messages in the current | ||
34 | priority, the first of them that is readable to the current user will be | ||
35 | examined. | ||
36 | |||
37 | By default, syslog configuration is read from file F</etc/syslog.conf>. This | ||
38 | can be changed by supplying the name of the file in the command line. Multiple | ||
39 | arguments are allowed. | ||
40 | |||
41 | The configuration parser is very permissive. It selects only lines that | ||
42 | can reliably be parsed as traditional syslog selector lines. This allows to | ||
43 | use B<syslogck> with any flavor of syslog that allows for traditional | ||
44 | configuration (e.g. B<rsyslogd>). | ||
45 | |||
46 | On success (test message appeared in the log), B<syslogck> silently exits with | ||
47 | code B<0>. If the message did not appear in the log within the time out period, | ||
48 | the program prints a descriptive diagnostics on the standard error and exits | ||
49 | with code 74 if the log file remained unmodified, or with code 65 if some | ||
50 | messages did appear in it, but the test message didn't. Code 74 most often | ||
51 | means that B<syslogd> is not running at all, whereas 65 indicates that it is | ||
52 | misconfigured. See B<EXIT CODES> for the exhaustive list of exit codes. | ||
53 | |||
54 | =head1 OPTIONS | ||
55 | |||
56 | =over 4 | ||
57 | |||
58 | =item B<-h> | ||
59 | |||
60 | Display a short option summary. | ||
61 | |||
62 | =item B<--help> | ||
63 | |||
64 | Display detailed manual. | ||
65 | |||
66 | =item B<--usage> | ||
67 | |||
68 | Display terse command line syntax summary. | ||
69 | |||
70 | =item B<-d>, B<--debug> | ||
71 | |||
72 | Print additional debugging information. | ||
73 | |||
74 | =item B<-p>, B<--priority=>I<FACILITY>[B<.>I<PRIORITY>] | ||
75 | |||
76 | Select the syslog facility and, optionally, priority to use. Default | ||
77 | is B<user.notice>. | ||
78 | |||
79 | =item B<-n>, B<--dry-run> | ||
80 | |||
81 | Verbosely list what is being done (see B<-d>), but don't actually | ||
82 | send the test message. | ||
83 | |||
84 | =item B<-t>, B<--tag=>I<TAG> | ||
85 | |||
86 | Set syslog tag. | ||
87 | |||
88 | =item B<-T>, B<--timeout=>I<N> | ||
89 | |||
90 | Wait I<N> seconds for the message to appear in the log file. Default is | ||
91 | 10. | ||
92 | |||
93 | =back | ||
94 | |||
95 | =head1 EXIT CODES | ||
96 | |||
97 | =over 4 | ||
98 | |||
99 | =item 0 | ||
100 | |||
101 | Success. Syslog works properly. | ||
102 | |||
103 | =item 64 | ||
104 | |||
105 | Command line usage error. | ||
106 | |||
107 | =item 65 | ||
108 | |||
109 | Test message did not appear in the log file, but other messages did. | ||
110 | This means that syslog is probably working, but misconfigured. | ||
111 | |||
112 | =item 66 | ||
113 | |||
114 | Can't open the selected log file. | ||
115 | |||
116 | =item 72 | ||
117 | |||
118 | No sutable log files found. Try another priority. | ||
119 | |||
120 | =item 74 | ||
121 | |||
122 | Timed out while waiting for the message to appear in the log file. Most | ||
123 | probably, syslog is not running. | ||
124 | |||
125 | =item 77 | ||
126 | |||
127 | None of the selected log files is readable for the current user. Either | ||
128 | select another priority (see B<-p>), or run B<syslogck> via B<sudo>. | ||
129 | |||
130 | =back | ||
131 | |||
132 | =head1 AUTHOR | ||
133 | |||
134 | Sergey Poznyakoff, <gray@gnu.org> | ||
135 | |||
136 | =cut | ||
137 | |||
22 | my $progname = basename($0); | 138 | my $progname = basename($0); |
23 | my $progdescr = 'FIXME'; | 139 | my $progdescr = 'check if syslog properly delivers messages'; |
24 | my $tag = $progname; | 140 | my $tag = $progname; |
25 | my $timeout = 10; | 141 | my $timeout = 10; |
26 | 142 | ||
@@ -203,7 +319,7 @@ if (@act) { | |||
203 | 319 | ||
204 | exit EX_OK if $dry_run; | 320 | exit EX_OK if $dry_run; |
205 | 321 | ||
206 | abend(EX_OSFILE, "no files") unless @act; | 322 | abend(EX_OSFILE, "no sutable files found (try another priority)") unless @act; |
207 | 323 | ||
208 | my $file; | 324 | my $file; |
209 | while ($file = shift @act) { | 325 | while ($file = shift @act) { |