FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
netdata/python.d/puppet.chart.py at master · absalan/netdata · GitHub
absalan
/
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
/
puppet.chart.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
122 lines (107 loc) · 3.79 KB
Breadcrumbs
netdata
/
python.d
/
puppet.chart.py
Copy path
File metadata and controls
122 lines (107 loc) · 3.79 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# -*- coding: utf-8 -*-
# Description: puppet netdata python.d module
# Author: Andrey Galkin <andrey@futoin.org> (andvgal)
#---
# This module should work both with OpenSource and PE versions
# of PuppetServer and PuppetDB.
#
# NOTE: PuppetDB may be configured to require proper TLS
# client certificate for security reasons. Use tls_key_file
# and tls_cert_file options then.
#---
from
bases
.
FrameworkServices
.
UrlService
import
UrlService
from
json
import
loads
import
socket
update_every
=
5
priority
=
60000
# very long clojure-based service startup time
retries
=
180
MB
=
1048576
CPU_SCALE
=
1000
ORDER
=
[
'jvm_heap'
,
'jvm_nonheap'
,
'cpu'
,
'fd_open'
,
]
CHARTS
=
{
'jvm_heap'
: {
'options'
: [
None
,
"JVM Heap"
,
"MB"
,
"resources"
,
"puppet.jvm"
,
"area"
],
'lines'
: [
[
"jvm_heap_committed"
,
'committed'
,
"absolute"
,
1
,
MB
],
[
"jvm_heap_used"
,
'used'
,
"absolute"
,
1
,
MB
],
],
'variables'
: [
[
'jvm_heap_max'
],
[
'jvm_heap_init'
],
],
},
'jvm_nonheap'
: {
'options'
: [
None
,
"JVM Non-Heap"
,
"MB"
,
"resources"
,
"puppet.jvm"
,
"area"
],
'lines'
: [
[
"jvm_nonheap_committed"
,
'committed'
,
"absolute"
,
1
,
MB
],
[
"jvm_nonheap_used"
,
'used'
,
"absolute"
,
1
,
MB
],
],
'variables'
: [
[
'jvm_nonheap_max'
],
[
'jvm_nonheap_init'
],
],
},
'cpu'
: {
'options'
: [
None
,
"CPU usage"
,
"percentage"
,
"resources"
,
"puppet.cpu"
,
"stacked"
],
'lines'
: [
[
"cpu_time"
,
'execution'
,
"absolute"
,
1
,
CPU_SCALE
],
[
"gc_time"
,
'GC'
,
"absolute"
,
1
,
CPU_SCALE
],
]
},
'fd_open'
: {
'options'
: [
None
,
"File Descriptors"
,
"descriptors"
,
"resources"
,
"puppet.fdopen"
,
"line"
],
'lines'
: [
[
"fd_used"
,
'used'
,
"absolute"
],
],
'variables'
: [
[
'fd_max'
],
],
},
}
class
Service
(
UrlService
):
def
__init__
(
self
,
configuration
=
None
,
name
=
None
):
UrlService
.
__init__
(
self
,
configuration
=
configuration
,
name
=
name
)
self
.
url
=
'https://{0}:8140'
.
format
(
socket
.
getfqdn
())
self
.
order
=
ORDER
self
.
definitions
=
CHARTS
def
_get_data
(
self
):
#---
# NOTE: there are several ways to retrieve data
# 1. Only PE versions:
# https://puppet.com/docs/pe/2018.1/api_status/status_api_metrics_endpoints.html
# 2. Inidividual Metrics API (JMX):
# https://puppet.com/docs/pe/2018.1/api_status/metrics_api.html
# 3. Extended status at debug level:
# https://puppet.com/docs/pe/2018.1/api_status/status_api_json_endpoints.html
#
# For sake of simplicity and efficiency the status one is used..
#---
raw_data
=
self
.
_get_raw_data
(
self
.
url
+
'/status/v1/services?level=debug'
)
if
raw_data
is
None
:
return
None
raw_data
=
loads
(
raw_data
)
data
=
{}
try
:
try
:
jvm_metrics
=
raw_data
[
'status-service'
][
'status'
][
'experimental'
][
'jvm-metrics'
]
except
KeyError
:
jvm_metrics
=
raw_data
[
'status-service'
][
'status'
][
'jvm-metrics'
]
heap_mem
=
jvm_metrics
[
'heap-memory'
]
non_heap_mem
=
jvm_metrics
[
'non-heap-memory'
]
for
k
in
[
'max'
,
'committed'
,
'used'
,
'init'
]:
data
[
'jvm_heap_'
+
k
]
=
heap_mem
[
k
]
data
[
'jvm_nonheap_'
+
k
]
=
non_heap_mem
[
k
]
fd_open
=
jvm_metrics
[
'file-descriptors'
]
data
[
'fd_max'
]
=
fd_open
[
'max'
]
data
[
'fd_used'
]
=
fd_open
[
'used'
]
data
[
'cpu_time'
]
=
int
(
jvm_metrics
[
'cpu-usage'
]
*
CPU_SCALE
)
data
[
'gc_time'
]
=
int
(
jvm_metrics
[
'gc-cpu-usage'
]
*
CPU_SCALE
)
except
KeyError
:
pass
return
data
or
None
Back
|
FazBrowse Home
|
New Git URL