FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
netdata/python.d/cpufreq.chart.py at master · Patechoc/netdata · GitHub
Patechoc
/
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
/
cpufreq.chart.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
80 lines (64 loc) · 2.22 KB
Breadcrumbs
netdata
/
python.d
/
cpufreq.chart.py
Copy path
File metadata and controls
80 lines (64 loc) · 2.22 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
# -*- coding: utf-8 -*-
# Description: cpufreq netdata python.d module
# Author: Pawel Krupa (paulfantom)
import
os
from
base
import
SimpleService
# default module values (can be overridden per job in `config`)
# update_every = 2
ORDER
=
[
'cpufreq'
]
CHARTS
=
{
'cpufreq'
: {
'options'
: [
None
,
'CPU Clock'
,
'MHz'
,
'cpufreq'
,
None
,
'line'
],
'lines'
: [
# lines are created dynamically in `check()` method
]}
}
class
Service
(
SimpleService
):
def
__init__
(
self
,
configuration
=
None
,
name
=
None
):
self
.
sys_dir
=
"/sys/devices"
self
.
filename
=
"scaling_cur_freq"
SimpleService
.
__init__
(
self
,
configuration
=
configuration
,
name
=
name
)
self
.
order
=
ORDER
self
.
definitions
=
CHARTS
self
.
_orig_name
=
""
self
.
assignment
=
{}
self
.
paths
=
[]
def
_get_data
(
self
):
raw
=
{}
for
path
in
self
.
paths
:
with
open
(
path
,
'r'
)
as
f
:
raw
[
path
]
=
f
.
read
()
data
=
{}
for
path
in
self
.
paths
:
data
[
self
.
assignment
[
path
]]
=
raw
[
path
]
return
data
def
check
(
self
):
try
:
self
.
sys_dir
=
str
(
self
.
configuration
[
'sys_dir'
])
except
(
KeyError
,
TypeError
):
self
.
error
(
"No path specified. Using: '"
+
self
.
sys_dir
+
"'"
)
self
.
_orig_name
=
self
.
chart_name
for
dirpath
,
_
,
filenames
in
os
.
walk
(
self
.
sys_dir
):
if
self
.
filename
in
filenames
:
self
.
paths
.
append
(
dirpath
+
"/"
+
self
.
filename
)
if
len
(
self
.
paths
)
==
0
:
return
False
self
.
paths
.
sort
()
i
=
0
for
path
in
self
.
paths
:
self
.
assignment
[
path
]
=
"cpu"
+
str
(
i
)
i
+=
1
for
name
in
self
.
assignment
:
dim
=
self
.
assignment
[
name
]
self
.
definitions
[
ORDER
[
0
]][
'lines'
].
append
([
dim
,
dim
,
'absolute'
,
1
,
1000
])
return
True
def
create
(
self
):
self
.
chart_name
=
"cpu"
status
=
SimpleService
.
create
(
self
)
self
.
chart_name
=
self
.
_orig_name
return
status
def
update
(
self
,
interval
):
self
.
chart_name
=
"cpu"
status
=
SimpleService
.
update
(
self
,
interval
=
interval
)
self
.
chart_name
=
self
.
_orig_name
return
status
Back
|
FazBrowse Home
|
New Git URL