Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37742138
en ru br
Репозитории ALT
S:0.1-alt2
5.1: 0.1-alt1
www.altlinux.org/Changes

Группа :: Система/Настройка/Прочее
Пакет: alterator-beancounters

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064112515647110014515gustar00rootroot0000000000000052 comment=ba143890960524c8d10b3fb0cb8f81a076e4ed32
alterator-beancounters-0.1/000075500000000000000000000000001125156471100160365ustar00rootroot00000000000000alterator-beancounters-0.1/.gear/000075500000000000000000000000001125156471100170325ustar00rootroot00000000000000alterator-beancounters-0.1/.gear/rules000064400000000000000000000000071125156471100201040ustar00rootroot00000000000000tar: .
alterator-beancounters-0.1/Makefile000064400000000000000000000001341125156471100174740ustar00rootroot00000000000000NAME=bc

all:
clean:
install: install-module

include /usr/share/alterator/build/module.mak
alterator-beancounters-0.1/alterator-beancounters.spec000064400000000000000000000012061125156471100233740ustar00rootroot00000000000000# vim: set ft=spec: -*- rpm-spec -*-

Name: alterator-beancounters
Version: 0.1
Release: alt1

Summary: OpenVZ beancounter observer module
Group: System/Configuration/Other
License: GPL

BuildArch: noarch

Source: %name-%version.tar

Requires: alterator >= 4.6-alt3
Requires: bc
Conflicts: alterator-fbi < 5.7-alt4

BuildPreReq: alterator >= 4.6-alt3

%description
OpenVZ beancounter observer module

%prep
%setup

%build
%make_build

%install
%makeinstall

%files
%_datadir/alterator/applications/*
%_datadir/alterator/ui/*/
%_alterator_backend3dir/*

%changelog
* Wed Sep 09 2009 Alexey I. Froloff <raorn@altlinux.org> 0.1-alt1
- Initial build
alterator-beancounters-0.1/applications/000075500000000000000000000000001125156471100205245ustar00rootroot00000000000000alterator-beancounters-0.1/applications/bc.desktop000064400000000000000000000002531125156471100225030ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-System
Terminal=false
Name=OpenVZ beancounters
Icon=bc
X-Alterator-URI=/bc
X-Alterator-UI=html
X-Alterator-Help=bc
alterator-beancounters-0.1/backend3/000075500000000000000000000000001125156471100175105ustar00rootroot00000000000000alterator-beancounters-0.1/backend3/bc000075500000000000000000000054631125156471100200320ustar00rootroot00000000000000#!/bin/sh

po_domain="alterator-bc"
alterator_api_version=1

. alterator-sh-functions

pagesize="$(getconf PAGESIZE)"
[ -n "$pagesize" ] || pagesize=4096

BC_ROOT="/proc/bc"

counter_status()
{
local max="$1" barr="$2" fail="$3"
local gap="95/100"

barr="$(echo "scale=0; $barr*$gap" | bc -q)"

if [ "$barr" -eq 0 -o "$max" -lt "$barr" ]; then
echo "OK::"
elif [ "$max" -ge "$barr" -a "$fail" -eq 0 ]; then
echo ":WARNING:"
else
echo "::ERROR"
fi
}

counter_value()
{
local name="$1" curr="$2" max="$3" barr="$4"
local divisor=1 suffix= scale=0

case "$name" in
*pages) # pages
divisor="$(( 1024*1024/$pagesize ))"
suffix=M
scale=2
;;
num*) # pieces
;;
*) # bytes
divisor=1048576
suffix=M
scale=2
;;
esac

case "$barr" in
9223372036854775807|2147483647)
barr="Unlimited"
;;
*)
barr="$(echo "scale=$scale; $barr/$divisor" | bc -q)$suffix"
;;
esac

curr="$(echo "scale=$scale; $curr/$divisor" | bc -q)$suffix"
max="$(echo "scale=$scale; $max/$divisor" | bc -q)$suffix"

printf '%s:%s:%s' "$curr" "$max" "$barr"
}

on_message()
{
env | grep '^in_'
case "$in_action" in
list)
case "$in__objects" in
/)
vzlist -aHo veid,name,status |
while read veid name status; do
ok="$status"
warn=
err=
if [ "$status" = "running" -a -f "$BC_ROOT/$veid/resources" ]; then
while read resname curr max barr lim fail; do
[ -n "${resname##*guar*}" ] || continue
status="$(counter_status "$max" "$barr" "$fail")"
if [ -n "${status#*:*:}" ]; then
ok=
warn=
err="${status#*:*:}"
break
fi
warn="${status%:*}"
warn="${warn#*:}"
done < "$BC_ROOT/$veid/resources"
fi
[ -z "$warn" ] || ok=
write_table_item \
veid "$veid" \
name "$name" \
ok "$ok" \
warn "$warn" \
err "$err"
done
;;
resources)
if [ -f "$BC_ROOT/$in_veid/resources" ]; then
while read resname curr max barr lim fail; do
[ -n "${resname##*guar*}" ] || continue
status="$(counter_status "$max" "$barr" "$fail")"
ok="${status%:*:*}"
warn="${status%:*}"
warn="${warn#*:}"
err="${status#*:*:}"
value="$(counter_value "$resname" "$curr" "$max" "$barr")"
curr="${value%:*:*}"
max="${value%:*}"
max="${max#*:}"
barr="${value#*:*:}"
write_table_item \
resource "$resname" \
curr "$curr" \
max "$max" \
barr "$barr" \
ok "$ok" \
warn "$warn" \
err "$err"
done < "$BC_ROOT/$in_veid/resources"
fi
;;
esac
;;
read)
case "$in__objects" in
resources)
write_string_param veid "$in_veid"
;;
esac
;;
esac
}

message_loop
# vim: set ts=4 sw=4:
alterator-beancounters-0.1/ui/000075500000000000000000000000001125156471100164535ustar00rootroot00000000000000alterator-beancounters-0.1/ui/bc/000075500000000000000000000000001125156471100170375ustar00rootroot00000000000000alterator-beancounters-0.1/ui/bc/index.html000064400000000000000000000021571125156471100210410ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html wf="form">
<body>
<form method="POST">
<table class="alterator-listbox" enumref="/bc" style="width:100%">
<thead>
<tr>
<th><span translate="_">VEID</span></th>
<th><span translate="_">Name</span></th>
<th><span translate="_">Status</span></th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap="yes">
<a href="/bc/resources?veid=" class="alterator-ref2" name="veid">
<span class="alterator-label" name="veid"/>
</a>
</td>
<td nowrap="yes"><span class="alterator-label" name="name"/></td>
<td nowrap="yes" align="center">
<span class="alterator-label" name="ok"/>
<span style="font-weight:bold;" class="alterator-label" name="warn"/>
<span style="color:red; font-weight:bold;" class="alterator-label" name="err"/>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
alterator-beancounters-0.1/ui/bc/resources/000075500000000000000000000000001125156471100210515ustar00rootroot00000000000000alterator-beancounters-0.1/ui/bc/resources/index.html000064400000000000000000000027321125156471100230520ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html wf="form">
<body>
<form method="POST">
<a href="/bc"><span translate="_">Back...</span></a>
<h2><span translate="_">OpenVZ container</span>&nbsp;<span class="alterator-label" name="veid"/></h2>
<table class="alterator-listbox" enumref="/bc/resources" style="width:100%">
<thead>
<tr>
<th><span translate="_">Resource</span></th>
<th><span translate="_">Current</span></th>
<th><span translate="_">Peak</span></th>
<th><span translate="_">Limit</span></th>
<th><span translate="_">Status</span></th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap="yes"><span class="alterator-label" name="resource"/></td>
<td nowrap="yes" align="right"><span class="alterator-label" name="curr"/></td>
<td nowrap="yes" align="right"><span class="alterator-label" name="max"/></td>
<td nowrap="yes" align="right"><span class="alterator-label" name="barr"/></td>
<td nowrap="yes" align="center">
<span class="alterator-label" name="ok"/>
<span style="font-weight:bold;" class="alterator-label" name="warn"/>
<span style="color:red; font-weight:bold;" class="alterator-label" name="err"/>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin