Skip to content

Commit

Permalink
Start monitoring Permanent cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudfroidmont committed Nov 26, 2021
1 parent e569a11 commit 0c7267a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions initial_mon.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ocid = ${cluster_ocid}
queue = ${queue}
shape = ${shape}
cluster_network = ${cluster_network}
private_ips = ${ips}
ocids = ${ocids}
hostnames = ${hostnames}
34 changes: 34 additions & 0 deletions initial_monitoring.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

scripts=`realpath $0`
folder=`dirname $scripts`

end_timestamp=`date -u +'%F %T'`
bastionName=`hostname`
cluster_name=${bastionName/-bastion/}
if [ -f $folder/../monitoring/activated ]
then
ocid=`cat /tmp/initial.mon | grep "cluster_ocid =" | awk '{print $3}'`
ips=`cat /tmp/initial.mon | grep "private_ips =" | awk '{print $3}'`
ocids=`cat /tmp/initial.mon | grep "ocids =" | awk '{print $3}'`
hostnames=`cat /tmp/initial.mon | grep "hostnames =" | awk '{print $3}'`
queue=`cat /tmp/initial.mon | grep "queue =" | awk '{print $3}'`
shape=`cat /tmp/initial.mon | grep "shape =" | awk '{print $3}'`
cluster_network=`cat /tmp/initial.mon | grep "cluster_network =" | awk '{print $3}'`

export IFS=","
for ip in ${ips}; do
ip_array+=( $ip )
done
for ocid in ${ocids}; do
ocid_array+=( $ocid )
done
for hostname in ${hostnames}; do
hostname_array+=( $hostname )
done
source $folder/../monitoring/env
mysqlsh $ENV_MYSQL_USER@$ENV_MYSQL_HOST -p$ENV_MYSQL_PASS --sql -e "use $ENV_MYSQL_DATABASE_NAME; INSERT INTO cluster_log.clusters (id,nodes,class_name,shape,CN,cpu_per_node,cluster_name,state,created,cluster_OCID) VALUES ('$cluster_name','${#ip_array[@]}','$queue','$shape',$cluster_network,36,'$cluster_name','running','$end_timestamp','$ocid');"
for index in "${!ip_array[@]}"; do
mysqlsh $ENV_MYSQL_USER@$ENV_MYSQL_HOST -p$ENV_MYSQL_PASS --sql -e "use $ENV_MYSQL_DATABASE_NAME; INSERT INTO cluster_log.nodes (cluster_id,cluster_index,cpus,created,state,class_name,shape,hostname,ip,node_OCID) VALUES ('$cluster_name',$index,36,'$end_timestamp','running','$queue','$shape','${hostname_array[$index]}','${ip_array[$index]}','${ocid_array[$index]}');"
done
fi

0 comments on commit 0c7267a

Please sign in to comment.