FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
netdata/python.d/dockerd.chart.py at master · devanthonyp/netdata · GitHub
devanthonyp
/
netdata
Public
forked from
netdata/netdata
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
netdata
/
python.d
/
dockerd.chart.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
75 lines (61 loc) · 2.32 KB
Breadcrumbs
netdata
/
python.d
/
dockerd.chart.py
Copy path
File metadata and controls
75 lines (61 loc) · 2.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
# Description: docker netdata python.d module
# Author: Kévin Darcel (@tuxity)
try
:
import
docker
HAS_DOCKER
=
True
except
ImportError
:
HAS_DOCKER
=
False
from
bases
.
FrameworkServices
.
SimpleService
import
SimpleService
# default module values (can be overridden per job in `config`)
# update_every = 1
priority
=
60000
retries
=
60
# charts order (can be overridden if you want less charts, or different order)
ORDER
=
[
'running_containers'
,
'healthy_containers'
,
'unhealthy_containers'
]
CHARTS
=
{
'running_containers'
: {
'options'
: [
None
,
'Number of running containers'
,
'running containers'
,
'running containers'
,
'docker.running_containers'
,
'line'
],
'lines'
: [
[
'running_containers'
,
'running'
]
]
},
'healthy_containers'
: {
'options'
: [
None
,
'Number of healthy containers'
,
'healthy containers'
,
'healthy containers'
,
'docker.healthy_containers'
,
'line'
],
'lines'
: [
[
'healthy_containers'
,
'healthy'
]
]
},
'unhealthy_containers'
: {
'options'
: [
None
,
'Number of unhealthy containers'
,
'unhealthy containers'
,
'unhealthy containers'
,
'docker.unhealthy_containers'
,
'line'
],
'lines'
: [
[
'unhealthy_containers'
,
'unhealthy'
]
]
}
}
class
Service
(
SimpleService
):
def
__init__
(
self
,
configuration
=
None
,
name
=
None
):
SimpleService
.
__init__
(
self
,
configuration
=
configuration
,
name
=
name
)
self
.
order
=
ORDER
self
.
definitions
=
CHARTS
def
check
(
self
):
if
not
HAS_DOCKER
:
self
.
error
(
'
\'
docker
\'
package is needed to use docker.chart.py'
)
return
False
self
.
client
=
docker
.
DockerClient
(
base_url
=
self
.
configuration
.
get
(
'url'
,
'unix://var/run/docker.sock'
))
try
:
self
.
client
.
ping
()
except
docker
.
errors
.
APIError
as
error
:
self
.
error
(
error
)
return
False
return
True
def
get_data
(
self
):
data
=
dict
()
data
[
'running_containers'
]
=
len
(
self
.
client
.
containers
.
list
(
sparse
=
True
))
data
[
'healthy_containers'
]
=
len
(
self
.
client
.
containers
.
list
(
filters
=
{
'health'
:
'healthy'
},
sparse
=
True
))
data
[
'unhealthy_containers'
]
=
len
(
self
.
client
.
containers
.
list
(
filters
=
{
'health'
:
'unhealthy'
},
sparse
=
True
))
return
data
or
None
Back
|
FazBrowse Home
|
New Git URL