Skip to content

Commit

Permalink
Fix/missing packages inventory solaris agent (#5144)
Browse files Browse the repository at this point in the history
* Add solaris to packages info

* Fix metrics error

* Add ports and process columns for solaris

* improve code

* modify changelog
  • Loading branch information
Tostti authored Jan 26, 2023
1 parent 942b6e5 commit 1b8d218
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 61 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed agent deployment instructions for HP-UX and Solaris. [#4943](https://github.com/wazuh/wazuh-kibana-app/pull/4943)
- Fixed Inventory checks table filters by stats [#4999](https://github.com/wazuh/wazuh-kibana-app/pull/4999)
- Fixed vulnerabilities default last scan date formatter [#4975](https://github.com/wazuh/wazuh-kibana-app/pull/4975)
- A solaris command has been fixed [5035](https://github.com/wazuh/wazuh-kibana-app/pull/5035)
- Fixed commands: Aix, OpenSUSE, Alpine, Suse11, Fedora, HP, Oracle Linux 5, Amazon Linux 2, Centos5. Changed the word 'or higher' in buttons to '+'.Fixed validations for Hp, Solaris and Alpine. [5045](https://github.com/wazuh/wazuh-kibana-app/pull/5045)
- Fixed error in Github module PDF report. [5069](https://github.com/wazuh/wazuh-kibana-app/pull/5069)
- Fixed password input in deploy new agent section [5098](https://github.com/wazuh/wazuh-kibana-app/pull/5098)
- A solaris command has been fixed [#5035](https://github.com/wazuh/wazuh-kibana-app/pull/5035)
- Fixed commands: Aix, OpenSUSE, Alpine, Suse11, Fedora, HP, Oracle Linux 5, Amazon Linux 2, Centos5. Changed the word 'or higher' in buttons to '+'.Fixed validations for Hp, Solaris and Alpine. [#5045](https://github.com/wazuh/wazuh-kibana-app/pull/5045)
- Fixed error in Github module PDF report. [#5069](https://github.com/wazuh/wazuh-kibana-app/pull/5069)
- Fixed password input in deploy new agent section [#5098](https://github.com/wazuh/wazuh-kibana-app/pull/5098)
- Fixed error when clicking on the selectors of agents in the group agents management [#5094](https://github.com/wazuh/wazuh-kibana-app/pull/5094)
- Fixed mispelling in the NIST module [#5107](https://github.com/wazuh/wazuh-kibana-app/pull/5107)
- Fixed Inventory module for solaris agents [#5144](https://github.com/wazuh/wazuh-kibana-app/pull/5144)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ export const packagesColumns = {
linux: linuxColumns,
apple: MacColumns,
freebsd: FreebsdColumns,
solaris: linuxColumns,
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export const portsColumns = {
linux: defaultColumns,
apple: defaultColumns,
freebsd: defaultColumns,
solaris: defaultColumns,
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ export const processColumns = {
linux: linuxColumns,
apple: macColumns,
freebsd: linuxColumns,
solaris: linuxColumns,
};
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>
);
}
40 changes: 26 additions & 14 deletions public/components/agents/syscollector/inventory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
*/

import React, { Fragment } from 'react';
import { EuiEmptyPrompt, EuiButton, EuiFlexGroup, EuiFlexItem, EuiCallOut } from '@elastic/eui';
import {
EuiEmptyPrompt,
EuiButton,
EuiFlexGroup,
EuiFlexItem,
EuiCallOut,
} from '@elastic/eui';
import { InventoryMetrics } from './components/syscollector-metrics';
import { SyscollectorTable } from './components/syscollector-table';
import { processColumns, portsColumns, packagesColumns } from './columns';
Expand All @@ -22,22 +28,27 @@ export function SyscollectorInventory({ agent }) {
if (agent && agent.status === API_NAME_AGENT_STATUS.NEVER_CONNECTED) {
return (
<EuiEmptyPrompt
iconType="securitySignalDetected"
iconType='securitySignalDetected'
style={{ marginTop: 20 }}
title={<h2>Agent has never connected.</h2>}
body={
<Fragment>
<p>The agent has been registered but has not yet connected to the manager.</p>
<p>
The agent has been registered but has not yet connected to the
manager.
</p>
<a
href={webDocumentationLink('user-manual/agents/agent-connection.html')}
target="_blank"
href={webDocumentationLink(
'user-manual/agents/agent-connection.html',
)}
target='_blank'
>
Checking connection with the Wazuh server
</a>
</Fragment>
}
actions={
<EuiButton href="#/agents-preview?" color="primary" fill>
<EuiButton href='#/agents-preview?' color='primary' fill>
Back
</EuiButton>
}
Expand All @@ -46,7 +57,6 @@ export function SyscollectorInventory({ agent }) {
}

let soPlatform;

if (((agent.os || {}).uname || '').includes('Linux')) {
soPlatform = 'linux';
} else if ((agent.os || {}).platform === 'windows') {
Expand All @@ -55,6 +65,8 @@ export function SyscollectorInventory({ agent }) {
soPlatform = 'apple';
} else if (((agent.os || {}).uname.toLowerCase() || '').includes('freebsd')) {
soPlatform = 'freebsd';
} else if (((agent.os || {}).uname.toLowerCase() || '').includes('sunos')) {
soPlatform = 'solaris';
}

const netifaceColumns = [
Expand All @@ -77,17 +89,17 @@ export function SyscollectorInventory({ agent }) {
{agent && agent.status === API_NAME_AGENT_STATUS.DISCONNECTED && (
<EuiCallOut
style={{ margin: '8px 16px 8px 16px' }}
title="This agent is currently disconnected, the data may be outdated."
iconType="iInCircle"
title='This agent is currently disconnected, the data may be outdated.'
iconType='iInCircle'
/>
)}
<EuiFlexGroup gutterSize="s">
<EuiFlexGroup gutterSize='s'>
<EuiFlexItem style={{ marginBottom: 0 }}>
<InventoryMetrics agent={agent}></InventoryMetrics>
</EuiFlexItem>
</EuiFlexGroup>

<EuiFlexGroup gutterSize="s">
<EuiFlexGroup gutterSize='s'>
<EuiFlexItem grow={2} style={{ marginRight: 4, marginTop: 0 }}>
<SyscollectorTable
tableParams={{
Expand All @@ -114,7 +126,7 @@ export function SyscollectorInventory({ agent }) {
</EuiFlexItem>
</EuiFlexGroup>

<EuiFlexGroup gutterSize="s">
<EuiFlexGroup gutterSize='s'>
<EuiFlexItem grow={3} style={{ marginRight: 4 }}>
<SyscollectorTable
tableParams={{
Expand Down Expand Up @@ -143,7 +155,7 @@ export function SyscollectorInventory({ agent }) {
)}
</EuiFlexGroup>

<EuiFlexGroup gutterSize="s">
<EuiFlexGroup gutterSize='s'>
<EuiFlexItem>
<SyscollectorTable
tableParams={{
Expand All @@ -159,7 +171,7 @@ export function SyscollectorInventory({ agent }) {
</EuiFlexItem>
</EuiFlexGroup>

<EuiFlexGroup gutterSize="s">
<EuiFlexGroup gutterSize='s'>
<EuiFlexItem>
<SyscollectorTable
tableParams={{
Expand Down

0 comments on commit 1b8d218

Please sign in to comment.