From 797e05d7fec18b9a0ad93ba5e883aac566f0b49e Mon Sep 17 00:00:00 2001 From: geek Date: Fri, 3 Nov 2017 11:33:53 +0900 Subject: [PATCH] tomcat jmx begin code --- .../@overflow/app/views/layout/AppLayout.tsx | 2 + .../@overflow/app/views/layout/LeftMenu.tsx | 11 ++- .../app/views/metric/TomcatMetric.tsx | 20 +++++ .../@overflow/metric/react/TomcatMetric.tsx | 23 +++++ .../metric/react/components/TomcatMetric.tsx | 83 +++++++++++++++++++ 5 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 src/ts/@overflow/app/views/metric/TomcatMetric.tsx create mode 100644 src/ts/@overflow/metric/react/TomcatMetric.tsx create mode 100644 src/ts/@overflow/metric/react/components/TomcatMetric.tsx diff --git a/src/ts/@overflow/app/views/layout/AppLayout.tsx b/src/ts/@overflow/app/views/layout/AppLayout.tsx index 09706d7..6e4351b 100644 --- a/src/ts/@overflow/app/views/layout/AppLayout.tsx +++ b/src/ts/@overflow/app/views/layout/AppLayout.tsx @@ -16,6 +16,7 @@ import TitleBarContainer from '@overflow/app/views/layout/TitleBarContainer'; import SensorSetup from '../../views/monitoring/sensor/Setup'; import NotificationList from '../../views/notification/Notification'; import Metric from '../../views/metric/Metric'; +import TomcatMetric from '../../views/metric/TomcatMetric'; export interface Props extends RouteComponentProps { } @@ -51,6 +52,7 @@ export class AppLayout extends React.Component { + diff --git a/src/ts/@overflow/app/views/layout/LeftMenu.tsx b/src/ts/@overflow/app/views/layout/LeftMenu.tsx index f9d0b24..8a3d07c 100644 --- a/src/ts/@overflow/app/views/layout/LeftMenu.tsx +++ b/src/ts/@overflow/app/views/layout/LeftMenu.tsx @@ -107,8 +107,15 @@ class LeftMenu extends React.Component {
- this.props.onChangeUrl('/metrics')}> -
+ + +
+ + + + this.props.onChangeUrl('/metrics')} style={{ 'marginLeft': '30px' }}>CPU + this.props.onChangeUrl('/tomcat_metrics')} style={{ 'marginLeft': '30px' }}>Tomcat + this.props.onChangeUrl('/temp/discovery')}> diff --git a/src/ts/@overflow/app/views/metric/TomcatMetric.tsx b/src/ts/@overflow/app/views/metric/TomcatMetric.tsx new file mode 100644 index 0000000..85a1ab1 --- /dev/null +++ b/src/ts/@overflow/app/views/metric/TomcatMetric.tsx @@ -0,0 +1,20 @@ +import * as React from 'react'; +import { RouteComponentProps } from 'react-router'; +import TomcatMetricContainer from '@overflow/metric/react/TomcatMetric'; + +class TomcatMetric extends React.Component, object> { + + public constructor(props?: RouteComponentProps, context?: object) { + super(props, context); + } + + public render(): JSX.Element { + return ( +
+ +
+ ); + } +} + +export default TomcatMetric; diff --git a/src/ts/@overflow/metric/react/TomcatMetric.tsx b/src/ts/@overflow/metric/react/TomcatMetric.tsx new file mode 100644 index 0000000..4ce446c --- /dev/null +++ b/src/ts/@overflow/metric/react/TomcatMetric.tsx @@ -0,0 +1,23 @@ +import { connect, Dispatch } from 'react-redux'; +import { + TomcatMetric, + StateProps as StateProps, + DispatchProps as DispatchProps, +} from './components/TomcatMetric'; + +import Domain from '@overflow/domain/api/model/Domain'; +import { push as routerPush } from 'react-router-redux'; +import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; + +export function mapStateToProps(state: any): StateProps { + return { + }; +} + +export function mapDispatchToProps(dispatch: Dispatch): DispatchProps { + return { + + }; +} + +export default connect(mapStateToProps, mapDispatchToProps)(TomcatMetric); diff --git a/src/ts/@overflow/metric/react/components/TomcatMetric.tsx b/src/ts/@overflow/metric/react/components/TomcatMetric.tsx new file mode 100644 index 0000000..e8a40e4 --- /dev/null +++ b/src/ts/@overflow/metric/react/components/TomcatMetric.tsx @@ -0,0 +1,83 @@ + +import * as React from 'react'; +import { Button, Label } from 'semantic-ui-react'; +import { + BarChart, Bar, XAxis, YAxis, ZAxis, Cell, CartesianGrid, Tooltip, Legend, LineChart, Line, + ResponsiveContainer, AreaChart, Area, PieChart, Pie, ReferenceLine, Brush, ComposedChart, +} from 'recharts'; + +export interface StateProps { +} + +export interface DispatchProps { +} + +export type Props = StateProps & DispatchProps; + +export interface State { + data: any; +} + +export class TomcatMetric extends React.Component { + + constructor(props: Props, context: State) { + super(props, context); + this.state = { + data: undefined, + }; + } + + public componentWillMount(): void { + const data = []; + for (let i = 0; i < 10; i++) { + let maxThread = Math.floor(Math.random() * 10000) + 1000; + let currentThread = Math.floor(Math.random() * 10000) + 1000; + let busyThread = Math.floor(Math.random() * 10000) + 1000; + + let elem = { 'id': i, 'maxThread': maxThread, 'currentThread': currentThread, 'busyThread': busyThread }; + data[i] = elem; + } + + this.setState({ + data: data, + }); + } + + private showTooltipData = (data: any) => { + if (data.active && data.payload) { + return ( +
+

{`Total Usage : ${data.payload[0].value}%`}

+

{`MaxThread : ${data.payload[0].payload.maxThread}`}

+

{`CurrentThread : ${data.payload[0].payload.currentThread}`}

+

{`BusyThread : ${data.payload[0].payload.busyThread}`}

+
+ ); + } + return null; + } + + public render(): JSX.Element { + const chartData = [ + { name: 'Used', value: 80, fill: '#8884d8', unit: '%' }, + { name: 'Free', value: 20, fill: '#82ca9d', unit: '%' }, + ]; + + return ( +
+ + + + {/* */} + + + + + + + +
+ ); + } +}