Bacula-users

Re: [Bacula-users] sorting output bconsole

2009-10-16 19:22:45
Subject: Re: [Bacula-users] sorting output bconsole
From: "Terry L. Inzauro" <tinzauro AT ha-solutions DOT net>
To: bacula-users <Bacula-users AT lists.sourceforge DOT net>
Date: Fri, 16 Oct 2009 18:19:59 -0500
John Drescher wrote:
> On Fri, Oct 16, 2009 at 6:30 PM, Terry L. Inzauro
> <tinzauro AT ha-solutions DOT net> wrote:
>> John Drescher wrote:
>>> On Fri, Oct 16, 2009 at 5:03 PM, Terry L. Inzauro
>>> <tinzauro AT ha-solutions DOT net> wrote:
>>>> Does bconsole support sorting of output?   For instance, can bconsole sort 
>>>> the output of "list volumes pool=FullPool" by size
>>>> or date?
>>>>
>>>> kind regards,
>>>>
>>> You can do that in a query.
>>>
>>> John
>>
>>
>> When you say query, I'm assuming you are suggesting I run an SQL query.  I 
>> like the idea, however,  I am not versed in the
>> ways of the SQL master.
>>
>> Is there a repository of SQL queries somewhere that may be of use for 
>> reporting purposes?
>>
>> I am trying to figure out a way to automate reporting for a client on a 
>> daily/weekly/monthly basis.
>>
> 
> type query in bconsole.
> 
> There are several builtin queries you can use as examples. I believe
> bacula-dir.conf specifies the location of where the query file is.
> 
> On my system I have
> 
>  QueryFile = "/usr/libexec/bacula/query.sql"
> 
> Add your query to that file at the end and bacula will load and
> execute that with the query command of bconsole.
> 
> John


Yup.  That should do it.

For testing, I've decided to use the mysql command line interface and I have 
one last question. How would I take take sums of
two columns such as JobFiles and JobBytes


[18:13:04 root@jenna:~]# mysql -u root -pxxxxx
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 489
Server version: 5.0.51a-24+lenny2-log (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use bacula;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT DISTINCT Job.JobId as JobId,Client.Name as Client,    
FileSet.FileSet AS FileSet,Level,StartTime,
JobFiles,JobBytes,VolumeName  FROM Client,Job,JobMedia,Media,FileSet  WHERE 
Client.Name='peyton'  AND
Client.ClientId=Job.ClientId AND Job.Type='B'  AND Job.JobStatus='T' AND 
Job.FileSetId=FileSet.FileSetId  AND
JobMedia.JobId=Job.JobId AND JobMedia.MediaId=Media.MediaId  ORDER BY 
Job.StartTime;
+-------+--------+---------------+-------+---------------------+----------+-----------+---------------+
| JobId | Client | FileSet       | Level | StartTime           | JobFiles | 
JobBytes  | VolumeName    |
+-------+--------+---------------+-------+---------------------+----------+-----------+---------------+
|  4700 | peyton | StandardLinux | F     | 2009-09-06 05:28:54 |    47498 | 
789899195 | FullPool_0067 |
|  4777 | peyton | StandardLinux | D     | 2009-09-13 00:37:11 |       50 |   
2442702 | DiffPool_0004 |
|  4910 | peyton | StandardLinux | I     | 2009-09-25 00:28:57 |       43 |   
2095221 | IncrPool_0036 |
|  4921 | peyton | StandardLinux | I     | 2009-09-26 00:29:15 |       41 |   
2072585 | IncrPool_0090 |
|  4932 | peyton | StandardLinux | D     | 2009-09-27 00:53:34 |       52 |   
2497277 | DiffPool_0011 |
|  4943 | peyton | StandardLinux | I     | 2009-09-28 00:29:48 |       50 |   
2366865 | IncrPool_0037 |
|  4954 | peyton | StandardLinux | I     | 2009-09-29 00:28:55 |       41 |   
2018132 | IncrPool_0119 |
|  4965 | peyton | StandardLinux | I     | 2009-09-30 00:38:28 |       41 |   
2035566 | IncrPool_0136 |
|  4976 | peyton | StandardLinux | I     | 2009-10-01 00:29:36 |       41 |   
2052047 | IncrPool_0130 |
|  4987 | peyton | StandardLinux | I     | 2009-10-02 00:31:56 |       45 |   
2069134 | IncrPool_0011 |
|  4998 | peyton | StandardLinux | I     | 2009-10-03 00:29:48 |       41 |   
2085954 | IncrPool_0140 |
|  5009 | peyton | StandardLinux | F     | 2009-10-04 05:36:39 |    47498 | 
789930570 | FullPool_0009 |
|  5020 | peyton | StandardLinux | I     | 2009-10-05 00:29:15 |       50 |   
2378897 | IncrPool_0029 |
|  5031 | peyton | StandardLinux | I     | 2009-10-06 00:29:07 |       41 |   
2029220 | IncrPool_0004 |
|  5042 | peyton | StandardLinux | I     | 2009-10-07 00:51:50 |       41 |   
2046245 | IncrPool_0055 |
|  5053 | peyton | StandardLinux | I     | 2009-10-08 00:28:28 |       41 |   
2062919 | IncrPool_0077 |
|  5108 | peyton | StandardLinux | I     | 2009-10-14 01:25:39 |       50 |   
2430892 | IncrPool_0079 |
|  5119 | peyton | StandardLinux | I     | 2009-10-14 02:41:33 |       50 |   
2431747 | IncrPool_0027 |
|  5130 | peyton | StandardLinux | I     | 2009-10-15 00:30:11 |       41 |   
2073822 | IncrPool_0009 |
|  5141 | peyton | StandardLinux | I     | 2009-10-16 00:30:07 |       41 |   
2091084 | IncrPool_0005 |
+-------+--------+---------------+-------+---------------------+----------+-----------+---------------+
20 rows in set (0.01 sec)



Thank you for all of your help.


Terry


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users