You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DESCRIPTION="Scans a logfile for set of pattern or regex and alarms on the number of findings."
31
+
DESCRIPTION="""Scans a logfile for a set of patterns or regex and alerts
32
+
on the number of matches."""
32
33
33
34
DEFAULT_ALARM_DURATION=60# minutes (1 hour)
34
35
DEFAULT_CRIT=1
@@ -51,7 +52,9 @@ def parse_args():
51
52
52
53
parser.add_argument(
53
54
'--alarm-duration',
54
-
help='How long should this check return an alarm on new matches (in minutes)? This is overwritten by --icinga-callback. Default: %(default)s',
55
+
help='How long should this check return an alert on new matches (in minutes)? '
56
+
'This is overwritten by --icinga-callback. '
57
+
'Default: %(default)s',
55
58
dest='ALARM_DURATION',
56
59
type=int,
57
60
default=DEFAULT_ALARM_DURATION,
@@ -67,7 +70,8 @@ def parse_args():
67
70
68
71
parser.add_argument(
69
72
'-c', '--critical',
70
-
help='Set the critical threshold for the number of found critical matches. Default: %(default)s',
73
+
help='Set the critical threshold for the number of found critical matches. '
74
+
'Default: %(default)s',
71
75
dest='CRIT',
72
76
default=DEFAULT_CRIT,
73
77
)
@@ -82,23 +86,24 @@ def parse_args():
82
86
83
87
parser.add_argument(
84
88
'--critical-regex',
85
-
help='Any line matching this python regex will count as a critical.',
89
+
help='Any line matching this Python regex will count as a critical.',
86
90
action='append',
87
91
dest='CRIT_REGEX',
88
92
default=[],
89
93
)
90
94
91
95
parser.add_argument(
92
96
'--filename',
93
-
help='Set the path of the logfile.',
97
+
help='Set the path to the logfile.',
94
98
dest='FILENAME',
95
99
required=True,
96
100
type=str,
97
101
)
98
102
99
103
parser.add_argument(
100
104
'--icinga-callback',
101
-
help='Get the service acknowledgement from Icinga. This overwrites --alarm-duration. Default: %(default)s',
105
+
help='Get the service acknowledgement from Icinga. This overwrites `--alarm-duration`. '
106
+
'Default: %(default)s',
102
107
dest='ICINGA_CALLBACK',
103
108
action='store_true',
104
109
default=DEFAULT_ICINGA_CALLBACK,
@@ -112,7 +117,9 @@ def parse_args():
112
117
113
118
parser.add_argument(
114
119
'--icinga-service-name',
115
-
help='Unique name of the service using this check within Icinga. Take it from the `__name` service attribute, for example `icinga-server!my-service-name`.',
120
+
help='Unique name of the service using this check within Icinga. '
121
+
'Take it from the `__name` service attribute, for example '
122
+
'`icinga-server!my-service-name`.',
116
123
dest='ICINGA_SERVICE_NAME',
117
124
)
118
125
@@ -138,7 +145,7 @@ def parse_args():
138
145
139
146
parser.add_argument(
140
147
'--ignore-regex',
141
-
help='Any line matching this python regex will be ignored.',
148
+
help='Any line matching this Python regex will be ignored.',
142
149
action='append',
143
150
default=[],
144
151
dest='IGNORE_REGEX',
@@ -154,7 +161,8 @@ def parse_args():
154
161
155
162
parser.add_argument(
156
163
'-w', '--warning',
157
-
help='Set the warning threshold for the number of found warning matches. Default: %(default)s',
164
+
help='Set the warning threshold for the number of found warning matches. '
165
+
'Default: %(default)s',
158
166
dest='WARN',
159
167
default=DEFAULT_WARN,
160
168
)
@@ -169,7 +177,7 @@ def parse_args():
169
177
170
178
parser.add_argument(
171
179
'--warning-regex',
172
-
help='Any line matching this python regex will count as a warning.',
180
+
help='Any line matching this Python regex will count as a warning.',
173
181
action='append',
174
182
dest='WARN_REGEX',
175
183
default=[],
@@ -185,17 +193,26 @@ def main():
185
193
exceptSystemExit:
186
194
sys.exit(STATE_UNKNOWN)
187
195
196
+
try:
197
+
file_stat=os.stat(args.FILENAME)
198
+
exceptFileNotFoundErrorase:
199
+
# no traceback wanted, so using oao() instead of cu()
msg_addendum+='Note: Acknowledge this service to reset the state to OK.'
354
367
exceptIndexError:
355
-
msg_addendum+='Note: Could not determine the acknowledgement from the Icinga API, this could be due to an incorrect service name.'
368
+
msg_addendum+='Note: Could not determine the acknowledgement from the Icinga API, this could be due to an incorrect service name.'# pylint: disable=C0301
356
369
else:
357
-
msg_addendum+='Note: Could not determine the acknowledgement from the Icinga API:\n{}.'.format(icinga)
370
+
msg_addendum+='Note: Could not determine the acknowledgement from the Icinga API:\n{}.'.format(icinga)# pylint: disable=C0301
358
371
359
372
# save to db, these lines will be alarmed until the service is acknowledged in icinga2
0 commit comments