()
| 359 | } |
| 360 | |
| 361 | func (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 | |
| 405 | func (j *Job) init() error { |
| 406 | if j.initialized { |
no test coverage detected