diff options
author | psyc://loupsycedyglgamf.onion/~lynX <BM-NB7xa9gEpmJgYp9PVnEdACiZcGmmEJcY> | 2016-08-10 15:28:10 +0000 |
---|---|---|
committer | psyc://loupsycedyglgamf.onion/~lynX <BM-NB7xa9gEpmJgYp9PVnEdACiZcGmmEJcY> | 2016-08-10 15:28:10 +0000 |
commit | c37ae6350f2656e3c05ef6420956be2b170574a6 (patch) | |
tree | a954aef4cd0223b9a9a18917ea0d2b993841e18f | |
parent | 6ec7ac1f0ce397303ea190e17b50ba4c0731178f (diff) | |
download | perlpsyc-c37ae6350f2656e3c05ef6420956be2b170574a6.tar.gz perlpsyc-c37ae6350f2656e3c05ef6420956be2b170574a6.zip |
documentation for syslog2psyc
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | bin/syslog2psyc | 100 |
2 files changed, 75 insertions, 27 deletions
@@ -15,6 +15,7 @@ manuals: htdocs $I | |||
15 | perldoc -oman bin/psyccmd >$M/man1/psyccmd.1 | 15 | perldoc -oman bin/psyccmd >$M/man1/psyccmd.1 |
16 | perldoc -oman bin/psycplay >$M/man1/psycplay.1 | 16 | perldoc -oman bin/psycplay >$M/man1/psycplay.1 |
17 | perldoc -oman bin/psyclisten >$M/man1/psyclisten.1 | 17 | perldoc -oman bin/psyclisten >$M/man1/psyclisten.1 |
18 | perldoc -oman bin/syslog2psyc >$M/man1/syslog2psyc.1 | ||
18 | 19 | ||
19 | html: htdocs | 20 | html: htdocs |
20 | perldoc -ohtml bin/remotor >htdocs/remotor.html | 21 | perldoc -ohtml bin/remotor >htdocs/remotor.html |
@@ -23,6 +24,7 @@ html: htdocs | |||
23 | perldoc -ohtml bin/psyccmd >htdocs/psyccmd.html | 24 | perldoc -ohtml bin/psyccmd >htdocs/psyccmd.html |
24 | perldoc -ohtml bin/psycplay >htdocs/psycplay.html | 25 | perldoc -ohtml bin/psycplay >htdocs/psycplay.html |
25 | perldoc -ohtml bin/psyclisten >htdocs/psyclisten.html | 26 | perldoc -ohtml bin/psyclisten >htdocs/psyclisten.html |
27 | perldoc -ohtml bin/syslog2psyc >htdocs/syslog2psyc.html | ||
26 | 28 | ||
27 | htdocs: | 29 | htdocs: |
28 | mkdir -p $@ $M/man1 $M/man3 | 30 | mkdir -p $@ $M/man1 $M/man3 |
diff --git a/bin/syslog2psyc b/bin/syslog2psyc index f4a1c83..7aef0c7 100755 --- a/bin/syslog2psyc +++ b/bin/syslog2psyc | |||
@@ -3,43 +3,32 @@ | |||
3 | # forwards syslog events to a PSYC target. -lynX 2006 | 3 | # forwards syslog events to a PSYC target. -lynX 2006 |
4 | # | 4 | # |
5 | # had i known how easy it is, i would have done this 1997 | 5 | # had i known how easy it is, i would have done this 1997 |
6 | # | ||
7 | # first set up a pipe where we can get syslog events from: | ||
8 | # mkfifo /dev/syslog2psyc | ||
9 | # chown <user> /dev/syslog2psyc | ||
10 | # | ||
11 | # then configure /dev/syslog2psyc as the destination for | ||
12 | # syslog messages. in syslog-ng.conf it may look like this: | ||
13 | # destination psyc { pipe("/dev/syslog2psyc"); }; | ||
14 | # log { source(src); destination(psyc); }; | ||
15 | # | ||
16 | # in syslog.conf it may look like this: | ||
17 | # *.warn;*.err |/dev/syslog2psyc | ||
18 | # | ||
19 | # finally run this script as <user> | ||
20 | # you may later want to refine the type of messages that are | ||
21 | # forwarded to you. | ||
22 | # | ||
23 | # If you don't own an always running PSYC server yet, | ||
24 | # visit http://www.psyced.org. The psyced LPC sandbox | ||
25 | # runtime has a syslog.c ready to use in the place/ folder. | ||
26 | 6 | ||
27 | $target = shift; | 7 | require 5.000; |
28 | $pipe = shift; | 8 | use Net::PSYC; |
9 | use Pod::Usage qw( pod2usage ); | ||
10 | |||
11 | $target = shift; | ||
12 | $pipe = shift; | ||
29 | $pipe = '/dev/syslog2psyc' unless -r $pipe; | 13 | $pipe = '/dev/syslog2psyc' unless -r $pipe; |
30 | $pipe = '/dev/console' unless -r $pipe; | 14 | $pipe = '/dev/console' unless -r $pipe; |
31 | $pipe = '/dev/xconsole' unless -r $pipe; | 15 | $pipe = '/dev/xconsole' unless -r $pipe; |
32 | $pipe = 0 unless -r $pipe; | 16 | $pipe = 0 unless -r $pipe; |
33 | 17 | ||
34 | die <<X unless $target and $pipe; | 18 | unless ($target and $pipe) { |
35 | please provide target and pipe as parameters, as in | 19 | print STDERR <<X unless $target and $pipe; |
36 | $0 psyc://localhost/\@syslog /dev/syslog2psyc | 20 | Please provide target and pipe as parameters, as in |
21 | $0 psyc://localhost/\@syslog /dev/syslog2psyc | ||
22 | |||
23 | See 'perldoc syslog2psyc' for an installation manual. | ||
24 | |||
37 | X | 25 | X |
26 | pod2usage; | ||
27 | exit; | ||
28 | } | ||
38 | 29 | ||
39 | $mc = '_notice_system_event'; | 30 | $mc = '_notice_system_event'; |
40 | 31 | ||
41 | use Net::PSYC; | ||
42 | |||
43 | $user = $ENV{'USER'}; | 32 | $user = $ENV{'USER'}; |
44 | $host = $ENV{'HOST'}; | 33 | $host = $ENV{'HOST'}; |
45 | 34 | ||
@@ -60,4 +49,61 @@ close IN; | |||
60 | 49 | ||
61 | # we indeed get here when syslog gets restarted. | 50 | # we indeed get here when syslog gets restarted. |
62 | # should we sleep and try again? | 51 | # should we sleep and try again? |
52 | sleep 2; | ||
53 | exit; | ||
54 | |||
55 | |||
56 | __END__ | ||
57 | |||
58 | =pod | ||
59 | |||
60 | =head1 NAME | ||
61 | |||
62 | syslog2psyc - a daemon that forwards syslog events to a PSYC entity | ||
63 | |||
64 | =head1 SYNOPSIS | ||
65 | |||
66 | syslog2psyc <target> [<pipe>] | ||
67 | |||
68 | <target> is a PSYC uniform to send syslog notices to. | ||
69 | <pipe> is a non-standard path to the syslog2psyc fifo | ||
70 | |||
71 | =head1 INSTALLATION | ||
72 | |||
73 | First set up a pipe where we can get syslog events from: | ||
74 | mkfifo /dev/syslog2psyc | ||
75 | chown <user> /dev/syslog2psyc | ||
76 | |||
77 | Then configure /dev/syslog2psyc as the destination for | ||
78 | syslog messages. In syslog-ng.conf it may look like this: | ||
79 | destination psyc { pipe("/dev/syslog2psyc"); }; | ||
80 | log { source(src); destination(psyc); }; | ||
81 | |||
82 | In syslog.conf it may look like this: | ||
83 | *.warn;*.err |/dev/syslog2psyc | ||
84 | |||
85 | Finally run this script as <user>. | ||
86 | You may later want to refine the type of messages that are | ||
87 | forwarded to you. | ||
88 | |||
89 | If you don't own an always running PSYC server yet, | ||
90 | visit http://www.psyced.org. The psyced LPC sandbox | ||
91 | runtime has a syslog.c ready to use in the place/ folder. | ||
92 | It is reachable at psyc://localhost/\@syslog while your | ||
93 | PSYC client can enter it by means of /subscribe syslog. | ||
94 | |||
95 | =head1 CAVEATS | ||
96 | |||
97 | As long as Net::PSYC does not provide any encryption, you | ||
98 | should use this within a trustworthy local network or | ||
99 | as a localhost service. | ||
100 | |||
101 | =head1 AUTHORS | ||
102 | |||
103 | carlo von lynX. | ||
104 | |||
105 | =head1 COPYRIGHT | ||
63 | 106 | ||
107 | This program is free software, published under the Affero GNU Public | ||
108 | License. A disclaimer isn't necessary in my country, nor do I need | ||
109 | to mention the current year to assert a copyright. | ||