Run cronjob in scriptherder and report errors found
This commit is contained in:
parent
800b2c4afc
commit
06d7fabf4b
3 changed files with 30 additions and 9 deletions
|
@ -110,11 +110,16 @@ define sunetdrive::app_type (
|
||||||
content => template('sunetdrive/application/scan_external_mounts.sh'),
|
content => template('sunetdrive/application/scan_external_mounts.sh'),
|
||||||
mode => '0744',
|
mode => '0744',
|
||||||
}
|
}
|
||||||
|
sunet::scriptherder::cronjob { 'scriptherder_scan_external_mounts':
|
||||||
|
cmd => '/usr/local/bin/scan_external_mounts',
|
||||||
|
hour => '1',
|
||||||
|
minute => '20',
|
||||||
|
ok_criteria => ['exit_status=0','max_age=2d'],
|
||||||
|
warn_criteria => ['exit_status=1','max_age=3d'],
|
||||||
|
}
|
||||||
cron { 'scan_external_mounts':
|
cron { 'scan_external_mounts':
|
||||||
command => '/usr/local/bin/scan_external_mounts',
|
ensure => absent,
|
||||||
user => 'root',
|
command => 'true',
|
||||||
minute => '20',
|
|
||||||
hour => '1',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file { '/opt/nextcloud/cron.sh':
|
file { '/opt/nextcloud/cron.sh':
|
||||||
|
|
|
@ -55,11 +55,16 @@ class sunetdrive::multinode (
|
||||||
content => template('sunetdrive/application/scan_external_mounts.sh'),
|
content => template('sunetdrive/application/scan_external_mounts.sh'),
|
||||||
mode => '0744',
|
mode => '0744',
|
||||||
}
|
}
|
||||||
|
sunet::scriptherder::cronjob { 'scriptherder_scan_external_mounts':
|
||||||
|
cmd => '/usr/local/bin/scan_external_mounts',
|
||||||
|
hour => '1',
|
||||||
|
minute => '20',
|
||||||
|
ok_criteria => ['exit_status=0','max_age=2d'],
|
||||||
|
warn_criteria => ['exit_status=1','max_age=3d'],
|
||||||
|
}
|
||||||
cron { 'scan_external_mounts':
|
cron { 'scan_external_mounts':
|
||||||
command => '/usr/local/bin/scan_external_mounts',
|
ensure => absent,
|
||||||
user => 'root',
|
command => 'true',
|
||||||
minute => '20',
|
|
||||||
hour => '1',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file { '/usr/local/bin/nocc':
|
file { '/usr/local/bin/nocc':
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
error_ids=""
|
||||||
# Only run if this is the only instance of this script running
|
# Only run if this is the only instance of this script running
|
||||||
# note: since this script forks to run pgrep, we need -eq 2 here
|
# note: since this script forks to run pgrep, we need -eq 2 here
|
||||||
if [[ $(pgrep -f "${0}" | wc -l) -eq 2 ]]; then
|
if [[ $(pgrep -f "${0}" | wc -l) -eq 2 ]]; then
|
||||||
|
@ -8,7 +9,17 @@ if [[ $(pgrep -f "${0}" | wc -l) -eq 2 ]]; then
|
||||||
sleep $((16#$(ip a | grep "link/ether" | head -1 | awk -F ':' '{print $6}' | awk '{print $1}') / 2))m
|
sleep $((16#$(ip a | grep "link/ether" | head -1 | awk -F ':' '{print $6}' | awk '{print $1}') / 2))m
|
||||||
for container in $(get_containers); do
|
for container in $(get_containers); do
|
||||||
for id in $(nocc "${container}" files_external:list --all --output json | jq '.[].mount_id' | jq .); do
|
for id in $(nocc "${container}" files_external:list --all --output json | jq '.[].mount_id' | jq .); do
|
||||||
nocc "${container}" files_external:scan "${id}"
|
nocc "${container}" files_external:scan "${id}" | grep Error
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if [[ ${?} -eq 0 ]]; then
|
||||||
|
error_ids="${error_ids} ${id}"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${error_ids}" ]]; then
|
||||||
|
echo "Errors found in the following mounts: ${error_ids}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue