• njmon(nimon) + influxdb2 + grafana 系统性能监控


    influxdb

    1. docker run --name influxdb -d -p 8086:8086 \
    2. -e DOCKER_INFLUXDB_INIT_MODE=setup \
    3. -e DOCKER_INFLUXDB_INIT_USERNAME=my-user \
    4. -e DOCKER_INFLUXDB_INIT_PASSWORD=my-password \
    5. -e DOCKER_INFLUXDB_INIT_ORG=my-org \
    6. -e DOCKER_INFLUXDB_INIT_BUCKET=my-bucket \
    7. influxdb:2.4.0

    获取token

    一次点击:Load Data, API Tokens, my-user's Token

     点击 复制到剪贴板

     

    grafana

    docker run -d --name=grafana -p 3000:3000 --link influxdb grafana/grafana:9.1.2

    默认账号密码 admin admin

    跳过 

    配置数据源

    选择InfluxDB

     

    Query Language选择Flux 

     配置influxdb地址(采用docker容器名)

    配置数据库详细信息

     点击保存并测试

    nimon 

     下载地址:https://master.dl.sourceforge.net/project/nmon/nmeasure_linux_v80beta2_influxdb2.zip?viasf=1

    解压编译

    1. unzip nmeasure_linux_v80beta2_influxdb2.zip
    2. gcc njmon_linux_v80.c -o nimon -D OSNAME=\"Deepin\" -D OSVERSION=\"20\" -D HW=\"unknown\" -O4

    注意:生成可执行程序必须命名nimon,方便启动nimon模式。

    启动nimon监控并向influxdb2写入数据

    sudo ./nimon -s 1 -i 127.0.0.1 -p 8086 -x "my-bucket" -y "my-user" -O "my-org" -T "LSeFOfZnz704NUEhI3EUeogLDsIPn5IjqAxBOfJgCTBckoaxk48qQrUuxw6AlGXwrrf7Y9f2-LZiL9rWS6tQZQ=="
    

    注意:

    1. 本指令用于测试 -s 设置为 1 ,实际情况应当适当放款以降低监工负载

    2. 实际监控环境应考虑结合cron保证 nimon进程存活状态。

    配置监控仪表盘

    可能是采用influxdb2原因,grafana官方找的几个仪表盘都不能呈现数据,自己随便做了几个

     配置文件内容 njmon-grafana.json

    1. {
    2. "annotations": {
    3. "list": [
    4. {
    5. "builtIn": 1,
    6. "datasource": {
    7. "type": "grafana",
    8. "uid": "-- Grafana --"
    9. },
    10. "enable": true,
    11. "hide": true,
    12. "iconColor": "rgba(0, 211, 255, 1)",
    13. "name": "Annotations & Alerts",
    14. "target": {
    15. "limit": 100,
    16. "matchAny": false,
    17. "tags": [],
    18. "type": "dashboard"
    19. },
    20. "type": "dashboard"
    21. }
    22. ]
    23. },
    24. "editable": true,
    25. "fiscalYearStartMonth": 0,
    26. "graphTooltip": 0,
    27. "id": 1,
    28. "links": [],
    29. "liveNow": false,
    30. "panels": [
    31. {
    32. "datasource": {
    33. "type": "influxdb",
    34. "uid": "hlW4MkG4k"
    35. },
    36. "fieldConfig": {
    37. "defaults": {
    38. "color": {
    39. "mode": "palette-classic"
    40. },
    41. "custom": {
    42. "axisCenteredZero": false,
    43. "axisColorMode": "text",
    44. "axisLabel": "",
    45. "axisPlacement": "auto",
    46. "barAlignment": 0,
    47. "drawStyle": "line",
    48. "fillOpacity": 0,
    49. "gradientMode": "none",
    50. "hideFrom": {
    51. "legend": false,
    52. "tooltip": false,
    53. "viz": false
    54. },
    55. "lineInterpolation": "linear",
    56. "lineWidth": 1,
    57. "pointSize": 5,
    58. "scaleDistribution": {
    59. "type": "linear"
    60. },
    61. "showPoints": "auto",
    62. "spanNulls": false,
    63. "stacking": {
    64. "group": "A",
    65. "mode": "none"
    66. },
    67. "thresholdsStyle": {
    68. "mode": "off"
    69. }
    70. },
    71. "mappings": [],
    72. "thresholds": {
    73. "mode": "absolute",
    74. "steps": [
    75. {
    76. "color": "green",
    77. "value": null
    78. },
    79. {
    80. "color": "red",
    81. "value": 80
    82. }
    83. ]
    84. }
    85. },
    86. "overrides": []
    87. },
    88. "gridPos": {
    89. "h": 8,
    90. "w": 12,
    91. "x": 0,
    92. "y": 0
    93. },
    94. "id": 14,
    95. "options": {
    96. "legend": {
    97. "calcs": [],
    98. "displayMode": "list",
    99. "placement": "bottom",
    100. "showLegend": true
    101. },
    102. "tooltip": {
    103. "mode": "single",
    104. "sort": "none"
    105. }
    106. },
    107. "targets": [
    108. {
    109. "datasource": {
    110. "type": "influxdb",
    111. "uid": "hlW4MkG4k"
    112. },
    113. "query": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"networks\")\n |> filter(fn: (r) => r[\"_field\"] == \"ibytes\" or r[\"_field\"] == \"obytes\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")",
    114. "refId": "A"
    115. }
    116. ],
    117. "title": "networks",
    118. "type": "timeseries"
    119. },
    120. {
    121. "datasource": {
    122. "type": "influxdb",
    123. "uid": "hlW4MkG4k"
    124. },
    125. "fieldConfig": {
    126. "defaults": {
    127. "color": {
    128. "mode": "palette-classic"
    129. },
    130. "custom": {
    131. "axisCenteredZero": false,
    132. "axisColorMode": "text",
    133. "axisLabel": "",
    134. "axisPlacement": "auto",
    135. "barAlignment": 0,
    136. "drawStyle": "line",
    137. "fillOpacity": 0,
    138. "gradientMode": "none",
    139. "hideFrom": {
    140. "legend": false,
    141. "tooltip": false,
    142. "viz": false
    143. },
    144. "lineInterpolation": "linear",
    145. "lineWidth": 1,
    146. "pointSize": 5,
    147. "scaleDistribution": {
    148. "type": "linear"
    149. },
    150. "showPoints": "auto",
    151. "spanNulls": false,
    152. "stacking": {
    153. "group": "A",
    154. "mode": "none"
    155. },
    156. "thresholdsStyle": {
    157. "mode": "off"
    158. }
    159. },
    160. "mappings": [],
    161. "thresholds": {
    162. "mode": "absolute",
    163. "steps": [
    164. {
    165. "color": "green",
    166. "value": null
    167. },
    168. {
    169. "color": "red",
    170. "value": 80
    171. }
    172. ]
    173. }
    174. },
    175. "overrides": []
    176. },
    177. "gridPos": {
    178. "h": 8,
    179. "w": 12,
    180. "x": 12,
    181. "y": 0
    182. },
    183. "id": 10,
    184. "options": {
    185. "legend": {
    186. "calcs": [],
    187. "displayMode": "list",
    188. "placement": "bottom",
    189. "showLegend": true
    190. },
    191. "tooltip": {
    192. "mode": "single",
    193. "sort": "none"
    194. }
    195. },
    196. "targets": [
    197. {
    198. "datasource": {
    199. "type": "influxdb",
    200. "uid": "hlW4MkG4k"
    201. },
    202. "query": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"disks\")\n |> filter(fn: (r) => r[\"_field\"] == \"reads\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")",
    203. "refId": "A"
    204. }
    205. ],
    206. "title": "disk read",
    207. "type": "timeseries"
    208. },
    209. {
    210. "datasource": {
    211. "type": "influxdb",
    212. "uid": "hlW4MkG4k"
    213. },
    214. "fieldConfig": {
    215. "defaults": {
    216. "color": {
    217. "mode": "palette-classic"
    218. },
    219. "custom": {
    220. "axisCenteredZero": false,
    221. "axisColorMode": "text",
    222. "axisLabel": "",
    223. "axisPlacement": "auto",
    224. "barAlignment": 0,
    225. "drawStyle": "line",
    226. "fillOpacity": 0,
    227. "gradientMode": "none",
    228. "hideFrom": {
    229. "legend": false,
    230. "tooltip": false,
    231. "viz": false
    232. },
    233. "lineInterpolation": "linear",
    234. "lineWidth": 1,
    235. "pointSize": 5,
    236. "scaleDistribution": {
    237. "type": "linear"
    238. },
    239. "showPoints": "auto",
    240. "spanNulls": false,
    241. "stacking": {
    242. "group": "A",
    243. "mode": "none"
    244. },
    245. "thresholdsStyle": {
    246. "mode": "off"
    247. }
    248. },
    249. "mappings": [],
    250. "thresholds": {
    251. "mode": "absolute",
    252. "steps": [
    253. {
    254. "color": "green",
    255. "value": null
    256. },
    257. {
    258. "color": "red",
    259. "value": 80
    260. }
    261. ]
    262. }
    263. },
    264. "overrides": []
    265. },
    266. "gridPos": {
    267. "h": 8,
    268. "w": 12,
    269. "x": 0,
    270. "y": 8
    271. },
    272. "id": 12,
    273. "options": {
    274. "legend": {
    275. "calcs": [],
    276. "displayMode": "list",
    277. "placement": "bottom",
    278. "showLegend": true
    279. },
    280. "tooltip": {
    281. "mode": "single",
    282. "sort": "none"
    283. }
    284. },
    285. "targets": [
    286. {
    287. "datasource": {
    288. "type": "influxdb",
    289. "uid": "hlW4MkG4k"
    290. },
    291. "query": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"disks\")\n |> filter(fn: (r) => r[\"_field\"] == \"writes\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")",
    292. "refId": "A"
    293. }
    294. ],
    295. "title": "disk write",
    296. "type": "timeseries"
    297. },
    298. {
    299. "datasource": {
    300. "type": "influxdb",
    301. "uid": "hlW4MkG4k"
    302. },
    303. "fieldConfig": {
    304. "defaults": {
    305. "color": {
    306. "mode": "palette-classic"
    307. },
    308. "custom": {
    309. "axisCenteredZero": false,
    310. "axisColorMode": "text",
    311. "axisLabel": "",
    312. "axisPlacement": "auto",
    313. "barAlignment": 0,
    314. "drawStyle": "line",
    315. "fillOpacity": 0,
    316. "gradientMode": "none",
    317. "hideFrom": {
    318. "legend": false,
    319. "tooltip": false,
    320. "viz": false
    321. },
    322. "lineInterpolation": "linear",
    323. "lineWidth": 1,
    324. "pointSize": 5,
    325. "scaleDistribution": {
    326. "type": "linear"
    327. },
    328. "showPoints": "auto",
    329. "spanNulls": false,
    330. "stacking": {
    331. "group": "A",
    332. "mode": "none"
    333. },
    334. "thresholdsStyle": {
    335. "mode": "off"
    336. }
    337. },
    338. "mappings": [],
    339. "thresholds": {
    340. "mode": "absolute",
    341. "steps": [
    342. {
    343. "color": "green",
    344. "value": null
    345. },
    346. {
    347. "color": "red",
    348. "value": 80
    349. }
    350. ]
    351. }
    352. },
    353. "overrides": []
    354. },
    355. "gridPos": {
    356. "h": 8,
    357. "w": 12,
    358. "x": 0,
    359. "y": 16
    360. },
    361. "id": 8,
    362. "options": {
    363. "legend": {
    364. "calcs": [],
    365. "displayMode": "list",
    366. "placement": "bottom",
    367. "showLegend": true
    368. },
    369. "tooltip": {
    370. "mode": "single",
    371. "sort": "none"
    372. }
    373. },
    374. "targets": [
    375. {
    376. "datasource": {
    377. "type": "influxdb",
    378. "uid": "hlW4MkG4k"
    379. },
    380. "query": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"disks\")\n |> filter(fn: (r) => r[\"_field\"] == \"busy\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")",
    381. "refId": "A"
    382. }
    383. ],
    384. "title": "disk busy",
    385. "type": "timeseries"
    386. },
    387. {
    388. "datasource": {
    389. "type": "influxdb",
    390. "uid": "hlW4MkG4k"
    391. },
    392. "fieldConfig": {
    393. "defaults": {
    394. "color": {
    395. "mode": "palette-classic"
    396. },
    397. "custom": {
    398. "axisCenteredZero": false,
    399. "axisColorMode": "text",
    400. "axisLabel": "",
    401. "axisPlacement": "auto",
    402. "barAlignment": 0,
    403. "drawStyle": "line",
    404. "fillOpacity": 0,
    405. "gradientMode": "none",
    406. "hideFrom": {
    407. "legend": false,
    408. "tooltip": false,
    409. "viz": false
    410. },
    411. "lineInterpolation": "linear",
    412. "lineWidth": 1,
    413. "pointSize": 5,
    414. "scaleDistribution": {
    415. "type": "linear"
    416. },
    417. "showPoints": "auto",
    418. "spanNulls": false,
    419. "stacking": {
    420. "group": "A",
    421. "mode": "none"
    422. },
    423. "thresholdsStyle": {
    424. "mode": "off"
    425. }
    426. },
    427. "mappings": [],
    428. "thresholds": {
    429. "mode": "absolute",
    430. "steps": [
    431. {
    432. "color": "green"
    433. },
    434. {
    435. "color": "red",
    436. "value": 80
    437. }
    438. ]
    439. }
    440. },
    441. "overrides": []
    442. },
    443. "gridPos": {
    444. "h": 8,
    445. "w": 12,
    446. "x": 0,
    447. "y": 24
    448. },
    449. "id": 6,
    450. "options": {
    451. "legend": {
    452. "calcs": [],
    453. "displayMode": "list",
    454. "placement": "bottom",
    455. "showLegend": true
    456. },
    457. "tooltip": {
    458. "mode": "single",
    459. "sort": "none"
    460. }
    461. },
    462. "targets": [
    463. {
    464. "datasource": {
    465. "type": "influxdb",
    466. "uid": "hlW4MkG4k"
    467. },
    468. "query": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"cpus\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")",
    469. "refId": "A"
    470. }
    471. ],
    472. "title": "CPUS",
    473. "type": "timeseries"
    474. },
    475. {
    476. "gridPos": {
    477. "h": 1,
    478. "w": 24,
    479. "x": 0,
    480. "y": 32
    481. },
    482. "id": 4,
    483. "title": "Row title",
    484. "type": "row"
    485. },
    486. {
    487. "datasource": {
    488. "type": "influxdb",
    489. "uid": "hlW4MkG4k"
    490. },
    491. "fieldConfig": {
    492. "defaults": {
    493. "color": {
    494. "mode": "palette-classic"
    495. },
    496. "custom": {
    497. "axisCenteredZero": false,
    498. "axisColorMode": "text",
    499. "axisLabel": "",
    500. "axisPlacement": "auto",
    501. "barAlignment": 0,
    502. "drawStyle": "line",
    503. "fillOpacity": 0,
    504. "gradientMode": "none",
    505. "hideFrom": {
    506. "legend": false,
    507. "tooltip": false,
    508. "viz": false
    509. },
    510. "lineInterpolation": "linear",
    511. "lineWidth": 1,
    512. "pointSize": 5,
    513. "scaleDistribution": {
    514. "type": "linear"
    515. },
    516. "showPoints": "auto",
    517. "spanNulls": false,
    518. "stacking": {
    519. "group": "A",
    520. "mode": "none"
    521. },
    522. "thresholdsStyle": {
    523. "mode": "off"
    524. }
    525. },
    526. "mappings": [],
    527. "thresholds": {
    528. "mode": "absolute",
    529. "steps": [
    530. {
    531. "color": "green"
    532. },
    533. {
    534. "color": "red",
    535. "value": 80
    536. }
    537. ]
    538. }
    539. },
    540. "overrides": []
    541. },
    542. "gridPos": {
    543. "h": 9,
    544. "w": 12,
    545. "x": 0,
    546. "y": 33
    547. },
    548. "id": 2,
    549. "options": {
    550. "legend": {
    551. "calcs": [],
    552. "displayMode": "list",
    553. "placement": "bottom",
    554. "showLegend": true
    555. },
    556. "tooltip": {
    557. "mode": "single",
    558. "sort": "none"
    559. }
    560. },
    561. "targets": [
    562. {
    563. "datasource": {
    564. "type": "influxdb",
    565. "uid": "hlW4MkG4k"
    566. },
    567. "query": "from(bucket: \"my-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"cpu_total\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")",
    568. "refId": "A"
    569. }
    570. ],
    571. "title": "CPU Total",
    572. "type": "timeseries"
    573. }
    574. ],
    575. "schemaVersion": 37,
    576. "style": "dark",
    577. "tags": [],
    578. "templating": {
    579. "list": []
    580. },
    581. "time": {
    582. "from": "now-1h",
    583. "to": "now"
    584. },
    585. "timepicker": {},
    586. "timezone": "",
    587. "title": "njmon",
    588. "uid": "c2JTNkMVk",
    589. "version": 2,
    590. "weekStart": ""
    591. }

    参考:nmon for Linux | Site / Njmon

  • 相关阅读:
    React 中的 Virtual DOM 是什么
    使用setuptools构建python包
    Django 4.1 可以做什么?
    Python实现猎人猎物优化算法(HPO)优化循环神经网络分类模型(LSTM分类算法)项目实战
    山东菏泽家乡网页代码 html静态网页设计制作 dw静态网页成品模板素材网页 web前端网页设计与制作 div静态网页设计
    栈和队列及表达式求值问题
    开发GD32遇到的坑B点
    Framwork入门のPiex 6P源码(下载/编译/刷机)
    redis stream 实现消息队列
    想让你的工作轻松高效吗?揭秘Java + React导出Excel/PDF的绝妙技巧!
  • 原文地址:https://blog.csdn.net/hknaruto/article/details/126644147