]>
git.ipfire.org Git - collecty.git/blob - src/collecty/client.py
2 ###############################################################################
4 # collecty - A system statistics collection daemon for IPFire #
5 # Copyright (C) 2012 IPFire development team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
32 class Collecty(object):
34 self
.bus
= dbus
.SystemBus()
36 self
.proxy
= self
.bus
.get_object(bus
.DOMAIN
, "/GraphGenerator")
38 def backup(self
, filename
):
40 Writes a backup of everything to file given filehandle
42 self
.proxy
.Backup(filename
)
44 def last_update(self
, template_name
, **kwargs
):
45 last_update
= self
.proxy
.LastUpdate(template_name
, kwargs
)
48 last_update
["timestamp"] = datetime
.datetime
.strptime(last_update
["timestamp"], "%Y-%m-%dT%H:%M:%S")
52 def list_templates(self
):
53 templates
= self
.proxy
.ListTemplates()
55 return ["%s" % t
for t
in templates
]
57 def graph_info(self
, template_name
, **kwargs
):
58 graph_info
= self
.proxy
.GraphInfo(template_name
, kwargs
,
61 return dict(graph_info
)
63 def generate_graph(self
, template_name
, **kwargs
):
64 graph
= self
.proxy
.GenerateGraph(template_name
, kwargs
,
67 # Convert the byte array into a byte string again
69 graph
["image"] = bytes(graph
["image"])
75 Returns the version of the daemon
77 return self
.proxy
.Version()