Skip to content

Commit 0347b2f

Browse files
committed
check_logfile: add example and update docs
1 parent 28a63e9 commit 0347b2f

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

docs/checks/commands/check_logfile.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ Checks logfiles or any other text format file for errors or other general patter
1818

1919
## Examples
2020

21+
### Default Check
22+
23+
Alert if there are errors in the snclient log file:
24+
25+
check_files files=/var/log/snclient/snclient.log 'warn=line like Warn' 'crit=line like Error'"
26+
OK - All 1787 / 1787 Lines OK
27+
2128
### Example using NRPE and Naemon
2229

2330
Naemon Config
@@ -31,7 +38,7 @@ Naemon Config
3138
host_name testhost
3239
service_description check_logfile
3340
use generic-service
34-
check_command check_nrpe!check_logfile!
41+
check_command check_nrpe!check_logfile!'files=/var/log/snclient/snclient.log' 'warn=line like Warn'
3542
}
3643

3744
## Argument Defaults

pkg/snclient/check_logfile.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@ func (c *CheckLogFile) Build() *CheckData {
7272
{name: "columnN", description: "Match the content of the N-th column only if enough columns exists"},
7373
},
7474
exampleDefault: `
75-
`,
76-
exampleArgs: ``,
75+
Alert if there are errors in the snclient log file:
76+
77+
check_files files=/var/log/snclient/snclient.log 'warn=line like Warn' 'crit=line like Error'"
78+
OK - All 1787 / 1787 Lines OK
79+
`,
80+
exampleArgs: `'files=/var/log/snclient/snclient.log' 'warn=line like Warn'`,
7781
}
7882
}
7983

pkg/snclient/checkdata.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,17 @@ func (cd *CheckData) buildListMacros() map[string]string {
297297

298298
// if there is only one problem, there is no need to add brackets
299299
if len(critList) > 0 {
300-
result["crit_list"] = "critical(" + strings.Join(critList, ", ") + ")"
300+
result["crit_list"] = "critical(" + strings.Join(critList, cd.listCombine) + ")"
301301
problemList = append(problemList, result["crit_list"])
302302
detailList = append(detailList, result["crit_list"])
303303
}
304304
if len(warnList) > 0 {
305-
result["warn_list"] = "warning(" + strings.Join(warnList, ", ") + ")"
305+
result["warn_list"] = "warning(" + strings.Join(warnList, cd.listCombine) + ")"
306306
problemList = append(problemList, result["warn_list"])
307307
detailList = append(detailList, result["warn_list"])
308308
}
309309
if len(okList) > 0 {
310-
result["ok_list"] = strings.Join(okList, ", ")
310+
result["ok_list"] = strings.Join(okList, cd.listCombine)
311311
detailList = append(detailList, result["ok_list"])
312312
}
313313

0 commit comments

Comments
 (0)