This is a widget for the Smashing dashboard. It displays quite a bit of statistics about your Bacula backup server environment.
It should be opbvious, but you will need a fully functional Bacula (community or enterprise edition) installation. This widget makes use of the Bacula command line tool called bconsole to query the Director for information, then sends the data to the Smashing server via curl.
Copy the smashing-BaculaStatus.sh bash shell script to any directory you like. It may be somewhere on the smashing server, on the Bacula Director, or any machine where cron is available. Near the top of this file, edit the variables to match your system. You will need to create a bconsole-smashing.conf file, and the information (password etc) in this file will need to match a console section in the Director's "bacula-dir.conf" config file. (see examples below)
Here is a snippet of a Console resource in the bacula-dir.conf file which will restrict our script/widget to just being able to issue the "list" command. After editing the bacula-dir.conf file, type reload in bconsole or restart the Director:
Console {
Name = smashing
Password = "dpvCLchbz0I4/tf5HAB8sN0z" # Some pseudo random password
CatalogACL = MyCatalog # Set this to the name of your Bacula catalog database
CommandACL = list # Only allow "list" command
JobACL = *all* # Allow "list jobs" command to show all jobs
ClientACL = *all* # Required for Bacula Enterprise Edition
FilesetACL = *all* # Required for Bacula Enterprise Edition
}
Director {
Name = bacula-dir # Set this to the name of your Bacula director
DIRport = 9101
Address = bacula.example.com # IP address or FQDN of your Bacula Director
Password = "" # Not used, so it may be blank
}
Console {
Name = smashing # Must match the name of the Console in the bacula-dir.conf
Password = "dpvCLchbz0I4/tf5HAB8sN0z" # Must match the Console's Password in the bacula-dir.conf above
Director = bacula-dir # Must match the Name of the Director in this file just above
}
At this point, we should be able to connect to the Director with bconsole using the bconsole-smashing.conf configuration file and type the "list jobs" "list jobtotals" and "list clients" commands that the widget will use:
$ bconsole -c /path/to/bconsole-smashing.conf
Connecting to Director bacula.example.com:9101
1000 OK: 103 bacula-dir Version: 9.0.3 (08 August 2017)
Enter a period to cancel a command.
*list jobs limit=10
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
+-------+-------------+---------------------+------+-------+----------+----------+-----------+
| jobid | name | starttime | type | level | jobfiles | jobbytes | jobstatus |
+-------+-------------+---------------------+------+-------+----------+----------+-----------+
| 9,730 | SpeedyVMs | 2016-06-21 20:00:00 | B | I | 0 | 0 | T |
| 9,743 | SpeedyMusic | 2016-06-22 20:00:01 | B | I | 0 | 0 | T |
[...]
And now the "list jobtotals" command:
*list jobtotals
+------+------------+---------------+------------------------+
| jobs | files | bytes | job |
+------+------------+---------------+------------------------+
| 24 | 22,886 | 506377942 | upsmon |
| 2 | 1,247,407 | 169475049168 | Speedy |
| 159 | 0 | 0 | UpdateSlots |
| 29 | 19,578,500 | 1296746802362 | Zimbra8 |
| 33 | 3,680 | 191430895439 | Catalog |
| 65 | 7,402 | 394530438401 | RestoreCatalog |
| 30 | 629,553 | 6319028879 | dns1 |
[...]
| 10 | 81,558 | 3967342055 | proxmox-a |
| 1 | 47 | 907607706207 | Proxmox_VM_Backups |
+------+------------+---------------+------------------------+
+-------+------------+---------------+
| jobs | files | bytes |
+-------+------------+---------------+
| 1,458 | 29,611,195 | 6526958283636 |
+-------+------------+---------------+
And finally the "list clients" command:
*list clients
+----------+-------------------+---------------+--------------+
| clientid | name | fileretention | jobretention |
+----------+-------------------+---------------+--------------+
| 1 | bacula-fd | 31,536,000 | 31,536,000 |
| 2 | speedy-fd | 31,536,000 | 31,536,000 |
| 3 | upsmon | 31,536,000 | 31,536,000 |
| 6 | zimbra8-fd | 31,536,000 | 31,536,000 |
[...]
Add the following to your dashboard.erb file:
<li data-row="1" data-col="1" data-sizex="1" data-sizey="2">
<div data-id="bacula" data-view="Bacula" data-title="Bacula Backups" data-runningjobs="Waiting on update" data totalclients="Waiting on update" data totaljobs="Waiting on update" data-goodjobs="Waiting on update" data-problemjobs="Waiting on update" data-incompletejobs="Waiting on update" data-firstlast="Waiting on update" data-adminjobs="Waiting on update" data-verifyjobs="Waiting on update" data-restorejobs="Waiting on update" data-totalfiles="Waiting on update" data-totalbytes="Waiting on update">
</div>
</li>
- Copy the bacula.coffee, bacula.html, and bacula.scss to widgets/bacula
- Copy the smashing-BaculaStatus.sh script somehere, and set it executable:
- # chmod +x smashing-BaculaStatus.sh
- Edit the system variables at the top of the smashing-BaculaStatus.sh script
- Add the following line you your cron scheduler. This example will run the script every 30 minutes:
*/30 * * * * /path/to/smashing-BaculaStatus.sh # Of course, use the correct path here :)
Please let me know if there is something terrribly wrong with this widget. It is my first one, and I am sure it can use some enhancements, or fixes.