mirror of
https://github.com/lephisto/crossover.git
synced 2025-12-06 12:19:20 +01:00
Compare commits
3 Commits
v0.5
...
010f04c412
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
010f04c412 | ||
|
|
13245fdf5e | ||
|
|
ae641a3927 |
31
crossover
31
crossover
@@ -9,13 +9,14 @@ declare opt_influx_api_url=''
|
|||||||
declare opt_influx_token=''
|
declare opt_influx_token=''
|
||||||
declare opt_influx_bucket=''
|
declare opt_influx_bucket=''
|
||||||
declare opt_influx_api_org=''
|
declare opt_influx_api_org=''
|
||||||
|
declare opt_influx_jobname=''
|
||||||
declare opt_influx_job_metrics='crossover_xmit'
|
declare opt_influx_job_metrics='crossover_xmit'
|
||||||
declare opt_influx_summary_metrics='crossover_jobs'
|
declare opt_influx_summary_metrics='crossover_jobs'
|
||||||
|
|
||||||
# Cross Pool Migration and incremental replication Tool for Proxmox VMs using Ceph.
|
# Cross Pool Migration and incremental replication Tool for Proxmox VMs using Ceph.
|
||||||
# Author: Bastian Mäuser <bma@netz.org>
|
# Author: Bastian Mäuser <bma@netz.org>
|
||||||
|
|
||||||
declare -r VERSION=0.5
|
declare -r VERSION=0.6
|
||||||
declare -r NAME=$(basename "$0")
|
declare -r NAME=$(basename "$0")
|
||||||
declare -r PROGNAME=${NAME%.*}
|
declare -r PROGNAME=${NAME%.*}
|
||||||
|
|
||||||
@@ -114,6 +115,7 @@ Options:
|
|||||||
--influxurl Influx API url (e.g. --influxurl=https://your-influxserver.com/api/)
|
--influxurl Influx API url (e.g. --influxurl=https://your-influxserver.com/api/)
|
||||||
--influxtoken Influx API token with write permission
|
--influxtoken Influx API token with write permission
|
||||||
--influxbucket Influx Bucket to write to (e.g. --influxbucket=telegraf/autogen)
|
--influxbucket Influx Bucket to write to (e.g. --influxbucket=telegraf/autogen)
|
||||||
|
--jobname Descriptive name for the job, used in Statistics
|
||||||
Switches:
|
Switches:
|
||||||
--online Allow online Copy
|
--online Allow online Copy
|
||||||
--nolock Don't lock source VM on Transfer (mainly for test purposes)
|
--nolock Don't lock source VM on Transfer (mainly for test purposes)
|
||||||
@@ -135,7 +137,7 @@ function parse_opts(){
|
|||||||
local args
|
local args
|
||||||
args=$(getopt \
|
args=$(getopt \
|
||||||
--options '' \
|
--options '' \
|
||||||
--longoptions=vmid:,prefixid:,excludevmids:,destination:,pool:,keeplocal:,keepremote:,rewrite:,influxurl:,influxorg:,influxtoken:,influxbucket:,online,nolock,keep-slock,keep-dlock,overwrite,dry-run,debug \
|
--longoptions=vmid:,prefixid:,excludevmids:,destination:,pool:,keeplocal:,keepremote:,rewrite:,influxurl:,influxorg:,influxtoken:,influxbucket:,jobname:,online,nolock,keep-slock,keep-dlock,overwrite,dry-run,debug \
|
||||||
--name "$PROGNAME" \
|
--name "$PROGNAME" \
|
||||||
-- "$@") \
|
-- "$@") \
|
||||||
|| end_process 128
|
|| end_process 128
|
||||||
@@ -156,6 +158,7 @@ function parse_opts(){
|
|||||||
--influxorg) opt_influx_api_org=$2; shift 2;;
|
--influxorg) opt_influx_api_org=$2; shift 2;;
|
||||||
--influxtoken) opt_influx_token=$2; shift 2;;
|
--influxtoken) opt_influx_token=$2; shift 2;;
|
||||||
--influxbucket) opt_influx_bucket=$2; shift 2;;
|
--influxbucket) opt_influx_bucket=$2; shift 2;;
|
||||||
|
--jobname) opt_influx_jobname=$2; shift 2;;
|
||||||
|
|
||||||
--online) opt_online=1; shift 2;;
|
--online) opt_online=1; shift 2;;
|
||||||
--dry-run) opt_dry_run=1; shift;;
|
--dry-run) opt_dry_run=1; shift;;
|
||||||
@@ -183,6 +186,8 @@ function parse_opts(){
|
|||||||
|
|
||||||
[ -z "$opt_vm_ids" ] && { log info "VM id is not set."; end_process 1; }
|
[ -z "$opt_vm_ids" ] && { log info "VM id is not set."; end_process 1; }
|
||||||
|
|
||||||
|
[ -z "$opt_influx_jobname" ] && { log info "Jobname is not set."; end_process 1; }
|
||||||
|
|
||||||
if [ -n "$opt_keep_local" ]; then
|
if [ -n "$opt_keep_local" ]; then
|
||||||
if ! [[ ${opt_keep_local:(-1)} == "s" || ${opt_keep_local:(-1)} == "d" ]]; then
|
if ! [[ ${opt_keep_local:(-1)} == "s" || ${opt_keep_local:(-1)} == "d" ]]; then
|
||||||
echo "--keeplocal: Parameter malformed. suffix s or d missing"
|
echo "--keeplocal: Parameter malformed. suffix s or d missing"
|
||||||
@@ -201,6 +206,7 @@ function parse_opts(){
|
|||||||
local all=''
|
local all=''
|
||||||
local data=''
|
local data=''
|
||||||
local cnt=''
|
local cnt=''
|
||||||
|
local ids=''
|
||||||
|
|
||||||
all=$(get_vm_ids "$QEMU_CONF_CLUSTER/*$EXT_CONF" "$LXC_CONF_CLUSTER/*$EXT_CONF")
|
all=$(get_vm_ids "$QEMU_CONF_CLUSTER/*$EXT_CONF" "$LXC_CONF_CLUSTER/*$EXT_CONF")
|
||||||
all=$(echo "$all" | tr ',' "\n")
|
all=$(echo "$all" | tr ',' "\n")
|
||||||
@@ -213,8 +219,17 @@ function parse_opts(){
|
|||||||
done
|
done
|
||||||
vm_ids=$(echo "$vm_ids" | tr ',' "\n")
|
vm_ids=$(echo "$vm_ids" | tr ',' "\n")
|
||||||
else
|
else
|
||||||
vm_ids=$(echo "$opt_vm_ids" | tr ',' "\n")
|
if [ ! -z $opt_prefix_id ]; then
|
||||||
|
ids=$(echo "$opt_vm_ids" | tr ',' "\n")
|
||||||
|
for id in $ids; do
|
||||||
|
vm_ids=$(echo "$vm_ids$id:$opt_prefix_id$id,")
|
||||||
|
done
|
||||||
|
vm_ids=$(echo "$vm_ids" | tr ',' "\n")
|
||||||
|
else
|
||||||
|
vm_ids=$(echo "$opt_vm_ids" | tr ',' "\n")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
log debug "vm_ids: $vm_ids"
|
||||||
}
|
}
|
||||||
|
|
||||||
human_readable() {
|
human_readable() {
|
||||||
@@ -333,13 +348,15 @@ function log(){
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
warn)
|
warn)
|
||||||
echo "WARNING: $message" 1>&2
|
echo -n $(echoyellow "WARNING: ")
|
||||||
|
echo $(echowhite "$message") 1>&2
|
||||||
echo -e "$message" >> "$LOG_FILE";
|
echo -e "$message" >> "$LOG_FILE";
|
||||||
[ $opt_syslog -eq 1 ] && logger -t "$PROGNAME" -p daemon.warn "$message"
|
[ $opt_syslog -eq 1 ] && logger -t "$PROGNAME" -p daemon.warn "$message"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
error)
|
error)
|
||||||
echo "ERROR: $message" 1>&2
|
echo -n $(echored "ERROR: ")
|
||||||
|
echo $(echowhite "$message") 1>&2
|
||||||
echo -e "$message" >> "$LOG_FILE";
|
echo -e "$message" >> "$LOG_FILE";
|
||||||
[ $opt_syslog -eq 1 ] && logger -t "$PROGNAME" -p daemon.err "$message"
|
[ $opt_syslog -eq 1 ] && logger -t "$PROGNAME" -p daemon.err "$message"
|
||||||
;;
|
;;
|
||||||
@@ -573,7 +590,7 @@ function mirror() {
|
|||||||
log info "VM $vm_id - Disk Summary: Took $(( enddisk - startdisk )) Seconds to transfer $(human_readable "$perf_bytes_total" 2) in a $xmittype run"
|
log info "VM $vm_id - Disk Summary: Took $(( enddisk - startdisk )) Seconds to transfer $(human_readable "$perf_bytes_total" 2) in a $xmittype run"
|
||||||
if [ -n "$opt_influx_api_url" ]; then
|
if [ -n "$opt_influx_api_url" ]; then
|
||||||
log info "VM $vm_id - Logging to InfluxDB: $opt_influx_api_url"
|
log info "VM $vm_id - Logging to InfluxDB: $opt_influx_api_url"
|
||||||
influxlp="$opt_influx_job_metrics,vmname=$vmname,destination=$opt_destination,srcimage=$src_image_name,dstimage=$dst_image_name,xmittype=$xmittype bytescalculated=$snapshotsize""i,bytesonwire=$perf_bytes_total""i,xmitrc=$xmitrc""i,freezerc=$freezerc""i,unfreezerc=$unfreezerc""i,basets=$basets""i"
|
influxlp="$opt_influx_job_metrics,vmname=$vmname,jobname=$opt_influx_jobname,destination=$opt_destination,srcimage=$src_image_name,dstimage=$dst_image_name,xmittype=$xmittype bytescalculated=$snapshotsize""i,bytesonwire=$perf_bytes_total""i,xmitrc=$xmitrc""i,freezerc=$freezerc""i,unfreezerc=$unfreezerc""i,basets=$basets""i"
|
||||||
log debug "InfluxLP: --->\n $influxlp"
|
log debug "InfluxLP: --->\n $influxlp"
|
||||||
cmd="curl --request POST \"$opt_influx_api_url/v2/write?org=$opt_influx_api_org&bucket=$opt_influx_bucket&precision=ns\" --header \"Authorization: Token $opt_influx_token\" --header \"Content-Type: text/plain; charset=utf-8\" --header \"Accept: application/json\" --data-binary '$influxlp'"
|
cmd="curl --request POST \"$opt_influx_api_url/v2/write?org=$opt_influx_api_org&bucket=$opt_influx_bucket&precision=ns\" --header \"Authorization: Token $opt_influx_token\" --header \"Content-Type: text/plain; charset=utf-8\" --header \"Accept: application/json\" --data-binary '$influxlp'"
|
||||||
do_run "$cmd"
|
do_run "$cmd"
|
||||||
@@ -601,7 +618,7 @@ function mirror() {
|
|||||||
log info "Differential Bytes .......: $(human_readable $perf_bytes_diff)"
|
log info "Differential Bytes .......: $(human_readable $perf_bytes_diff)"
|
||||||
if [ -n "$opt_influx_api_url" ]; then
|
if [ -n "$opt_influx_api_url" ]; then
|
||||||
log info "VM $vm_id - Logging Job summary to InfluxDB: $opt_influx_api_url"
|
log info "VM $vm_id - Logging Job summary to InfluxDB: $opt_influx_api_url"
|
||||||
influxlp="$opt_influx_summary_metrics perf_bytes_diff=$perf_bytes_diff""i,perf_bytes_full=$perf_bytes_full""i,perf_bytes_total=$perf_bytes_total""i,perf_diff_failed=$perf_diff_failed""i,perf_diff_ok=$perf_diff_ok""i,perf_freeze_failed=$perf_freeze_failed""i,perf_freeze_ok=$perf_freeze_ok""i,perf_full_failed=$perf_full_failed""i,perf_full_ok=$perf_full_ok""i,perf_ss_failed=$perf_ss_failed""i,perf_ss_ok=$perf_ss_ok""i,perf_vm_running=$perf_vm_running""i,perf_vm_stopped=$perf_vm_stopped""i"
|
influxlp="$opt_influx_summary_metrics,jobname=$opt_influx_jobname perf_bytes_diff=$perf_bytes_diff""i,perf_bytes_full=$perf_bytes_full""i,perf_bytes_total=$perf_bytes_total""i,perf_diff_failed=$perf_diff_failed""i,perf_diff_ok=$perf_diff_ok""i,perf_freeze_failed=$perf_freeze_failed""i,perf_freeze_ok=$perf_freeze_ok""i,perf_full_failed=$perf_full_failed""i,perf_full_ok=$perf_full_ok""i,perf_ss_failed=$perf_ss_failed""i,perf_ss_ok=$perf_ss_ok""i,perf_vm_running=$perf_vm_running""i,perf_vm_stopped=$perf_vm_stopped""i"
|
||||||
log debug "InfluxLP: --->\n $influxlp"
|
log debug "InfluxLP: --->\n $influxlp"
|
||||||
cmd="curl --request POST \"$opt_influx_api_url/v2/write?org=$opt_influx_api_org&bucket=$opt_influx_bucket&precision=ns\" --header \"Authorization: Token $opt_influx_token\" --header \"Content-Type: text/plain; charset=utf-8\" --header \"Accept: application/json\" --data-binary '$influxlp'"
|
cmd="curl --request POST \"$opt_influx_api_url/v2/write?org=$opt_influx_api_org&bucket=$opt_influx_bucket&precision=ns\" --header \"Authorization: Token $opt_influx_token\" --header \"Content-Type: text/plain; charset=utf-8\" --header \"Accept: application/json\" --data-binary '$influxlp'"
|
||||||
do_run "$cmd"
|
do_run "$cmd"
|
||||||
|
|||||||
Reference in New Issue
Block a user