MCPcopy
hub / github.com/netdata/netdata / Cleanup

Method Cleanup

src/go/plugin/framework/jobruntime/job_v1.go:361–403  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

359}
360
361func (j *Job) Cleanup() {
362 j.buf.Reset()
363 if !collectorapi.ShouldObsoleteCharts() {
364 return
365 }
366
367 // Netdata automatically obsoletes vnode charts when no updates are sent.
368 // For virtual nodes with a stale label, we must not send anything:
369 // - Sending a HOST line would incorrectly mark the vnode as active.
370 isVnodeWithStaleConfig := j.vnode.Labels["_node_stale_after_seconds"] != ""
371
372 if !isVnodeWithStaleConfig {
373 if !j.vnodeCreated && j.vnode.GUID != "" {
374 j.sendVnodeHostInfo()
375 j.vnodeCreated = true
376 }
377 j.api.HOST(j.vnode.GUID)
378
379 if j.charts != nil {
380 for _, chart := range *j.charts {
381 if chart.IsCreated() {
382 chart.MarkRemove()
383 j.createChart(chart)
384 }
385 }
386 }
387 }
388
389 j.api.HOST("")
390
391 if j.collectStatusChart.IsCreated() {
392 j.collectStatusChart.MarkRemove()
393 j.createChart(j.collectStatusChart)
394 }
395 if j.collectDurationChart.IsCreated() {
396 j.collectDurationChart.MarkRemove()
397 j.createChart(j.collectDurationChart)
398 }
399
400 if j.buf.Len() > 0 {
401 _, _ = io.Copy(j.out, j.buf)
402 }
403}
404
405func (j *Job) init() error {
406 if j.initialized {

Callers 1

StartMethod · 0.95

Calls 8

sendVnodeHostInfoMethod · 0.95
createChartMethod · 0.95
HOSTMethod · 0.80
IsCreatedMethod · 0.80
MarkRemoveMethod · 0.80
ResetMethod · 0.65
LenMethod · 0.65
CopyMethod · 0.45

Tested by

no test coverage detected