#!/bin/sh

po_domain="alterator-backup-server"
alterator_api_version=1
backup_server_config=/etc/sysconfig/backup-server

. bacula-alterator-sh-functions
. alterator-hw-functions
. shell-config

on_message()
{
  case "$in_action" in
    read)
	write_string_param "backup_server_director" "$(bacula_director_get_name)"
	write_string_param "backup_server_datetime" "$(run_localized date +'%F %T')"
	local path="$(bacula_storage_get_path)"
	local usage="$([ -z "$path" ] || bacula_storage_get_usage "$path")"
	write_string_param "backup_server_archive"  "$(printf '%s %s' `_ "utilization"` "$usage")"
	local iface_name="$(shell_config_get "$backup_server_config" STORAGE_IFACE_NAME)"
	[ -z "$iface_name" ] || write_string_param "backup_server_network" "$(netdev_read_ip "$iface_name"|head -n1)"
	;;
  esac
}

message_loop
