Skip to content

feat: add bandwidth stats #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules
build
release
package-lock.json
out
*.log
*.log
*.lock
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"electron-is-dev": "^0.3.0",
"electron-squirrel-startup": "^1.0.0",
"file-extension": "^4.0.0",
"ipfs-api": "^17.1.3",
"ipfs-api": "^17.2.4",
"ipfs-geoip": "^2.3.0",
"ipfsd-ctl": "^0.26.0",
"menubar": "^5.2.3",
Expand Down
1 change: 1 addition & 0 deletions src/js/screens/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Menu extends Component {
<div className='panel right-panel'>
<NodeInfoScreen
{...this.state.stats.node}
bandwidth={this.state.stats.bw}
repo={this.state.stats.repo} />
</div>
</div>
Expand Down
21 changes: 20 additions & 1 deletion src/js/screens/menu/node-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ export default function NodeScreen (props) {
Location
</InfoBlock>

<InfoBlock info={prettyBytes(props.bandwidth.TotalIn + props.bandwidth.TotalOut)}>
Bandwidth Used
</InfoBlock>

<InfoBlock info={prettyBytes(props.bandwidth.RateIn) + '/s'}>
Down Speed
</InfoBlock>

<InfoBlock info={prettyBytes(props.bandwidth.RateOut) + '/s'}>
Up Speed
</InfoBlock>

<InfoBlock info={props.protocolVersion}>
Protocol Version
</InfoBlock>
Expand Down Expand Up @@ -82,7 +94,8 @@ NodeScreen.propTypes = {
protocolVersion: PropTypes.string,
publicKey: PropTypes.string,
addresses: PropTypes.array,
repo: PropTypes.object
repo: PropTypes.object,
bandwidth: PropTypes.object
}

NodeScreen.defaultProps = {
Expand All @@ -94,5 +107,11 @@ NodeScreen.defaultProps = {
repo: {
RepoSize: 0,
NumObjects: 'NA'
},
bandwidth: {
TotalIn: 0,
TotalOut: 0,
RateIn: 0,
RateOut: 0
}
}
7 changes: 7 additions & 0 deletions src/utils/stats-poller.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export default class StatsPoller extends EventEmitter {
})
.catch(this.logger.error)

this.ipfs.stats.bw()
.then(stats => {
this.statsCache.bw = stats
this.emit('change', this.statsCache)
})
.catch(this.logger.error)

this.ipfs.repo.stat()
.then(repo => {
this.statsCache.repo = repo
Expand Down