diff --git a/src/Lhp/Remote.hs b/src/Lhp/Remote.hs index 4837ccb..5db4a44 100644 --- a/src/Lhp/Remote.hs +++ b/src/Lhp/Remote.hs @@ -21,6 +21,7 @@ import Data.Maybe (catMaybes, fromMaybe) import qualified Data.Scientific as S import qualified Data.Text as T import qualified Lhp.Config as Config +import Lhp.Types (HostReport (_hostReportTimezone)) import qualified Lhp.Types as Types import System.Exit (ExitCode (..)) import System.IO (hPutStrLn, stderr) @@ -65,6 +66,8 @@ compileHostReport compileHostReport h@Types.Host {..} = do kvs <- (++) <$> _fetchHostInfo _hostName <*> _fetchHostCloudInfo _hostName let _hostReportHost = h + _hostReportHostname <- _toParseError _hostName $ _getParse pure "LHP_GENERAL_HOSTNAME" kvs + _hostReportTimezone <- _toParseError _hostName $ _getParse pure "LHP_GENERAL_TIMEZONE" kvs _hostReportCloud <- _mkCloud _hostName kvs _hostReportHardware <- _mkHardware _hostName kvs _hostReportKernel <- _mkKernel _hostName kvs diff --git a/src/Lhp/Types.hs b/src/Lhp/Types.hs index 819f080..28cb26e 100644 --- a/src/Lhp/Types.hs +++ b/src/Lhp/Types.hs @@ -69,6 +69,8 @@ instance ADC.HasCodec Host where -- | Data definition for host patrol report. data HostReport = HostReport { _hostReportHost :: !Host + , _hostReportHostname :: !T.Text + , _hostReportTimezone :: !T.Text , _hostReportCloud :: !Cloud , _hostReportHardware :: !Hardware , _hostReportKernel :: !Kernel @@ -90,6 +92,8 @@ instance ADC.HasCodec HostReport where ADC.object "Report" $ HostReport <$> ADC.requiredField "host" "Host descriptor." ADC..= _hostReportHost + <*> ADC.requiredField "hostname" "Hostname of the host." ADC..= _hostReportHostname + <*> ADC.requiredField "timezone" "Timezone of the host." ADC..= _hostReportTimezone <*> ADC.requiredField "cloud" "Cloud information." ADC..= _hostReportCloud <*> ADC.requiredField "hardware" "Hardware information." ADC..= _hostReportHardware <*> ADC.requiredField "kernel" "Kernel information." ADC..= _hostReportKernel diff --git a/src/scripts/info.sh b/src/scripts/info.sh index d6933f0..74a74e5 100644 --- a/src/scripts/info.sh +++ b/src/scripts/info.sh @@ -53,6 +53,8 @@ _check_file /etc/os-release # PROCEDURE # ############# +_print_var "LHP_GENERAL_HOSTNAME" "$(hostname)" +_print_var "LHP_GENERAL_TIMEZONE" "$(timedatectl | grep "Time zone" | cut -f 2- -d ":" | xargs)" _print_var "LHP_HW_CPU" "$(nproc)" _print_var "LHP_HW_RAM" "$(grep -oP 'MemTotal:\s+\K\d+' /proc/meminfo)" _print_var "LHP_HW_DISK" "$(df -k --output=size / | tail -n +2 | grep -o '[[:digit:]]*')" diff --git a/website/src/components/report/ShowHostDetails.tsx b/website/src/components/report/ShowHostDetails.tsx index f827df7..b5b1f57 100644 --- a/website/src/components/report/ShowHostDetails.tsx +++ b/website/src/components/report/ShowHostDetails.tsx @@ -9,7 +9,7 @@ import { KVBox } from '../helpers'; export function ShowHostDetails({ host }: { host: LhpHostReport }) { return (
-

+

{host.host.name} {host.host.url && ( @@ -19,12 +19,18 @@ export function ShowHostDetails({ host }: { host: LhpHostReport }) { )}
-
- {(host.host.tags || []).map((x) => ( - - {x} - - ))} +
+
+ {host.hostname} on {host.timezone} +
+ +
+ {(host.host.tags || []).map((x) => ( + + {x} + + ))} +

diff --git a/website/src/components/report/TabulateHosts.tsx b/website/src/components/report/TabulateHosts.tsx index 37d9d83..b4c9c86 100644 --- a/website/src/components/report/TabulateHosts.tsx +++ b/website/src/components/report/TabulateHosts.tsx @@ -40,6 +40,28 @@ export function TabulateHosts({
+
+ +
+
+ Name Hostname + Timezone Cloud Distribution Arch @@ -353,6 +377,8 @@ export function TabulateHosts({ )}
+ {host.hostname} + {host.timezone.split(' ', 1)[0] || 'UNKNOWN'} {host.cloud.name} {host.cloud.hostRegion && {host.cloud.hostRegion}} diff --git a/website/src/lib/data.ts b/website/src/lib/data.ts index eb818d9..e8b07b7 100644 --- a/website/src/lib/data.ts +++ b/website/src/lib/data.ts @@ -144,6 +144,7 @@ export const LHP_PATROL_REPORT_SCHEMA = { required: ['name'], type: 'object', }, + hostname: { $comment: 'Hostname of the host.', type: 'string' }, kernel: { $comment: 'Kernel information.\nKernel Information\nKernel', properties: { @@ -167,6 +168,7 @@ export const LHP_PATROL_REPORT_SCHEMA = { items: { type: 'string' }, type: 'array', }, + timezone: { $comment: 'Timezone of the host.', type: 'string' }, }, required: [ 'systemdTimers', @@ -177,6 +179,8 @@ export const LHP_PATROL_REPORT_SCHEMA = { 'kernel', 'hardware', 'cloud', + 'timezone', + 'hostname', 'host', ], type: 'object',