]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
ServiceDiscovery: Enhance version scripts to discover vRLi and
authorJohn Wolfe <jwolfe@vmware.com>
Mon, 8 Nov 2021 21:33:57 +0000 (13:33 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Mon, 8 Nov 2021 21:33:57 +0000 (13:33 -0800)
                  Cassandra services versions.

open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh

index a16fa1da193d0f47cc05435e6ec7c94a437d21f3..c46054e203979660381c708e4670fcaf654134dc 100644 (file)
@@ -1,12 +1,13 @@
 #!/bin/sh
 
-# Copyright (C) 2020 VMware, Inc.  All rights reserved.
+# Copyright (c) 2021 VMware, Inc.  All rights reserved.
 
 # check if necesary commands exist
 command -v ss >/dev/null 2>&1 || { echo >&2 "ss doesn't exist"; exit 1; }
 command -v grep >/dev/null 2>&1 || { echo >&2 "grep doesn't exist"; exit 1; }
 command -v sort >/dev/null 2>&1 || { echo >&2 "sort doesn't exist"; exit 1; }
 command -v ps >/dev/null 2>&1 || { echo >&2 "ps doesn't exist"; exit 1; }
+command -v awk>/dev/null 2>&1 || { echo >&2 "awk doesn't exist"; exit 1; }
 
 space_separated_pids=$(ss -lntup | grep -Eo "pid=[0-9]+" | grep -Eo "[0-9]*" | sort -u)
 
@@ -82,6 +83,25 @@ get_tcserver_version() {
   command -v tcserver >/dev/null 2>&1 && { tcserver version 2>/dev/null; }
 }
 
+get_cassandra_version() {
+  PATTERN="/usr/lib/.*apache-cassandra"
+  for p in $space_separated_pids
+  do
+    CASSANDRA_CMD=$(get_command_line $p | grep -Eo "$PATTERN")
+    CASSANDRA_INSTALL_PATH=`echo $CASSANDRA_CMD | awk 'match($0,/\/usr\/lib\/[a-zA-Z-]*\/[a-zA-Z\/]*\/apache-cassandra-[0-9.]*\//) {print substr($0,RSTART,RLENGTH)}'`
+    [ ! -z "$CASSANDRA_INSTALL_PATH" ] && echo VERSIONSTART cassandra_version "$("${CASSANDRA_INSTALL_PATH}/bin/cassandra" -v 2>/dev/null)" VERSIONEND
+  done
+}
+
+get_vrli_version() {
+  FILE_PATH_TEMPLATE=/storage/core/loginsight/config/loginsight-config.xml#
+  FILE_NAMES=($(ls /storage/core/loginsight/config/ 2>/dev/null | grep -o "[0-9].*"))
+  [ ! -z "$FILE_NAMES" ] && LATEST_FILE_NUM=$(printf '%s\n' "${FILE_NAMES[@]}" | awk '$1 > m || NR == 1 { m = $1 } END { print m }')
+  VERSION_FILE_NAME="$FILE_PATH_TEMPLATE$LATEST_FILE_NUM"
+  VERSION=$(cat $VERSION_FILE_NAME 2>/dev/null | grep 'strata-version value=' | grep -oE "[0-9.]+" | head -1)
+  [ ! -z "$VERSION" ] && echo VERSIONSTART vrli_version $VERSION VERSIONEND
+}
+
 echo VERSIONSTART "vcops_version" "$(get_vcops_version)" VERSIONEND
 echo VERSIONSTART "srm_mgt_server_version" "$(get_srm_mgt_server_version)" VERSIONEND
 echo VERSIONSTART "vcenter_appliance_version" "$(get_vcenter_appliance_version)" VERSIONEND
@@ -98,4 +118,6 @@ get_version "/\S+/dataserver($|\s)" -v
 get_vcloud_director_version
 get_weblogic_version
 get_apache_tomcat_version
-get_jboss_version
\ No newline at end of file
+get_jboss_version
+get_cassandra_version
+get_vrli_version