Merge pull request #54 from k-kinzal/fixes-panic-logfilepath-empty
fixes panic appears when tailer is nil
This commit is contained in:
commit
8e63fbbe8d
@ -612,6 +612,9 @@ func NewPostfixExporter(showqPath string, logfilePath string, journal *Journal,
|
|||||||
func (e *PostfixExporter) Describe(ch chan<- *prometheus.Desc) {
|
func (e *PostfixExporter) Describe(ch chan<- *prometheus.Desc) {
|
||||||
ch <- postfixUpDesc
|
ch <- postfixUpDesc
|
||||||
|
|
||||||
|
if e.tailer == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
ch <- e.cleanupProcesses.Desc()
|
ch <- e.cleanupProcesses.Desc()
|
||||||
ch <- e.cleanupRejects.Desc()
|
ch <- e.cleanupRejects.Desc()
|
||||||
ch <- e.cleanupNotAccepted.Desc()
|
ch <- e.cleanupNotAccepted.Desc()
|
||||||
@ -664,7 +667,7 @@ func (e *PostfixExporter) foreverCollectFromJournal(ctx context.Context) {
|
|||||||
func (e *PostfixExporter) StartMetricCollection(ctx context.Context) {
|
func (e *PostfixExporter) StartMetricCollection(ctx context.Context) {
|
||||||
if e.journal != nil {
|
if e.journal != nil {
|
||||||
e.foreverCollectFromJournal(ctx)
|
e.foreverCollectFromJournal(ctx)
|
||||||
} else {
|
} else if e.tailer != nil {
|
||||||
e.CollectLogfileFromFile(ctx)
|
e.CollectLogfileFromFile(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,6 +700,9 @@ func (e *PostfixExporter) Collect(ch chan<- prometheus.Metric) {
|
|||||||
e.showqPath)
|
e.showqPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if e.tailer == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
ch <- e.cleanupProcesses
|
ch <- e.cleanupProcesses
|
||||||
ch <- e.cleanupRejects
|
ch <- e.cleanupRejects
|
||||||
ch <- e.cleanupNotAccepted
|
ch <- e.cleanupNotAccepted
|
||||||
|
Loading…
Reference in New Issue
Block a user