#!/bin/bash
# Elast服务器托管网icsearch集群的URL
es_url="http://localhost:9200"
# 索引名称的前缀(假设索引名称为 "logs-2023.06.15")
index_prefix="logs-"
# 获取当前日期
current_date=$(date +%Y.%m.%d)
# 获取前一天的日期
previous_date=$(date -d "yesterday" +%Y.%m.%d)
# 构建前一天和当前日期的索引名称
previous_index="${index_prefix}${previous_date}"
current_index="${index_prefix}${current_date}"
# 获取前一天和当前日期的文档数量
previous_docs=$(curl -s "${es_u服务器托管网rl}/${previous_index}/_count" | jq -r '.count')
current_docs=$(curl -s "${es_url}/${current_index}/_count" | jq -r '.count')
# 获取前一天和当前日期的索引大小(字节)
previous_size=$(curl -s "${es_url}/${previous_index}/_stats/store" | jq -r '.indices."'"${previous_index}"'".total.store.size_in_bytes')
current_size=$(curl -s "${es_url}/${current_index}/_stats/store" | jq -r '.indices."'"${current_index}"'".total.store.size_in_bytes')
# 计算索引增量
index_increment=$((current_docs - previous_docs))
# 计算索引大小增量(以MB为单位)
size_increment=$(( (current_size - previous_size) / 1024 / 1024 ))
# 保存结果到文件
result_file="${current_date}.txt"
echo "Index Increment on $current_date:" > "$result_file"
echo "Previous Index: $previous_index ($previous_docs documents, ${previous_size} bytes)" >> "$result_file"
echo "Current Index: $current_index ($current_docs documents, ${current_size} bytes)" >> "$result_file"
echo "Index Increment: $index_increment documents" >> "$result_file"
echo "Size Increment: ${size_increment} MB" >> "$result_file"
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: 黑苹果macOS Catalina 10.15.7升级为Big Sur(i5 3470+XSB75M-PK+HD 7750)
配置 AMD免驱显卡推荐 以下是一些推荐使用的AMD免驱显卡: HD 7700HD 7730HD 7750HD 7770HD 7790HD 7850HD 7870HD 7950HD 7970HD 7990 我本次使用的是 HD 7750 进行安装黑苹果(闲鱼8…