├── README.md ├── Synology_dashboard.json └── synology_snmp.sh /README.md: -------------------------------------------------------------------------------- 1 | ## synology-monitoring 2 | 3 | #### **NOTICE 2025-03-07:** This project has not been updated in some time and will be archived. Checkout [wallacebrf/synology_snmp](https://github.com/wallacebrf/synology_snmp) 4 | 5 | Simple shell script for capturing SNMP stats to [InfluxDB](https://docs.influxdata.com/influxdb/v1.7/) and monitoring health in [Grafana](https://grafana.com/). 6 | 7 | ![Grafana Dashboard](https://user-images.githubusercontent.com/25406580/56866768-f22a7d00-69a2-11e9-80e6-fd3145d619ac.png) 8 | 9 | 10 | ###### Requirements 11 | * InfluxDB 12 | * Grafana 13 | * Synology NAS with SNMP enabled 14 | 15 | 16 | ###### Setup 17 | The script is best suited to run on the NAS itself and highly recommended. It can be ran on another device but the device would need to be able to run shell scripts, able to make SNMP calls such as using snmpwalk and has the [Synology SNMP MIB's](https://global.download.synology.com/download/Document/MIBGuide/Synology_DiskStation_MIB_Guide.pdf) . With minimal configuration, the Synology NAS should be more than capable of capturing this itself. 18 | 19 | 1. Save the script to a known location on the NAS. For example, /volume1/Local/Scripts/synology_snmp.sh 20 | 2. Input the InfluxDB information such as URL/IP, ports, database name, username and password. 21 | 3. Modify any other configuration settings, each should have an explanation. 22 | 4. On the Synology NAS, Select Control Panel > Terminal & SNMP > SNMP and enable SNMP V1, V2c service.
Ensure that you set the community to 'public' in the Synology settings as the `snmpwalk` command is utilizing the `-c public` flag 23 | 5. On the Synology NAS, Select Control Panel > Task Scheduler > Create >> Scheduled Task >> User-defined Script. 24 | 6. Give the Task a recognizable name. 25 | 7. On the Task Settings, set the Run command to *bash /path/to/synology_snmp.sh* 26 | 8. On the Schedule: 27 | * Run on the following days: **Daily** 28 | * First run time: **00:00** 29 | * Frequency: **Every minute** *The frequency of times it runs within that minute is defined in the script itself* 30 | * Last run time: **23:59** 31 | 9. Import the Synology_dashboard.json file to your Grafana instance, Create > Import > Import .json file. 32 | -------------------------------------------------------------------------------- /Synology_dashboard.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Panel for Synology metrics", 3 | "editable": false, 4 | "gnetId": null, 5 | "graphTooltip": 0, 6 | "id": 30, 7 | "iteration": 1558251818354, 8 | "links": [], 9 | "panels": [ 10 | { 11 | "columns": [], 12 | "fontSize": "120%", 13 | "gridPos": { 14 | "h": 3, 15 | "w": 24, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": "150", 20 | "id": 7, 21 | "interval": "", 22 | "links": [], 23 | "pageSize": null, 24 | "scroll": true, 25 | "showHeader": true, 26 | "sort": { 27 | "col": null, 28 | "desc": false 29 | }, 30 | "styles": [ 31 | { 32 | "alias": "Time", 33 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 34 | "pattern": "Time", 35 | "type": "hidden" 36 | }, 37 | { 38 | "alias": "", 39 | "colorMode": "value", 40 | "colors": [ 41 | "rgba(50, 172, 45, 0.97)", 42 | "#E02F44", 43 | "rgba(245, 54, 54, 0.9)" 44 | ], 45 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 46 | "decimals": 2, 47 | "link": false, 48 | "linkUrl": "https://", 49 | "mappingType": 1, 50 | "pattern": "System Status", 51 | "thresholds": [ 52 | "2" 53 | ], 54 | "type": "string", 55 | "unit": "short", 56 | "valueMaps": [ 57 | { 58 | "text": "Normal", 59 | "value": "1" 60 | }, 61 | { 62 | "text": "Failed", 63 | "value": "2" 64 | } 65 | ] 66 | }, 67 | { 68 | "alias": "", 69 | "colorMode": "value", 70 | "colors": [ 71 | "rgba(50, 172, 45, 0.97)", 72 | "#E02F44", 73 | "rgba(245, 54, 54, 0.9)" 74 | ], 75 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 76 | "decimals": 2, 77 | "mappingType": 1, 78 | "pattern": "Fan Status", 79 | "thresholds": [ 80 | "2" 81 | ], 82 | "type": "string", 83 | "unit": "short", 84 | "valueMaps": [ 85 | { 86 | "text": "Normal", 87 | "value": "1" 88 | }, 89 | { 90 | "text": "Failed", 91 | "value": "2" 92 | } 93 | ] 94 | }, 95 | { 96 | "alias": "", 97 | "colorMode": "value", 98 | "colors": [ 99 | "rgba(50, 172, 45, 0.97)", 100 | "rgba(237, 129, 40, 0.89)", 101 | "rgba(245, 54, 54, 0.9)" 102 | ], 103 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 104 | "decimals": null, 105 | "pattern": "Temperature", 106 | "thresholds": [ 107 | "50", 108 | "70" 109 | ], 110 | "type": "number", 111 | "unit": "celsius" 112 | }, 113 | { 114 | "alias": "", 115 | "colorMode": null, 116 | "colors": [ 117 | "rgba(245, 54, 54, 0.9)", 118 | "rgba(237, 129, 40, 0.89)", 119 | "rgba(50, 172, 45, 0.97)" 120 | ], 121 | "decimals": 2, 122 | "mappingType": 1, 123 | "pattern": "Upgrade Status", 124 | "thresholds": [], 125 | "type": "string", 126 | "unit": "short", 127 | "valueMaps": [ 128 | { 129 | "text": "Upgrade Available", 130 | "value": "1" 131 | }, 132 | { 133 | "text": "Up to Date", 134 | "value": "2" 135 | }, 136 | { 137 | "text": "Checking for Update", 138 | "value": "3" 139 | }, 140 | { 141 | "text": "Unable to Check", 142 | "value": "4" 143 | }, 144 | { 145 | "text": "Other", 146 | "value": "5" 147 | } 148 | ] 149 | }, 150 | { 151 | "alias": "", 152 | "colorMode": null, 153 | "colors": [ 154 | "rgba(245, 54, 54, 0.9)", 155 | "rgba(237, 129, 40, 0.89)", 156 | "rgba(50, 172, 45, 0.97)" 157 | ], 158 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 159 | "decimals": 1, 160 | "mappingType": 1, 161 | "pattern": "Uptime", 162 | "thresholds": [], 163 | "type": "number", 164 | "unit": "dtdurations" 165 | } 166 | ], 167 | "targets": [ 168 | { 169 | "alias": "$col", 170 | "dsType": "influxdb", 171 | "groupBy": [], 172 | "limit": "1", 173 | "measurement": "synology_system", 174 | "orderByTime": "DESC", 175 | "policy": "default", 176 | "refId": "C", 177 | "resultFormat": "table", 178 | "select": [ 179 | [ 180 | { 181 | "params": [ 182 | "system_temp" 183 | ], 184 | "type": "field" 185 | }, 186 | { 187 | "params": [], 188 | "type": "last" 189 | }, 190 | { 191 | "params": [ 192 | "Temperature" 193 | ], 194 | "type": "alias" 195 | } 196 | ], 197 | [ 198 | { 199 | "params": [ 200 | "system_status" 201 | ], 202 | "type": "field" 203 | }, 204 | { 205 | "params": [], 206 | "type": "last" 207 | }, 208 | { 209 | "params": [ 210 | "System Status" 211 | ], 212 | "type": "alias" 213 | } 214 | ], 215 | [ 216 | { 217 | "params": [ 218 | "fan_status" 219 | ], 220 | "type": "field" 221 | }, 222 | { 223 | "params": [], 224 | "type": "last" 225 | }, 226 | { 227 | "params": [ 228 | "Fan Status" 229 | ], 230 | "type": "alias" 231 | } 232 | ], 233 | [ 234 | { 235 | "params": [ 236 | "upgrade_status" 237 | ], 238 | "type": "field" 239 | }, 240 | { 241 | "params": [], 242 | "type": "last" 243 | }, 244 | { 245 | "params": [ 246 | "Upgrade Status" 247 | ], 248 | "type": "alias" 249 | } 250 | ], 251 | [ 252 | { 253 | "params": [ 254 | "dsm_version" 255 | ], 256 | "type": "field" 257 | }, 258 | { 259 | "params": [], 260 | "type": "last" 261 | }, 262 | { 263 | "params": [ 264 | "DSM Version" 265 | ], 266 | "type": "alias" 267 | } 268 | ], 269 | [ 270 | { 271 | "params": [ 272 | "uptime" 273 | ], 274 | "type": "field" 275 | }, 276 | { 277 | "params": [], 278 | "type": "last" 279 | }, 280 | { 281 | "params": [ 282 | "/ 100" 283 | ], 284 | "type": "math" 285 | }, 286 | { 287 | "params": [ 288 | "Uptime" 289 | ], 290 | "type": "alias" 291 | } 292 | ], 293 | [ 294 | { 295 | "params": [ 296 | "model" 297 | ], 298 | "type": "field" 299 | }, 300 | { 301 | "params": [], 302 | "type": "last" 303 | }, 304 | { 305 | "params": [ 306 | "Model" 307 | ], 308 | "type": "alias" 309 | } 310 | ], 311 | [ 312 | { 313 | "params": [ 314 | "serial_number" 315 | ], 316 | "type": "field" 317 | }, 318 | { 319 | "params": [], 320 | "type": "last" 321 | }, 322 | { 323 | "params": [ 324 | "Serial Number" 325 | ], 326 | "type": "alias" 327 | } 328 | ] 329 | ], 330 | "tags": [ 331 | { 332 | "key": "nas_name", 333 | "operator": "=~", 334 | "value": "/^$nas_host$/" 335 | } 336 | ] 337 | } 338 | ], 339 | "title": "$nas_host Overview", 340 | "transform": "table", 341 | "transparent": true, 342 | "type": "table" 343 | }, 344 | { 345 | "aliasColors": { 346 | "CPU Usage": "#705DA0" 347 | }, 348 | "bars": false, 349 | "dashLength": 10, 350 | "dashes": false, 351 | "decimals": 0, 352 | "fill": 1, 353 | "gridPos": { 354 | "h": 6, 355 | "w": 12, 356 | "x": 0, 357 | "y": 3 358 | }, 359 | "height": "300", 360 | "id": 2, 361 | "interval": "$default_interval", 362 | "legend": { 363 | "alignAsTable": true, 364 | "avg": true, 365 | "current": true, 366 | "max": true, 367 | "min": false, 368 | "rightSide": true, 369 | "show": false, 370 | "sideWidth": null, 371 | "total": false, 372 | "values": true 373 | }, 374 | "lines": true, 375 | "linewidth": 1, 376 | "links": [], 377 | "maxPerRow": 4, 378 | "nullPointMode": "connected", 379 | "paceLength": 10, 380 | "percentage": false, 381 | "pointradius": 5, 382 | "points": false, 383 | "renderer": "flot", 384 | "seriesOverrides": [ 385 | { 386 | "alias": "Temp", 387 | "color": "#6ED0E0", 388 | "yaxis": 2 389 | }, 390 | { 391 | "alias": "CPU", 392 | "color": "#7EB26D", 393 | "fill": 3, 394 | "linewidth": 2, 395 | "yaxis": 1 396 | }, 397 | { 398 | "alias": "Mem", 399 | "color": "#705DA0", 400 | "linewidth": 2, 401 | "yaxis": 1 402 | } 403 | ], 404 | "spaceLength": 10, 405 | "stack": false, 406 | "steppedLine": false, 407 | "targets": [ 408 | { 409 | "alias": "CPU", 410 | "dsType": "influxdb", 411 | "groupBy": [ 412 | { 413 | "params": [ 414 | "$__interval" 415 | ], 416 | "type": "time" 417 | }, 418 | { 419 | "params": [ 420 | "null" 421 | ], 422 | "type": "fill" 423 | } 424 | ], 425 | "hide": false, 426 | "measurement": "syno_snmp", 427 | "orderByTime": "ASC", 428 | "policy": "thirty_days", 429 | "query": "SELECT 100 - mean(\"usage_idle\") FROM \"synology_cpu\" WHERE \"nas_name\" =~ /^$nas_host$/ AND $timeFilter GROUP BY time($__interval) fill(null)", 430 | "rawQuery": true, 431 | "refId": "A", 432 | "resultFormat": "time_series", 433 | "select": [ 434 | [ 435 | { 436 | "params": [ 437 | "cpu_free" 438 | ], 439 | "type": "field" 440 | }, 441 | { 442 | "params": [], 443 | "type": "mean" 444 | } 445 | ] 446 | ], 447 | "tags": [ 448 | { 449 | "key": "host", 450 | "operator": "=~", 451 | "value": "/^$nas_host$/" 452 | }, 453 | { 454 | "condition": "AND", 455 | "key": "stat", 456 | "operator": "=", 457 | "value": "nas_cpu" 458 | } 459 | ] 460 | }, 461 | { 462 | "alias": "Temp", 463 | "dsType": "influxdb", 464 | "groupBy": [ 465 | { 466 | "params": [ 467 | "$__interval" 468 | ], 469 | "type": "time" 470 | }, 471 | { 472 | "params": [ 473 | "null" 474 | ], 475 | "type": "fill" 476 | } 477 | ], 478 | "hide": false, 479 | "orderByTime": "ASC", 480 | "policy": "default", 481 | "query": "SELECT mean(\"system_temp\") FROM \"synology_system\" WHERE \"nas_name\" =~ /^$nas_host$/ AND $timeFilter GROUP BY time($__interval) fill(null)", 482 | "rawQuery": true, 483 | "refId": "B", 484 | "resultFormat": "time_series", 485 | "select": [ 486 | [ 487 | { 488 | "params": [ 489 | "value" 490 | ], 491 | "type": "field" 492 | }, 493 | { 494 | "params": [], 495 | "type": "mean" 496 | } 497 | ] 498 | ], 499 | "tags": [] 500 | }, 501 | { 502 | "alias": "Mem", 503 | "dsType": "influxdb", 504 | "groupBy": [ 505 | { 506 | "params": [ 507 | "$__interval" 508 | ], 509 | "type": "time" 510 | }, 511 | { 512 | "params": [ 513 | "null" 514 | ], 515 | "type": "fill" 516 | } 517 | ], 518 | "orderByTime": "ASC", 519 | "policy": "default", 520 | "query": "SELECT ((mean(\"mem_total\") - mean(\"mem_avail_real\") - mean(\"mem_buffer\") - mean(\"mem_cached\"))/mean(\"mem_total\") * 100) FROM \"synology_memory\" WHERE \"nas_name\" =~ /^$nas_host$/ AND $timeFilter GROUP BY time($__interval) fill(null)", 521 | "rawQuery": true, 522 | "refId": "C", 523 | "resultFormat": "time_series", 524 | "select": [ 525 | [ 526 | { 527 | "params": [ 528 | "value" 529 | ], 530 | "type": "field" 531 | }, 532 | { 533 | "params": [], 534 | "type": "mean" 535 | } 536 | ] 537 | ], 538 | "tags": [] 539 | } 540 | ], 541 | "thresholds": [], 542 | "timeFrom": null, 543 | "timeRegions": [], 544 | "timeShift": null, 545 | "title": "Resource Stats", 546 | "tooltip": { 547 | "shared": true, 548 | "sort": 0, 549 | "value_type": "individual" 550 | }, 551 | "transparent": true, 552 | "type": "graph", 553 | "xaxis": { 554 | "buckets": null, 555 | "mode": "time", 556 | "name": null, 557 | "show": true, 558 | "values": [] 559 | }, 560 | "yaxes": [ 561 | { 562 | "format": "percent", 563 | "label": null, 564 | "logBase": 1, 565 | "max": "100", 566 | "min": "0", 567 | "show": true 568 | }, 569 | { 570 | "decimals": 0, 571 | "format": "celsius", 572 | "label": null, 573 | "logBase": 1, 574 | "max": null, 575 | "min": null, 576 | "show": true 577 | } 578 | ], 579 | "yaxis": { 580 | "align": false, 581 | "alignLevel": null 582 | } 583 | }, 584 | { 585 | "aliasColors": { 586 | "Rx": "#6ED0E0", 587 | "Tx": "#7EB26D", 588 | "bond0:in": "#6ED0E0", 589 | "bond0:out": "#9AC48A", 590 | "eth2:in": "#1F78C1" 591 | }, 592 | "bars": false, 593 | "dashLength": 10, 594 | "dashes": false, 595 | "decimals": 1, 596 | "fill": 1, 597 | "gridPos": { 598 | "h": 6, 599 | "w": 12, 600 | "x": 12, 601 | "y": 3 602 | }, 603 | "height": "325", 604 | "id": 5, 605 | "interval": "$default_interval", 606 | "legend": { 607 | "alignAsTable": true, 608 | "avg": true, 609 | "current": true, 610 | "max": true, 611 | "min": false, 612 | "rightSide": true, 613 | "show": false, 614 | "sideWidth": null, 615 | "total": false, 616 | "values": true 617 | }, 618 | "lines": true, 619 | "linewidth": 1, 620 | "links": [], 621 | "maxPerRow": 4, 622 | "nullPointMode": "null", 623 | "paceLength": 10, 624 | "percentage": false, 625 | "pointradius": 5, 626 | "points": false, 627 | "renderer": "flot", 628 | "seriesOverrides": [ 629 | { 630 | "alias": "/Rx/", 631 | "color": "#EAB839", 632 | "yaxis": 1 633 | }, 634 | { 635 | "alias": "/Tx/", 636 | "color": "#1F78C1", 637 | "transform": "negative-Y" 638 | } 639 | ], 640 | "spaceLength": 10, 641 | "stack": false, 642 | "steppedLine": false, 643 | "targets": [ 644 | { 645 | "alias": "$tag_interface_name:$col", 646 | "dsType": "influxdb", 647 | "groupBy": [ 648 | { 649 | "params": [ 650 | "$__interval" 651 | ], 652 | "type": "time" 653 | }, 654 | { 655 | "params": [ 656 | "interface_name" 657 | ], 658 | "type": "tag" 659 | }, 660 | { 661 | "params": [ 662 | "none" 663 | ], 664 | "type": "fill" 665 | } 666 | ], 667 | "measurement": "synology_network", 668 | "orderByTime": "ASC", 669 | "policy": "default", 670 | "refId": "C", 671 | "resultFormat": "time_series", 672 | "select": [ 673 | [ 674 | { 675 | "params": [ 676 | "bytes_recv" 677 | ], 678 | "type": "field" 679 | }, 680 | { 681 | "params": [], 682 | "type": "mean" 683 | }, 684 | { 685 | "params": [ 686 | "1s" 687 | ], 688 | "type": "non_negative_derivative" 689 | }, 690 | { 691 | "params": [ 692 | "*8" 693 | ], 694 | "type": "math" 695 | }, 696 | { 697 | "params": [ 698 | "Rx" 699 | ], 700 | "type": "alias" 701 | } 702 | ], 703 | [ 704 | { 705 | "params": [ 706 | "bytes_sent" 707 | ], 708 | "type": "field" 709 | }, 710 | { 711 | "params": [], 712 | "type": "mean" 713 | }, 714 | { 715 | "params": [ 716 | "1s" 717 | ], 718 | "type": "non_negative_derivative" 719 | }, 720 | { 721 | "params": [ 722 | "*8" 723 | ], 724 | "type": "math" 725 | }, 726 | { 727 | "params": [ 728 | "Tx" 729 | ], 730 | "type": "alias" 731 | } 732 | ] 733 | ], 734 | "tags": [ 735 | { 736 | "key": "nas_name", 737 | "operator": "=~", 738 | "value": "/^$nas_host$/" 739 | }, 740 | { 741 | "condition": "AND", 742 | "key": "interface_name", 743 | "operator": "=~", 744 | "value": "/^$nas_interface$/" 745 | } 746 | ] 747 | } 748 | ], 749 | "thresholds": [], 750 | "timeFrom": null, 751 | "timeRegions": [], 752 | "timeShift": null, 753 | "title": "$nas_interface Interface Rx/Tx Rate", 754 | "tooltip": { 755 | "shared": true, 756 | "sort": 0, 757 | "value_type": "individual" 758 | }, 759 | "transparent": true, 760 | "type": "graph", 761 | "xaxis": { 762 | "buckets": null, 763 | "mode": "time", 764 | "name": null, 765 | "show": true, 766 | "values": [] 767 | }, 768 | "yaxes": [ 769 | { 770 | "format": "bps", 771 | "label": null, 772 | "logBase": 1, 773 | "max": null, 774 | "min": null, 775 | "show": true 776 | }, 777 | { 778 | "format": "bps", 779 | "label": null, 780 | "logBase": 1, 781 | "max": null, 782 | "min": null, 783 | "show": true 784 | } 785 | ], 786 | "yaxis": { 787 | "align": false, 788 | "alignLevel": null 789 | } 790 | }, 791 | { 792 | "aliasColors": {}, 793 | "bars": false, 794 | "dashLength": 10, 795 | "dashes": false, 796 | "decimals": 0, 797 | "fill": 1, 798 | "gridPos": { 799 | "h": 6, 800 | "w": 17, 801 | "x": 0, 802 | "y": 9 803 | }, 804 | "height": "250", 805 | "id": 19, 806 | "interval": "$default_interval", 807 | "legend": { 808 | "alignAsTable": true, 809 | "avg": true, 810 | "current": true, 811 | "hideEmpty": false, 812 | "hideZero": true, 813 | "max": true, 814 | "min": false, 815 | "rightSide": true, 816 | "show": true, 817 | "sideWidth": null, 818 | "total": false, 819 | "values": true 820 | }, 821 | "lines": true, 822 | "linewidth": 1, 823 | "links": [], 824 | "nullPointMode": "connected", 825 | "paceLength": 10, 826 | "percentage": false, 827 | "pointradius": 5, 828 | "points": false, 829 | "renderer": "flot", 830 | "seriesOverrides": [ 831 | { 832 | "alias": "/Write/", 833 | "transform": "negative-Y" 834 | } 835 | ], 836 | "spaceLength": 10, 837 | "stack": false, 838 | "steppedLine": false, 839 | "targets": [ 840 | { 841 | "alias": "$tag_disk_path:$col", 842 | "groupBy": [ 843 | { 844 | "params": [ 845 | "$__interval" 846 | ], 847 | "type": "time" 848 | }, 849 | { 850 | "params": [ 851 | "disk_path" 852 | ], 853 | "type": "tag" 854 | }, 855 | { 856 | "params": [ 857 | "previous" 858 | ], 859 | "type": "fill" 860 | } 861 | ], 862 | "measurement": "synology_disk", 863 | "orderByTime": "ASC", 864 | "policy": "default", 865 | "refId": "B", 866 | "resultFormat": "time_series", 867 | "select": [ 868 | [ 869 | { 870 | "params": [ 871 | "disk_reads" 872 | ], 873 | "type": "field" 874 | }, 875 | { 876 | "params": [], 877 | "type": "mean" 878 | }, 879 | { 880 | "params": [ 881 | "1s" 882 | ], 883 | "type": "non_negative_derivative" 884 | }, 885 | { 886 | "params": [ 887 | "Read" 888 | ], 889 | "type": "alias" 890 | } 891 | ], 892 | [ 893 | { 894 | "params": [ 895 | "disk_writes" 896 | ], 897 | "type": "field" 898 | }, 899 | { 900 | "params": [], 901 | "type": "mean" 902 | }, 903 | { 904 | "params": [ 905 | "1s" 906 | ], 907 | "type": "non_negative_derivative" 908 | }, 909 | { 910 | "params": [ 911 | "Write" 912 | ], 913 | "type": "alias" 914 | } 915 | ] 916 | ], 917 | "tags": [ 918 | { 919 | "key": "nas_name", 920 | "operator": "=~", 921 | "value": "/^$nas_host$/" 922 | }, 923 | { 924 | "condition": "AND", 925 | "key": "disk_path", 926 | "operator": "=~", 927 | "value": "/^$nas_disk$/" 928 | } 929 | ] 930 | } 931 | ], 932 | "thresholds": [], 933 | "timeFrom": null, 934 | "timeRegions": [], 935 | "timeShift": null, 936 | "title": "$nas_disk Disk IO Rates", 937 | "tooltip": { 938 | "shared": true, 939 | "sort": 0, 940 | "value_type": "individual" 941 | }, 942 | "transparent": true, 943 | "type": "graph", 944 | "xaxis": { 945 | "buckets": null, 946 | "mode": "time", 947 | "name": null, 948 | "show": true, 949 | "values": [] 950 | }, 951 | "yaxes": [ 952 | { 953 | "decimals": 0, 954 | "format": "decbytes", 955 | "label": null, 956 | "logBase": 1, 957 | "max": null, 958 | "min": null, 959 | "show": true 960 | }, 961 | { 962 | "decimals": 0, 963 | "format": "celsius", 964 | "label": null, 965 | "logBase": 1, 966 | "max": null, 967 | "min": null, 968 | "show": true 969 | } 970 | ], 971 | "yaxis": { 972 | "align": false, 973 | "alignLevel": null 974 | } 975 | }, 976 | { 977 | "columns": [], 978 | "fontSize": "100%", 979 | "gridPos": { 980 | "h": 6, 981 | "w": 7, 982 | "x": 17, 983 | "y": 9 984 | }, 985 | "height": "250", 986 | "id": 17, 987 | "interval": "", 988 | "links": [], 989 | "pageSize": null, 990 | "scroll": false, 991 | "showHeader": true, 992 | "sort": { 993 | "col": null, 994 | "desc": false 995 | }, 996 | "styles": [ 997 | { 998 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 999 | "pattern": "Time", 1000 | "type": "hidden" 1001 | }, 1002 | { 1003 | "colorMode": null, 1004 | "colors": [ 1005 | "rgba(245, 54, 54, 0.9)", 1006 | "rgba(237, 129, 40, 0.89)", 1007 | "rgba(50, 172, 45, 0.97)" 1008 | ], 1009 | "decimals": 2, 1010 | "pattern": "Model", 1011 | "thresholds": [], 1012 | "type": "string", 1013 | "unit": "short" 1014 | }, 1015 | { 1016 | "colorMode": "cell", 1017 | "colors": [ 1018 | "rgba(50, 172, 45, 0.97)", 1019 | "rgba(237, 129, 40, 0.89)", 1020 | "rgba(245, 54, 54, 0.9)" 1021 | ], 1022 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1023 | "decimals": 0, 1024 | "mappingType": 1, 1025 | "pattern": "Status", 1026 | "thresholds": [ 1027 | "4", 1028 | "5" 1029 | ], 1030 | "type": "string", 1031 | "unit": "short", 1032 | "valueMaps": [ 1033 | { 1034 | "text": "Healthy", 1035 | "value": "1" 1036 | } 1037 | ] 1038 | }, 1039 | { 1040 | "alias": "Temp", 1041 | "colorMode": "cell", 1042 | "colors": [ 1043 | "rgba(50, 172, 45, 0.97)", 1044 | "rgba(237, 129, 40, 0.89)", 1045 | "rgba(245, 54, 54, 0.9)" 1046 | ], 1047 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1048 | "decimals": 0, 1049 | "pattern": "Temp", 1050 | "thresholds": [ 1051 | "42", 1052 | "50" 1053 | ], 1054 | "type": "number", 1055 | "unit": "celsius" 1056 | }, 1057 | { 1058 | "alias": "Disk", 1059 | "colorMode": null, 1060 | "colors": [ 1061 | "rgba(245, 54, 54, 0.9)", 1062 | "rgba(237, 129, 40, 0.89)", 1063 | "rgba(50, 172, 45, 0.97)" 1064 | ], 1065 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1066 | "decimals": 2, 1067 | "pattern": "disk", 1068 | "thresholds": [], 1069 | "type": "number", 1070 | "unit": "short" 1071 | } 1072 | ], 1073 | "targets": [ 1074 | { 1075 | "groupBy": [ 1076 | { 1077 | "params": [ 1078 | "disk_name" 1079 | ], 1080 | "type": "tag" 1081 | } 1082 | ], 1083 | "limit": "1", 1084 | "measurement": "synology_disk", 1085 | "orderByTime": "DESC", 1086 | "policy": "default", 1087 | "refId": "C", 1088 | "resultFormat": "table", 1089 | "select": [ 1090 | [ 1091 | { 1092 | "params": [ 1093 | "disk_status" 1094 | ], 1095 | "type": "field" 1096 | }, 1097 | { 1098 | "params": [], 1099 | "type": "last" 1100 | }, 1101 | { 1102 | "params": [ 1103 | "Status" 1104 | ], 1105 | "type": "alias" 1106 | } 1107 | ], 1108 | [ 1109 | { 1110 | "params": [ 1111 | "disk_model" 1112 | ], 1113 | "type": "field" 1114 | }, 1115 | { 1116 | "params": [], 1117 | "type": "last" 1118 | }, 1119 | { 1120 | "params": [ 1121 | "Model" 1122 | ], 1123 | "type": "alias" 1124 | } 1125 | ], 1126 | [ 1127 | { 1128 | "params": [ 1129 | "disk_type" 1130 | ], 1131 | "type": "field" 1132 | }, 1133 | { 1134 | "params": [], 1135 | "type": "last" 1136 | }, 1137 | { 1138 | "params": [ 1139 | "Type" 1140 | ], 1141 | "type": "alias" 1142 | } 1143 | ] 1144 | ], 1145 | "tags": [ 1146 | { 1147 | "key": "nas_name", 1148 | "operator": "=~", 1149 | "value": "/^$nas_host$/" 1150 | } 1151 | ] 1152 | } 1153 | ], 1154 | "title": "Disk Information", 1155 | "transform": "table", 1156 | "transparent": true, 1157 | "type": "table" 1158 | }, 1159 | { 1160 | "aliasColors": { 1161 | "volume2: Used %": "#0A437C", 1162 | "volume2:Available %": "#1F78C1", 1163 | "volume2:Used %": "#1F78C1" 1164 | }, 1165 | "bars": false, 1166 | "dashLength": 10, 1167 | "dashes": false, 1168 | "decimals": 1, 1169 | "fill": 1, 1170 | "gridPos": { 1171 | "h": 6, 1172 | "w": 17, 1173 | "x": 0, 1174 | "y": 15 1175 | }, 1176 | "height": "250", 1177 | "hideTimeOverride": false, 1178 | "id": 20, 1179 | "interval": "$default_interval", 1180 | "legend": { 1181 | "alignAsTable": true, 1182 | "avg": true, 1183 | "current": true, 1184 | "max": true, 1185 | "min": false, 1186 | "rightSide": true, 1187 | "show": true, 1188 | "sideWidth": null, 1189 | "total": false, 1190 | "values": true 1191 | }, 1192 | "lines": true, 1193 | "linewidth": 1, 1194 | "links": [], 1195 | "nullPointMode": "connected", 1196 | "paceLength": 10, 1197 | "percentage": false, 1198 | "pointradius": 5, 1199 | "points": false, 1200 | "renderer": "flot", 1201 | "seriesOverrides": [], 1202 | "spaceLength": 10, 1203 | "stack": false, 1204 | "steppedLine": false, 1205 | "targets": [ 1206 | { 1207 | "alias": "$tag_raid_name", 1208 | "dsType": "influxdb", 1209 | "groupBy": [ 1210 | { 1211 | "params": [ 1212 | "$__interval" 1213 | ], 1214 | "type": "time" 1215 | }, 1216 | { 1217 | "params": [ 1218 | "drive" 1219 | ], 1220 | "type": "tag" 1221 | } 1222 | ], 1223 | "measurement": "syno_snmp", 1224 | "orderByTime": "ASC", 1225 | "policy": "default", 1226 | "query": "SELECT ((mean(\"raid_total_size\") - mean(\"raid_free_size\"))/ mean(\"raid_total_size\")) * 100 FROM \"synology_raid\" WHERE \"nas_name\" =~ /^$nas_host$/ AND \"raid_name\" =~ /^$nas_volume$/ AND $timeFilter GROUP BY time($__interval), \"raid_name\" fill(none)", 1227 | "rawQuery": true, 1228 | "refId": "A", 1229 | "resultFormat": "time_series", 1230 | "select": [ 1231 | [ 1232 | { 1233 | "params": [ 1234 | "drive_temp" 1235 | ], 1236 | "type": "field" 1237 | }, 1238 | { 1239 | "params": [], 1240 | "type": "last" 1241 | }, 1242 | { 1243 | "params": [ 1244 | "Temp" 1245 | ], 1246 | "type": "alias" 1247 | } 1248 | ] 1249 | ], 1250 | "tags": [ 1251 | { 1252 | "key": "host", 1253 | "operator": "=~", 1254 | "value": "/^$nas_host$/" 1255 | }, 1256 | { 1257 | "condition": "AND", 1258 | "key": "stat", 1259 | "operator": "=", 1260 | "value": "nas_volumes" 1261 | }, 1262 | { 1263 | "condition": "AND", 1264 | "key": "volume", 1265 | "operator": "=~", 1266 | "value": "/^$nas_volume$/" 1267 | } 1268 | ] 1269 | } 1270 | ], 1271 | "thresholds": [], 1272 | "timeFrom": "$volume_interval", 1273 | "timeRegions": [], 1274 | "timeShift": null, 1275 | "title": "$nas_volume Volume Usage", 1276 | "tooltip": { 1277 | "shared": true, 1278 | "sort": 0, 1279 | "value_type": "individual" 1280 | }, 1281 | "transparent": true, 1282 | "type": "graph", 1283 | "xaxis": { 1284 | "buckets": null, 1285 | "mode": "time", 1286 | "name": null, 1287 | "show": true, 1288 | "values": [] 1289 | }, 1290 | "yaxes": [ 1291 | { 1292 | "decimals": 1, 1293 | "format": "percent", 1294 | "label": null, 1295 | "logBase": 1, 1296 | "max": "100", 1297 | "min": "0", 1298 | "show": true 1299 | }, 1300 | { 1301 | "decimals": 0, 1302 | "format": "decgbytes", 1303 | "label": null, 1304 | "logBase": 1, 1305 | "max": null, 1306 | "min": "0", 1307 | "show": false 1308 | } 1309 | ], 1310 | "yaxis": { 1311 | "align": false, 1312 | "alignLevel": null 1313 | } 1314 | }, 1315 | { 1316 | "columns": [], 1317 | "fontSize": "100%", 1318 | "gridPos": { 1319 | "h": 6, 1320 | "w": 7, 1321 | "x": 17, 1322 | "y": 15 1323 | }, 1324 | "height": "250", 1325 | "id": 18, 1326 | "interval": "$default_interval", 1327 | "links": [], 1328 | "pageSize": null, 1329 | "scroll": false, 1330 | "showHeader": true, 1331 | "sort": { 1332 | "col": null, 1333 | "desc": false 1334 | }, 1335 | "styles": [ 1336 | { 1337 | "alias": "Volume", 1338 | "colorMode": null, 1339 | "colors": [ 1340 | "rgba(245, 54, 54, 0.9)", 1341 | "rgba(237, 129, 40, 0.89)", 1342 | "rgba(50, 172, 45, 0.97)" 1343 | ], 1344 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1345 | "decimals": 2, 1346 | "pattern": "raid_name", 1347 | "thresholds": [], 1348 | "type": "string", 1349 | "unit": "short" 1350 | }, 1351 | { 1352 | "alias": "", 1353 | "colorMode": null, 1354 | "colors": [ 1355 | "rgba(245, 54, 54, 0.9)", 1356 | "rgba(237, 129, 40, 0.89)", 1357 | "rgba(50, 172, 45, 0.97)" 1358 | ], 1359 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1360 | "decimals": 1, 1361 | "pattern": "Size", 1362 | "thresholds": [], 1363 | "type": "number", 1364 | "unit": "decgbytes" 1365 | }, 1366 | { 1367 | "alias": "", 1368 | "colorMode": null, 1369 | "colors": [ 1370 | "rgba(245, 54, 54, 0.9)", 1371 | "rgba(237, 129, 40, 0.89)", 1372 | "rgba(50, 172, 45, 0.97)" 1373 | ], 1374 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1375 | "decimals": 2, 1376 | "pattern": "Used", 1377 | "thresholds": [], 1378 | "type": "number", 1379 | "unit": "decgbytes" 1380 | }, 1381 | { 1382 | "alias": "", 1383 | "colorMode": null, 1384 | "colors": [ 1385 | "rgba(245, 54, 54, 0.9)", 1386 | "rgba(237, 129, 40, 0.89)", 1387 | "rgba(50, 172, 45, 0.97)" 1388 | ], 1389 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1390 | "decimals": 2, 1391 | "mappingType": 1, 1392 | "pattern": "Time", 1393 | "thresholds": [], 1394 | "type": "hidden", 1395 | "unit": "short" 1396 | }, 1397 | { 1398 | "alias": "Free", 1399 | "colorMode": null, 1400 | "colors": [ 1401 | "rgba(245, 54, 54, 0.9)", 1402 | "rgba(237, 129, 40, 0.89)", 1403 | "rgba(50, 172, 45, 0.97)" 1404 | ], 1405 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1406 | "decimals": 1, 1407 | "mappingType": 1, 1408 | "pattern": "Free", 1409 | "thresholds": [], 1410 | "type": "number", 1411 | "unit": "decgbytes" 1412 | } 1413 | ], 1414 | "targets": [ 1415 | { 1416 | "dsType": "influxdb", 1417 | "groupBy": [ 1418 | { 1419 | "params": [ 1420 | "volume" 1421 | ], 1422 | "type": "tag" 1423 | } 1424 | ], 1425 | "limit": "1", 1426 | "measurement": "syno_snmp", 1427 | "orderByTime": "ASC", 1428 | "policy": "default", 1429 | "query": "SELECT \"raid_total_size\" / 1024 / 1024 / 1024 AS \"Size\", (\"raid_total_size\" - \"raid_free_size\") / 1024 / 1024 / 1024 AS \"Used\", \"raid_free_size\" / 1024 / 1024 / 1024 AS \"Free\" FROM \"synology_raid\" WHERE \"nas_name\" =~ /^$nas_host$/ AND $timeFilter GROUP BY \"raid_name\" LIMIT 1", 1430 | "rawQuery": true, 1431 | "refId": "A", 1432 | "resultFormat": "table", 1433 | "select": [ 1434 | [ 1435 | { 1436 | "params": [ 1437 | "vol_totalsize" 1438 | ], 1439 | "type": "field" 1440 | }, 1441 | { 1442 | "params": [ 1443 | "Volume Size" 1444 | ], 1445 | "type": "alias" 1446 | } 1447 | ], 1448 | [ 1449 | { 1450 | "params": [ 1451 | "vol_used" 1452 | ], 1453 | "type": "field" 1454 | }, 1455 | { 1456 | "params": [ 1457 | "Used" 1458 | ], 1459 | "type": "alias" 1460 | } 1461 | ], 1462 | [ 1463 | { 1464 | "params": [ 1465 | "vol_used" 1466 | ], 1467 | "type": "field" 1468 | } 1469 | ] 1470 | ], 1471 | "tags": [ 1472 | { 1473 | "key": "host", 1474 | "operator": "=~", 1475 | "value": "/^$nas_host$/" 1476 | }, 1477 | { 1478 | "condition": "AND", 1479 | "key": "stat", 1480 | "operator": "=", 1481 | "value": "nas_volumes" 1482 | } 1483 | ] 1484 | } 1485 | ], 1486 | "title": "Volume Information", 1487 | "transform": "table", 1488 | "transparent": true, 1489 | "type": "table" 1490 | } 1491 | ], 1492 | "refresh": "5m", 1493 | "schemaVersion": 18, 1494 | "style": "dark", 1495 | "tags": [], 1496 | "templating": { 1497 | "list": [ 1498 | { 1499 | "auto": false, 1500 | "auto_count": 30, 1501 | "auto_min": "10s", 1502 | "current": { 1503 | "text": "5m", 1504 | "value": "5m" 1505 | }, 1506 | "hide": 0, 1507 | "label": "Interval", 1508 | "name": "default_interval", 1509 | "options": [ 1510 | { 1511 | "selected": false, 1512 | "text": "30s", 1513 | "value": "30s" 1514 | }, 1515 | { 1516 | "selected": false, 1517 | "text": "1m", 1518 | "value": "1m" 1519 | }, 1520 | { 1521 | "selected": true, 1522 | "text": "5m", 1523 | "value": "5m" 1524 | }, 1525 | { 1526 | "selected": false, 1527 | "text": "30m", 1528 | "value": "30m" 1529 | }, 1530 | { 1531 | "selected": false, 1532 | "text": "1h", 1533 | "value": "1h" 1534 | }, 1535 | { 1536 | "selected": false, 1537 | "text": "12h", 1538 | "value": "12h" 1539 | } 1540 | ], 1541 | "query": "30s,1m,5m,30m,1h,12h", 1542 | "refresh": 2, 1543 | "skipUrlSync": false, 1544 | "type": "interval" 1545 | }, 1546 | { 1547 | "allValue": null, 1548 | "current": { 1549 | "text": "GalaxyServices", 1550 | "value": "GalaxyServices" 1551 | }, 1552 | "datasource": "default", 1553 | "definition": "SHOW TAG VALUES FROM \"synology_system\" WITH KEY = \"nas_name\"", 1554 | "hide": 0, 1555 | "includeAll": false, 1556 | "label": "NAS", 1557 | "multi": false, 1558 | "name": "nas_host", 1559 | "options": [], 1560 | "query": "SHOW TAG VALUES FROM \"synology_system\" WITH KEY = \"nas_name\"", 1561 | "refresh": 1, 1562 | "regex": "", 1563 | "skipUrlSync": false, 1564 | "sort": 1, 1565 | "tagValuesQuery": "", 1566 | "tags": [], 1567 | "tagsQuery": "", 1568 | "type": "query", 1569 | "useTags": false 1570 | }, 1571 | { 1572 | "allValue": "", 1573 | "current": { 1574 | "text": "bond0", 1575 | "value": [ 1576 | "bond0" 1577 | ] 1578 | }, 1579 | "datasource": "default", 1580 | "definition": "SHOW TAG VALUES FROM \"synology_network\" WITH KEY = \"interface_name\" WHERE \"nas_name\" =~ /^$nas_host/", 1581 | "hide": 0, 1582 | "includeAll": true, 1583 | "label": "Interface", 1584 | "multi": true, 1585 | "name": "nas_interface", 1586 | "options": [], 1587 | "query": "SHOW TAG VALUES FROM \"synology_network\" WITH KEY = \"interface_name\" WHERE \"nas_name\" =~ /^$nas_host/", 1588 | "refresh": 1, 1589 | "regex": "", 1590 | "skipUrlSync": false, 1591 | "sort": 1, 1592 | "tagValuesQuery": "", 1593 | "tags": [], 1594 | "tagsQuery": "", 1595 | "type": "query", 1596 | "useTags": false 1597 | }, 1598 | { 1599 | "allValue": "", 1600 | "current": { 1601 | "text": "All", 1602 | "value": [ 1603 | "$__all" 1604 | ] 1605 | }, 1606 | "datasource": "default", 1607 | "definition": "SHOW TAG VALUES FROM \"synology_disk\" WITH KEY = \"disk_path\" WHERE \"nas_name\" =~ /^$nas_host/", 1608 | "hide": 0, 1609 | "includeAll": true, 1610 | "label": "Disk", 1611 | "multi": true, 1612 | "name": "nas_disk", 1613 | "options": [], 1614 | "query": "SHOW TAG VALUES FROM \"synology_disk\" WITH KEY = \"disk_path\" WHERE \"nas_name\" =~ /^$nas_host/", 1615 | "refresh": 1, 1616 | "regex": "", 1617 | "skipUrlSync": false, 1618 | "sort": 1, 1619 | "tagValuesQuery": "", 1620 | "tags": [], 1621 | "tagsQuery": "", 1622 | "type": "query", 1623 | "useTags": false 1624 | }, 1625 | { 1626 | "allValue": "", 1627 | "current": { 1628 | "text": "All", 1629 | "value": "$__all" 1630 | }, 1631 | "datasource": "default", 1632 | "definition": "SHOW TAG VALUES FROM \"synology_raid\" WITH KEY = \"raid_name\" WHERE \"nas_name\" =~ /^$nas_host/", 1633 | "hide": 0, 1634 | "includeAll": true, 1635 | "label": "Volume", 1636 | "multi": true, 1637 | "name": "nas_volume", 1638 | "options": [], 1639 | "query": "SHOW TAG VALUES FROM \"synology_raid\" WITH KEY = \"raid_name\" WHERE \"nas_name\" =~ /^$nas_host/", 1640 | "refresh": 1, 1641 | "regex": "", 1642 | "skipUrlSync": false, 1643 | "sort": 1, 1644 | "tagValuesQuery": "", 1645 | "tags": [], 1646 | "tagsQuery": "", 1647 | "type": "query", 1648 | "useTags": false 1649 | }, 1650 | { 1651 | "allValue": null, 1652 | "current": { 1653 | "selected": true, 1654 | "text": "30d", 1655 | "value": "30d" 1656 | }, 1657 | "hide": 0, 1658 | "includeAll": false, 1659 | "label": "Volume Interval", 1660 | "multi": false, 1661 | "name": "volume_interval", 1662 | "options": [ 1663 | { 1664 | "selected": false, 1665 | "text": "7d", 1666 | "value": "7d" 1667 | }, 1668 | { 1669 | "selected": false, 1670 | "text": "14d", 1671 | "value": "14d" 1672 | }, 1673 | { 1674 | "selected": true, 1675 | "text": "30d", 1676 | "value": "30d" 1677 | }, 1678 | { 1679 | "selected": false, 1680 | "text": "60d", 1681 | "value": "60d" 1682 | }, 1683 | { 1684 | "selected": false, 1685 | "text": "90d", 1686 | "value": "90d" 1687 | }, 1688 | { 1689 | "selected": false, 1690 | "text": "180d", 1691 | "value": "180d" 1692 | }, 1693 | { 1694 | "selected": false, 1695 | "text": "365d", 1696 | "value": "365d" 1697 | } 1698 | ], 1699 | "query": "7d,14d,30d,60d,90d,180d,365d", 1700 | "skipUrlSync": false, 1701 | "type": "custom" 1702 | } 1703 | ] 1704 | }, 1705 | "time": { 1706 | "from": "now-24h", 1707 | "to": "now" 1708 | }, 1709 | "timepicker": { 1710 | "refresh_intervals": [ 1711 | "5s", 1712 | "10s", 1713 | "30s", 1714 | "1m", 1715 | "5m", 1716 | "15m", 1717 | "30m", 1718 | "1h", 1719 | "2h", 1720 | "1d" 1721 | ], 1722 | "time_options": [ 1723 | "5m", 1724 | "15m", 1725 | "1h", 1726 | "6h", 1727 | "12h", 1728 | "24h", 1729 | "2d", 1730 | "7d", 1731 | "30d" 1732 | ] 1733 | }, 1734 | "timezone": "browser", 1735 | "title": "Synology Status", 1736 | "uid": "UxxqNOZZz", 1737 | "version": 2 1738 | } 1739 | -------------------------------------------------------------------------------- /synology_snmp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #This script pulls various information from the Synology NAS 4 | #Edit /etc/crontab then restart, synoservice -restart crond 5 | 6 | #Metrics to capture, set to false if you want to skip that specific set 7 | capture_system="true" #model information, temperature, update status, 8 | capture_memory="true" #information about memory stats 9 | capture_cpu="true" #CPU usage 10 | capture_volume="true" #Volume statistics, this is similar to raid but is not a Synology MIB 11 | capture_raid="true" #Synology volume/raid statistics. Preferred stats as they are syno specific. 12 | capture_disk="true" #disk specific stats such as model, type, reads, writes, load and temperature 13 | capture_ups="false" #get UPS status such as runtime, status and charge level. Default false as it will fail if no UPS is configured. 14 | capture_network="true" #Get network stats, Rx and Tx 15 | 16 | #Set capture intervals in seconds. Tor instance 10 which will be 6 times in a minute. Do not recommend more frequent than 10 seconds with between 15-20 being ideal. Set it higher than 60 and you are an idiot 17 | capture_interval=20 18 | 19 | #NAS DETAILS 20 | nas_url="localhost" #url/IP to the NAS itself. Since it is likely running on the NAS just leave it to localhost 21 | nas_name="" #Leave empty if you want to get the name from the NAS itself, otherwise provide a custom name 22 | ups_group="NAS" #For filtering metrics if more than one UPS, only necessary if capturing ups stats is enabled 23 | 24 | #INFLUXDB SETTINGS 25 | influxdb_host="127.0.0.1" #URL/IP for influxdb 26 | influxdb_port="8086" #Port influxdb is running on 27 | influxdb_name="telegraf" #influxdb database name, default telegraf 28 | influxdb_user="" #influxdb user, leave blank if you do not have an influxdb user, shame on you. 29 | influxdb_pass="" #influxdb password 30 | 31 | #HTTP METHOD SETTINGS 32 | http_method="http" #Setting for https or http URL, default for influx is http and thus 'http'. Set to 'https' if using a secure port such as through a Reverse Proxy 33 | 34 | # Getting NAS hostname from NAS if it was not manually set 35 | if [[ -z $nas_name ]]; then 36 | nas_name=`snmpwalk -c public -v 2c $nas_url SNMPv2-MIB::sysName.0 -Ovqt` 37 | fi 38 | 39 | #loop the script 40 | total_executions=$(( 60 / $capture_interval)) 41 | echo "Capturing $total_executions times" 42 | i=0 43 | while [ $i -lt $total_executions ]; do 44 | 45 | #Create empty URL 46 | post_url= 47 | 48 | #GETTING VARIOUS SYSTEM INFORMATION 49 | if (${capture_system,,} = "true"); then 50 | 51 | measurement="synology_system" 52 | 53 | #System uptime 54 | system_uptime=`snmpwalk -c public -v 2c $nas_url HOST-RESOURCES-MIB::hrSystemUptime.0 -Ovt` 55 | 56 | #System Status, 1 is online, 0 is failed/offline 57 | system_status=`snmpwalk -v 2c -c public $nas_url SYNOLOGY-SYSTEM-MIB::systemStatus.0 -Oqv` 58 | 59 | #Fan status1 is online, 0 is failed/offline 60 | system_fan_status=`snmpwalk -c public -v 2c $nas_url SYNOLOGY-SYSTEM-MIB::systemFanStatus.0 -Oqv` 61 | 62 | #Various SYNOLOGY-SYSTEM stats for common OID 63 | while IFS= read -r line; do 64 | 65 | if [[ $line == SYNOLOGY-SYSTEM-MIB::modelName.0* ]]; then 66 | model=${line/"SYNOLOGY-SYSTEM-MIB::modelName.0 = STRING: "/} 67 | #model=${line#*'"'}; model=${model%'"'*} 68 | 69 | elif [[ $line == SYNOLOGY-SYSTEM-MIB::serialNumber.0* ]]; then 70 | serial=${line/"SYNOLOGY-SYSTEM-MIB::serialNumber.0 = STRING: "/} 71 | 72 | elif [[ $line == SYNOLOGY-SYSTEM-MIB::upgradeAvailable.0* ]]; then 73 | upgrade=${line/SYNOLOGY-SYSTEM-MIB::upgradeAvailable.0 = INTEGER: /} 74 | 75 | elif [[ $line == SYNOLOGY-SYSTEM-MIB::version.0* ]]; then 76 | version=${line/"SYNOLOGY-SYSTEM-MIB::version.0 = STRING: "/} 77 | 78 | fi 79 | done < <(snmpwalk -c public -v 2c $nas_url 1.3.6.1.4.1.6574.1.5) #Parent OID for SYNOLOGY-SYSTEM-MIB 80 | 81 | # synology NAS Temperature 82 | system_temp=`snmpwalk -v 2c -c public $nas_url 1.3.6.1.4.1.6574.1.2 -Oqv` 83 | 84 | #System details to post 85 | post_url=$post_url"$measurement,nas_name=$nas_name uptime=$system_uptime,system_status=$system_status,fan_status=$system_fan_status,model=$model,serial_number=$serial,upgrade_status=$upgrade,dsm_version=$version,system_temp=$system_temp 86 | " 87 | else 88 | echo "Skipping system capture" 89 | fi 90 | 91 | 92 | # GETTING MEMORY STATS 93 | if (${capture_memory,,} = "true"); then 94 | 95 | measurement="synology_memory" 96 | 97 | #Various Memory stats for common Memory OID 98 | while IFS= read -r line; do 99 | 100 | # Calculation for used percent 101 | # ($mem_total - $mem_avail_real - $mem_buffer - $mem_cached)/$mem_total) * 100") 102 | 103 | if [[ $line == UCD-SNMP-MIB::memTotalReal.0* ]]; then 104 | mem_total=${line/"UCD-SNMP-MIB::memTotalReal.0 = INTEGER: "/} 105 | mem_total=${mem_total/" kB"/} 106 | 107 | elif [[ $line == UCD-SNMP-MIB::memAvailReal.0* ]]; then 108 | mem_avail_real=${line/"UCD-SNMP-MIB::memAvailReal.0 = INTEGER: "/} 109 | mem_avail_real=${mem_avail_real/" kB"/} 110 | 111 | elif [[ $line == UCD-SNMP-MIB::memBuffer.0* ]]; then 112 | mem_buffer=${line/"UCD-SNMP-MIB::memBuffer.0 = INTEGER: "/} 113 | mem_buffer=${mem_buffer/" kB"/} 114 | 115 | elif [[ $line == UCD-SNMP-MIB::memCached.0* ]]; then 116 | mem_cached=${line/"UCD-SNMP-MIB::memCached.0 = INTEGER: "/} 117 | mem_cached=${mem_cached/" kB"/} 118 | 119 | elif [[ $line == UCD-SNMP-MIB::memTotalFree.0* ]]; then 120 | mem_free=${line/"UCD-SNMP-MIB::memTotalFree.0 = INTEGER: "/} 121 | mem_free=${mem_free/" kB"/} 122 | 123 | fi 124 | 125 | done < <(snmpwalk -c public -v 2c $nas_url 1.3.6.1.4.1.2021.4) #Parent OID for UCD-SNMP-MIB Memory stats 126 | 127 | post_url=$post_url"$measurement,nas_name=$nas_name mem_total=$mem_total,mem_avail_real=$mem_avail_real,mem_buffer=$mem_buffer,mem_cached=$mem_cached,mem_free=$mem_free 128 | " 129 | else 130 | echo "Skipping memory capture" 131 | fi 132 | 133 | 134 | # GETTING CPU USAGE 135 | if (${capture_cpu,,} = "true"); then 136 | 137 | # UCD-SNMP-MIB::ssCpuIdle.0 = INTEGER: 93 138 | measurement="synology_cpu" 139 | usage_idle=`snmpwalk -c public -v 2c $nas_url UCD-SNMP-MIB::ssCpuIdle.0 -Oqv` 140 | post_url=$post_url"$measurement,nas_name=$nas_name usage_idle=$usage_idle 141 | " 142 | else 143 | echo "Skipping CPU capture" 144 | fi 145 | 146 | 147 | # GETTING VOLUME information based upon the SYNOLOGY-RAID-MIB it is basically the summarized version of what information we want. 148 | if (${capture_volume,,} = "true"); then 149 | measurement="synology_volume" 150 | 151 | while IFS= read -r line; do 152 | 153 | if [[ $line =~ "/volume"+([0-9]$) ]]; then 154 | id=${line/"HOST-RESOURCES-MIB::hrStorageDescr."/}; id=${id%" = STRING:"*} 155 | vol_name=${line#*STRING: } 156 | 157 | # Allocation units for volume in bytes (typically 4096) 158 | vol_blocksize=`snmpwalk -v 2c -c public $nas_url HOST-RESOURCES-MIB::hrStorageAllocationUnits.$id -Ovq | awk {'print $1'}` 159 | 160 | # Total Volume Size is size before being multipled by allocation units 161 | vol_totalsize=`snmpwalk -v 2c -c public $nas_url HOST-RESOURCES-MIB::hrStorageSize.$id -Oqv` 162 | 163 | # Volume Usage 164 | vol_used=`snmpwalk -v 2c -c public $nas_url HOST-RESOURCES-MIB::hrStorageUsed.$id -Oqv` 165 | 166 | # Need to actually convert the sizes provided by their allocation unit, leaving in bytes format 167 | # Calculation to TB is =(vol_totalsize*vol_blocksize)/1024/1024/1024/1024 168 | vol_totalsize=$(($vol_totalsize * $vol_blocksize)) 169 | vol_used=$(($vol_used * $vol_blocksize)) 170 | post_url=$post_url"$measurement,nas_name=$nas_name,volume=$vol_name vol_totalsize=$vol_totalsize,vol_used=$vol_used 171 | " 172 | 173 | fi 174 | done < <(snmpwalk -c public -v 2c $nas_url 1.3.6.1.2.1.25.2.3.1.3) 175 | 176 | else 177 | echo "Skipping volume capture" 178 | fi 179 | 180 | 181 | #GETTING RAID INFO 182 | if (${capture_raid,,} = "true"); then 183 | measurement="synology_raid" 184 | 185 | raid_info=() 186 | 187 | while IFS= read -r line; do 188 | 189 | id=${line/"SYNOLOGY-RAID-MIB::raidName."/}; id=${id%" = STRING:"*} 190 | raid_name=${line#*STRING: };raid_name=${raid_name// /};raid_name=${raid_name//\"} 191 | raid_info+=([$id]=$raid_name) 192 | 193 | done< <(snmpwalk -v 2c -c public localhost SYNOLOGY-RAID-MIB::raidName) 194 | 195 | for id in "${!raid_info[@]}" 196 | do 197 | 198 | while IFS= read -r line; do 199 | 200 | raid_name=${raid_info[$id]} 201 | 202 | if [[ $line == SYNOLOGY-RAID-MIB::raidStatus.$id* ]]; then 203 | raid_status=${line/"SYNOLOGY-RAID-MIB::raidStatus."$id" = INTEGER: "/} 204 | fi 205 | 206 | if [[ $line == SYNOLOGY-RAID-MIB::raidFreeSize.$id* ]]; then 207 | raid_free_size=${line/"SYNOLOGY-RAID-MIB::raidFreeSize."$id" = Counter64: "/} 208 | fi 209 | 210 | if [[ $line == SYNOLOGY-RAID-MIB::raidTotalSize.$id* ]]; then 211 | raid_total_size=${line/"SYNOLOGY-RAID-MIB::raidTotalSize."$id" = Counter64: "/} 212 | fi 213 | 214 | done < <(snmpwalk -c public -v 2c $nas_url 1.3.6.1.4.1.6574.3.1.1) 215 | 216 | post_url=$post_url"$measurement,nas_name=$nas_name,raid_name=$raid_name raid_status=$raid_status,raid_free_size=$raid_free_size,raid_total_size=$raid_total_size 217 | " 218 | done 219 | 220 | else 221 | echo "Skipping RAID capture" 222 | fi 223 | 224 | 225 | #GETTING DISK INFO 226 | if (${capture_disk,,} = "true"); then 227 | measurement="synology_disk" 228 | 229 | disk_info=() 230 | 231 | while IFS= read -r line; do 232 | 233 | id=${line/"SYNOLOGY-DISK-MIB::diskID."/}; id=${id%" = STRING:"*} 234 | disk_name=${line#*STRING: }; disk_name=${disk_name// /};disk_name=${disk_name//\"} 235 | disk_info+=([$id]=$disk_name) 236 | 237 | done< <(snmpwalk -v 2c -c public localhost SYNOLOGY-DISK-MIB::diskID) 238 | 239 | for id in "${!disk_info[@]}" 240 | do 241 | 242 | while IFS= read -r line; do 243 | 244 | disk_name=${disk_info[$id]} 245 | 246 | if [[ $line == SYNOLOGY-DISK-MIB::diskModel.$id* ]]; then 247 | disk_model=${line/"SYNOLOGY-DISK-MIB::diskModel."$id" = STRING: "/}; disk_model=${disk_model// /} 248 | fi 249 | 250 | if [[ $line == SYNOLOGY-DISK-MIB::diskType.$id* ]]; then 251 | disk_type=${line/"SYNOLOGY-DISK-MIB::diskType."$id" = STRING: "/} 252 | fi 253 | 254 | if [[ $line == SYNOLOGY-DISK-MIB::diskStatus.$id* ]]; then 255 | disk_status=${line/"SYNOLOGY-DISK-MIB::diskStatus."$id" = INTEGER: "/} 256 | fi 257 | 258 | if [[ $line == SYNOLOGY-DISK-MIB::diskTemperature.$id* ]]; then 259 | disk_temp=${line/"SYNOLOGY-DISK-MIB::diskTemperature."$id" = INTEGER: "/} 260 | fi 261 | 262 | done < <(snmpwalk -c public -v 2c $nas_url 1.3.6.1.4.1.6574.2.1.1) 263 | 264 | post_url=$post_url"$measurement,nas_name=$nas_name,disk_name=$disk_name disk_model=$disk_model,disk_type=$disk_type,disk_temp=$disk_temp,disk_status=$disk_status 265 | " 266 | 267 | done 268 | 269 | #GETTING Disk IO STATS 270 | disk_info=() 271 | 272 | while IFS= read -r line; do 273 | 274 | id=${line/"SYNOLOGY-STORAGEIO-MIB::storageIODevice."/}; id=${id%" = STRING:"*} 275 | disk_path=${line#*STRING: }; 276 | disk_info+=([$id]=$disk_path) 277 | 278 | done< <(snmpwalk -v 2c -c public localhost SYNOLOGY-STORAGEIO-MIB::storageIODevice) 279 | 280 | for id in "${!disk_info[@]}" 281 | do 282 | disk_path="/dev/"${disk_info[$id]} 283 | 284 | while IFS= read -r line; do 285 | if [[ $line == "SYNOLOGY-STORAGEIO-MIB::storageIONReadX.$id "* ]]; then 286 | disk_reads=${line/"SYNOLOGY-STORAGEIO-MIB::storageIONReadX."$id" = Counter64: "/}; 287 | fi 288 | 289 | if [[ $line == "SYNOLOGY-STORAGEIO-MIB::storageIONWrittenX.$id "* ]]; then 290 | disk_writes=${line/"SYNOLOGY-STORAGEIO-MIB::storageIONWrittenX."$id" = Counter64: "/} 291 | fi 292 | 293 | if [[ $line == "SYNOLOGY-STORAGEIO-MIB::storageIOLA.$id "* ]]; then 294 | disk_load=${line/"SYNOLOGY-STORAGEIO-MIB::storageIOLA."$id" = INTEGER: "/} 295 | fi 296 | done< <(snmpwalk -v 2c -c public localhost 1.3.6.1.4.1.6574.101) 297 | 298 | post_url=$post_url"$measurement,nas_name=$nas_name,disk_path=$disk_path disk_reads=$disk_reads,disk_writes=$disk_writes,disk_load=$disk_load 299 | " 300 | 301 | done 302 | else 303 | echo "Skipping Disk capture" 304 | fi 305 | 306 | 307 | #GETTING UPS STATUS 308 | if (${capture_ups,,} = "true"); then 309 | measurement="synology_ups" 310 | 311 | #UPS Battery charge level 312 | ups_battery_charge=`snmpwalk -v 2c -c public $nas_url SYNOLOGY-UPS-MIB::upsBatteryChargeValue.0 -Oqv`; ups_battery_charge=${ups_battery_charge%\.*} 313 | 314 | #UPS Load 315 | ups_load=`snmpwalk -v 2c -c public $nas_url SYNOLOGY-UPS-MIB::upsInfoLoadValue.0 -Oqv`;ups_load=${ups_load%\.*} 316 | 317 | #UPS State (OL is online, OL CHRG is plugged in but charging, OL DISCHRG is on battery") 318 | ups_status=`snmpwalk -v 2c -c public $nas_url SYNOLOGY-UPS-MIB::upsInfoStatus.0 -Oqv`; ups_status=${ups_status//\"} 319 | 320 | if [[ $ups_status == "OL" ]]; 321 | then 322 | ups_status=1 323 | elif [[ $ups_status == "OL CHRG" ]]; 324 | then 325 | ups_status=2 326 | elif [[ $ups_status == "OL DISCHRG" ]]; 327 | then 328 | ups_status=3 329 | fi 330 | 331 | #Battery Runtime 332 | ups_battery_runtime=`snmpwalk -c public -v 2c $nas_url SYNOLOGY-UPS-MIB::upsBatteryRuntimeValue.0 -Oqv | awk {'print $1'}` 333 | 334 | post_url=$post_url"$measurement,nas_name=$nas_name,ups_group=$ups_group ups_status=$ups_status,ups_load=$ups_load,ups_battery_runtime=$ups_battery_runtime,ups_battery_charge=$ups_battery_charge 335 | " 336 | else 337 | echo "Skipping UPS capture" 338 | fi 339 | 340 | 341 | #GETTING NETWORK STATS 342 | if (${capture_network,,} = "true"); then 343 | measurement="synology_network" 344 | 345 | network_info=() 346 | 347 | while IFS= read -r line; do 348 | 349 | id=${line/"IF-MIB::ifName."/}; id=${id%" = STRING:"*} 350 | interface_name=${line#*STRING: }; 351 | network_info+=([$id]=$interface_name) 352 | 353 | done< <(snmpwalk -v 2c -c public localhost IF-MIB::ifName | grep -E 'eth*|bond*') 354 | 355 | for id in "${!network_info[@]}" 356 | do 357 | interface_name=${network_info[$id]} 358 | 359 | while IFS= read -r line; do 360 | if [[ $line =~ "IF-MIB::ifHCInOctets.$id =" ]]; then 361 | bytes_recv=${line/"IF-MIB::ifHCInOctets."$id" = Counter64: "/}; 362 | fi 363 | 364 | if [[ $line =~ "IF-MIB::ifHCOutOctets.$id =" ]]; then 365 | bytes_sent=${line/"IF-MIB::ifHCOutOctets."$id" = Counter64: "/}; 366 | fi 367 | 368 | done< <(snmpwalk -v 2c -c public localhost 1.3.6.1.2.1.31.1.1.1) 369 | 370 | post_url=$post_url"$measurement,nas_name=$nas_name,interface_name=$interface_name bytes_recv=$bytes_recv,bytes_sent=$bytes_sent 371 | " 372 | done 373 | 374 | else 375 | echo "Skipping Network capture" 376 | fi 377 | 378 | #Post to influxdb 379 | if [[ -z $influxdb_user ]]; then 380 | curl -i -XPOST "$http_method://$influxdb_host:$influxdb_port/write?db=$influxdb_name" --data-binary "$post_url" 381 | else 382 | curl -i -XPOST "$http_method://$influxdb_host:$influxdb_port/write?db=$influxdb_name&u=$influxdb_user&p=$influxdb_pass" --data-binary "$post_url" 383 | fi 384 | echo "$post_url" 385 | 386 | let i=i+1 387 | 388 | echo "Capture #$i complete" 389 | 390 | #Sleeping for capture interval unless its last capture then we dont sleep 391 | if (( $i < $total_executions)); then 392 | sleep $capture_interval 393 | fi 394 | 395 | done 396 | --------------------------------------------------------------------------------