jina verze

This commit is contained in:
2026-08-12 10:53:04 +02:00
parent f186ec26a8
commit 93d4f24f07
43 changed files with 1686 additions and 1959 deletions
+9 -11
View File
@@ -11,8 +11,8 @@ function metricKube() {
mkdir -p -- "$metricPromPath" || return 1
local vhostAllCount vhostUpCount
vhostAllCount=$(openlitespeedConfigVhostList all | grep -c . || true)
vhostUpCount=$(openlitespeedConfigVhostList up | grep -c . || true)
vhostAllCount=$(openlitespeedVhostList all | grep -c . || true)
vhostUpCount=$(openlitespeedVhostList up | grep -c . || true)
local appTimestamp
appTimestamp=$(date -d "$appDate ${appTime//-/:}" +%s)
@@ -37,8 +37,8 @@ function metricKube() {
read -r _req _lim <<< "$_line"
slaveMemReq=$(sizeToBytes "$_req"); slaveMemLim=$(sizeToBytes "$_lim")
_line=$(k3sRun get pods -l "app=$olsKube" \
-o jsonpath="{.items[0].spec.containers[?(@.name=='${olsKube}')].resources.requests.memory} {.items[0].spec.containers[?(@.name=='${olsKube}')].resources.limits.memory}" 2>/dev/null)
_line=$(k3sRun get pods -l "app=$openlitespeedKube" \
-o jsonpath="{.items[0].spec.containers[?(@.name=='${openlitespeedKube}')].resources.requests.memory} {.items[0].spec.containers[?(@.name=='${openlitespeedKube}')].resources.limits.memory}" 2>/dev/null)
read -r _req _lim <<< "$_line"
olsMemReq=$(sizeToBytes "$_req"); olsMemLim=$(sizeToBytes "$_lim")
@@ -97,7 +97,7 @@ function metricLsphp() {
mkdir -p -- "$metricPromPath" || return 1
local podList error
run podList error k3sPodListStatus "$olsKube" || return 1
run podList error k3sPodListStatus "$openlitespeedKube" || return 1
local pod phase output cpu mem count domain
{
@@ -110,10 +110,8 @@ function metricLsphp() {
while IFS='|' read -r pod phase; do
[[ "$phase" == "Running" ]] || continue
# run output error openlitespeedPodExec "$pod" sh -c "ps aux | grep lsphp | grep -v grep | awk '{u=\$1;cpu[u]+=\$3;mem[u]+=\$4;count[u]++} END {for(u in cpu){name=u;cmd=\"find $olsPodPrivatePath -maxdepth 1 -uid \"u\" -type d 2>/dev/null\";if((cmd|getline dir)>0&&dir!=\"\"){n=split(dir,a,\"/\");name=a[n]};close(cmd);print cpu[u],mem[u],count[u],name}}'" || continue
run output error openlitespeedPodExec "$pod" sh -c "ps aux | awk '/lsphp/ && !/nobody/ {u=\$1;cpu[u]+=\$3;mem[u]+=\$4;count[u]++} END {for(u in cpu){name=u;cmd=\"find $olsPodPrivatePath -maxdepth 1 -uid \"u\" -type d 2>/dev/null\";if((cmd|getline dir)>0&&dir!=\"\"){n=split(dir,a,\"/\");name=a[n]};close(cmd);printf \"%.1f\\t%.1f\\t%d\\t%s\\n\",cpu[u],mem[u],count[u],name}}'" || continue
while IFS=$'\t' read -r cpu mem count domain; do
run output error openlitespeedPodExec "$pod" sh -c "ps aux | grep lsphp | grep -v grep | awk '{u=\$1;cpu[u]+=\$3;mem[u]+=\$4;count[u]++} END {for(u in cpu){name=u;cmd=\"find /var/www/data -maxdepth 1 -uid \"u\" -type d 2>/dev/null\";if((cmd|getline dir)>0&&dir!=\"\"){n=split(dir,a,\"/\");name=a[n]};close(cmd);print cpu[u],mem[u],count[u],name}}'" || continue
while IFS=' ' read -r cpu mem count domain; do
[[ -n "$domain" ]] || continue
printf 'lsphp_cpu_percent{domain="%s",pod="%s"} %s\n' "$domain" "$pod" "$cpu"
printf 'lsphp_memory_percent{domain="%s",pod="%s"} %s\n' "$domain" "$pod" "$mem"
@@ -137,13 +135,13 @@ function metricSites() {
dataJson='{}'
local error vhostList
run vhostList error openlitespeedConfigVhostList || {
run vhostList error openlitespeedVhostList all || {
appError "Error retrieving vhost list: $error"
return 1
}
while IFS= read -r domain <&3; do
local diskUsage domainJson
diskUsage="$(pathSize "$olsVhostsPath/$domain" "mb" || true)"
diskUsage="$(pathSize "$vhostsPath/$domain" "mb" || true)"
[[ -n "$diskUsage" ]] || continue
domainJson="$(