From 7ff3cf8a02da0dba53656620833769d6a711e310 Mon Sep 17 00:00:00 2001 From: Giacomo Sanchietti Date: Fri, 12 Apr 2024 16:34:12 +0200 Subject: [PATCH 1/2] inventory: add get-facts --- imageroot/actions/get-facts/10get_facts | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 imageroot/actions/get-facts/10get_facts diff --git a/imageroot/actions/get-facts/10get_facts b/imageroot/actions/get-facts/10get_facts new file mode 100755 index 0000000..797ba41 --- /dev/null +++ b/imageroot/actions/get-facts/10get_facts @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +# +# Copyright (C) 2024 Nethesis S.r.l. +# SPDX-License-Identifier: GPL-2.0-only +# + +import json +import subprocess +import os +import sys +import agent + +units = 0 +users = 0 +try: + p = subprocess.run(["/usr/bin/podman", "exec", "-ti", "vpn", "find", "/etc/openvpn/ccd", "-type", "f"], capture_output=True, text=True) + units = len(p.stdout.split("\n")) - 1 +except Exception as ex: + print(agent.SD_ERR, ex, file=sys.stderr) + units = 0 + +try: + p = subprocess.run(["/usr/bin/podman", "exec", "-ti", "api", "sqlite3", "/nethsecurity-api/data/db.sqlite", "select count(*) from accounts;"], capture_output=True, text=True) + users = int(p.stdout.strip()) +except Exception as ex: + print(agent.SD_ERR, ex, file=sys.stderr) + users = 0 + +json.dump({ + "units": units, + "active_users": users, + "total_users": users +}, fp=sys.stdout) From 3061649167f9224b58e18d1757ac0d380f89e7f5 Mon Sep 17 00:00:00 2001 From: Giacomo Sanchietti Date: Fri, 12 Apr 2024 17:15:55 +0200 Subject: [PATCH 2/2] build: bump controller to 0.0.24 Required for get-facts --- build-images.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-images.sh b/build-images.sh index d858bb0..b3ab806 100755 --- a/build-images.sh +++ b/build-images.sh @@ -9,7 +9,7 @@ images=() repobase="${REPOBASE:-ghcr.io/nethserver}" # Configure the image name reponame="nethsecurity-controller" -controller_version=0.0.23 +controller_version=0.0.24 promtail_version=2.7.1 loki_version=2.9.4 prometheus_version=2.50.1