This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added socker.io for reporting system health stats
- Loading branch information
Showing
19 changed files
with
356 additions
and
207 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.container { | ||
position: absolute; | ||
top:5px; | ||
right: 10px; | ||
} | ||
|
||
.stat { | ||
padding:0 10px; | ||
} | ||
|
||
.stat i { | ||
width:15px; | ||
margin-right: 5px; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import withStyles from 'isomorphic-style-loader/lib/withStyles'; | ||
import mathjs from 'mathjs'; | ||
|
||
import * as statsAction from '../../actions/stats'; | ||
|
||
import s from './MiniStats.css'; | ||
|
||
const mapStateToProps = (state) => { | ||
return { | ||
isChecking: state.stats.get('isChecking'), | ||
disk: state.stats.get('disk'), | ||
cpu: state.stats.get('cpu'), | ||
memory: state.stats.get('memory'), | ||
} | ||
}; | ||
|
||
class MiniStats extends Component | ||
{ | ||
render() { | ||
const { isChecking, disk, memory, cpu } = this.props; | ||
if (isChecking) { | ||
return (<span />); | ||
} | ||
|
||
return ( | ||
<div className={s.container}> | ||
<div className={s.stat}> | ||
<i className="fa fa-database" /> | ||
<span>{ mathjs.round(disk.get('availablePercentage'), 2) }%</span> | ||
</div> | ||
<div className={s.stat}> | ||
<i className="fa fa-tachometer" /> | ||
<span>{ mathjs.round(memory.get('percentage'), 2) }%</span> | ||
</div> | ||
<div className={s.stat}> | ||
<i className="fa fa-fire" /> | ||
<span>{ mathjs.round(0, 2) }%</span> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps)(withStyles(s)(MiniStats)); |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "MiniStats", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "./MiniStats.js" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux' | ||
import history from '../core/history'; | ||
|
||
import io from 'socket.io-client'; | ||
|
||
import * as actions from '../actions/stats'; | ||
|
||
const mapStateToProps = (state) => { | ||
return { | ||
|
||
} | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch) => { | ||
return { | ||
update: data => dispatch(actions.update(data)) | ||
} | ||
}; | ||
|
||
const statEvent = 'system_health'; | ||
|
||
class SystemHealth extends Component | ||
{ | ||
socket; | ||
|
||
componentDidMount() { | ||
const { port, ip } = this.props; | ||
this.socket = io(`http://${ip}:${port}`); | ||
this.socket.on('init', () => { | ||
console.log('init!'); | ||
}); | ||
|
||
this.socket.on(statEvent, ::this._receiveData); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.socket.removeAllListeners(statEvent); | ||
} | ||
|
||
_receiveData(time, data) { | ||
this.props.update(data); | ||
} | ||
|
||
render() { | ||
return(<s />); | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(SystemHealth); |
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
Oops, something went wrong.