bareos / python-bareos

Python libraries to access Bareos
7 stars 10 forks source link

wrong Json output #7

Closed svennd closed 7 years ago

svennd commented 7 years ago

I'm trying to get all connected clients; director.call('status director')['client-connection']

However the output is incomplete (there are two clients in my setup) : {u'protocol_version': 54, u'connect_time': u'22-Mar-17 12:05', u'authenticated': 1, u'name': u'LaptopSvenn'}

When I call director.call('status director')

I get both clients but the format is incorrect. {u'protocol_version': 54, u'connect_time': u'22-Mar-17 12:06', u'authenticated': 1, u'name': u'rocky', u'client-connection': {u'protocol_version': 54, u'connect_time': u'22-Mar-17 12:05', u'authenticated': 1, u'name': u'LaptopSvenn'}} I ran this on Centos 7 / Python 2.7.5

For reference this is the non-json result :

[root@lungo-02 python]# python test.py
### director.call('status director')
{u'protocol_version': 54, u'connect_time': u'22-Mar-17 12:06', u'authenticated': 1, u'name': u'rocky', u'client-connection': {u'protocol_version': 54, u'connect_time': u'22-Mar-17 12:05', u'authenticated': 1, u'name': u'LaptopSvenn'}}

###  director.call('status director')['client-connection']
{u'protocol_version': 54, u'connect_time': u'22-Mar-17 12:05', u'authenticated': 1, u'name': u'LaptopSvenn'}

### director.call('status director')
bareos-dir Version: 16.2.4 (01 July 2016) x86_64-redhat-linux-gnu redhat CentOS Linux release 7.0.1406 (Core)
Daemon started 22-Mar-17 12:05. Jobs: run=0, running=0 mode=0 db=mysql
 Heap: heap=1,142,784 smbytes=230,022 max_bytes=234,702 bufs=1,388 max_bufs=1,401
Plugin Info:
 Plugin     : python-dir.so
 Description: Python Director Daemon Plugin
 Version    : 3, Date: October 2013
 Author     : Marco van Wieringen
 License    : Bareos AGPLv3
 Usage      : python:instance=<instance_id>:module_path=<path-to-python-mod

Scheduled Jobs:
Level          Type     Pri  Scheduled          Name               Volume
===========================================================================
Incremental    Backup    10  22-Mar-17 21:00    backup-bareos-fd   Incremen
[...]
Full           Backup    11  22-Mar-17 21:10    BackupCatalog      Incremen
====

Running Jobs:
Console connected at 22-Mar-17 12:26
Console connected at 22-Mar-17 12:27
No Jobs running.
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name
====================================================================
   145  Incr          0         0   OK       22-Mar-17 02:07 TriggerBackup
   146  Incr          0         0   OK       22-Mar-17 03:07 TriggerBackup
   147  Incr          0         0   OK       22-Mar-17 04:07 TriggerBackup
   148  Incr          0         0   OK       22-Mar-17 05:07 TriggerBackup
   149  Incr          0         0   OK       22-Mar-17 06:07 TriggerBackup
   150  Incr          0         0   OK       22-Mar-17 07:07 TriggerBackup
   151  Incr          0         0   OK       22-Mar-17 08:07 TriggerBackup
   152  Incr          0         0   OK       22-Mar-17 09:07 TriggerBackup
   153  Incr          0         0   OK       22-Mar-17 10:07 TriggerBackup
   154  Incr          2       213   OK       22-Mar-17 11:07 TriggerBackup

Client Initiated Connections (waiting for jobs):
Connect time        Protocol            Authenticated       Name
===========================================================================
22-Mar-17 12:05     54                  1                   LaptopSvenn
22-Mar-17 12:06     54                  1                   rocky
====

Perhaps relevant I get this error : bareos-dir: ERROR in output_formatter.c:126 Failed to add JSON reference client-connection (stack size: 1) already exists. This should not happen. Ignoring.

joergsteffens commented 7 years ago

There is a bugfix for the json "status director" output in bareos-16.2.5.