Added HP-UX plugins check_hpux_drd_status, check_hpux_patch_version
Added routines to include_data.sh
This commit is contained in:
parent
17f15593ed
commit
99a5198096
@ -60,6 +60,7 @@ This is the OS/platform plugin package"
|
||||
|
||||
directory ../../sources/lib/platform/hp-ux=/opt/hc/lib/platform/hp-ux
|
||||
file -m 755 check_hpux_autopath.sh
|
||||
file -m 755 check_hpux_drd_status.sh
|
||||
file -m 755 check_hpux_file_age.sh
|
||||
file -m 755 check_hpux_file_change.sh
|
||||
file -m 755 check_hpux_fs_mounts.sh
|
||||
@ -73,6 +74,7 @@ This is the OS/platform plugin package"
|
||||
file -m 755 check_hpux_kernel_usage.sh
|
||||
file -m 755 check_hpux_named_status.sh
|
||||
file -m 755 check_hpux_ntp_status.sh
|
||||
file -m 755 check_hpux_patch_version.sh
|
||||
file -m 755 check_hpux_ovpa_status.sh
|
||||
file -m 755 check_hpux_postfix_status.sh
|
||||
file -m 755 check_hpux_root_crontab.sh
|
||||
@ -99,6 +101,7 @@ This is the OS/platform plugin package"
|
||||
file_permissions -u 0222 -o root -g sys
|
||||
|
||||
directory ../../configs/etc/=/etc/opt/hc
|
||||
file -m 644 check_hpux_drd_status.conf.dist
|
||||
file -m 644 check_hpux_file_age.conf.dist
|
||||
file -m 644 check_hpux_file_change.conf.dist
|
||||
file -m 644 check_hpux_fs_mounts_options.conf.dist
|
||||
@ -108,6 +111,7 @@ This is the OS/platform plugin package"
|
||||
file -m 644 check_hpux_kernel_params.conf.dist
|
||||
file -m 644 check_hpux_kernel_usage.conf.dist
|
||||
file -m 644 check_hpux_ntp_status.conf.dist
|
||||
file -m 755 check_hpux_patch_version.conf.dist
|
||||
file -m 644 check_hpux_root_crontab.conf.dist
|
||||
file -m 644 check_hpux_sg_package_status.conf.dist
|
||||
file -m 644 check_hpux_sg_package_config.conf.dist
|
||||
|
28
configs/etc/check_hpux_drd_status.conf.dist
Normal file
28
configs/etc/check_hpux_drd_status.conf.dist
Normal file
@ -0,0 +1,28 @@
|
||||
#******************************************************************************
|
||||
# @(#) check_hpux_drd_status.conf.dist
|
||||
#******************************************************************************
|
||||
# This is a configuration file for the check_hpux_drd_status HC plugin.
|
||||
# All lines starting with a '#' are comment lines.
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# check clone age? (yes|no)
|
||||
# [default: yes]
|
||||
check_clone=yes
|
||||
|
||||
# maximum days before the drd clone gets flagged as 'too old'
|
||||
# [default: 30]
|
||||
clone_age=30
|
||||
|
||||
# check sync age? (yes|no)
|
||||
# [default: yes]
|
||||
check_sync=yes
|
||||
|
||||
# maximum days before the drd sync gets flagged as 'too old'
|
||||
# [default: 30]
|
||||
sync_age=30
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
#******************************************************************************
|
20
configs/etc/check_hpux_patch_version.conf.dist
Normal file
20
configs/etc/check_hpux_patch_version.conf.dist
Normal file
@ -0,0 +1,20 @@
|
||||
#******************************************************************************
|
||||
# @(#) check_hpux_patch_version.conf
|
||||
#******************************************************************************
|
||||
# This is a configuration file for the check_hpux_patch_version HC plugin.
|
||||
# All lines starting with a '#' are comment lines.
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# OE version that should be checked (version string as displayed by 'swlist')
|
||||
# [default: none]
|
||||
required_oe=""
|
||||
|
||||
# comma-separated list of SD patches that should be checked
|
||||
# [default: none]
|
||||
required_patches=""
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
#******************************************************************************
|
@ -341,7 +341,7 @@ fi
|
||||
# --check-host,--check/--disable/--enable/--run/--show/--archive,--hc
|
||||
if [[ -n "${ARG_HC}" ]] && (( ARG_ACTION == 0 ))
|
||||
then
|
||||
print -u2 "ERROR: you must specify an action for the HC (--check/--disable/--enable/--run/--show)"
|
||||
print -u2 "ERROR: you must specify an action for the HC (--archive/--check/--disable/--enable/--run/--show)"
|
||||
exit 1
|
||||
fi
|
||||
if (( ARG_CHECK_HOST == 0 ))
|
||||
|
@ -165,6 +165,22 @@ print -R "${1}" 2>/dev/null | tr ',' ' ' 2>/dev/null
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_comma2pipe()
|
||||
# DOES: replace commas with a pipe
|
||||
# EXPECTS: [string] with commas
|
||||
# OUTPUTS: [string] with pipes
|
||||
# RETURNS: 0
|
||||
# REQUIRES: n/a
|
||||
function data_comma2pipe
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
|
||||
print -R "${1}" 2>/dev/null | tr ',' '|' 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_comma2newline()
|
||||
# DOES: replace commas with a space
|
||||
@ -229,6 +245,22 @@ print -R "${1}" 2>/dev/null | tr -s ' ' 2>/dev/null | tr ' ' ',' 2>/dev/null
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_pipe2comma()
|
||||
# DOES: replace pipes with a comma
|
||||
# EXPECTS: [string] with pipes
|
||||
# OUTPUTS: [string] with commas
|
||||
# RETURNS: 0
|
||||
# REQUIRES: n/a
|
||||
function data_pipe2comma
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
|
||||
print -R "${1}" 2>/dev/null | tr -s '|' 2>/dev/null | tr ' '|',' 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_space2hash()
|
||||
# DOES: replace spaces with a hash
|
||||
@ -261,6 +293,70 @@ print -R "${1}" 2>/dev/null | tr -d '\n' 2>/dev/null | tr -d '\r' 2>/dev/null
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_strip_space()
|
||||
# DOES: remove spaces
|
||||
# EXPECTS: [string] with spaces (all whitespace)
|
||||
# OUTPUTS: [string] without spaces (all whitespace)
|
||||
# RETURNS: 0
|
||||
# REQUIRES: n/a
|
||||
function data_strip_space
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
|
||||
print -R "${1}" 2>/dev/null | tr -d '[:space:]' 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_strip_leading_space()
|
||||
# DOES: remove leading spaces
|
||||
# EXPECTS: [string] with leading spaces (all whitespace)
|
||||
# OUTPUTS: [string] without leading spaces (all whitespace)
|
||||
# RETURNS: 0
|
||||
# REQUIRES: n/a
|
||||
function data_strip_leading_space
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
|
||||
print -R "${1}" | sed 's/^[[:blank:]]*//' 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_strip_trailing_space()
|
||||
# DOES: remove trailing spaces
|
||||
# EXPECTS: [string] with trailing spaces (all whitespace)
|
||||
# OUTPUTS: [string] without trailing spaces (all whitespace)
|
||||
# RETURNS: 0
|
||||
# REQUIRES: n/a
|
||||
function data_strip_trailing_space
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
|
||||
print -R "${1}" | sed 's/[[:blank:]]*$//' 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_strip_outer_space()
|
||||
# DOES: remove leading + trailing spaces
|
||||
# EXPECTS: [string] with leading + trailing spaces (all whitespace)
|
||||
# OUTPUTS: [string] without leading + trailing spaces (all whitespace)
|
||||
# RETURNS: 0
|
||||
# REQUIRES: n/a
|
||||
function data_strip_outer_space
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
|
||||
print -R "${1}" | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//' 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_lc()
|
||||
# DOES: switch to lower case
|
||||
@ -272,7 +368,7 @@ function data_lc
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
|
||||
print -R "${1}" 2>/dev/null | tr '[:upper:]' '[:lower:]' 2>/dev/null
|
||||
print -R "${1}" 2>/dev/null | tr '[:upper:]' '[:lower:]' 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -288,7 +384,7 @@ function data_uc
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
|
||||
print -R "${1}" 2>/dev/null | tr '[:lower:]' '[:upper:]' 2>/dev/null
|
||||
print -R "${1}" 2>/dev/null | tr '[:lower:]' '[:upper:]' 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -499,6 +595,53 @@ _RC=$(print "${_IP}" | grep -c -E -e '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{
|
||||
return ${_RC}
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_date2epoch()
|
||||
# DOES: converts a given date into UNIX epoch seconds
|
||||
# EXPECTS: date formatted as individual parameters:
|
||||
# $1 : YYYY
|
||||
# $2 : MM
|
||||
# $3 : DD
|
||||
# $4 : HH
|
||||
# $5 : MM
|
||||
# $6 : SS
|
||||
# OUTPUTS: UNIX epoch seconds [number]
|
||||
# RETURNS: 0
|
||||
# REQUIRES: n/a
|
||||
# REFERENCE: https://groups.google.com/forum/#!topic/comp.unix.shell/aPoPzFWP2Og
|
||||
function data_date2epoch
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _YEAR="$1"
|
||||
typeset _MONTH="$2"
|
||||
typeset _DAY="$3"
|
||||
typeset _HOUR="$4"
|
||||
typeset _MINUTE="$5"
|
||||
typeset _SECOND="$6"
|
||||
typeset _DAYS_ACC
|
||||
typeset _YEAR_DAY
|
||||
typeset _EPOCH
|
||||
typeset _LEAP_YEARS
|
||||
set -A _DAYS_ACC 0 0 31 59 90 120 151 181 212 243 273 304 334 365
|
||||
|
||||
# calculate day of year (counting from 0)
|
||||
_YEAR_DAY=$(( (${_DAY} - 1) + ${_DAYS_ACC[${_MONTH}]} ))
|
||||
|
||||
# calculate number of leap years
|
||||
_LEAP_YEARS=$(( (${_YEAR} - 1968) / 4 ))
|
||||
_LEAP_YEARS=$(( ${_LEAP_YEARS} - ${_YEAR} / 100 + ${_YEAR} / 400 + 15 ))
|
||||
|
||||
# adjust if we are still in Jan/Feb of leap year
|
||||
[[ $((${_YEAR} % 4)) = 0 && ${_MONTH} < 3 ]] && _LEAP_YEARS=$(( ${_LEAP_YEARS} - 1 ))
|
||||
|
||||
# calculate the time since epoch
|
||||
_EPOCH=$(( ((${_YEAR} - 1970) * 365 + ${_YEAR_DAY} + ${_LEAP_YEARS}) * 86400
|
||||
+ ${_HOUR} * 3600 + ${_MINUTE} * 60 + ${_SECOND} ))
|
||||
|
||||
print ${_EPOCH}
|
||||
}
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
|
273
sources/lib/platform/hp-ux/check_hpux_drd_status.sh
Normal file
273
sources/lib/platform/hp-ux/check_hpux_drd_status.sh
Normal file
@ -0,0 +1,273 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_hpux_drd_status.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2018 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||
#
|
||||
# This program is a free software; you can redistribute it and/or modify
|
||||
# it under the same terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
|
||||
#******************************************************************************
|
||||
#
|
||||
# DOCUMENTATION (MAIN)
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) MAIN: check_hpux_drd_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), data_get_lvalue_from_config(), data_date2epoch(),
|
||||
# data_lc(), data_strip_space(), data_strip_outer_space(),
|
||||
# init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2018-05-11: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_hpux_drd_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _DRD_BIN="/opt/drd/bin/drd"
|
||||
typeset _VERSION="2018-05-11" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||
typeset _ARGS=$(data_space2comma "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _RC=0
|
||||
typeset _CHECK_CLONE=""
|
||||
typeset _CHECK_SYNC=""
|
||||
typeset _CLONE_MAX_AGE=30
|
||||
typeset _SYNC_MAX_AGE=30
|
||||
typeset _CLONE_DISK=""
|
||||
typeset _ORIGINAL_DISK=""
|
||||
typeset _ACTIVE_DISK=""
|
||||
typeset _BOOTED_DISK=""
|
||||
typeset _NOW_EPOCH=""
|
||||
typeset _EFI_CLONE=""
|
||||
typeset _EFI_ORIGINAL=""
|
||||
typeset _CLONE_DATE=""
|
||||
typeset _CLONE_YEAR=""
|
||||
typeset _CLONE_MONTH=""
|
||||
typeset _CLONE_DAY=""
|
||||
typeset _CLONE_HOUR=""
|
||||
typeset _CLONE_MINUTE=""
|
||||
typeset _CLONE_SECOND=""
|
||||
typeset _CLONE_EPOCH=""
|
||||
typeset _SYNC_DATE=""
|
||||
typeset _SYNC_YEAR=""
|
||||
typeset _SYNC_MONTH=""
|
||||
typeset _SYNC_DAY=""
|
||||
typeset _SYNC_HOUR=""
|
||||
typeset _SYNC_MINUTE=""
|
||||
typeset _SYNC_SECOND=""
|
||||
typeset _SYNC_EPOCH=""
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# handle configuration file
|
||||
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
|
||||
if [[ ! -r ${_CONFIG_FILE} ]]
|
||||
then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
# read required configuration values
|
||||
_CHECK_CLONE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_clone')
|
||||
if [[ -z "${_CHECK_CLONE}" ]]
|
||||
then
|
||||
# default
|
||||
_CHECK_CLONE="yes"
|
||||
fi
|
||||
_CLONE_MAX_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'clone_age')
|
||||
_CHECK_SYNC=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_sync')
|
||||
if [[ -z "${_CHECK_SYNC}" ]]
|
||||
then
|
||||
# default
|
||||
_CHECK_SYNC="yes"
|
||||
fi
|
||||
_SYNC_MAX_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'sync_age')
|
||||
|
||||
# get drd status
|
||||
if [[ ! -x ${_DRD_BIN} ]]
|
||||
then
|
||||
warn "${_DRD_BIN} is not installed here"
|
||||
return 1
|
||||
else
|
||||
log "executing {${_DRD_BIN}} ..."
|
||||
# drd outputs on STDERR
|
||||
${_DRD_BIN} status >${HC_STDOUT_LOG} 2>&1
|
||||
_RC=$?
|
||||
fi
|
||||
|
||||
# check drd status
|
||||
if (( _RC == 0 )) && (( $(grep -c -E -e ".*Displaying.*succeeded" ${HC_STDOUT_LOG} 2>/dev/null) > 0 ))
|
||||
then
|
||||
# convert NOW to epoch (pass date values as unquoted parameters)
|
||||
#_NOW_EPOCH=$(data_date2epoch "$(date '+%Y')" "$(date '+%m')" "$(date '+%d')" "$(date '+%H')" "$(date '+%M')" "$(date '+%S')")
|
||||
_NOW_EPOCH=$(data_date2epoch $(date '+%Y %m %d %H %M %S'))
|
||||
|
||||
# get devices
|
||||
_ORIGINAL_DISK=$(data_strip_space "$(grep "Original Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d':')")
|
||||
_CLONE_DISK=$(data_strip_space "$(grep 'Clone Disk:' ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d':')")
|
||||
|
||||
_BOOTED_DISK=$(grep "Booted Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d'(' | cut -f1 -d ')')
|
||||
_ACTIVE_DISK=$(grep "Activated Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d'(' | cut -f1 -d ')')
|
||||
|
||||
# check clone status: after a fresh clone -> booted == activated == original
|
||||
if [[ "${_ORIGINAL_DISK}" = "${_BOOTED_DISK}" ]] &&
|
||||
[[ "${_ORIGINAL_DISK}" = "${_ACTIVE_DISK}" ]] &&
|
||||
[[ "${_BOOTED_DISK}" = "${_ACTIVE_DISK}" ]]
|
||||
then
|
||||
_MSG="clone disk ${_CLONE_DISK} was correctly created"
|
||||
log_hc "$0" 0 "${_MSG}"
|
||||
else
|
||||
_MSG="clone disk ${_CLONE_DISK} was probably not correctly created"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
fi
|
||||
|
||||
# check EFI status
|
||||
_EFI_CLONE=$(data_strip_outer_space "$(grep 'Clone EFI Partition:' ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d':')")
|
||||
if [[ "${_EFI_CLONE}" = "AUTO file present, Boot loader present" ]]
|
||||
then
|
||||
_MSG="clone disk ${_CLONE_DISK} has a bootable EFI partition"
|
||||
log_hc "$0" 0 "${_MSG}"
|
||||
else
|
||||
_MSG="clone disk ${_CLONE_DISK} does not have a bootable EFI partition"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
fi
|
||||
_EFI_ORIGINAL=$(data_strip_outer_space "$(grep 'Original EFI Partition:' ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d':')")
|
||||
if [[ "${_EFI_ORIGINAL}" = "AUTO file present, Boot loader present" ]]
|
||||
then
|
||||
_MSG="original disk ${_ORIGINAL_DISK} has a bootable EFI partition"
|
||||
log_hc "$0" 0 "${_MSG}"
|
||||
else
|
||||
_MSG="original disk ${_ORIGINAL_DISK} does not have a bootable EFI partition"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
fi
|
||||
|
||||
# check clone age
|
||||
if [[ $(data_lc "${_CHECK_CLONE}") = "yes" ]]
|
||||
then
|
||||
# e.g.: 05/10/18 16:52:21 METDST (always in US format)
|
||||
_CLONE_DATE=$(data_strip_outer_space "$(grep 'Clone Creation Date:' ${HC_STDOUT_LOG} 2>/dev/null | cut -f2- -d':')")
|
||||
|
||||
if [[ "${_CLONE_DATE}" != "None" ]]
|
||||
then
|
||||
# split into year/month/day/hour/minute/second
|
||||
_CLONE_YEAR=$(print "${_CLONE_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f3 -d'/')
|
||||
_CLONE_MONTH=$(print "${_CLONE_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f1 -d'/')
|
||||
_CLONE_DAY=$(print "${_CLONE_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f2 -d'/')
|
||||
|
||||
_CLONE_HOUR=$(print "${_CLONE_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f1 -d':')
|
||||
_CLONE_MINUTE=$(print "${_CLONE_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f2 -d':')
|
||||
_CLONE_SECOND=$(print "${_CLONE_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f3 -d':')
|
||||
|
||||
# convert _CLONE_DATE to epoch
|
||||
_CLONE_EPOCH=$(data_date2epoch "20${_CLONE_YEAR}" "${_CLONE_MONTH}" "${_CLONE_DAY}" "${_CLONE_HOUR}" "${_CLONE_MINUTE}" "${_CLONE_SECOND}")
|
||||
|
||||
# check age
|
||||
if (( _CLONE_EPOCH > (_NOW_EPOCH - (_CLONE_MAX_AGE * 24 * 60 * 60)) ))
|
||||
then
|
||||
_MSG="clone age is younger than ${_CLONE_MAX_AGE} days [${_CLONE_DATE}]"
|
||||
log_hc "$0" 0 "${_MSG}"
|
||||
else
|
||||
_MSG="clone age is older than ${_CLONE_MAX_AGE} days [${_CLONE_DATE}]"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
fi
|
||||
else
|
||||
_MSG="clone has not yet been created"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
fi
|
||||
else
|
||||
log "not checking age of clone (see ${_CONFIG_FILE})"
|
||||
fi
|
||||
|
||||
# check sync age
|
||||
if [[ $(data_lc "${_CHECK_SYNC}") = "yes" ]]
|
||||
then
|
||||
# e.g.: 05/10/18 16:52:21 METDST (always in US format)
|
||||
_SYNC_DATE=$(data_strip_outer_space "$(grep 'Last Sync Date:' ${HC_STDOUT_LOG} 2>/dev/null | cut -f2- -d':')")
|
||||
|
||||
if [[ "${_SYNC_DATE}" != "None" ]]
|
||||
then
|
||||
# split into year/month/day/hour/minute/second
|
||||
_SYNC_YEAR=$(print "${_SYNC_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f3 -d'/')
|
||||
_SYNC_MONTH=$(print "${_SYNC_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f1 -d'/')
|
||||
_SYNC_DAY=$(print "${_SYNC_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f2 -d'/')
|
||||
|
||||
_SYNC_HOUR=$(print "${_SYNC_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f1 -d':')
|
||||
_SYNC_MINUTE=$(print "${_SYNC_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f2 -d':')
|
||||
_SYNC_SECOND=$(print "${_SYNC_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f3 -d':')
|
||||
|
||||
# convert _SYNC_DATE to epoch
|
||||
_SYNC_EPOCH=$(data_date2epoch "20${_SYNC_YEAR}" "${_SYNC_MONTH}" "${_SYNC_DAY}" "${_SYNC_HOUR}" "${_SYNC_MINUTE}" "${_SYNC_SECOND}")
|
||||
|
||||
# check age
|
||||
if (( _SYNC_EPOCH > (_NOW_EPOCH - (_SYNC_MAX_AGE * 24 * 60 * 60)) ))
|
||||
then
|
||||
_MSG="sync age is younger than ${_SYNC_MAX_AGE} days [${_SYNC_DATE}]"
|
||||
log_hc "$0" 0 "${_MSG}"
|
||||
else
|
||||
_MSG="sync age is older than ${_SYNC_MAX_AGE} days [${_SYNC_DATE}]"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
fi
|
||||
else
|
||||
_MSG="sync has not yet been executed"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
fi
|
||||
else
|
||||
log "not checking age of sync (see ${_CONFIG_FILE})"
|
||||
fi
|
||||
else
|
||||
_MSG="unable to run command: {${_DRD_BIN}}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
check_clone=<yes|no>
|
||||
clone_age=<max_age_of_clone_in_days>
|
||||
check_sync=<yes|no>
|
||||
sync_age=<max_age_of_sync_in_days>
|
||||
PURPOSE : Checks whether the DRD clone was correctly created
|
||||
Checks for correct EFI partitions
|
||||
Checks the age of the DRD clone and/or sync
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
@ -19,13 +19,15 @@
|
||||
# @(#) MAIN: check_hpux_ioscan
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc(), warn()
|
||||
# REQUIRES: data_space2comma(), data_comma2pipe(), data_dequote(),
|
||||
# init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-08-28: initial version [Patrick Van der Veken]
|
||||
# @(#) 2013-08-29: more verbosity & kernel_mode setting [Patrick Van der Veken]
|
||||
# @(#) 2016-06-08: introduced _AGILE_VIEW parameter [Patrick Van der Veken]
|
||||
# @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken]
|
||||
# @(#) 2018-05-11: small optimizations [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -37,7 +39,7 @@ function check_hpux_ioscan
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _IOSCAN_BIN="/usr/sbin/ioscan"
|
||||
typeset _IOSCAN_OPTS="-Fn"
|
||||
typeset _VERSION="2016-12-01" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-11" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -80,10 +82,10 @@ _CLASS_LINE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'ioscan
|
||||
if [[ -z "${_CLASS_LINE}" ]]
|
||||
then
|
||||
# default
|
||||
_IOSCAN_CLASSES="ctl|diag|disk|ext_bus|fc|fcp|i2o|ipmi|lan|lvm|olar|${DEBUG_OPTS}vm"
|
||||
_IOSCAN_CLASSES="ctl|diag|disk|ext_bus|fc|fcp|i2o|ipmi|lan|lvm|olar|vm"
|
||||
else
|
||||
# convert comma's
|
||||
_IOSCAN_CLASSES="$(print ${_CLASS_LINE} | tr -s ',' '|' | tr -d '\"')"
|
||||
# convert commas and strip quotes
|
||||
_IOSCAN_CLASSES=$(data_comma2pipe $(data_dequote "${_CLASS_LINE}"))
|
||||
fi
|
||||
_KERNEL_MODE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'kernel_mode')
|
||||
if [[ -z "${_KERNEL_MODE}" ]]
|
||||
@ -125,7 +127,7 @@ else
|
||||
${_IOSCAN_BIN} ${_IOSCAN_OPTS} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
if (( $? != 0 ))
|
||||
then
|
||||
_MSG="unable to gather ioscan information"
|
||||
_MSG="unable to run command: {${_IOSCAN_BIN}}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
return 0
|
||||
fi
|
||||
@ -156,7 +158,6 @@ do
|
||||
continue
|
||||
esac
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
_STC=0
|
||||
done
|
||||
|
181
sources/lib/platform/hp-ux/check_hpux_patch_version.sh
Normal file
181
sources/lib/platform/hp-ux/check_hpux_patch_version.sh
Normal file
@ -0,0 +1,181 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_hpux_patch_version.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2018 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||
#
|
||||
# This program is a free software; you can redistribute it and/or modify
|
||||
# it under the same terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
|
||||
#******************************************************************************
|
||||
#
|
||||
# DOCUMENTATION (MAIN)
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) MAIN: check_hpux_patch_version
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), data_get_lvalue_from_config(), data_dequote(),
|
||||
# init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2018-05-11: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_hpux_patch_version
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _SWLIST_BIN="/usr/sbin/swlist"
|
||||
typeset _SWLIST_OPTS=""
|
||||
typeset _SHOW_PATCHES_BIN="/usr/contrib/bin/show_patches"
|
||||
typeset _SHOW_PATCHES_OPTS=""
|
||||
typeset _VERSION="2018-05-11" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||
typeset _ARGS=$(data_space2comma "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _OE_VERSION=""
|
||||
typeset _PATCH_LINE=""
|
||||
typeset _PATCHES=""
|
||||
typeset _PATCH=""
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# handle configuration file
|
||||
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
|
||||
if [[ ! -r ${_CONFIG_FILE} ]]
|
||||
then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
# read required configuration values
|
||||
_OE_VERSION=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'required_oe')
|
||||
_PATCH_LINE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'required_patches')
|
||||
if [[ -n "${_PATCH_LINE}" ]]
|
||||
then
|
||||
# convert commas and strip quotes
|
||||
_PATCHES=$(data_comma2space $(data_dequote "${_PATCH_LINE}"))
|
||||
fi
|
||||
|
||||
# get and check OE version
|
||||
if [[ -n "${_OE_VERSION}" ]]
|
||||
then
|
||||
if [[ ! -x ${_SWLIST_BIN} ]]
|
||||
then
|
||||
warn "${_SWLIST_BIN} is not installed here"
|
||||
return 1
|
||||
else
|
||||
if [[ -n "${_SWLIST_OPTS}" ]]
|
||||
then
|
||||
log "executing {${_SWLIST_BIN}} with options: ${_SWLIST_OPTS}"
|
||||
${_SWLIST_BIN} ${_SWLIST_OPTS} >${HC_STDOUT_LOG} 2>${HC_STDERR_LOG}
|
||||
else
|
||||
log "executing {${_SWLIST_BIN}}"
|
||||
${_SWLIST_BIN} >${HC_STDOUT_LOG} 2>${HC_STDERR_LOG}
|
||||
fi
|
||||
fi
|
||||
if (( $? == 0 ))
|
||||
then
|
||||
if (( $(grep -c -E -e "${_OE_VERSION}.*Operating Environment" ${HC_STDOUT_LOG} 2>/dev/null) > 0 ))
|
||||
then
|
||||
_MSG="required OE with version ${_OE_VERSION} is installed"
|
||||
log_hc "$0" 0 "${_MSG}"
|
||||
else
|
||||
_MSG="required OE with version ${_OE_VERSION} is not installed"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
fi
|
||||
else
|
||||
_MSG="unable to run command: {${_SWLLST_BIN}}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
warn "required OE will not be checked (not configured in ${_CONFIG_FILE})"
|
||||
fi
|
||||
|
||||
# get and check patches
|
||||
if [[ -n "${_PATCHES}" ]]
|
||||
then
|
||||
if [[ ! -x ${_SHOW_PATCHES_BIN} ]]
|
||||
then
|
||||
warn "${_SHOW_PATCHES_BIN} is not installed here"
|
||||
return 1
|
||||
else
|
||||
if [[ -n "${_SHOW_PATCHES_OPTS}" ]]
|
||||
then
|
||||
log "executing {${_SHOW_PATCHES_BIN}} with options: ${_SHOW_PATCHES_OPTS}"
|
||||
print "=== show_patches ===" >>${HC_STDOUT_LOG}
|
||||
${_SHOW_PATCHES_BIN} ${_SHOW_PATCHES_OPTS} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
else
|
||||
log "executing {${_SHOW_PATCHES_BIN}}"
|
||||
print "=== show_patches ===" >>${HC_STDOUT_LOG}
|
||||
${_SHOW_PATCHES_BIN} ${_SHOW_PATCHES_OPTS} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
fi
|
||||
fi
|
||||
if (( $? == 0 ))
|
||||
then
|
||||
for _PATCH in ${_PATCHES}
|
||||
do
|
||||
if (( $(grep -c "${_PATCH}" ${HC_STDOUT_LOG} 2>/dev/null) > 0 ))
|
||||
then
|
||||
_MSG="required patch ${_PATCH} is installed"
|
||||
log_hc "$0" 0 "${_MSG}"
|
||||
else
|
||||
_MSG="required patch ${_PATCH} is not installed"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
fi
|
||||
done
|
||||
else
|
||||
_MSG="unable to run command: {${_SHOW_PATCHES_BIN}}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
warn "required patches will not be checked (not configured in ${_CONFIG_FILE})"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
required_patches=<list_of_patches_to_check>
|
||||
required_oe=<OE_version>
|
||||
PURPOSE : Checks whether the required OE (Operating Environment) version is installed
|
||||
Checks whether the required patches are installed
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
Loading…
x
Reference in New Issue
Block a user