From 2a4652bd5503fd5c4fa6e5e56e330fc46d903f6a Mon Sep 17 00:00:00 2001 From: paspo Date: Thu, 9 May 2019 19:04:38 +0200 Subject: [PATCH] added inventory check --- cron/libreschool-client | 1 + libreschool-client | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/cron/libreschool-client b/cron/libreschool-client index 6434024..9d19989 100644 --- a/cron/libreschool-client +++ b/cron/libreschool-client @@ -1,2 +1,3 @@ */5 * * * * root /usr/sbin/libreschool-client +* */1 * * * root /usr/sbin/libreschool-client --with-inventory @reboot root /usr/sbin/libreschool-client diff --git a/libreschool-client b/libreschool-client index ecbc072..bc11e4c 100755 --- a/libreschool-client +++ b/libreschool-client @@ -10,6 +10,7 @@ import sys import socket import fileinput import json +import commands def get_default_gateway_linux(): """Read the default gateway directly from /proc.""" @@ -74,6 +75,14 @@ data = { 'last_config': config['server'].get('last_config','0') } +if '--with-inventory' in sys.argv: + _, cpu = commands.getstatusoutput('cat /proc/cpuinfo | grep \'^model\ name\' | head -n 1 | sed \'s/model\\ name\\s:\\s*\\(.*\\)/\\1/\'') + _, ram = commands.getstatusoutput('vmstat -s | grep \'total memory$\' | awk \'{print $1}\'') + _, distro = commands.getstatusoutput('lsb_release -d') + data['cpu'] = cpu + data['ram'] = ram + data['distro'] = distro + # if server uuid is set if 'uuid' in config['server']: # and is in the correct format