-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/missing packages inventory solaris agent (#5144)
* Add solaris to packages info * Fix metrics error * Add ports and process columns for solaris * improve code * modify changelog
- Loading branch information
Showing
6 changed files
with
145 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 111 additions & 43 deletions
154
public/components/agents/syscollector/components/syscollector-metrics.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,123 @@ | ||
import React, { useState } from "react"; | ||
import {EuiPanel, EuiFlexGroup, EuiFlexItem, EuiText, EuiLoadingSpinner, EuiIcon} from "@elastic/eui"; | ||
import React, { useState } from 'react'; | ||
import { | ||
EuiPanel, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiText, | ||
EuiLoadingSpinner, | ||
EuiIcon, | ||
} from '@elastic/eui'; | ||
import mapValues from 'lodash'; | ||
import {useGenericRequest} from '../../../common/hooks/useGenericRequest'; | ||
import { useGenericRequest } from '../../../common/hooks/useGenericRequest'; | ||
import { formatUIDate } from '../../../../react-services/time-service'; | ||
|
||
export function InventoryMetrics({agent}) { | ||
const [params, setParams] = useState({}); | ||
const offsetTimestamp = (text, time) => { | ||
try { | ||
return text + formatUIDate(time); | ||
} catch (error) { | ||
return time !== '-' ? `${text}${time} (UTC)` : time; | ||
} | ||
} | ||
const syscollector = useGenericRequest('GET', `/api/syscollector/${agent.id}`, params, (result) => {return (result || {}).data || {};}); | ||
|
||
export function InventoryMetrics({ agent }) { | ||
const [params, setParams] = useState({}); | ||
const offsetTimestamp = (text, time) => { | ||
try { | ||
return text + formatUIDate(time); | ||
} catch (error) { | ||
return time !== '-' ? `${text}${time} (UTC)` : time; | ||
} | ||
}; | ||
const syscollector = useGenericRequest( | ||
'GET', | ||
`/api/syscollector/${agent.id}`, | ||
params, | ||
result => { | ||
return (result || {}).data || {}; | ||
}, | ||
); | ||
console.log('syscollector', syscollector); | ||
if ( | ||
!syscollector.isLoading && | ||
(mapValues.isEmpty(syscollector.data.hardware) || mapValues.isEmpty(syscollector.data.os)) | ||
(mapValues.isEmpty(syscollector.data.hardware) || | ||
mapValues.isEmpty(syscollector.data.os)) | ||
) { | ||
return ( | ||
<EuiPanel paddingSize="s" style={{ margin: 16, textAlign: 'center' }}> | ||
<EuiIcon type="iInCircle" /> Not enough hardware or operating system information | ||
<EuiPanel paddingSize='s' style={{ margin: 16, textAlign: 'center' }}> | ||
<EuiIcon type='iInCircle' /> Not enough hardware or operating system | ||
information | ||
</EuiPanel> | ||
); | ||
} | ||
|
||
return ( | ||
<EuiPanel paddingSize="s" style={{margin: 16}}> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={false}> | ||
<EuiText>Cores: {syscollector.isLoading ? <EuiLoadingSpinner size="s" /> : <strong>{syscollector.data.hardware.cpu.cores}</strong>}</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText>Memory: {syscollector.isLoading ? <EuiLoadingSpinner size="s" /> : <strong>{ (syscollector.data.hardware.ram.total / 1024).toFixed(2) } MB</strong>}</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText>Arch: {syscollector.isLoading ? <EuiLoadingSpinner size="s" /> : <strong>{syscollector.data.os.architecture}</strong>}</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText>OS: {syscollector.isLoading ? <EuiLoadingSpinner size="s" /> : <strong>{syscollector.data.os.os.name} {syscollector.data.os.os.version}</strong>}</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={true}> | ||
<EuiText>CPU: {syscollector.isLoading ? <EuiLoadingSpinner size="s" /> : <strong>{syscollector.data.hardware.cpu.name}</strong>}</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText>Last scan: {syscollector.isLoading ? <EuiLoadingSpinner size="s" /> : <strong>{offsetTimestamp('',syscollector.data.os.scan.time)}</strong>}</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPanel> | ||
); | ||
|
||
|
||
return ( | ||
<EuiPanel paddingSize='s' style={{ margin: 16 }}> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={false}> | ||
<EuiText> | ||
Cores:{' '} | ||
{syscollector.isLoading ? ( | ||
<EuiLoadingSpinner size='s' /> | ||
) : syscollector.data.hardware.cpu?.cores ? ( | ||
<strong>{syscollector.data.hardware.cpu.cores}</strong> | ||
) : ( | ||
<strong>-</strong> | ||
)} | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText> | ||
Memory:{' '} | ||
{syscollector.isLoading ? ( | ||
<EuiLoadingSpinner size='s' /> | ||
) : syscollector.data.hardware.ram?.total ? ( | ||
<strong> | ||
{(syscollector.data.hardware.ram.total / 1024).toFixed(2)} MB | ||
</strong> | ||
) : ( | ||
<strong>-</strong> | ||
)} | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText> | ||
Arch:{' '} | ||
{syscollector.isLoading ? ( | ||
<EuiLoadingSpinner size='s' /> | ||
) : ( | ||
<strong>{syscollector.data.os.architecture}</strong> | ||
)} | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText> | ||
OS:{' '} | ||
{syscollector.isLoading ? ( | ||
<EuiLoadingSpinner size='s' /> | ||
) : ( | ||
<strong> | ||
{syscollector.data.os.os.name} {syscollector.data.os.os.version} | ||
</strong> | ||
)} | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={true}> | ||
<EuiText> | ||
CPU:{' '} | ||
{syscollector.isLoading ? ( | ||
<EuiLoadingSpinner size='s' /> | ||
) : syscollector.data.hardware.cpu?.name ? ( | ||
<strong>{syscollector.data.hardware.cpu.name}</strong> | ||
) : ( | ||
<strong>-</strong> | ||
)} | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText> | ||
Last scan:{' '} | ||
{syscollector.isLoading ? ( | ||
<EuiLoadingSpinner size='s' /> | ||
) : ( | ||
<strong> | ||
{offsetTimestamp('', syscollector.data.os.scan.time)} | ||
</strong> | ||
)} | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPanel> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters