From e14787c1eaadbf292e0b3407d4bc048123a33e3f Mon Sep 17 00:00:00 2001 From: Shaw Date: Wed, 28 Sep 2022 16:11:15 +1000 Subject: [PATCH 1/3] Add Div new features change --- node_collector.sh | 55 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/node_collector.sh b/node_collector.sh index 2036611..4f77795 100755 --- a/node_collector.sh +++ b/node_collector.sh @@ -17,6 +17,14 @@ ip=$(hostname --ip-address | tr -d [:blank:]) data_dir=/tmp/DataCollection_${ip} data_file=$data_dir/disk.info io_stats_file=$data_dir/io_stat.info +cpu_info=$data_dir/cpu.info +data_file_count=$data_dir/sstable_count.info +block_info=$data_dir/storage_device.info + +#Managing Instacollector version +ic_version=2 +echo "Instacollector version = ${ic_version}" > $data_dir/ic_version.info + copy_config_files() { @@ -25,7 +33,7 @@ local config_files=("$CONFIG_PATH/cassandra.yaml" "$CONFIG_PATH/cassandra-env.sh if [ "$GC_LOGGING_ENABLED" == "yes" ] then - config_files+=( "$GC_LOG_PATH/gc.log*" ) + config_files+=( "$GC_LOG_PATH/gc.log*" ) fi for i in "${config_files[@]}" @@ -44,14 +52,41 @@ for i in "${commands[@]}" do for j in "${paths[@]}" do - echo "" >> $data_file - k=$(echo $i $j) - echo "$k" >> $data_file - eval $k >> $data_file + echo "" >> $data_file + k=$(echo $i $j) + echo "$k" >> $data_file + eval $k >> $data_file + done +done +} + + +get_datafile_count() +{ +echo "$ip : Executing sstables count command" +local paths=($(echo "$DATA_PATHS" | tr ',' '\n')) +for j in "${paths[@]}" +do + find ${j} -maxdepth 3 -type f | wc -l | xargs -n1 echo "Total sstable count : " >> $data_file_count + for i in `ls -1 ${j}`; + do + find ${j}/${i} -maxdepth 2 -type f | wc -l | xargs -n1 echo "Keyspace ${i}, Total number of sstables : " >> $data_file_count done done } +get_block_info() +{ +echo "$ip : Executing lsblk command" +lsblk > $block_info +} + +get_cpu_info() +{ + echo "$ip : Executing /proc/cpuinfo command" + cat /proc/cpuinfo > $cpu_info +} + get_io_stats() { echo "$ip : Executing iostat command" @@ -65,12 +100,12 @@ get_node_tool_info() #The nodetool commands and their respective filenames are on the same index in the arrays #the total number of entries in the arrays is used in the for loop. -local commands=("nodetool info" "nodetool version" "nodetool status" "nodetool tpstats" "nodetool compactionstats -H" "nodetool gossipinfo" "nodetool cfstats -H" "nodetool ring") -local filenames=("nodetool_info" "nodetool_version" "nodetool_status" "nodetool_tpstats" "nodetool_compactionstats" "nodetool_gossipinfo" "nodetool_cfstats" "nodetool_ring") +local commands=("nodetool info" "nodetool version" "nodetool status" "nodetool tpstats" "nodetool compactionstats -H" "nodetool gossipinfo" "nodetool cfstats -H" "nodetool ring" "nodetool describecluster") +local filenames=("nodetool_info" "nodetool_version" "nodetool_status" "nodetool_tpstats" "nodetool_compactionstats" "nodetool_gossipinfo" "nodetool_cfstats" "nodetool_ring" "nodetool_describecluster") echo "$ip : Executing nodetool commands " -for i in {1..8} +for i in {0..8} do local cmd_file=$data_dir/${filenames[i]}.info echo "" >> $cmd_file @@ -85,11 +120,13 @@ mv $data_dir $data_dir_`date +%Y%m%d%H%M` 2>/dev/null mkdir $data_dir #start execution +get_datafile_count & +get_cpu_info & get_io_stats & copy_config_files & get_size_info & get_node_tool_info & - +get_block_info & echo "$ip : Waiting for background functions to complete" wait From 7cf8c860c192c4a2483e97e369088fcedb6c3444 Mon Sep 17 00:00:00 2001 From: Shaw Date: Wed, 28 Sep 2022 17:26:08 +1000 Subject: [PATCH 2/3] Add mem_info and change format a bit --- node_collector.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/node_collector.sh b/node_collector.sh index 4f77795..bfc4f2c 100755 --- a/node_collector.sh +++ b/node_collector.sh @@ -18,6 +18,7 @@ data_dir=/tmp/DataCollection_${ip} data_file=$data_dir/disk.info io_stats_file=$data_dir/io_stat.info cpu_info=$data_dir/cpu.info +mem_info=$data_dir/mem.info data_file_count=$data_dir/sstable_count.info block_info=$data_dir/storage_device.info @@ -81,12 +82,16 @@ echo "$ip : Executing lsblk command" lsblk > $block_info } -get_cpu_info() -{ +get_cpu_info() { echo "$ip : Executing /proc/cpuinfo command" cat /proc/cpuinfo > $cpu_info } +get_mem_info() { + echo "$ip : Executing /proc/meminfo command" + cat /proc/meminfo > $mem_info +} + get_io_stats() { echo "$ip : Executing iostat command" @@ -122,6 +127,7 @@ mkdir $data_dir #start execution get_datafile_count & get_cpu_info & +get_mem_info & get_io_stats & copy_config_files & get_size_info & From 88118957a02f4b5b71576b09aeae0fcf169978aa Mon Sep 17 00:00:00 2001 From: Shaw Date: Wed, 28 Sep 2022 18:02:17 +1000 Subject: [PATCH 3/3] Fix indentation, rename consistently, fix data path --- node_collector.sh | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/node_collector.sh b/node_collector.sh index bfc4f2c..1c05075 100755 --- a/node_collector.sh +++ b/node_collector.sh @@ -7,7 +7,7 @@ LOG_PATH=/var/log/cassandra #List of data directories; if more than one list all with delimiter ',' #e.g. DATA_PATHS=path/to/dir1,path/to/dir2 -DATA_PATHS=/var/lib/cassandra/data/data +DATA_PATHS=/var/lib/cassandra/data GC_LOGGING_ENABLED=yes CASSANDRA_HOME=/var/lib/cassandra GC_LOG_PATH=${CASSANDRA_HOME}/logs @@ -17,10 +17,10 @@ ip=$(hostname --ip-address | tr -d [:blank:]) data_dir=/tmp/DataCollection_${ip} data_file=$data_dir/disk.info io_stats_file=$data_dir/io_stat.info -cpu_info=$data_dir/cpu.info -mem_info=$data_dir/mem.info -data_file_count=$data_dir/sstable_count.info -block_info=$data_dir/storage_device.info +cpu_info_file=$data_dir/cpu.info +mem_info_file=$data_dir/mem.info +sstable_count_file=$data_dir/sstable_count.info +block_info_file=$data_dir/block.info #Managing Instacollector version ic_version=2 @@ -62,34 +62,32 @@ done } -get_datafile_count() -{ -echo "$ip : Executing sstables count command" -local paths=($(echo "$DATA_PATHS" | tr ',' '\n')) -for j in "${paths[@]}" -do - find ${j} -maxdepth 3 -type f | wc -l | xargs -n1 echo "Total sstable count : " >> $data_file_count - for i in `ls -1 ${j}`; +get_sstable_count() { + echo "$ip : Executing sstables count command" + local paths=($(echo "$DATA_PATHS" | tr ',' '\n')) + for j in "${paths[@]}" do - find ${j}/${i} -maxdepth 2 -type f | wc -l | xargs -n1 echo "Keyspace ${i}, Total number of sstables : " >> $data_file_count + find ${j} -maxdepth 3 -type f | wc -l | xargs -n1 echo "Total sstable count : " >> $sstable_count_file + for i in `ls -1 ${j}`; + do + find ${j}/${i} -maxdepth 2 -type f | wc -l | xargs -n1 echo "Keyspace ${i}, Total number of sstables : " >> $sstable_count_file + done done -done } -get_block_info() -{ -echo "$ip : Executing lsblk command" -lsblk > $block_info +get_block_info() { + echo "$ip : Executing lsblk command" + lsblk > $block_info_file } get_cpu_info() { echo "$ip : Executing /proc/cpuinfo command" - cat /proc/cpuinfo > $cpu_info + cat /proc/cpuinfo > $cpu_info_file } get_mem_info() { echo "$ip : Executing /proc/meminfo command" - cat /proc/meminfo > $mem_info + cat /proc/meminfo > $mem_info_file } get_io_stats() @@ -125,7 +123,7 @@ mv $data_dir $data_dir_`date +%Y%m%d%H%M` 2>/dev/null mkdir $data_dir #start execution -get_datafile_count & +get_sstable_count & get_cpu_info & get_mem_info & get_io_stats &