Revision | 107 (tree) |
---|---|
Zeit | 2019-11-10 17:51:46 |
Autor | ![]() |
Linuxでビルド
@@ -0,0 +1,146 @@ | ||
1 | +/* | |
2 | + * イベントログに対するアクション設定 | |
3 | + * ================================ | |
4 | + * イベントログに記録されたログが条件に一致した場合にアクションを実行します。 | |
5 | + * 条件には次のものを指定できます。 | |
6 | + * ・ログレベル(logLebel) | |
7 | + * ・ホスト名に一致する正規表現パターン(hostname) | |
8 | + * ・メッセージに一致する正規表現パターン(match) | |
9 | + * ・メッセージに一致すれば無視する正規表現パターン(ignore) | |
10 | + * 監視対象のイベントログ毎に複数の条件を指定できます。 | |
11 | + * | |
12 | + * EventLog: { | |
13 | + * Application: [ | |
14 | + * { | |
15 | + * logLevel:ログレベル, | |
16 | + * match:一致する正規表現パターン, | |
17 | + * ignore:一致すれば無視する正規表現パターン, | |
18 | + * actions: [ | |
19 | + * { | |
20 | + * type:アクション種別, | |
21 | + * ... | |
22 | + * }, | |
23 | + * ... | |
24 | + * ] | |
25 | + * }, | |
26 | + * ... | |
27 | + * ], | |
28 | + * System: [ | |
29 | + * ... | |
30 | + * ], | |
31 | + * }, | |
32 | + * | |
33 | + * | |
34 | + * ファイルに対するアクション設定 | |
35 | + * ============================ | |
36 | + * ファイルを監視して条件に一致した場合にアクションを実行します。 | |
37 | + * イベントログに対するものと同じ条件を指定できますが、ログレベルは無視されます。 | |
38 | + * 監視対象のファイル毎に複数の条件を指定できます。 | |
39 | + * | |
40 | + * File: { | |
41 | + * ファイルパス: [ | |
42 | + * { | |
43 | + * match:一致する正規表現パターン, | |
44 | + * ignore:一致すれば無視する正規表現パターン, | |
45 | + * actions: [ | |
46 | + * { | |
47 | + * type:アクション種別, | |
48 | + * ... | |
49 | + * }, | |
50 | + * ... | |
51 | + * ] | |
52 | + * } | |
53 | + * ], | |
54 | + * ファイルパス: [ | |
55 | + * .... | |
56 | + * ], | |
57 | + * ... | |
58 | + * } | |
59 | + * | |
60 | + * syslog転送に対するアクション設定 | |
61 | + * ============================== | |
62 | + * リモートサーバーからsyslog転送されたログに対して条件に一致した場合にアクションを実行します。 | |
63 | + * 条件はファイルに対するものと同じものを指定できます。 | |
64 | + * 待ち受けるポート番号毎に複数の条件を指定できます。通常は 514 だけになります。 | |
65 | + * | |
66 | + * Syslog: { | |
67 | + * 待ち受けポート番号: [ | |
68 | + * { | |
69 | + * match:一致する正規表現パターン, | |
70 | + * ignore:一致すれば無視する正規表現パターン, | |
71 | + * actions: [ | |
72 | + * { | |
73 | + * type:アクション種別, | |
74 | + * ... | |
75 | + * }, | |
76 | + * ... | |
77 | + * ] | |
78 | + * } | |
79 | + * ], | |
80 | + * ... | |
81 | + * } | |
82 | + * | |
83 | + * | |
84 | + * アクションの記述について | |
85 | + * ====================== | |
86 | + * 現在は次のアクションが指定可能です。 | |
87 | + * ・nop ... 何もしません。 | |
88 | + * ・exec ... CommandLine で指定したコマンドを実行します。$timestamp $hostname $source $level $code $message が指定可能です。 | |
89 | + * ・smtp ... ServerHost で指定したSMTPサーバーを利用して通知メールを送信します。 | |
90 | + * ・syslog ... RemoteHost で指定したsyslogサーバーにログを転送します。 | |
91 | + * ・mantis ... MantisBT に通知します。 | |
92 | + * ・slack ... Slack に通知します。 | |
93 | + */ | |
94 | +{ | |
95 | + Actions: [ | |
96 | + { | |
97 | + name: 'forwardTest', | |
98 | + type: 'forward', | |
99 | + Destination: '127.0.0.1' | |
100 | + }, | |
101 | + { | |
102 | + name: 'executeTest', | |
103 | + type: 'execute', | |
104 | + CommandLine: '"C:\\Program Files (x86)\\Growl for Windows\\growlnotify.exe" /t:EWatch "$message"' | |
105 | + }, | |
106 | + { | |
107 | + name: 'mantisTest', | |
108 | + type: 'mantis', | |
109 | + BaseUrl:'http://192.168.1.33/mantis/', | |
110 | + UserID:'ewatch', | |
111 | + Password:'ewatch', | |
112 | + Project:'やってみる' | |
113 | + }, | |
114 | + { | |
115 | + name: 'slackTest', | |
116 | + type:'slack', | |
117 | + URL:'https://hooks.slack.com/services/xxxxxxxx', | |
118 | + IconEmoji:':mario:', | |
119 | + UserName:'MARIO', | |
120 | + Attachments: '{ color:"#da071b", pretext:"エラーまたは警告が発生しました。" }' | |
121 | + }, | |
122 | + { | |
123 | + name: 'smtpTest', | |
124 | + type:'smtp', | |
125 | + FromAddress:'user@example.com', | |
126 | + ToAddress:'user2@example.com,user@example.com', | |
127 | + ServerHost:'localhost:25' | |
128 | + } | |
129 | + ], | |
130 | + File: { | |
131 | + "/tmp/test.log" :[ | |
132 | + { match:'\\[ERROR\\]', ignore:null, actions:[ 'executeTest' ]}, | |
133 | + ] | |
134 | + }, | |
135 | + Syslog: { | |
136 | + "514" : [ | |
137 | + { match:'ERR', ignore:null, actions:[ 'executeTest' ]}, | |
138 | + ] | |
139 | + }, | |
140 | + Server: { | |
141 | + Port : 31301, | |
142 | + Rules: [ | |
143 | + { logLevel:'E', match:null, ignore:null, actions:[ 'executeTest' ]} | |
144 | + ] | |
145 | + } | |
146 | +} |
@@ -0,0 +1,36 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8" ?> | |
2 | +<configuration> | |
3 | + <log4net> | |
4 | + <appender name="application" type="log4net.Appender.RollingFileAppender"> | |
5 | + <File value="log/ewatch.log" /> | |
6 | + <AppendToFile value="true" /> | |
7 | + <staticLogFileName value="true" /> | |
8 | + <param name="RollingStyle" value="date" /> | |
9 | + <datePattern value="'.'yyyy-MM-dd'.log'" /> | |
10 | + <MaxSizeRollBackups value="20" /> | |
11 | + <layout type="log4net.Layout.PatternLayout"> | |
12 | + <ConversionPattern value="%date{ISO8601} [%-5level] %thread - %logger - %message%n" /> | |
13 | + </layout> | |
14 | + <Encoding value="UTF-8"/> | |
15 | + </appender> | |
16 | + <appender name="action" type="log4net.Appender.RollingFileAppender"> | |
17 | + <File value="log/action.log" /> | |
18 | + <staticLogFileName value="true" /> | |
19 | + <param name="RollingStyle" value="date" /> | |
20 | + <datePattern value="'.'yyyy-MM-dd'.log'" /> | |
21 | + <MaxSizeRollBackups value="20" /> | |
22 | + <layout type="log4net.Layout.PatternLayout"> | |
23 | + <ConversionPattern value="%date{ISO8601} [%-5level] %message%n" /> | |
24 | + </layout> | |
25 | + <Encoding value="UTF-8"/> | |
26 | + </appender> | |
27 | + <root> | |
28 | + <level value="INFO" /> | |
29 | + <appender-ref ref="application" /> | |
30 | + </root> | |
31 | + <logger name="EWatch.Utils.ActionLogger" additivity="false"> | |
32 | + <level value="INFO" /> | |
33 | + <appender-ref ref="action" /> | |
34 | + </logger> | |
35 | + </log4net> | |
36 | +</configuration> |
@@ -0,0 +1,4 @@ | ||
1 | +#!/bin/sh | |
2 | +target=$1 | |
3 | +[ "$target" == "" ] && target=Rebuild | |
4 | +xbuild EWatch.sln /t:$target /p:Configuration=Release /p:Platform="Any CPU";PlatformTarget=AnyCPU |
@@ -0,0 +1,10 @@ | ||
1 | +#!/bin/sh | |
2 | +WORKDIR=pack | |
3 | + | |
4 | +rm -rf $WORKDIR | |
5 | +mkdir -p $WORKDIR/EWatch/etc | |
6 | +cp EWatch/bin/Release/*.dll $WORKDIR/EWatch | |
7 | +cp EWatch/bin/Release/EWatch.exe $WORKDIR/EWatch | |
8 | +cp EWatchCLI/bin/Release/EWatchCLI.exe $WORKDIR/EWatch | |
9 | +cp EWatch/etc/notWindows/* $WORKDIR/EWatch/etc | |
10 | + |