From: Nicolas Boisselier Date: Mon, 18 Mar 2019 06:16:36 +0000 (+0000) Subject: etc/profile.d/sys.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=c521791a1c6a62a117d78314e8e59b32410453cd;p=nb.git etc/profile.d/sys.sh --- diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index 3be92ca5..2a93ed13 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -14,6 +14,23 @@ sys_watch() { # NB 08.08.17 watch --no-title $opt bash -c "sys_activity" } +sys_model() { + case "$OSTYPE" in + darwin*) + echo 'Apple '$( + system_profiler -timeout 1 SPHardwareDataType -detailLevel mini | awk -F': ' '/Model Identifier: /{print $2; exit}' + ) + ;; + *) + if [ -e /proc/device-tree/model ]; then + tr -d '\000' < /proc/device-tree/model + elif which lshw > /dev/null; then + lshw -quiet -class system | awk -F': ' '/product: /{print $2}' + fi + ;; + esac +} + sys_infos() { local s="$(printf '\t')" grep -vE "^[^${s}]+${s}$" << EOF @@ -21,7 +38,7 @@ arch${s}$(sys_arch) nproc${s}$(sys_nproc) ips${s}$(echo -n $(ips 2>/dev/null)) interfaces${s}$(echo -n $(sys_interfaces)) -model${s}$([ -r /proc/device-tree/model ] && printf '%s\t%s\n' model "$(tr -d '\000' < /proc/device-tree/model)") +model${s}$(sys_model) os${s}$(sys_os) date_install${s}$(sys_date_install) mem_total${s}$(sys_mem_total) diff --git a/lib/postgres/host.sql b/lib/postgres/host.sql index dbb2285e..a5232d67 100644 --- a/lib/postgres/host.sql +++ b/lib/postgres/host.sql @@ -3,8 +3,9 @@ CREATE VIEW host AS SELECT host ,LEFT(CAST(MAX(updated) AS TEXT),19) as updated ,count(*) as infos - ,array_to_string(array_agg(DISTINCT CASE WHEN key LIKE 'git.%.name' THEN val ELSE null END),' ') as installed + -- ,array_to_string(array_agg(DISTINCT CASE WHEN key LIKE 'git.%.name' THEN val ELSE null END),' ') as installed ,array_to_string(array_agg(DISTINCT CASE WHEN key LIKE 'git.%.branch' THEN val ELSE null END),' ') as branches + ,array_to_string(array_agg(DISTINCT CASE WHEN key IN ( 'sys.nproc','sys.arch','sys.width','sys.product' ) THEN val ELSE null END),chr(10)) as product FROM host_info GROUP BY host ;