Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cpu_info, describecluster and Sstable cluster #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 51 additions & 10 deletions node_collector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix default path

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems default for DSE, apache cassandra, Ubuntu distro all use /var/lib/cassandra/data rather than /var/lib/cassandra/data/data

GC_LOGGING_ENABLED=yes
CASSANDRA_HOME=/var/lib/cassandra
GC_LOG_PATH=${CASSANDRA_HOME}/logs
Expand All @@ -17,6 +17,15 @@ 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_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
echo "Instacollector version = ${ic_version}" > $data_dir/ic_version.info


copy_config_files()
{
Expand All @@ -25,7 +34,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*" )
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace tab with 4 spaces

fi

for i in "${config_files[@]}"
Expand All @@ -44,14 +53,43 @@ 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_sstable_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 : " >> $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
}

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_file
}

get_mem_info() {
echo "$ip : Executing /proc/meminfo command"
cat /proc/meminfo > $mem_info_file
}

get_io_stats()
{
echo "$ip : Executing iostat command"
Expand All @@ -65,12 +103,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
Expand All @@ -85,11 +123,14 @@ mv $data_dir $data_dir_`date +%Y%m%d%H%M` 2>/dev/null
mkdir $data_dir

#start execution
get_sstable_count &
get_cpu_info &
get_mem_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
Expand Down