Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 9c57f6f

Browse files
Initial commit
0 parents  commit 9c57f6f

8 files changed

+2312
-0
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
indent_size = 4
13+
trim_trailing_whitespace = false

.eslintrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extends: standard

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

LICENSE

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright 2018 Excitable Aardvark <[email protected]>
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# monerod_exporter
2+
> Monero Prometheus exporter
3+
4+
### Environment Variables
5+
6+
* `DAEMON_HOST` - monerod host, example: `http://localhost:18081`
7+
* `PORT` - port to expose metrics on
8+
9+
### Metrics Exported
10+
11+
* `monerod_connections_incoming` - Number of incoming connections
12+
* `monerod_connections_outgoing` - Number of outgoing connections
13+
* `monerod_mempool_size` - Number of transactions in the mempool
14+
15+
### License
16+
17+
Released under the terms of the 3-Clause BSD License. See `LICENSE` for more
18+
information.

index.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2018 Excitable Aardvark <[email protected]>
3+
*
4+
* Licensed under the 3-Clause BSD license. See LICENSE in the project root for
5+
* more information.
6+
*/
7+
8+
const Daemon = require('monero-rpc').Daemon
9+
const express = require('express')
10+
const prometheus = require('prom-client')
11+
12+
const DAEMON_HOST = process.env.DAEMON_HOST || 'http://localhost:18081'
13+
const PORT = process.env.PORT || 3000
14+
const Gauge = prometheus.Gauge
15+
16+
const app = express()
17+
const daemon = new Daemon(DAEMON_HOST)
18+
19+
const incomingConnections = new Gauge({ name: 'monerod_connections_incoming', help: 'Number of incoming connections' })
20+
const outgoingConnections = new Gauge({ name: 'monerod_connections_outgoing', help: 'Number of outgoing connections' })
21+
const mempoolSize = new Gauge({ name: 'monerod_mempool_size', help: 'Number of transactions in the mempool' })
22+
23+
app.get('/metrics', (req, res) => {
24+
console.log('.')
25+
26+
daemon.getInfo((err, info) => {
27+
if (err) return console.log(err)
28+
29+
incomingConnections.set(Number(info.incoming_connections_count))
30+
outgoingConnections.set(Number(info.outgoing_connections_count))
31+
mempoolSize.set(Number(info.tx_pool_size))
32+
33+
res.end(prometheus.register.metrics())
34+
})
35+
})
36+
37+
app.listen(PORT, () => console.log(`Listening on :${PORT}`))

0 commit comments

Comments
 (0)