Bug 8065 - Drive a database decision on SMBTA and implement it
Summary: Drive a database decision on SMBTA and implement it
Status: RESOLVED FIXED
Alias: None
Product: smbta
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All All
: P5 enhancement
Target Milestone: ---
Assignee: Holger Hetterich
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 8049
  Show dependency treegraph
 
Reported: 2011-04-06 20:09 UTC by Holger Hetterich
Modified: 2011-04-23 20:32 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Hetterich 2011-04-06 20:09:17 UTC
This is a more general bug, which will track a big issue with SMBTA.

Currently, SMBTA is employing sqlite for all it's database actions. Using sqlite has several advantages, compared to "the big ones" such as mysql or postresql:
- no need to setup at all from an administrator side
- easy API

However, I come to the conclusion that sqlite is no more sufficient for SMBTA.
- smbtad has to serve as a network gate for the clients, as sqlite is not server based
- the database part of the SMBTA components cannot be driven networked.

I was looking deeper into the postgresql development documentation and think its the right way to go.

Using a server based database, smbtatools can connect completely independent from smbtad and run queries.

I would like to use the first comment in this bug for a decision, and then track the development of this (which are larger changes) with this bug.

So, the questions are now:
1) develop a "general database layer" so that plugins can be used to serve different databases?
2) just fix SMBTA to use postgresql only, and that's it?
3) if (1) applies, shall we get rid of sqlite completely, as it requires smbtad to run queries for clients ( which adds a lot of complexity to smbtad, that would not be needed if the layer would work on server based databases only) ?

I would like to hear you opinion on this.
Comment 1 Robert Piasek (dead mail address) 2011-04-06 20:16:00 UTC
Hey,

Personally I think database abstraction layer is the way to go. While I love postgresql and use it everywhere, some people might prefer mysql.

If you move to proper database, supporting sqlite will be really hard. I believe dropping it for db abstraction layer is the best way forward.
Comment 2 Benjamin Brunner 2011-04-07 10:01:08 UTC
I also would say an database abstraction layer is the best way, because of the flexibility.
And also removing sqlite3 to avoid the way over smbtad to connect to the database with the tools.
Comment 3 Holger Hetterich 2011-04-07 10:39:07 UTC
Ok. I created a new branch "devel-dblayer" on github for the smbtad repository in which I'll work on this. We can later merge these changes into devel.
Comment 4 Holger Hetterich 2011-04-07 10:50:39 UTC
Thinking about employing:
http://libdbi.sourceforge.net
for database abstraction.
Comment 5 Holger Hetterich 2011-04-11 19:43:54 UTC
Ok, there is now a fork of smbtad in the devel-dblayer branch that builds finally, and is based in libdbi. It is completely untested. Robert, Benjamin, please if you have the time, test.

I've added a cmake test to check for libdbi.
Comment 6 Holger Hetterich 2011-04-12 18:58:42 UTC
Status update:
DBI enabled smbtad builds and works tested on the postgresql driver.



Suggested setup workflow w/ DBI enabled smbtad:

setup an empty database
create a user that has access to the database
then, a call to smbtad : 
./smbtad -S holger -H localhost -M pgsql -N smbtad -P the_password -T

Runs the initial setup (as given with the -T option), which will build up the tables in the required database.
-S specifies the user to make the connection to the database with,
-H specifies the hostname where the database server is running
-M specifies the libDBI driver to be used, in this case postgresql,
-N specifies the name of the database to use
-P specifies the password of the user

-T runs the initial setup and will exit after a successful run. It will not daemonize.

After the database is setup, smbta can be started for normal operation:
./smbtad -S holger -H localhost -M pgsql -N smbtad -P the_password -u -q 3491

Would setup smbtad to run with these given parameters and an open port for smbtamonitor on 3491

-------

- currently smbtamonitor will not work with smbtad, it's on my list
- some code needs cleanup, since we no longer need to differ for smbtamonitor or smbtaquery as clients many code can be removed.
- smbtaquery needs to be adapted to work based on DBI

--------

Robert, Benjamin, I'd love to see some testing on this, even if smbtamonitor is currently not running against it, it should fill it's database.

I am setting up a designated machine at SUSE labs for long term testing of this version.
Comment 7 Holger Hetterich 2011-04-12 19:19:03 UTC
Since the libdbi connection works in general, this bug will be blocking the 1.2.4 release tracker.
Comment 8 Robert Piasek (dead mail address) 2011-04-14 08:39:22 UTC
Hi Holger,

I'll be testing this extensively for the next couple of days. I will let you know about any problems I find.

Rob
Comment 9 Holger Hetterich 2011-04-14 19:54:53 UTC
We should get rid of the enhanced monitor functionality to do internal queries on their own, for example the MONITOR_TOTAL function, which was retrieving the total sum of the object first, internal inside of smbtad. I don't want to see smbtad doing anything else than pushing data into the database anymore, and sometimes run the maintenance routine, as well as serving smbtamonitor.

This task - doing preparation queries - can be outsourced to the clients too. The smbtamonitor client can simply do this SQL query on it's self via DBI. This will further simplify the smbtad code.

So my next step is to make the smbtad code simpler by removing the MONITOR_TOTAL function, and instead rely on MONITOR_READ and MONITOR_WRITE, which simply transfer the count of bytes on VFS functions, then adapt smbtatools to DBI.
Comment 10 Holger Hetterich 2011-04-14 20:31:32 UTC
removed the MONITOR_TOTAL function, and the full code to do internal database queries. This removes a lot of complexity from the code.
 2 files changed, 8 insertions(+), 181 deletions(-)
Comment 11 Holger Hetterich 2011-04-14 20:38:36 UTC
Since this bug is blocking the tracker bug, I could also merge the code now into devel. But we should wait with that until smbtatools is on DBI too, since Benjamin requires a working set of smbtad/smbtatools for his webgui development.
Comment 12 Holger Hetterich 2011-04-14 21:15:42 UTC
I've created a devel-dblayer branch in smbtatools and work on getting the tools on libdbi. Currently it doesn't build.
Comment 13 Holger Hetterich 2011-04-17 07:46:26 UTC
a status update on smbtatools

wrapper functions in smbtatools to make it work on DBI are in place. Many of the functions are already working.

Since sqlite stores a full timestamp (date+time) in a DATE datatype, and postgresql only stores a date (it cuts the time value), the database format has to be changed to declare a timstamp. (right step, as postgresql follows SQL standard)

The wrapper function is only a short term solution, longer term task should be to convert to DBI in the query functions directly and get rid of the old functionality.
Comment 14 Holger Hetterich 2011-04-17 12:45:34 UTC
The changes on the database table have been done, and smbtaquery should now work completely by using libDBI (celebrate!) :)

This requires a new database and a new setup done by smbtad -T.

I will now work on smbtamonitor to work with smbtad again.
Comment 15 Holger Hetterich 2011-04-18 04:54:38 UTC
Benjamin, below are the new arguments that the webui must honor due to run DBI enabled smbtaquery:


holger@linux-lm9n:~/Dev/smbtatools/run> ./smbtaquery 
ERROR: not enough arguments.

smbtaquery version 1.2.3-devel
(C)opyright 2011 by Benjamin Brunner
(C)opyright 2011 by Michael Haefner
(C)opyright 2011 by Holger Hetterich
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

-M	--dbdriver <str>	Set the libDBI database driver to use.
-N	--dbname <str>		Set the name of the database to open.
-S	--dbuser <str>		Set the name of the user for the database.
-H	--dbhost <str>		Set the hostname to connect to.
-P	--dbpassword <str>	Set the password to use.


-M is a string argument that can contain "pgsql" "mysql" "sqlite" in a select box.
Comment 16 Holger Hetterich 2011-04-18 05:12:13 UTC
Benjamin, please commit these changes into devel-dblayer. This way you can work on a sqlite based setup until we finally merge every code to devel.

When we merged this to devel, you can run the webui against seizewell, until we have created a Stresstest appliance that is fully postgresql and DBI based.
Comment 17 Holger Hetterich 2011-04-18 09:32:52 UTC
all of smbtatools devel-dblayer has been merged and pushed into devel, we will continue development here.

smbtad to follow a bit later.
Comment 18 Robert Piasek (dead mail address) 2011-04-18 12:29:37 UTC
(In reply to comment #17)
> all of smbtatools devel-dblayer has been merged and pushed into devel, we will
> continue development here.
> 
> smbtad to follow a bit later.

Yaay that's brilliant news! You're pushing these changes really quickly!

Grats
Comment 19 Holger Hetterich 2011-04-18 19:13:05 UTC
short status update

- no work on smbtad has been done today :)

- smbtaquery functionality should now completely running via libDBI (we fixed make_human_readable to work via long long to not overflow, fix division by zero in the percentage function, fixed the top function and the usage function to work over libDBI, fixed the list function)

Benjamin, please check all function via the webui.
Comment 20 Holger Hetterich 2011-04-18 19:22:02 UTC
Merged anything from smbtad devel-dblayer branch into the devel branch, since smbtatools is already there and the usage of libDBI has been proven a success, we can continue developing in "mainline devel".
Comment 21 Holger Hetterich 2011-04-18 20:47:42 UTC
currently, if one does want to configure the main parameters (network/database) for smbtamonitor, rrddriver, and smbtaquery, each of it is using it's own configuration file in $(HOME)/./smbtatools .

Since the three tools share a lot of configuration data, I suggest to create a single configuration file, as smbtamonitor and smbtaquery will require the same data to connect to the database.

Any thoughts? We can logically differ about the applications thanks to the excellent iniparser library, such as [general], [smbtamonitor], [smbtaquery] as sections.
Comment 22 Holger Hetterich 2011-04-18 21:48:00 UTC
created bso#8097 for comment#21
Comment 23 Benjamin Brunner 2011-04-19 11:40:32 UTC
I checked all functions in the webui and they seem to be working (except last_activity #8096)
Comment 24 Holger Hetterich 2011-04-23 20:32:50 UTC
I think we can resolve this bug to fixed. DBI is in place all over, and the last problems related to it have been fixed. What's needed is work on the surroundings of this change, such as a tool to convert existing databases, which I am currently working on. This is tracked in bso#8094.