Skip to content

Commit

Permalink
feat(mbean): include more OS/runtime details (#1111)
Browse files Browse the repository at this point in the history
* feat(mbean): add total physical memory

* feat(mbean): add total swap

* feat(mbean): add OS name

* feat(mbean): add classpath list

* chore(labels): rename component more generically

* feat(mbean): add library paths

* feat(mbean): add input arguments

* feat(mbean): add system properties
  • Loading branch information
andrewazores authored Sep 19, 2023
1 parent 164159c commit e19d1be
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/app/Shared/Services/Api.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,7 @@ export interface MBeanMetrics {
daemonThreadCount?: number;
};
os?: {
name?: string;
arch?: string;
availableProcessors?: number;
version?: string;
Expand All @@ -1654,6 +1655,7 @@ export interface MBeanMetrics {
processCpuLoad?: number;
totalPhysicalMemorySize?: number;
freePhysicalMemorySize?: number;
totalSwapSpaceSize?: number;
};
memory?: {
heapMemoryUsage?: MemoryUsage;
Expand All @@ -1670,7 +1672,7 @@ export interface MBeanMetrics {
specName?: string;
specVendor?: string;
startTime?: number;
// systemProperties?: Object
systemProperties?: object;
uptime?: number;
vmName?: string;
vmVendor?: string;
Expand Down
72 changes: 68 additions & 4 deletions src/app/Topology/Shared/Entity/EntityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ServiceContext } from '@app/Shared/Services/Services';
import { ActionDropdown, NodeAction } from '@app/Topology/Actions/NodeActions';
import useDayjs from '@app/utils/useDayjs';
import { useSubscriptions } from '@app/utils/useSubscriptions';
import { hashCode, portalRoot, splitWordsOnUppercase } from '@app/utils/utils';
import { formatBytes, hashCode, portalRoot, splitWordsOnUppercase } from '@app/utils/utils';
import {
Alert,
AlertActionCloseButton,
Expand Down Expand Up @@ -55,7 +55,7 @@ import { EnvironmentNode, isTargetNode, TargetNode } from '../../typings';
import { EmptyText } from '../EmptyText';
import { actionFactory, getStatusTargetNode, ListElement, nodeTypeToAbbr, StatusExtra } from '../utils';
import { EntityAnnotations } from './EntityAnnotations';
import { EntityLabels } from './EntityLabels';
import { EntityKeyValues, keyValueEntryTransformer } from './EntityKeyValues';
import { EntityTitle } from './EntityTitle';
import {
DescriptionConfig,
Expand Down Expand Up @@ -213,7 +213,7 @@ export const TargetDetails: React.FC<{
'Target',
['labels'],
),
content: <EntityLabels labels={serviceRef.labels} maxDisplay={3} />,
content: <EntityKeyValues kv={serviceRef.labels} maxDisplay={3} transformer={keyValueEntryTransformer} />,
},
{
key: 'Annotations',
Expand Down Expand Up @@ -270,11 +270,18 @@ const MBeanDetails: React.FC<{
startTime
vmVendor
vmVersion
classPath
libraryPath
inputArguments
systemProperties
}
os {
name
version
arch
availableProcessors
totalPhysicalMemorySize
totalSwapSpaceSize
}
}
}
Expand Down Expand Up @@ -320,6 +327,13 @@ const MBeanDetails: React.FC<{
helperDescription: 'The vendor who supplied this JVM',
content: mbeanMetrics.runtime?.vmVendor || <EmptyText text="Unknown JVM vendor" />,
},
{
key: 'Operating System Name',
title: 'Operating System Name',
helperTitle: 'Operating System Name',
helperDescription: 'The name of the host system.',
content: mbeanMetrics.os?.name || <EmptyText text="Unknown operating system name" />,
},
{
key: 'Operating System Architecture',
title: 'Operating System Architecture',
Expand All @@ -341,6 +355,56 @@ const MBeanDetails: React.FC<{
helperDescription: 'The count of total processors available to the JVM process on its host.',
content: mbeanMetrics.os?.availableProcessors || <EmptyText text="Unknown number of processors" />,
},
{
key: 'Total Physical Memory',
title: 'Total Physical Memory',
helperTitle: 'Total Physical Memory',
helperDescription: 'The total amount of physical memory of the host operating system.',
content: mbeanMetrics.os?.totalPhysicalMemorySize ? (
formatBytes(mbeanMetrics.os?.totalPhysicalMemorySize)
) : (
<EmptyText text="Unknown amount of physical memory" />
),
},
{
key: 'Total Swap Space',
title: 'Total Swap Space',
helperTitle: 'Total Swap Space',
helperDescription: 'The total amount of swap space of the host operating system.',
content: mbeanMetrics.os?.totalSwapSpaceSize ? (
formatBytes(mbeanMetrics.os?.totalSwapSpaceSize)
) : (
<EmptyText text="Unknown amount of swap space" />
),
},
{
key: 'Class Path',
title: 'Class Path',
helperTitle: 'JVM Class Path',
helperDescription: 'The list of class path locations for this JVM',
content: <EntityKeyValues kv={mbeanMetrics.runtime?.classPath?.split(':')} />,
},
{
key: 'Library Paths',
title: 'Library Paths',
helperTitle: 'JVM Library Paths',
helperDescription: 'The list of library path locations for this JVM',
content: <EntityKeyValues kv={mbeanMetrics.runtime?.libraryPath?.split(':')} />,
},
{
key: 'Input Arguments',
title: 'Input Arguments',
helperTitle: 'JVM Input Arguments',
helperDescription: 'The arguments passed to this JVM on startup',
content: <EntityKeyValues kv={mbeanMetrics.runtime?.inputArguments} />,
},
{
key: 'System Properties',
title: 'System Properties',
helperTitle: 'JVM System Properties',
helperDescription: 'The current system properties of this JVM',
content: <EntityKeyValues kv={mbeanMetrics.runtime?.systemProperties} transformer={keyValueEntryTransformer} />,
},
];
}, [mbeanMetrics, dayjs, dateTimeFormat.timeZone.full]);

Expand All @@ -365,7 +429,7 @@ export const GroupDetails: React.FC<{
title: 'Labels',
helperTitle: 'Labels',
helperDescription: 'Map of string keys and values that can be used to organize and categorize targets.',
content: <EntityLabels labels={envNode.labels} />,
content: <EntityKeyValues kv={envNode.labels} transformer={keyValueEntryTransformer} />,
},
];
}, [envNode]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,29 @@ import { Label, LabelGroup } from '@patternfly/react-core';
import * as React from 'react';
import { EmptyText } from '../EmptyText';

export const EntityLabels: React.FC<{ labels?: object; maxDisplay?: number }> = ({ labels, maxDisplay, ...props }) => {
const _transformedLabels = React.useMemo(() => {
return labels ? Object.keys(labels).map((k) => `${k}=${labels[k]}`) : [];
}, [labels]);
export function keyValueEntryTransformer(kv: object): string[] {
return Object.entries(kv).map(([k, v]) => `${k}=${v}`);
}

return _transformedLabels.length ? (
<div className="entity-overview__displayed-labels-wrapper" {...props}>
export const valuesEntryTransformer: (kv: string[] | object) => string[] = Object.values;

export const EntityKeyValues: React.FC<{
kv?: string[] | object;
maxDisplay?: number;
transformer?: (o: object) => string[];
}> = ({ kv, maxDisplay, transformer = valuesEntryTransformer, ...props }) => {
const _transformedKv = React.useMemo(() => (kv ? transformer(kv) : []), [kv, transformer]);
return _transformedKv.length ? (
<div className="entity-overview__displayed-keyvalues-wrapper" {...props}>
<LabelGroup numLabels={maxDisplay}>
{_transformedLabels.map((l) => (
{_transformedKv.map((l) => (
<Label color="blue" key={l} isTruncated>
{l}
</Label>
))}
</LabelGroup>
</div>
) : (
<EmptyText text="No labels." />
<EmptyText text="No entries." />
);
};
2 changes: 1 addition & 1 deletion src/app/Topology/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Below CSS rules only apply to Topology components
color: var(--pf-global--palette--blue-400);
}

.entity-overview__displayed-labels-wrapper {
.entity-overview__displayed-keyvalues-wrapper {
border: 1px solid var(--pf-global--palette--black-200);
padding: 4px;
width: fit-content;
Expand Down

0 comments on commit e19d1be

Please sign in to comment.