Skip to content

Commit

Permalink
All directories under data_file_directories in cassandra.yaml need to…
Browse files Browse the repository at this point in the history
… be monitored

Currently the database nodemgr only monitors the first entry under the
data_file_directories in cassandra.yaml.

Modified DatabaseNodemgr.py to monitor all the directories listed under
data_file_directories and then send the sum of their disk usage.
Closes-bug: #1446852

Change-Id: I179d22653108fe10c09491233aab7507e60e58a8
  • Loading branch information
akumari committed May 18, 2015
1 parent 8d7c347 commit ffed636
Showing 1 changed file with 60 additions and 44 deletions.
104 changes: 60 additions & 44 deletions src/nodemgr/database_event_manager.py
Expand Up @@ -74,39 +74,47 @@ def process(self):

(linux_dist, x, y) = platform.linux_distribution()
if (linux_dist == 'Ubuntu'):
popen_cmd = "set `df -Pk \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d'-'" + \
" -f2 \`/ContrailAnalytics | grep %` && echo $3 |" + \
" cut -d'%' -f1"
popen_cmd = "set `df -Pk" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d '-' -f2" + \
" | sed 's/$/\/ContrailAnalytics/'\` | grep % |" + \
" awk '{s+=$3}END{print s}'` && echo $1"
(disk_space_used, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
popen_cmd = "set `df -Pk \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d'-'" + \
" -f2\`/ContrailAnalytics | grep %` && echo $4" + \
" | cut -d'%' -f1"
popen_cmd = "set `df -Pk" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d '-' -f2" + \
" | sed 's/$/\/ContrailAnalytics/'\` | grep % |" + \
" awk '{s+=$4}END{print s}'` && echo $1"
(disk_space_available, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
popen_cmd = "set `du -skL \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d'-'" + \
" -f2\`/ContrailAnalytics` && echo $1 | cut -d'%' -f1"
popen_cmd = "set `du -skL" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d '-' -f2" + \
" | sed 's/$/\/ContrailAnalytics/'\` |" + \
" awk '{s+=$1}END{print s}'` && echo $1"
(analytics_db_size, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
else:
popen_cmd = "set `df -Pk \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' |" + \
" cut -d'-' -f2 \`/ContrailAnalytics | grep %` &&" + \
" echo $3 | cut -d'%' -f1"
popen_cmd = "set `df -Pk" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' |" + \
" cut -d '-' -f2 | sed 's/$/\/ContrailAnalytics/'\` |" + \
" grep % | awk '{s+=$3}END{print s}'` && echo $1"
(disk_space_used, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
popen_cmd = "set `df -Pk \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' |" + \
" cut -d'-' -f2\`/ContrailAnalytics | grep %` && echo $4" + \
" | cut -d'%' -f1"
popen_cmd = "set `df -Pk" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' |" + \
" cut -d '-' -f2 | sed 's/$/\/ContrailAnalytics/'\` |" + \
" grep % | awk '{s+=$4}END{print s}'` && echo $1"
(disk_space_available, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
popen_cmd = "set `du -skL \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' | cut -d" + \
"'-' -f2\`/ContrailAnalytics` && echo $1 | cut -d'%' -f1"
popen_cmd = "set `du -skL" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' |" + \
" cut -d '-' -f2 | sed 's/$/\/ContrailAnalytics/'\` |" + \
" awk '{s+=$1}END{print s}'` && echo $1"
(analytics_db_size, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
disk_space_total = int(disk_space_used) + int(disk_space_available)
Expand Down Expand Up @@ -143,39 +151,47 @@ def get_failbits_nodespecific_desc(self, fail_status_bits):
def database_periodic(self):
(linux_dist, x, y) = platform.linux_distribution()
if (linux_dist == 'Ubuntu'):
popen_cmd = "set `df -Pk \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d" + \
"'-' -f2 \`/ContrailAnalytics | grep %` && echo $3 |" + \
" cut -d'%' -f1"
popen_cmd = "set `df -Pk" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d '-' -f2" + \
" | sed 's/$/\/ContrailAnalytics/'\` | grep % |" + \
" awk '{s+=$3}END{print s}'` && echo $1"
(disk_space_used, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
popen_cmd = "set `df -Pk \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d'-'" + \
" -f2\`/ContrailAnalytics | grep %` && echo $4 |" + \
" cut -d'%' -f1"
popen_cmd = "set `df -Pk" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d '-' -f2" + \
" | sed 's/$/\/ContrailAnalytics/'\` | grep % |" + \
" awk '{s+=$4}END{print s}'` && echo $1"
(disk_space_available, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
popen_cmd = "set `du -skL \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d'-'" + \
" -f2\`/ContrailAnalytics` && echo $1 | cut -d'%' -f1"
popen_cmd = "set `du -skL" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/cassandra.yaml | grep '-' | cut -d '-' -f2" + \
" | sed 's/$/\/ContrailAnalytics/'\` |" + \
" awk '{s+=$1}END{print s}'` && echo $1"
(analytics_db_size, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
else:
popen_cmd = "set `df -Pk \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' |" + \
" cut -d'-' -f2 \`/ContrailAnalytics | grep %` && echo" + \
" $3 | cut -d'%' -f1"
popen_cmd = "set `df -Pk" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' |" + \
" cut -d '-' -f2 | sed 's/$/\/ContrailAnalytics/'\` |" + \
" grep % | awk '{s+=$3}END{print s}'` && echo $1"
(disk_space_used, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
popen_cmd = "set `df -Pk \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' | cut -d" + \
"'-' -f2\`/ContrailAnalytics | grep %` && echo $4" + \
" | cut -d'%' -f1"
popen_cmd = "set `df -Pk" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' |" + \
" cut -d '-' -f2 | sed 's/$/\/ContrailAnalytics/'\` |" + \
" grep % | awk '{s+=$4}END{print s}'` && echo $1"
(disk_space_available, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
popen_cmd = "set `du -skL \`grep -A 1 'data_file_directories:'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' | cut -d" + \
"'-' -f2\`/ContrailAnalytics` && echo $1 | cut -d'%' -f1"
popen_cmd = "set `du -skL" + \
" \`sed -n -e '/'data_file_directories'/,/'#'/p'" + \
" /etc/cassandra/conf/cassandra.yaml | grep '-' |" + \
" cut -d '-' -f2 | sed 's/$/\/ContrailAnalytics/'\` |" + \
" awk '{s+=$1}END{print s}'` && echo $1"
(analytics_db_size, error_value) = \
Popen(popen_cmd, shell=True, stdout=PIPE).communicate()
db_stat = DatabaseUsageStats()
Expand Down

0 comments on commit ffed636

Please sign in to comment.