Compare commits
No commits in common. "b57db23a3586b6db8955c0a6b7c0800e34ef55c5" and "1d06e1c1802c74cde98dd9f021737b4e460ad957" have entirely different histories.
b57db23a35
...
1d06e1c180
@ -14,7 +14,7 @@ rec {
|
|||||||
packages.x86_64-linux = with nixpkgs.legacyPackages.x86_64-linux; rec {
|
packages.x86_64-linux = with nixpkgs.legacyPackages.x86_64-linux; rec {
|
||||||
pvemon = python3Packages.buildPythonApplication {
|
pvemon = python3Packages.buildPythonApplication {
|
||||||
pname = "pvemon";
|
pname = "pvemon";
|
||||||
version = "1.3.2";
|
version = "1.3.1";
|
||||||
src = ./src;
|
src = ./src;
|
||||||
propagatedBuildInputs = with python3Packages; [
|
propagatedBuildInputs = with python3Packages; [
|
||||||
pexpect
|
pexpect
|
||||||
|
|||||||
@ -87,53 +87,15 @@ def parse_storage_cfg(file_path='/etc/pve/storage.cfg'):
|
|||||||
|
|
||||||
def get_storage_size(storage):
|
def get_storage_size(storage):
|
||||||
try:
|
try:
|
||||||
if storage["type"] == "zfspool":
|
if storage["type"] in ["dir", "nfs", "cephfs", "zfspool"]:
|
||||||
if "pool" not in storage:
|
if storage["type"] == "zfspool":
|
||||||
logging.debug(f"ZFS pool {storage['name']} has no pool name configured")
|
path = storage["mountpoint"]
|
||||||
return None
|
else:
|
||||||
|
path = storage["path"]
|
||||||
# Extract the pool name (could be in format like rpool/data)
|
# Get filesystem statistics
|
||||||
pool_name = storage["pool"].split("/")[0]
|
|
||||||
|
|
||||||
# Use zpool command to get accurate size information
|
|
||||||
import subprocess
|
|
||||||
try:
|
|
||||||
result = subprocess.run(
|
|
||||||
["zpool", "list", pool_name, "-p"],
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
check=True
|
|
||||||
)
|
|
||||||
|
|
||||||
# Parse the output
|
|
||||||
lines = result.stdout.strip().split("\n")
|
|
||||||
if len(lines) < 2:
|
|
||||||
logging.warn(f"Unexpected zpool list output format for {pool_name}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Extract values from the second line (the data line)
|
|
||||||
values = lines[1].split()
|
|
||||||
if len(values) < 4:
|
|
||||||
logging.warn(f"Insufficient data in zpool list output for {pool_name}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Values are: NAME SIZE ALLOC FREE ...
|
|
||||||
# We need the SIZE and FREE values (index 1 and 3)
|
|
||||||
total_size = int(values[1])
|
|
||||||
free_space = int(values[3])
|
|
||||||
|
|
||||||
return {
|
|
||||||
"total": total_size,
|
|
||||||
"free": free_space
|
|
||||||
}
|
|
||||||
except (subprocess.SubprocessError, ValueError, IndexError) as e:
|
|
||||||
logging.warn(f"Error running zpool list for {pool_name}: {e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
elif storage["type"] in ["dir", "nfs", "cephfs"]:
|
|
||||||
# For non-ZFS storage, use statvfs
|
|
||||||
path = storage["path"]
|
|
||||||
stats = os.statvfs(path)
|
stats = os.statvfs(path)
|
||||||
|
# Calculate total size and free space in bytes
|
||||||
|
# TODO: find an alternative way to calculate total_size for ZFS
|
||||||
total_size = stats.f_frsize * stats.f_blocks
|
total_size = stats.f_frsize * stats.f_blocks
|
||||||
free_space = stats.f_frsize * stats.f_bavail
|
free_space = stats.f_frsize * stats.f_bavail
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='pvemon',
|
name='pvemon',
|
||||||
version = "1.3.2",
|
version = "1.3.1",
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user