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 widget to just being able to query the status of the Director and list jobs. 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 = status, list # Only allow "status" and "list" commands
JobACL = *all* # Allow "status director" command to show all jobs
}
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" and "status director" 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.
* status director
bacula-dir Version: 9.0.3 (08 August 2017) x86_64-pc-linux-gnu gentoo
Daemon started 23-Sep-17 13:12, conf reloaded 23-Sep-2017 13:12:52
Jobs: run=0, running=0 mode=0,0
Heap: heap=389,120 smbytes=489,382 max_bytes=499,788 bufs=3,324 max_bufs=3,331
Res: njobs=69 nclients=22 nstores=4 npools=13 ncats=1 nfsets=36 nscheds=12
Scheduled Jobs:
Level Type Pri Scheduled Job Name Volume
===================================================================================
Admin Admin 5 23-Sep-17 20:00 UpdateSlots
Incremental Backup 10 23-Sep-17 20:00 pi c0_0004_0066
Incremental Backup 10 23-Sep-17 20:00 jabber c0_0004_0066
Incremental Backup 10 23-Sep-17 20:00 dns1 c0_0004_0066
Incremental Backup 10 23-Sep-17 20:00 helpdesk c0_0004_0066
[...]
Running Jobs:
Console connected at 23-Sep-17 13:12
No Jobs running.
====
Terminated Jobs:
JobId Level Files Bytes Status Finished Name
====================================================================
16833 Incr 20 15.29 M OK 23-Sep-17 01:20 pi
16834 Admin 0 0 OK 23-Sep-17 01:20 UpdateSlots
16835 Full 681,136 45.60 G OK 23-Sep-17 04:29 Zimbra8
16837 Restore 120 6.911 G OK 23-Sep-17 04:46 RestoreCatalog
[...]
And now test the "list jobs" 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 |
[...]
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 totaljobs="Waiting on update" data-firstlast="Waiting on update" data-goodjobs="Waiting on update" data-problemjobs="Waiting on update" data-incompletejobs="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.
