Skip to content
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

Release/v0.4.1 #146

Merged
merged 14 commits into from
Oct 15, 2019
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: 4 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[FORMAT]

# Maximum number of characters on a single line.
max-line-length=132
4 changes: 4 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[style]
based_on_style=google

# custom rules
# 132 is the max column size for editor window of VSCODE without scrolling bar on a 13' MacBook
COLUMN_LIMIT=132
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [v0.4.0](https://github.com/cryptape/cita-monitor/releases/tag/v0.4.0) ([compare](https://github.com/cryptape/cita-monitor/compare/v0.3.0...v0.4.0))
## [v0.4.1](https://github.com/cryptape/cita-monitor/releases/tag/v0.5.0) ([compare](https://github.com/cryptape/cita-monitor/compare/v0.4.0...v0.4.1))

### Added
- Add: show rabbitmq-server process info in process info dashboard ([43d3e57](https://github.com/cryptape/cita-monitor/commit/43d3e5763a522abfa06357e541056f494da8987b) by RainChen).

### Documented
- Docs: fix typo in release flow ([75bf6eb](https://github.com/cryptape/cita-monitor/commit/75bf6ebd8cb876a23374ecbe7afcd1dfec61584c) by RainChen).

### Fixed
- Fix prometheus not connected due to incorrect container name alertmanager ([fd0b5b2](https://github.com/cryptape/cita-monitor/commit/fd0b5b276cfef7f72491fa4887c974b7ff3eb662) by JiangXL).
- Fix live update of soft version ([0e9ea40](https://github.com/cryptape/cita-monitor/commit/0e9ea402b8129944c9f4a27fb5d3b345780ffeff) by blankwu).

### Misc
- Refactor: format python codes ([3a83b26](https://github.com/cryptape/cita-monitor/commit/3a83b262c4b6f415427002f6fd24ce83e67eaa0a) by RainChen).
- Change yapf/pylinctrc config with custom rules ([8d54754](https://github.com/cryptape/cita-monitor/commit/8d54754e166bb6a2de57cd233f85b7b5bdab358e) by RainChen).


## [v0.4.0](https://github.com/cryptape/cita-monitor/releases/tag/v0.4.0) ([compare](https://github.com/cryptape/cita-monitor/compare/v0.3.0...v0.4.0)) - 2019-07-30

### Added
- Agent script gets block consensus node votes ([66dbeb7](https://github.com/cryptape/cita-monitor/commit/66dbeb7683a46c8e204a87c884af19e74f5f2e75) by JiangXL).
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
0.4.1
167 changes: 54 additions & 113 deletions agent/cita_monitor_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
FILE_TOTAL_SIZE = None
DATA_TOTAL_SIZE = None
SOFT_VERSION_TXT = '%s/bin/cita-chain -V' % (SOFT_FILE_PATH)
try:
SOFT_VERSION_EXEC = os.popen(SOFT_VERSION_TXT)
SOFT_VERSION = str(SOFT_VERSION_EXEC.read().split(' ')[1].split('\n')[0])
except IndexError:
SOFT_VERSION = 'null'

# exporter label variable
SERVICE_STATUS_TITLE = "[ value is 1 or 0 ] \
Expand Down Expand Up @@ -221,100 +216,59 @@ def exporter():
"""Agent execution function"""
# definition tag
registry = CollectorRegistry(auto_describe=False)
service_status = Gauge("Node_Get_ServiceStatus",
SERVICE_STATUS_TITLE, ["NodeIP", "NodePort"],
registry=registry)
genesis_block_details = Gauge(
"Node_Get_GenesisBlockNumberDetails",
GENESIS_BLOCK_DETAILS_TITLE,
["NodeIP", "NodePort", "GenesisBlockNumberHash"],
registry=registry)
service_status = Gauge("Node_Get_ServiceStatus", SERVICE_STATUS_TITLE, ["NodeIP", "NodePort"], registry=registry)
genesis_block_details = Gauge("Node_Get_GenesisBlockNumberDetails",
GENESIS_BLOCK_DETAILS_TITLE, ["NodeIP", "NodePort", "GenesisBlockNumberHash"],
registry=registry)
chain_info = Gauge("Node_Get_ChainInfo",
CHAIN_INFO_TITLE, [
"NodeIP", "NodePort", "ChainName", "Operator",
"TokenName", "TokenSymbol", "Version"
],
registry=registry)
node_peers = Gauge("Node_Get_NodePeers",
NODE_PEERS_TITLE, ["NodeIP", "NodePort"],
CHAIN_INFO_TITLE, ["NodeIP", "NodePort", "ChainName", "Operator", "TokenName", "TokenSymbol", "Version"],
registry=registry)
chain_nodes = Gauge("Node_Get_ChainNodes",
CHAIN_NODES_TITLE, ["NodeIP", "NodePort"],
registry=registry)
last_block_number = Gauge(
"Node_Get_LastBlockNumber",
LAST_BLOCK_NUMBER_TITLE, [
"NodeIP", "NodePort", "GenesisBlockNumberHash", "NodeID",
"NodeAddress"
],
registry=registry)
check_proposer = Gauge("Node_CheckProposer",
CHECK_PROPOSER_TITLE, ["NodeIP", "NodePort"],
registry=registry)
last_block_details = Gauge(
"Node_Get_LastBlockNumberDetails",
LAST_BLOCK_DETAILS_TITLE, [
"NodeIP", "NodePort", "LastBlocknumber", "LastBlockProposer",
"LastBlockHash", "NodeID", "HostPlatform", "HostName",
"ConsensusStatus", "SoftVersion"
],
registry=registry)
vote_node = Gauge("Node_Get_VoteNode",
VOTE_NODE_TITLE,
["NodeIP", "NodePort", "NodeID", "Voter"],
registry=registry)
block_height_difference = Gauge(
"Node_Get_BlockDifference",
BLOCK_HEIGHT_DIFFERENCE_TITLE,
["NodeIP", "NodePort", "CurrentHeight", "PreviousHeight"],
registry=registry)
node_peers = Gauge("Node_Get_NodePeers", NODE_PEERS_TITLE, ["NodeIP", "NodePort"], registry=registry)
chain_nodes = Gauge("Node_Get_ChainNodes", CHAIN_NODES_TITLE, ["NodeIP", "NodePort"], registry=registry)
last_block_number = Gauge("Node_Get_LastBlockNumber",
LAST_BLOCK_NUMBER_TITLE, ["NodeIP", "NodePort", "GenesisBlockNumberHash", "NodeID", "NodeAddress"],
registry=registry)
check_proposer = Gauge("Node_CheckProposer", CHECK_PROPOSER_TITLE, ["NodeIP", "NodePort"], registry=registry)
last_block_details = Gauge("Node_Get_LastBlockNumberDetails",
LAST_BLOCK_DETAILS_TITLE, [
"NodeIP", "NodePort", "LastBlocknumber", "LastBlockProposer", "LastBlockHash", "NodeID",
"HostPlatform", "HostName", "ConsensusStatus", "SoftVersion"
],
registry=registry)
vote_node = Gauge("Node_Get_VoteNode", VOTE_NODE_TITLE, ["NodeIP", "NodePort", "NodeID", "Voter"], registry=registry)
block_height_difference = Gauge("Node_Get_BlockDifference",
BLOCK_HEIGHT_DIFFERENCE_TITLE, ["NodeIP", "NodePort", "CurrentHeight", "PreviousHeight"],
registry=registry)
dir_total_size = Gauge("Node_Get_DirInfo_TotalFileSize",
NODE_DIR_TOTAL_SIZE_TITLE,
["NodeIP", "NodePort", "NodeDir"],
NODE_DIR_TOTAL_SIZE_TITLE, ["NodeIP", "NodePort", "NodeDir"],
registry=registry)
dir_data_size = Gauge("Node_Get_DirInfo_DataFileSize",
NODE_DIR_DATA_SIZE_TITLE,
["NodeIP", "NodePort", "NodeDir"],
NODE_DIR_DATA_SIZE_TITLE, ["NodeIP", "NodePort", "NodeDir"],
registry=registry)
disk_used_size = Gauge("Node_Get_DiskInfo_UsedSize",
NODE_DISK_USED_SIZE_TITLE,
["NodeIP", "NodePort", "NodeDir"],
NODE_DISK_USED_SIZE_TITLE, ["NodeIP", "NodePort", "NodeDir"],
registry=registry)
disk_free_size = Gauge("Node_Get_DiskInfo_FreeSize",
NODE_DISK_FREE_SIZE_TITLE,
["NodeIP", "NodePort", "NodeDir"],
registry=registry)
block_interval = Gauge("Node_Get_BlockTimeDifference",
BLOCK_INTERVAL_TITLE, ["NodeIP", "NodePort"],
NODE_DISK_FREE_SIZE_TITLE, ["NodeIP", "NodePort", "NodeDir"],
registry=registry)
block_interval = Gauge("Node_Get_BlockTimeDifference", BLOCK_INTERVAL_TITLE, ["NodeIP", "NodePort"], registry=registry)
last_block_transactions = Gauge("Node_Get_LastBlockNumberTransactions",
LAST_BLOCK_TRANSACTIONS_TITLE,
["NodeIP", "NodePort"],
LAST_BLOCK_TRANSACTIONS_TITLE, ["NodeIP", "NodePort"],
registry=registry)
last_block_quota_used = Gauge("Node_Get_LastBlockNumberQuotaUsed",
LAST_BLOCK_QUOTA_USED_TITLE,
["NodeIP", "NodePort"],
LAST_BLOCK_QUOTA_USED_TITLE, ["NodeIP", "NodePort"],
registry=registry)
chain_quota_price = Gauge("Node_Get_QuotaPrice",
CHAIN_QUOTA_PRICE_TITLE, ["NodeIP", "NodePort"],
registry=registry)
block_quota_limit = Gauge("Node_Get_BlockQuotaLimit",
BLOCK_QUOTA_LIMIT_TITLE, ["NodeIP", "NodePort"],
registry=registry)
local_voter = Gauge("Node_Get_LocalVoter",
LOCAL_VOTE_TITLE, ["NodeIP", "NodePort"],
registry=registry)
vote_number = Gauge("Block_Vote_Number",
BLOCK_VOTE_NUMBER_TITLE, ["NodeIP", "NodePort"],
registry=registry)
chain_quota_price = Gauge("Node_Get_QuotaPrice", CHAIN_QUOTA_PRICE_TITLE, ["NodeIP", "NodePort"], registry=registry)
block_quota_limit = Gauge("Node_Get_BlockQuotaLimit", BLOCK_QUOTA_LIMIT_TITLE, ["NodeIP", "NodePort"], registry=registry)
local_voter = Gauge("Node_Get_LocalVoter", LOCAL_VOTE_TITLE, ["NodeIP", "NodePort"], registry=registry)
vote_number = Gauge("Block_Vote_Number", BLOCK_VOTE_NUMBER_TITLE, ["NodeIP", "NodePort"], registry=registry)
# run exporter
node_ip = str(NODE.split(':')[0])
node_port = str(NODE.split(':')[1])
check_process = os.popen("ps alx |grep 'cita-chain' |grep -c -v grep")
if check_process.read() == '0\n':
service_status.labels(NodeIP=node_ip, NodePort=node_port).set(0)
return Response(prometheus_client.generate_latest(registry),
mimetype="text/plain")
return Response(prometheus_client.generate_latest(registry), mimetype="text/plain")

service_status.labels(NodeIP=node_ip, NodePort=node_port).set(1)
class_result = ExporterFunctions(node_ip, node_port)
Expand Down Expand Up @@ -344,10 +298,8 @@ def exporter():
if 'result' in genesis_block_info:
genesis_block_hash = genesis_block_info['result']['hash']
genesis_block_time = genesis_block_info['result']['header']['timestamp']
genesis_block_details.labels(
NodeIP=node_ip,
NodePort=node_port,
GenesisBlockNumberHash=genesis_block_hash).set(genesis_block_time)
genesis_block_details.labels(NodeIP=node_ip, NodePort=node_port,
GenesisBlockNumberHash=genesis_block_hash).set(genesis_block_time)
else:
print(genesis_block_info)
block_number_info = class_result.block_number()
Expand Down Expand Up @@ -378,8 +330,7 @@ def exporter():
Version=chain_version).set(economical_model)
consensus_node_list = metadata_info['result']['validators']
consensus_node_count = len(consensus_node_list)
chain_nodes.labels(NodeIP=node_ip,
NodePort=node_port).set(consensus_node_count)
chain_nodes.labels(NodeIP=node_ip, NodePort=node_port).set(consensus_node_count)
else:
print(metadata_info)
block_info = class_result.block_number_detail(hex_number)
Expand All @@ -392,8 +343,7 @@ def exporter():
#Get the previous version of CITA v0.19.1 gasUsed
block_head_info.get('gasUsed')
block_quota_used = int(block_head_info['gasUsed'], 16)
block_commits = list(
block_info['result']['header']['proof']['Bft']['commits'].keys())
block_commits = list(block_info['result']['header']['proof']['Bft']['commits'].keys())
block_vote_number = len(block_commits)
consensus_nodes_count = len(consensus_node_list)
for i in range(consensus_nodes_count):
Expand All @@ -402,29 +352,28 @@ def exporter():
vote_status = 1
else:
vote_status = 0
vote_node.labels(NodeIP=node_ip,
NodePort=node_port,
NodeID=NODE_ID,
Voter=voter_address).set(vote_status)
vote_node.labels(NodeIP=node_ip, NodePort=node_port, NodeID=NODE_ID, Voter=voter_address).set(vote_status)
if ADDRESS in block_commits:
is_committer = 1
else:
is_committer = 0
vote_number.labels(NodeIP=node_ip,
NodePort=node_port).set(block_vote_number)
vote_number.labels(NodeIP=node_ip, NodePort=node_port).set(block_vote_number)
local_voter.labels(NodeIP=node_ip, NodePort=node_port).set(is_committer)
block_hash = block_info['result']['hash']
block_time = int(block_head_info['timestamp'])
block_transactions = int(
len(block_info['result']['body']['transactions']))
block_transactions = int(len(block_info['result']['body']['transactions']))
block_proposer = block_head_info['proposer']
previous_block_time = int(
previous_block_info['result']['header']['timestamp'])
previous_block_time = int(previous_block_info['result']['header']['timestamp'])
interval = abs(block_time - previous_block_time)
if ADDRESS in consensus_node_list:
consensus = 1
else:
consensus = 0
try:
soft_version_exec = os.popen(SOFT_VERSION_TXT)
soft_version = str(soft_version_exec.read().split(' ')[1].split('\n')[0])
except IndexError:
soft_version = 'null'
last_block_details.labels(NodeIP=node_ip,
NodePort=node_port,
LastBlocknumber=int(hex_number, 16),
Expand All @@ -434,18 +383,14 @@ def exporter():
HostPlatform=EXPORTER_PLATFORM,
HostName=AGENT_NAME,
ConsensusStatus=consensus,
SoftVersion=SOFT_VERSION).set(block_time)
SoftVersion=soft_version).set(block_time)
block_height_difference.labels(NodeIP=node_ip,
NodePort=node_port,
CurrentHeight=int(hex_number, 16),
PreviousHeight=int(
previous_hex_number,
16)).set(interval)
PreviousHeight=int(previous_hex_number, 16)).set(interval)
block_interval.labels(NodeIP=node_ip, NodePort=node_port).set(interval)
last_block_transactions.labels(
NodeIP=node_ip, NodePort=node_port).set(block_transactions)
last_block_quota_used.labels(NodeIP=node_ip,
NodePort=node_port).set(block_quota_used)
last_block_transactions.labels(NodeIP=node_ip, NodePort=node_port).set(block_transactions)
last_block_quota_used.labels(NodeIP=node_ip, NodePort=node_port).set(block_quota_used)
if ADDRESS == block_proposer:
proposer = 1
else:
Expand All @@ -457,27 +402,23 @@ def exporter():
peer_info = class_result.peer_count()
if 'result' in peer_info:
peers = peer_info['result']
node_peers.labels(NodeIP=node_ip,
NodePort=node_port).set(int(peers, 16))
node_peers.labels(NodeIP=node_ip, NodePort=node_port).set(int(peers, 16))
else:
print(peer_info)
quota_price = class_result.quota_price()
if 'result' in quota_price:
price = quota_price['result']
chain_quota_price.labels(NodeIP=node_ip,
NodePort=node_port).set(int(price, 16))
chain_quota_price.labels(NodeIP=node_ip, NodePort=node_port).set(int(price, 16))
else:
print(quota_price)
block_limit = class_result.block_limit()
if 'result' in block_limit:
limit = block_limit['result']
block_quota_limit.labels(NodeIP=node_ip,
NodePort=node_port).set(int(limit, 16))
block_quota_limit.labels(NodeIP=node_ip, NodePort=node_port).set(int(limit, 16))
else:
print(block_limit)

return Response(prometheus_client.generate_latest(registry),
mimetype="text/plain")
return Response(prometheus_client.generate_latest(registry), mimetype="text/plain")


# flask object
Expand Down
3 changes: 3 additions & 0 deletions agent/process_exporter_config/process_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ process_names:
- cita-chain
- cita-auth
- cita-executor
- name: "{{.Comm}}"
cmdline:
- 'rabbitmq-server'
2 changes: 1 addition & 1 deletion docs/release-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

1. Plan: set release date
2. Freeze: freeze codes into a public release branch e.g.: "release/v0.3.0", based on develop branch
3. Test: test & bug-fix, prepare changelog & release nodes
3. Test: test & bug-fix, prepare changelog & release notes
4. Release: merge release branch into master and push tags
5. Announcements: send mail to the mailing lists

Expand Down
2 changes: 1 addition & 1 deletion server/config/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ global:
alerting:
alertmanagers:
- static_configs:
- targets: ['cita_monitor_server_alertmanager:9093']
- targets: ['citamon_server_alertmanager:9093']

rule_files:
- 'alert.rules'
Expand Down