janitoo_datalog_rrd package
Submodules
janitoo_datalog_rrd.bus module
The Raspberry hardware worker
Define a node for the cpu with 3 values : temperature, frequency and voltage
http://www.maketecheasier.com/finding-raspberry-pi-system-information/
-
class
janitoo_datalog_rrd.bus.
RrdBus
(**kwargs)[source]
Bases: janitoo.bus.JNTBus
A pseudo-bus to manage RRDTools
-
check_heartbeat
()[source]
Check that the component is ‘available’
-
get_count_series
(node_uuid, index)[source]
-
get_count_values
(node_uuid, index)[source]
-
get_package_name
()[source]
Return the name of the package. Needed to publish static files
MUST be copy paste in every extension that publish statics files
-
set_action
(node_uuid, index, data)[source]
Act on the server
-
start
(mqttc, trigger_thread_reload_cb=None, **kwargs)[source]
-
stop
(**kwargs)[source]
-
class
janitoo_datalog_rrd.bus.
RrdStoreThread
(section, options={})[source]
Bases: janitoo.thread.BaseThread
The Rdd cache thread
Implement a cache.
-
add_config
(rrd_file, step, config)[source]
- ret = rrdtool.create(“example.rrd”, “–step”, “1800”, “–start”, ‘0’,
- “DS:metric1:GAUGE:2000:U:U”,
“DS:metric2:GAUGE:2000:U:U”,
“RRA:AVERAGE:0.5:1:600”,
“RRA:AVERAGE:0.5:6:700”,
“RRA:AVERAGE:0.5:24:775”,
“RRA:AVERAGE:0.5:288:797”,
“RRA:MAX:0.5:1:600”,
“RRA:MAX:0.5:6:700”,
“RRA:MAX:0.5:24:775”,
“RRA:MAX:0.5:444:797”)
Let’s consider all lines in details. First line include name of RRD database (“example.rrd”) and you can use here any path you want,
step of parameters checking (30 minutes in our case), and the start point (0 or N means ‘now’).
‘DS’ in line 4-5 means Data Source, these lines include two our metrics.
‘2000’ means that RRD can wait for 2000 seconds to get new values until it considers them as unknown
(that’s is why we use 2000, which 200 seconds more of our 30 minutes interval).
Last two parameters – ‘U:U’ – stand for min and max values of each metric (‘unknown’ in our case).
Lines 6-13 describe what types of gained values RRD should store in its database.
It’s pretty self-describing (average and max values). Mentioned values describe how many parameters RRD should keep.
Considering it can be confusing I will omit explanation but note that these values were choosen to be compatible with MRTG (actually, it’s not quite true
since we use 1800 seconds periods and not 5 minutes, so you might need to modify it (if you also don’t use 5 minutes period) or keep like I did).
GAUGE, COUNTER, DERIVE or ABSOLUTE
-
add_rrd_to_list
(rrd_file)[source]
Add the rrd_file to index.txt
-
config_thread
(cache_rrd_ttl=None, cache_pickle_ttl=None, cache_dead_ttl=None, dirmask='rrd', filemask='%(rrd_file)s.rrd')[source]
-
create_store_index
()[source]
Create an in dex of keys
:ret: a list of tuple () of values in cache
-
dump
()[source]
Dump data to disk using pickle
-
flush
(rrd_file)[source]
Flush data from a value to rrd file and remove them from cache
-
flush_all
()[source]
Flush all data to rrd files and remove them from cache
-
get_count_series
()[source]
Retrieve the number of series of values cached
-
get_count_values
()[source]
Retrieve the number of values cached
-
get_list_filename
()[source]
Restore data from disk using pickle
-
get_pickle_filename
()[source]
Restore data from disk using pickle
-
get_rrd_directory
(params)[source]
Get and create the direcotry if needed
-
get_rrd_file
(params)[source]
-
get_rrd_filename
(rrd_file)[source]
-
get_rrd_httpname
(rrd_file)[source]
-
get_rrd_label
(index, rrd_file, config)[source]
-
get_rrd_public_directory
(params)[source]
Get and create the direcotry if needed
-
get_values_to_dump
()[source]
Return a list of tuples (hadd, value_uuid, value_index) of values in timeout. They must be flush to disk
-
loop
()[source]
Launch after finishing the run loop. The node manager is still available.
-
on_value
(client, userdata, message)[source]
On value
Do not lock as it don’t add new values to dict. Should be ok using keys instead of iterator.
Parameters: |
- client (paho.mqtt.client.Client) – the Client instance that is calling the callback.
- userdata (all) – user data of any type and can be set when creating a new client instance or with user_data_set(userdata).
- message (paho.mqtt.client.MQTTMessage) – The message variable is a MQTTMessage that describes all of the message parameters.
|
-
post_loop
()[source]
Launch after finishing the run loop. The node manager is still available.
-
pre_loop
()[source]
Launch before entering the run loop. The node manager is available.
-
remove_config
(rrd_file)[source]
Remove an entry in cache and its rrd file
-
remove_rrd_from_list
(rrd_file)[source]
Remove the rrd from index.txt
-
restore
()[source]
Restore data from disk using pickle
-
rrd_rotate
(rrd_file, etime=None)[source]
Rotate
-
run
()[source]
Run the loop
-
start_timer_dead
()[source]
-
start_timer_pickle
()[source]
-
stop_timer_dead
()[source]
-
stop_timer_pickle
()[source]
-
timer_add_config
(rrd_file, step, config)[source]
Add a config via a separate thread in a timer
-
timer_dead
()[source]
Remove dead entries from cache
-
timer_flush
(rrd_file)[source]
Flush data from in cache from a value via a separate thread in a timer
-
timer_flush_all
()[source]
Flush all data via a separate thread in a timer
-
timer_pickle
()[source]
Dump cache to file using pickle
-
timer_rrd_rotate
(rrd_file, etime=None)[source]
Rotate via a separate thread in a timer
-
update_last
(hadd, value_uuid, value_index, data)[source]
An helper to find
:ret:
janitoo_datalog_rrd.components module
The Raspberry hardware worker
Define a node for the cpu with 3 values : temperature, frequency and voltage
http://www.maketecheasier.com/finding-raspberry-pi-system-information/
-
class
janitoo_datalog_rrd.components.
RrdDatasource
(bus=None, addr=None, **kwargs)[source]
Bases: janitoo.component.JNTComponent
Use psutil to retrieve informations.
-
check_heartbeat
()[source]
Check that the component is ‘available’
-
get_http_rrd_file
(node_uuid, index)[source]
-
get_package_name
()[source]
Return the name of the package. Needed to publish static files
MUST be copy paste in every extension that publish statics files
-
get_rrd_label
(node_uuid, index)[source]
-
start
(mqttc)[source]
Start the component.
-
stop
()[source]
Stop the component.
-
class
janitoo_datalog_rrd.components.
RrdResourceComponent
(bus=None, addr=None, **kwargs)[source]
Bases: janitoo_factory.threads.http.BasicResourceComponent
A resource ie /rrd
-
check_heartbeat
()[source]
Check that the component is ‘available’
-
get_package_name
()[source]
Return the name of the package. Needed to publish static files
MUST be copy paste in every extension that publish statics files
-
janitoo_datalog_rrd.components.
make_datasource
(**kwargs)[source]
-
janitoo_datalog_rrd.components.
make_http_resource
(**kwargs)[source]
janitoo_datalog_rrd.server module
The Datalog RRD server
-
class
janitoo_datalog_rrd.server.
DatalogServer
(options)[source]
Bases: janitoo.server.JNTServer
The data logger Server
janitoo_datalog_rrd.thread module
The grapher worker
Store and graph data with rrdtools
-
class
janitoo_datalog_rrd.thread.
RrdThread
(options={})[source]
Bases: janitoo.thread.JNTBusThread
The grapher thread
-
init_bus
()[source]
Build the bus
-
janitoo_datalog_rrd.thread.
make_thread
(options, force=False)[source]
Module contents