]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/sys.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 18 Mar 2019 06:16:36 +0000 (06:16 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 18 Mar 2019 06:16:36 +0000 (06:16 +0000)
etc/profile.d/sys.sh
lib/postgres/host.sql

index 3be92ca5d957c684ac4822a11737a63ac6f50d81..2a93ed13c5e72ef9a91c1a416e052f4210e145ec 100644 (file)
@@ -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)
index dbb2285e9b9705ccb8e5287fccb1302787b77c2e..a5232d679d389935d89e473170e171fa5c6c2ab6 100644 (file)
@@ -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
 ;