Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Miguel Montes
nucleo
Commits
0c124b2b
Commit
0c124b2b
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
monitor.sh ahora se llama monitor.js y se mejoro
parent
3935331d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/libbfa.js
+7
-0
7 additions, 0 deletions
bin/libbfa.js
bin/monitor.js
+43
-0
43 additions, 0 deletions
bin/monitor.js
bin/monitor.sh
+0
-76
0 additions, 76 deletions
bin/monitor.sh
with
50 additions
and
76 deletions
bin/libbfa.js
+
7
−
0
View file @
0c124b2b
...
...
@@ -100,6 +100,13 @@ module.exports = class Libbfa
params
:
0
}]
});
w3
.
eth
.
extend
({
methods
:
[{
name
:
'
adminpeers
'
,
call
:
'
admin_peers
'
,
params
:
0
}]
});
if
(
undefined
!=
process
.
env
.
BFAACCOUNT
)
{
w3
.
eth
.
defaultAccount
=
this
.
account
;
}
...
...
This diff is collapsed.
Click to expand it.
bin/monitor.js
0 → 100755
+
43
−
0
View file @
0c124b2b
#!/usr/bin/node
// vim:syntax:filetype=javascript:ai:sm
// vim:expandtab:backspace=indent,eol,start:softtabstop=4
"
use strict
"
const
Libbfa
=
require
(
process
.
env
.
BFAHOME
+
'
/bin/libbfa.js
'
);
function
monitor
()
{
var
bfa
=
new
Libbfa
();
var
web3
=
bfa
.
newweb3
();
var
now
=
new
Date
();
//console.log(web3.eth);
web3
.
eth
.
adminpeers
().
then
(
function
(
nodelist
)
{
var
peers
=
[];
nodelist
.
forEach
(
function
(
node
)
{
if
(
typeof
(
node
.
protocols
.
eth
)
==
'
object
'
)
{
var
dir
=
"
out
"
;
if
(
node
.
network
.
inbound
)
dir
=
"
in
"
;
peers
.
push
(
"
peer
"
+
dir
+
"
:
"
+
node
.
enode
);
}
}
);
console
.
log
(
"
UTC:
"
+
now
.
toUTCString
()
+
"
\n
"
+
"
BFA peers:
"
+
peers
.
length
+
"
\n
"
+
peers
.
sort
().
join
(
"
\n
"
)
);
},
function
(
x
)
{
console
.
log
(
x
);
process
.
exit
(
1
)
}
);
}
monitor
();
This diff is collapsed.
Click to expand it.
bin/monitor.sh
deleted
100755 → 0
+
0
−
76
View file @
3935331d
#!/bin/bash
if
[
-z
"
${
BFAHOME
}
"
]
;
then
echo
"
\$
BFAHOME not set. Did you source bfa/bin/env ?"
>
&2
;
exit
1
;
fi
source
${
BFAHOME
}
/bin/libbfa.sh
||
exit
1
ERRTEXT
=
"Monitoring failed"
function
json_query
{
local
ERRTEXT
=
"Monitoring RPC failed"
trap
''
ERR
json
=
$(
geth_rpc
$*
)
trap
errtrap ERR
}
function
json_arraylength
{
jq
-r
length
}
json_query admin_peers
test
-n
"
${
json
}
"
||
exit
0
numpeers
=
$(
echo
$json
| json_arraylength
)
statusfile
=
$(
mktemp
)
cleanup
"
${
statusfile
}
"
chmod
644
"
${
statusfile
}
"
echo
-n
"time: "
>
${
statusfile
}
date
>>
${
statusfile
}
echo
"total-peer-count:
${
numpeers
}
"
>>
${
statusfile
}
peercount
=
0
for
idx
in
$(
seq
0
$((
$numpeers
-
1
))
)
do
eth
=
$(
echo
"
$json
"
| jq
-r
.[
$idx
]
.protocols.eth
)
if
[
"
$eth
"
=
"handshake"
]
then
continue
fi
#echo -n "$idx: "; echo "$eth" | jq -c
remoteid
=
$(
echo
"
$json
"
|
jq
-r
.[
$idx
]
.id
)
remoteaddress
=
$(
echo
"
$json
"
|
jq
-r
.[
$idx
]
.network.remoteAddress
)
remoteip
=
$(
echo
"
$remoteaddress
"
|
sed
's/:[0-9][0-9]*$//'
)
# IPv6 has the address surrounded by [ and ] - we strip that away
if
[
"
${
remoteip
:0:1
}
"
=
"["
-a
"
${
remoteip
:
$((${#
remoteip
}
-
1
))}
"
=
"]"
]
then
remoteip
=
"
${
remoteip
:1:
$((${#
remoteip
}
-
2
))}
"
fi
remoteport
=
$(
echo
"
$remoteaddress
"
|
sed
's/^.*://'
)
echo
"peer: enode://
${
remoteid
}
@[
${
remoteip
}
]:
${
remoteport
}
"
>>
$statusfile
mkdir
-p
"
${
BFANETWORKDIR
}
/lastseen/
${
remoteid
}
"
if
[
-r
"
${
BFANETWORKDIR
}
/lastseen/
${
remoteid
}
/
${
remoteip
}
"
]
then
storedport
=
$(
cat
"
${
BFANETWORKDIR
}
/lastseen/
${
remoteid
}
/
${
remoteip
}
"
)
test
"
${
remoteport
}
"
=
"
${
storedport
}
"
&&
unset
remoteport
fi
if
[
-n
"
${
remoteport
}
"
]
then
echo
"
${
remoteport
}
"
>
"
${
BFANETWORKDIR
}
/lastseen/
${
remoteid
}
/
${
remoteip
}
"
else
touch
"
${
BFANETWORKDIR
}
/lastseen/
${
remoteid
}
/
${
remoteip
}
"
fi
peercount
=
$((
$peercount
+
1
))
done
echo
"valid-peer-count:
${
peercount
}
"
>>
$statusfile
mv
-f
$statusfile
${
BFANETWORKDIR
}
/status
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment