Skip to content

Fixed index size display #145

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

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 0 additions & 16 deletions util/indexer.main.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ set -o pipefail

MAINTMPFILE="/var/run/piler/main.indexer.tmp"
CONFIG_FILE="SYSCONFDIR/piler/sphinx.conf"
INDEXDIR=sphinx
PRIORITY="mail.info"
TOUCHFILE="/var/piler/stat/indexer"
MAIN_INDEX="main1"

if [[ -f SYSCONFDIR/piler/MANTICORE ]]; then
CONFIG_FILE=SYSCONFDIR/piler/manticore.conf
INDEXDIR=manticore
fi

export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
Expand All @@ -22,17 +20,6 @@ finish() {
rm -f "$MAINTMPFILE"
}

get_index_size() {
local mainfiles="$1"
local sum=0

# shellcheck disable=SC2034
while read -r a b; do
sum=$(( sum + b ))
done < <( find /var/piler/${INDEXDIR}/ -type f -name "$mainfiles" -printf "%TY%Tm%Td %s\\n" )
printf "%d" $sum
}

if [[ -f "$MAINTMPFILE" ]]; then
echo "INDEXER ERROR: indexer merging to main index is already running. It started at $(cat "$MAINTMPFILE")" | logger -p "$PRIORITY"
exit 1
Expand All @@ -57,6 +44,3 @@ echo "INDEXER INFO: resetting daily delta started" | logger -p "$PRIORITY"
indexer --config "$CONFIG_FILE" --quiet dailydelta1 --rotate

echo "INDEXER INFO: resetting daily delta finished" | logger -p "$PRIORITY"

get_index_size "main*.sp[dp]" > /var/piler/stat/total_index_size
get_index_size "${MAIN_INDEX}*.sp[dp]" > /var/piler/stat/current_main_index_size
17 changes: 10 additions & 7 deletions webui/model/health/health.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public function collect_data() {
$this->data['indexer_stat'] = $this->indexer_stat();
$this->data['purge_stat'] = $this->purge_stat();

$this->data['sphinx_current_main_size'] = $this->get_index_size(SPHINX_CURRENT_MAIN_INDEX_SIZE);
$this->data['sphinx_total_size'] = $this->get_index_size(SPHINX_TOTAL_INDEX_SIZE);
$this->data['sphinx_total_size'] = $this->get_index_size() ;

$this->get_average_count_values();
$this->get_average_size_values($archivesizeraw);
Expand Down Expand Up @@ -282,8 +281,8 @@ public function toggle_option($option = '') {
public function get_database_size() {
$data = array();

$query = $this->db->query("SELECT table_schema AS `name`,
SUM( data_length + index_length ) AS `size`
$query = $this->db->query("SELECT table_schema AS `name`,
SUM( data_length + index_length ) AS `size`
FROM information_schema.TABLES
WHERE table_schema = '".DB_DATABASE."'
GROUP BY table_schema;");
Expand Down Expand Up @@ -353,11 +352,15 @@ public function purge_stat() {
}


public function get_index_size($statfile = '') {
public function get_index_size() {
$size = 0;

if(file_exists($statfile)) {
$size = (int) file_get_contents($statfile);
$indexes = explode(',', SPHINX_MAIN_INDEX);
foreach($indexes as $index) {
$query = $this->sphx->query('SHOW INDEX ' . $index . ' STATUS LIKE \'disk_bytes\'');
foreach($query->rows as $row) {
$size += $row[1];
}
}

return $size;
Expand Down
4 changes: 2 additions & 2 deletions webui/templates/health/worker.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@
<td><?php if ($health['usagetrend'] > 0) { print $text_usage_increasing; } elseif($health['usagetrend'] < 0) { print $text_usage_decreasing; } else { print $text_usage_neutral; } ?></td>
</tr>
<tr>
<td>Sphinx main (total) index</td>
<td<?php if($health['sphinx_current_main_size'] > SPHINX_MAIN_INDEX_THRESHOLD) { ?> class="text-error"<?php } ?>><?php print nice_size($health['sphinx_current_main_size']); ?> (<?php print nice_size($health['sphinx_total_size']); ?>) </td>
<td>Sphinx total index</td>
<td><?php print nice_size($health['sphinx_total_size']); ?></td>
</tr>
</table>

Expand Down