├── LICENSE ├── README.md ├── dashboard ├── esxmon.sh ├── example-daemon ├── inet.sh ├── ping.sh ├── speedtest.sh ├── sump_monitor.py ├── switch.sh ├── temp_readings.py └── upsmon.sh /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 danodemano 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Custom Monitoring Scripts 2 | A dump of the scripts used to monitor my environment and write to InfluxDB 3 | 4 | This is a dump of all the custom bash and python scripts being used to monitor my network/power/enviroment for my home lab. I used SNMP wherever possible however some things (such as the memory usage of ESXi) I was unable to poll and had to get creative. Feel free to take this and tweak them to your needs! 5 | 6 | The example-daemon can be used to turn these into startup script and be able to control them via the "service" command. In the case of CentOS dump it into /etc/init.d, change the variables at the top, then run: 7 | 8 | ``` 9 | chmod +x /etc/init.d/script-name 10 | chkconfig --add script-name 11 | chkconfig script-name on 12 | service script-name start 13 | ``` 14 | 15 | The "dashboard" file contains an export of the dashboard displayed here: http://i.imgur.com/iwtQcsL.jpg 16 | -------------------------------------------------------------------------------- /dashboard: -------------------------------------------------------------------------------- 1 | { 2 | "id": 1, 3 | "title": "Bunyard Server Stack", 4 | "originalTitle": "Bunyard Server Stack", 5 | "tags": [], 6 | "style": "dark", 7 | "timezone": "browser", 8 | "editable": true, 9 | "hideControls": false, 10 | "sharedCrosshair": false, 11 | "rows": [ 12 | { 13 | "collapse": false, 14 | "editable": true, 15 | "height": "200px", 16 | "panels": [ 17 | { 18 | "aliasColors": {}, 19 | "bars": false, 20 | "datasource": "Main Home DB", 21 | "decimals": 0, 22 | "editable": true, 23 | "error": false, 24 | "fill": 1, 25 | "grid": { 26 | "leftLogBase": 1, 27 | "leftMax": null, 28 | "leftMin": null, 29 | "rightLogBase": 1, 30 | "rightMax": null, 31 | "rightMin": null, 32 | "threshold1": null, 33 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 34 | "threshold2": null, 35 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 36 | }, 37 | "id": 5, 38 | "interval": ">90s", 39 | "isNew": true, 40 | "leftYAxisLabel": "Usage", 41 | "legend": { 42 | "alignAsTable": true, 43 | "avg": true, 44 | "current": true, 45 | "hideZero": false, 46 | "max": true, 47 | "min": true, 48 | "rightSide": true, 49 | "show": true, 50 | "total": false, 51 | "values": true 52 | }, 53 | "lines": true, 54 | "linewidth": 1, 55 | "links": [], 56 | "nullPointMode": "connected", 57 | "percentage": false, 58 | "pointradius": 5, 59 | "points": false, 60 | "renderer": "flot", 61 | "seriesOverrides": [ 62 | { 63 | "alias": "Memory", 64 | "fill": 0, 65 | "linewidth": 2 66 | } 67 | ], 68 | "span": 5, 69 | "stack": false, 70 | "steppedLine": false, 71 | "targets": [ 72 | { 73 | "alias": "CPU1", 74 | "dsType": "influxdb", 75 | "groupBy": [ 76 | { 77 | "params": [ 78 | "$interval" 79 | ], 80 | "type": "time" 81 | }, 82 | { 83 | "params": [ 84 | "null" 85 | ], 86 | "type": "fill" 87 | } 88 | ], 89 | "measurement": "esxi_stats", 90 | "query": "SELECT mean(\"value\") FROM \"esxi_stats\" WHERE \"type\" = 'cpu_usage' AND \"cpu_number\" = '1' AND \"host\" = 'esxi1' AND $timeFilter GROUP BY time($interval) fill(null)", 91 | "refId": "A", 92 | "resultFormat": "time_series", 93 | "select": [ 94 | [ 95 | { 96 | "params": [ 97 | "value" 98 | ], 99 | "type": "field" 100 | }, 101 | { 102 | "params": [], 103 | "type": "mean" 104 | } 105 | ] 106 | ], 107 | "tags": [ 108 | { 109 | "key": "type", 110 | "operator": "=", 111 | "value": "cpu_usage" 112 | }, 113 | { 114 | "condition": "AND", 115 | "key": "cpu_number", 116 | "operator": "=", 117 | "value": "1" 118 | }, 119 | { 120 | "condition": "AND", 121 | "key": "host", 122 | "operator": "=", 123 | "value": "esxi1" 124 | } 125 | ] 126 | }, 127 | { 128 | "alias": "CPU2", 129 | "dsType": "influxdb", 130 | "groupBy": [ 131 | { 132 | "params": [ 133 | "$interval" 134 | ], 135 | "type": "time" 136 | }, 137 | { 138 | "params": [ 139 | "null" 140 | ], 141 | "type": "fill" 142 | } 143 | ], 144 | "measurement": "esxi_stats", 145 | "query": "SELECT mean(\"value\") FROM \"esxi_stats\" WHERE \"type\" = 'cpu_usage' AND \"cpu_number\" = '2' AND \"host\" = 'esxi1' AND $timeFilter GROUP BY time($interval) fill(null)", 146 | "refId": "B", 147 | "resultFormat": "time_series", 148 | "select": [ 149 | [ 150 | { 151 | "params": [ 152 | "value" 153 | ], 154 | "type": "field" 155 | }, 156 | { 157 | "params": [], 158 | "type": "mean" 159 | } 160 | ] 161 | ], 162 | "tags": [ 163 | { 164 | "key": "type", 165 | "operator": "=", 166 | "value": "cpu_usage" 167 | }, 168 | { 169 | "condition": "AND", 170 | "key": "cpu_number", 171 | "operator": "=", 172 | "value": "2" 173 | }, 174 | { 175 | "condition": "AND", 176 | "key": "host", 177 | "operator": "=", 178 | "value": "esxi1" 179 | } 180 | ] 181 | }, 182 | { 183 | "alias": "CPU3", 184 | "dsType": "influxdb", 185 | "groupBy": [ 186 | { 187 | "params": [ 188 | "$interval" 189 | ], 190 | "type": "time" 191 | }, 192 | { 193 | "params": [ 194 | "null" 195 | ], 196 | "type": "fill" 197 | } 198 | ], 199 | "measurement": "esxi_stats", 200 | "query": "SELECT mean(\"value\") FROM \"esxi_stats\" WHERE \"type\" = 'cpu_usage' AND \"cpu_number\" = '3' AND \"host\" = 'esxi1' AND $timeFilter GROUP BY time($interval) fill(null)", 201 | "refId": "C", 202 | "resultFormat": "time_series", 203 | "select": [ 204 | [ 205 | { 206 | "params": [ 207 | "value" 208 | ], 209 | "type": "field" 210 | }, 211 | { 212 | "params": [], 213 | "type": "mean" 214 | } 215 | ] 216 | ], 217 | "tags": [ 218 | { 219 | "key": "type", 220 | "operator": "=", 221 | "value": "cpu_usage" 222 | }, 223 | { 224 | "condition": "AND", 225 | "key": "cpu_number", 226 | "operator": "=", 227 | "value": "3" 228 | }, 229 | { 230 | "condition": "AND", 231 | "key": "host", 232 | "operator": "=", 233 | "value": "esxi1" 234 | } 235 | ] 236 | }, 237 | { 238 | "alias": "CPU4", 239 | "dsType": "influxdb", 240 | "groupBy": [ 241 | { 242 | "params": [ 243 | "$interval" 244 | ], 245 | "type": "time" 246 | }, 247 | { 248 | "params": [ 249 | "null" 250 | ], 251 | "type": "fill" 252 | } 253 | ], 254 | "measurement": "esxi_stats", 255 | "query": "SELECT mean(\"value\") FROM \"esxi_stats\" WHERE \"type\" = 'cpu_usage' AND \"cpu_number\" = '4' AND \"host\" = 'esxi1' AND $timeFilter GROUP BY time($interval) fill(null)", 256 | "refId": "D", 257 | "resultFormat": "time_series", 258 | "select": [ 259 | [ 260 | { 261 | "params": [ 262 | "value" 263 | ], 264 | "type": "field" 265 | }, 266 | { 267 | "params": [], 268 | "type": "mean" 269 | } 270 | ] 271 | ], 272 | "tags": [ 273 | { 274 | "key": "type", 275 | "operator": "=", 276 | "value": "cpu_usage" 277 | }, 278 | { 279 | "condition": "AND", 280 | "key": "cpu_number", 281 | "operator": "=", 282 | "value": "4" 283 | }, 284 | { 285 | "condition": "AND", 286 | "key": "host", 287 | "operator": "=", 288 | "value": "esxi1" 289 | } 290 | ] 291 | }, 292 | { 293 | "alias": "Memory", 294 | "dsType": "influxdb", 295 | "groupBy": [ 296 | { 297 | "params": [ 298 | "$interval" 299 | ], 300 | "type": "time" 301 | }, 302 | { 303 | "params": [ 304 | "null" 305 | ], 306 | "type": "fill" 307 | } 308 | ], 309 | "measurement": "esxi_stats", 310 | "query": "SELECT mean(\"value\") FROM \"esxi_stats\" WHERE \"type\" = 'memory_usage' AND \"host\" = 'esxi1' AND $timeFilter GROUP BY time($interval) fill(null)", 311 | "refId": "E", 312 | "resultFormat": "time_series", 313 | "select": [ 314 | [ 315 | { 316 | "params": [ 317 | "value" 318 | ], 319 | "type": "field" 320 | }, 321 | { 322 | "params": [], 323 | "type": "mean" 324 | } 325 | ] 326 | ], 327 | "tags": [ 328 | { 329 | "key": "type", 330 | "operator": "=", 331 | "value": "memory_usage" 332 | }, 333 | { 334 | "condition": "AND", 335 | "key": "host", 336 | "operator": "=", 337 | "value": "esxi1" 338 | } 339 | ] 340 | } 341 | ], 342 | "timeFrom": null, 343 | "timeShift": null, 344 | "title": "ESXi Main Resource Usage", 345 | "tooltip": { 346 | "shared": true, 347 | "value_type": "cumulative" 348 | }, 349 | "type": "graph", 350 | "x-axis": true, 351 | "y-axis": true, 352 | "y_formats": [ 353 | "percent", 354 | "none" 355 | ] 356 | }, 357 | { 358 | "aliasColors": {}, 359 | "bars": false, 360 | "datasource": "Main Home DB", 361 | "decimals": 0, 362 | "editable": true, 363 | "error": false, 364 | "fill": 0, 365 | "grid": { 366 | "leftLogBase": 1, 367 | "leftMax": null, 368 | "leftMin": null, 369 | "rightLogBase": 1, 370 | "rightMax": null, 371 | "rightMin": 0, 372 | "threshold1": null, 373 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 374 | "threshold2": null, 375 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 376 | }, 377 | "id": 4, 378 | "interval": ">60s", 379 | "isNew": true, 380 | "leftYAxisLabel": "Latency", 381 | "legend": { 382 | "alignAsTable": true, 383 | "avg": true, 384 | "current": true, 385 | "max": true, 386 | "min": true, 387 | "rightSide": true, 388 | "show": true, 389 | "total": false, 390 | "values": true 391 | }, 392 | "lines": true, 393 | "linewidth": 1, 394 | "links": [], 395 | "nullPointMode": "connected", 396 | "percentage": false, 397 | "pointradius": 5, 398 | "points": false, 399 | "renderer": "flot", 400 | "rightYAxisLabel": "Packet Loss", 401 | "seriesOverrides": [ 402 | { 403 | "alias": "Loss", 404 | "bars": true, 405 | "color": "#890F02", 406 | "lines": false, 407 | "pointradius": 1, 408 | "points": true, 409 | "yaxis": 2 410 | }, 411 | { 412 | "alias": "Max", 413 | "fillBelowTo": "Min", 414 | "lines": false 415 | }, 416 | { 417 | "alias": "Min", 418 | "lines": false 419 | }, 420 | { 421 | "alias": "Avg", 422 | "fillBelowTo": "Min", 423 | "lines": false 424 | }, 425 | { 426 | "alias": "Min", 427 | "lines": false 428 | } 429 | ], 430 | "span": 5, 431 | "stack": false, 432 | "steppedLine": false, 433 | "targets": [ 434 | { 435 | "alias": "Min", 436 | "dsType": "influxdb", 437 | "groupBy": [ 438 | { 439 | "params": [ 440 | "$interval" 441 | ], 442 | "type": "time" 443 | }, 444 | { 445 | "params": [ 446 | "previous" 447 | ], 448 | "type": "fill" 449 | } 450 | ], 451 | "hide": false, 452 | "measurement": "ping", 453 | "query": "SELECT min(\"value\") FROM \"ping\" WHERE \"host\" = '8.8.8.8' AND \"measurement\" = 'min' AND $timeFilter GROUP BY time($interval) fill(previous)", 454 | "refId": "A", 455 | "resultFormat": "time_series", 456 | "select": [ 457 | [ 458 | { 459 | "params": [ 460 | "value" 461 | ], 462 | "type": "field" 463 | }, 464 | { 465 | "params": [], 466 | "type": "min" 467 | } 468 | ] 469 | ], 470 | "tags": [ 471 | { 472 | "key": "host", 473 | "operator": "=", 474 | "value": "8.8.8.8" 475 | }, 476 | { 477 | "condition": "AND", 478 | "key": "measurement", 479 | "operator": "=", 480 | "value": "min" 481 | } 482 | ] 483 | }, 484 | { 485 | "alias": "Avg", 486 | "dsType": "influxdb", 487 | "groupBy": [ 488 | { 489 | "params": [ 490 | "$interval" 491 | ], 492 | "type": "time" 493 | }, 494 | { 495 | "params": [ 496 | "previous" 497 | ], 498 | "type": "fill" 499 | } 500 | ], 501 | "measurement": "ping", 502 | "query": "SELECT mean(\"value\") FROM \"ping\" WHERE \"host\" = '8.8.8.8' AND \"measurement\" = 'avg' AND $timeFilter GROUP BY time($interval) fill(previous)", 503 | "refId": "B", 504 | "resultFormat": "time_series", 505 | "select": [ 506 | [ 507 | { 508 | "params": [ 509 | "value" 510 | ], 511 | "type": "field" 512 | }, 513 | { 514 | "params": [], 515 | "type": "mean" 516 | } 517 | ] 518 | ], 519 | "tags": [ 520 | { 521 | "key": "host", 522 | "operator": "=", 523 | "value": "8.8.8.8" 524 | }, 525 | { 526 | "condition": "AND", 527 | "key": "measurement", 528 | "operator": "=", 529 | "value": "avg" 530 | } 531 | ] 532 | }, 533 | { 534 | "alias": "Max", 535 | "dsType": "influxdb", 536 | "groupBy": [ 537 | { 538 | "params": [ 539 | "$interval" 540 | ], 541 | "type": "time" 542 | }, 543 | { 544 | "params": [ 545 | "previous" 546 | ], 547 | "type": "fill" 548 | } 549 | ], 550 | "measurement": "ping", 551 | "query": "SELECT max(\"value\") FROM \"ping\" WHERE \"host\" = '8.8.8.8' AND \"measurement\" = 'max' AND $timeFilter GROUP BY time($interval) fill(previous)", 552 | "refId": "C", 553 | "resultFormat": "time_series", 554 | "select": [ 555 | [ 556 | { 557 | "params": [ 558 | "value" 559 | ], 560 | "type": "field" 561 | }, 562 | { 563 | "params": [], 564 | "type": "max" 565 | } 566 | ] 567 | ], 568 | "tags": [ 569 | { 570 | "key": "host", 571 | "operator": "=", 572 | "value": "8.8.8.8" 573 | }, 574 | { 575 | "condition": "AND", 576 | "key": "measurement", 577 | "operator": "=", 578 | "value": "max" 579 | } 580 | ] 581 | }, 582 | { 583 | "alias": "Loss", 584 | "dsType": "influxdb", 585 | "groupBy": [ 586 | { 587 | "params": [ 588 | "$interval" 589 | ], 590 | "type": "time" 591 | }, 592 | { 593 | "params": [ 594 | "previous" 595 | ], 596 | "type": "fill" 597 | } 598 | ], 599 | "hide": false, 600 | "measurement": "ping", 601 | "query": "SELECT mean(\"value\") FROM \"ping\" WHERE \"host\" = '8.8.8.8' AND \"measurement\" = 'loss' AND $timeFilter GROUP BY time($interval) fill(previous)", 602 | "refId": "D", 603 | "resultFormat": "time_series", 604 | "select": [ 605 | [ 606 | { 607 | "params": [ 608 | "value" 609 | ], 610 | "type": "field" 611 | }, 612 | { 613 | "params": [], 614 | "type": "mean" 615 | } 616 | ] 617 | ], 618 | "tags": [ 619 | { 620 | "key": "host", 621 | "operator": "=", 622 | "value": "8.8.8.8" 623 | }, 624 | { 625 | "condition": "AND", 626 | "key": "measurement", 627 | "operator": "=", 628 | "value": "loss" 629 | } 630 | ] 631 | } 632 | ], 633 | "timeFrom": "30m", 634 | "timeShift": null, 635 | "title": "Smokeping Google DNS", 636 | "tooltip": { 637 | "shared": true, 638 | "value_type": "cumulative" 639 | }, 640 | "transparent": false, 641 | "type": "graph", 642 | "x-axis": true, 643 | "y-axis": true, 644 | "y_formats": [ 645 | "ms", 646 | "percent" 647 | ] 648 | }, 649 | { 650 | "content": "
\"Find
Click for weather forecast
", 651 | "editable": true, 652 | "error": false, 653 | "id": 10, 654 | "isNew": true, 655 | "links": [], 656 | "mode": "html", 657 | "span": 2, 658 | "style": {}, 659 | "title": "Weather", 660 | "type": "text" 661 | } 662 | ], 663 | "title": "Row" 664 | }, 665 | { 666 | "collapse": false, 667 | "editable": true, 668 | "height": "250px", 669 | "panels": [ 670 | { 671 | "aliasColors": {}, 672 | "bars": false, 673 | "datasource": "Main Home DB", 674 | "editable": true, 675 | "error": false, 676 | "fill": 0, 677 | "grid": { 678 | "leftLogBase": 1, 679 | "leftMax": null, 680 | "leftMin": null, 681 | "rightLogBase": 1, 682 | "rightMax": null, 683 | "rightMin": null, 684 | "threshold1": null, 685 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 686 | "threshold2": null, 687 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 688 | }, 689 | "id": 6, 690 | "interval": ">90s", 691 | "isNew": true, 692 | "legend": { 693 | "alignAsTable": true, 694 | "avg": true, 695 | "current": true, 696 | "max": true, 697 | "min": true, 698 | "rightSide": false, 699 | "show": true, 700 | "total": false, 701 | "values": true 702 | }, 703 | "lines": true, 704 | "linewidth": 1, 705 | "links": [], 706 | "nullPointMode": "connected", 707 | "percentage": false, 708 | "pointradius": 5, 709 | "points": false, 710 | "renderer": "flot", 711 | "seriesOverrides": [], 712 | "span": 4, 713 | "stack": false, 714 | "steppedLine": false, 715 | "targets": [ 716 | { 717 | "alias": "Main Trunk", 718 | "dsType": "influxdb", 719 | "groupBy": [ 720 | { 721 | "params": [ 722 | "$interval" 723 | ], 724 | "type": "time" 725 | }, 726 | { 727 | "params": [ 728 | "null" 729 | ], 730 | "type": "fill" 731 | } 732 | ], 733 | "measurement": "network_traffic", 734 | "query": "SELECT sum(\"value\") FROM \"network_traffic\" WHERE \"host\" = 'zyxel1' AND \"interface\" = 'gig1' AND $timeFilter GROUP BY time($interval) fill(null)", 735 | "refId": "A", 736 | "resultFormat": "time_series", 737 | "select": [ 738 | [ 739 | { 740 | "params": [ 741 | "value" 742 | ], 743 | "type": "field" 744 | }, 745 | { 746 | "params": [], 747 | "type": "sum" 748 | } 749 | ] 750 | ], 751 | "tags": [ 752 | { 753 | "key": "host", 754 | "operator": "=", 755 | "value": "zyxel1" 756 | }, 757 | { 758 | "condition": "AND", 759 | "key": "interface", 760 | "operator": "=", 761 | "value": "gig1" 762 | } 763 | ] 764 | }, 765 | { 766 | "alias": "2TB NAS", 767 | "dsType": "influxdb", 768 | "groupBy": [ 769 | { 770 | "params": [ 771 | "$interval" 772 | ], 773 | "type": "time" 774 | }, 775 | { 776 | "params": [ 777 | "null" 778 | ], 779 | "type": "fill" 780 | } 781 | ], 782 | "measurement": "network_traffic", 783 | "query": "SELECT sum(\"value\") FROM \"network_traffic\" WHERE \"host\" = 'zyxel1' AND \"interface\" = 'gig2' AND $timeFilter GROUP BY time($interval) fill(null)", 784 | "refId": "B", 785 | "resultFormat": "time_series", 786 | "select": [ 787 | [ 788 | { 789 | "params": [ 790 | "value" 791 | ], 792 | "type": "field" 793 | }, 794 | { 795 | "params": [], 796 | "type": "sum" 797 | } 798 | ] 799 | ], 800 | "tags": [ 801 | { 802 | "key": "host", 803 | "operator": "=", 804 | "value": "zyxel1" 805 | }, 806 | { 807 | "condition": "AND", 808 | "key": "interface", 809 | "operator": "=", 810 | "value": "gig2" 811 | } 812 | ] 813 | }, 814 | { 815 | "alias": "VM1 VMnetwork", 816 | "dsType": "influxdb", 817 | "groupBy": [ 818 | { 819 | "params": [ 820 | "$interval" 821 | ], 822 | "type": "time" 823 | }, 824 | { 825 | "params": [ 826 | "null" 827 | ], 828 | "type": "fill" 829 | } 830 | ], 831 | "measurement": "network_traffic", 832 | "query": "SELECT sum(\"value\") FROM \"network_traffic\" WHERE \"host\" = 'zyxel1' AND \"interface\" = 'gig9' AND $timeFilter GROUP BY time($interval) fill(null)", 833 | "refId": "C", 834 | "resultFormat": "time_series", 835 | "select": [ 836 | [ 837 | { 838 | "params": [ 839 | "value" 840 | ], 841 | "type": "field" 842 | }, 843 | { 844 | "params": [], 845 | "type": "sum" 846 | } 847 | ] 848 | ], 849 | "tags": [ 850 | { 851 | "key": "host", 852 | "operator": "=", 853 | "value": "zyxel1" 854 | }, 855 | { 856 | "condition": "AND", 857 | "key": "interface", 858 | "operator": "=", 859 | "value": "gig9" 860 | } 861 | ] 862 | }, 863 | { 864 | "alias": "QNAP iSCSI", 865 | "dsType": "influxdb", 866 | "groupBy": [ 867 | { 868 | "params": [ 869 | "$interval" 870 | ], 871 | "type": "time" 872 | }, 873 | { 874 | "params": [ 875 | "null" 876 | ], 877 | "type": "fill" 878 | } 879 | ], 880 | "measurement": "network_traffic", 881 | "query": "SELECT sum(\"value\") FROM \"network_traffic\" WHERE \"host\" = 'zyxel1' AND \"interface\" = 'gig14' AND $timeFilter GROUP BY time($interval) fill(null)", 882 | "refId": "D", 883 | "resultFormat": "time_series", 884 | "select": [ 885 | [ 886 | { 887 | "params": [ 888 | "value" 889 | ], 890 | "type": "field" 891 | }, 892 | { 893 | "params": [], 894 | "type": "sum" 895 | } 896 | ] 897 | ], 898 | "tags": [ 899 | { 900 | "key": "host", 901 | "operator": "=", 902 | "value": "zyxel1" 903 | }, 904 | { 905 | "condition": "AND", 906 | "key": "interface", 907 | "operator": "=", 908 | "value": "gig14" 909 | } 910 | ] 911 | } 912 | ], 913 | "timeFrom": null, 914 | "timeShift": null, 915 | "title": "Core Network Traffic (Aggregate)", 916 | "tooltip": { 917 | "shared": true, 918 | "value_type": "cumulative" 919 | }, 920 | "type": "graph", 921 | "x-axis": true, 922 | "y-axis": true, 923 | "y_formats": [ 924 | "bps", 925 | "short" 926 | ] 927 | }, 928 | { 929 | "aliasColors": {}, 930 | "bars": false, 931 | "datasource": "Main Home DB", 932 | "editable": true, 933 | "error": false, 934 | "fill": 1, 935 | "grid": { 936 | "leftLogBase": 1, 937 | "leftMax": null, 938 | "leftMin": null, 939 | "rightLogBase": 1, 940 | "rightMax": null, 941 | "rightMin": null, 942 | "threshold1": null, 943 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 944 | "threshold2": null, 945 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 946 | }, 947 | "id": 2, 948 | "interval": ">90s", 949 | "isNew": true, 950 | "legend": { 951 | "alignAsTable": true, 952 | "avg": true, 953 | "current": true, 954 | "max": true, 955 | "min": true, 956 | "rightSide": false, 957 | "show": true, 958 | "total": false, 959 | "values": true 960 | }, 961 | "lines": true, 962 | "linewidth": 2, 963 | "links": [], 964 | "nullPointMode": "connected", 965 | "percentage": false, 966 | "pointradius": 5, 967 | "points": false, 968 | "renderer": "flot", 969 | "seriesOverrides": [ 970 | { 971 | "alias": "Outbound Main/Media", 972 | "transform": "negative-Y" 973 | }, 974 | { 975 | "alias": "Outbound Kids/Guests", 976 | "transform": "negative-Y" 977 | } 978 | ], 979 | "span": 4, 980 | "stack": false, 981 | "steppedLine": false, 982 | "targets": [ 983 | { 984 | "alias": "Inbound Main/Media", 985 | "dsType": "influxdb", 986 | "groupBy": [ 987 | { 988 | "params": [ 989 | "$interval" 990 | ], 991 | "type": "time" 992 | }, 993 | { 994 | "params": [ 995 | "null" 996 | ], 997 | "type": "fill" 998 | } 999 | ], 1000 | "measurement": "network_traffic", 1001 | "query": "SELECT mean(\"value\") FROM \"network_traffic\" WHERE \"host\" = 'sophosutm' AND \"interface\" = 'eth2' AND \"direction\" = 'inbound' AND $timeFilter GROUP BY time($interval) fill(null)", 1002 | "refId": "A", 1003 | "resultFormat": "time_series", 1004 | "select": [ 1005 | [ 1006 | { 1007 | "params": [ 1008 | "value" 1009 | ], 1010 | "type": "field" 1011 | }, 1012 | { 1013 | "params": [], 1014 | "type": "mean" 1015 | } 1016 | ] 1017 | ], 1018 | "tags": [ 1019 | { 1020 | "key": "host", 1021 | "operator": "=", 1022 | "value": "sophosutm" 1023 | }, 1024 | { 1025 | "condition": "AND", 1026 | "key": "interface", 1027 | "operator": "=", 1028 | "value": "eth2" 1029 | }, 1030 | { 1031 | "condition": "AND", 1032 | "key": "direction", 1033 | "operator": "=", 1034 | "value": "inbound" 1035 | } 1036 | ] 1037 | }, 1038 | { 1039 | "alias": "Inbound Kids/Guest", 1040 | "dsType": "influxdb", 1041 | "groupBy": [ 1042 | { 1043 | "params": [ 1044 | "$interval" 1045 | ], 1046 | "type": "time" 1047 | }, 1048 | { 1049 | "params": [ 1050 | "null" 1051 | ], 1052 | "type": "fill" 1053 | } 1054 | ], 1055 | "measurement": "network_traffic", 1056 | "query": "SELECT mean(\"value\") FROM \"network_traffic\" WHERE \"host\" = 'sophosutm' AND \"interface\" = 'eth1' AND \"direction\" = 'inbound' AND $timeFilter GROUP BY time($interval) fill(null)", 1057 | "refId": "C", 1058 | "resultFormat": "time_series", 1059 | "select": [ 1060 | [ 1061 | { 1062 | "params": [ 1063 | "value" 1064 | ], 1065 | "type": "field" 1066 | }, 1067 | { 1068 | "params": [], 1069 | "type": "mean" 1070 | } 1071 | ] 1072 | ], 1073 | "tags": [ 1074 | { 1075 | "key": "host", 1076 | "operator": "=", 1077 | "value": "sophosutm" 1078 | }, 1079 | { 1080 | "condition": "AND", 1081 | "key": "interface", 1082 | "operator": "=", 1083 | "value": "eth1" 1084 | }, 1085 | { 1086 | "condition": "AND", 1087 | "key": "direction", 1088 | "operator": "=", 1089 | "value": "inbound" 1090 | } 1091 | ] 1092 | }, 1093 | { 1094 | "alias": "Outbound Main/Media", 1095 | "dsType": "influxdb", 1096 | "groupBy": [ 1097 | { 1098 | "params": [ 1099 | "$interval" 1100 | ], 1101 | "type": "time" 1102 | }, 1103 | { 1104 | "params": [ 1105 | "null" 1106 | ], 1107 | "type": "fill" 1108 | } 1109 | ], 1110 | "measurement": "network_traffic", 1111 | "query": "SELECT mean(\"value\") FROM \"network_traffic\" WHERE \"host\" = 'sophosutm' AND \"interface\" = 'eth2' AND \"direction\" = 'outbound' AND $timeFilter GROUP BY time($interval) fill(null)", 1112 | "refId": "B", 1113 | "resultFormat": "time_series", 1114 | "select": [ 1115 | [ 1116 | { 1117 | "params": [ 1118 | "value" 1119 | ], 1120 | "type": "field" 1121 | }, 1122 | { 1123 | "params": [], 1124 | "type": "mean" 1125 | } 1126 | ] 1127 | ], 1128 | "tags": [ 1129 | { 1130 | "key": "host", 1131 | "operator": "=", 1132 | "value": "sophosutm" 1133 | }, 1134 | { 1135 | "condition": "AND", 1136 | "key": "interface", 1137 | "operator": "=", 1138 | "value": "eth2" 1139 | }, 1140 | { 1141 | "condition": "AND", 1142 | "key": "direction", 1143 | "operator": "=", 1144 | "value": "outbound" 1145 | } 1146 | ] 1147 | }, 1148 | { 1149 | "alias": "Outbound Kids/Guests", 1150 | "dsType": "influxdb", 1151 | "groupBy": [ 1152 | { 1153 | "params": [ 1154 | "$interval" 1155 | ], 1156 | "type": "time" 1157 | }, 1158 | { 1159 | "params": [ 1160 | "null" 1161 | ], 1162 | "type": "fill" 1163 | } 1164 | ], 1165 | "measurement": "network_traffic", 1166 | "query": "SELECT mean(\"value\") FROM \"network_traffic\" WHERE \"host\" = 'sophosutm' AND \"interface\" = 'eth1' AND \"direction\" = 'outbound' AND $timeFilter GROUP BY time($interval) fill(null)", 1167 | "refId": "D", 1168 | "resultFormat": "time_series", 1169 | "select": [ 1170 | [ 1171 | { 1172 | "params": [ 1173 | "value" 1174 | ], 1175 | "type": "field" 1176 | }, 1177 | { 1178 | "params": [], 1179 | "type": "mean" 1180 | } 1181 | ] 1182 | ], 1183 | "tags": [ 1184 | { 1185 | "key": "host", 1186 | "operator": "=", 1187 | "value": "sophosutm" 1188 | }, 1189 | { 1190 | "condition": "AND", 1191 | "key": "interface", 1192 | "operator": "=", 1193 | "value": "eth1" 1194 | }, 1195 | { 1196 | "condition": "AND", 1197 | "key": "direction", 1198 | "operator": "=", 1199 | "value": "outbound" 1200 | } 1201 | ] 1202 | } 1203 | ], 1204 | "timeFrom": null, 1205 | "timeShift": null, 1206 | "title": "WAN Usage", 1207 | "tooltip": { 1208 | "shared": true, 1209 | "value_type": "cumulative" 1210 | }, 1211 | "type": "graph", 1212 | "x-axis": true, 1213 | "y-axis": true, 1214 | "y_formats": [ 1215 | "Bps", 1216 | "none" 1217 | ] 1218 | }, 1219 | { 1220 | "aliasColors": {}, 1221 | "bars": false, 1222 | "datasource": "Main Home DB", 1223 | "editable": true, 1224 | "error": false, 1225 | "fill": 1, 1226 | "grid": { 1227 | "leftLogBase": 1, 1228 | "leftMax": null, 1229 | "leftMin": null, 1230 | "rightLogBase": 1, 1231 | "rightMax": null, 1232 | "rightMin": null, 1233 | "threshold1": null, 1234 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 1235 | "threshold2": null, 1236 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 1237 | }, 1238 | "id": 9, 1239 | "interval": ">90s", 1240 | "isNew": true, 1241 | "legend": { 1242 | "alignAsTable": true, 1243 | "avg": true, 1244 | "current": true, 1245 | "max": true, 1246 | "min": true, 1247 | "show": true, 1248 | "total": false, 1249 | "values": true 1250 | }, 1251 | "lines": true, 1252 | "linewidth": 2, 1253 | "links": [], 1254 | "nullPointMode": "connected", 1255 | "percentage": false, 1256 | "pointradius": 5, 1257 | "points": false, 1258 | "renderer": "flot", 1259 | "rightYAxisLabel": "Latency", 1260 | "seriesOverrides": [ 1261 | { 1262 | "alias": "Ping", 1263 | "yaxis": 2 1264 | }, 1265 | { 1266 | "alias": "Download", 1267 | "yaxis": 1 1268 | }, 1269 | { 1270 | "alias": "Upload", 1271 | "yaxis": 1 1272 | } 1273 | ], 1274 | "span": 4, 1275 | "stack": false, 1276 | "steppedLine": false, 1277 | "targets": [ 1278 | { 1279 | "alias": "Ping", 1280 | "dsType": "influxdb", 1281 | "groupBy": [ 1282 | { 1283 | "params": [ 1284 | "$interval" 1285 | ], 1286 | "type": "time" 1287 | }, 1288 | { 1289 | "params": [ 1290 | "null" 1291 | ], 1292 | "type": "fill" 1293 | } 1294 | ], 1295 | "measurement": "speedtest", 1296 | "query": "SELECT mean(\"value\") FROM \"speedtest\" WHERE \"metric\" = 'ping' AND $timeFilter GROUP BY time($interval) fill(null)", 1297 | "refId": "A", 1298 | "resultFormat": "time_series", 1299 | "select": [ 1300 | [ 1301 | { 1302 | "params": [ 1303 | "value" 1304 | ], 1305 | "type": "field" 1306 | }, 1307 | { 1308 | "params": [], 1309 | "type": "mean" 1310 | } 1311 | ] 1312 | ], 1313 | "tags": [ 1314 | { 1315 | "key": "metric", 1316 | "operator": "=", 1317 | "value": "ping" 1318 | } 1319 | ] 1320 | }, 1321 | { 1322 | "alias": "Download", 1323 | "dsType": "influxdb", 1324 | "groupBy": [ 1325 | { 1326 | "params": [ 1327 | "$interval" 1328 | ], 1329 | "type": "time" 1330 | }, 1331 | { 1332 | "params": [ 1333 | "null" 1334 | ], 1335 | "type": "fill" 1336 | } 1337 | ], 1338 | "measurement": "speedtest", 1339 | "query": "SELECT mean(\"value\") FROM \"speedtest\" WHERE \"metric\" = 'download' AND $timeFilter GROUP BY time($interval) fill(null)", 1340 | "refId": "B", 1341 | "resultFormat": "time_series", 1342 | "select": [ 1343 | [ 1344 | { 1345 | "params": [ 1346 | "value" 1347 | ], 1348 | "type": "field" 1349 | }, 1350 | { 1351 | "params": [], 1352 | "type": "mean" 1353 | } 1354 | ] 1355 | ], 1356 | "tags": [ 1357 | { 1358 | "key": "metric", 1359 | "operator": "=", 1360 | "value": "download" 1361 | } 1362 | ] 1363 | }, 1364 | { 1365 | "alias": "Upload", 1366 | "dsType": "influxdb", 1367 | "groupBy": [ 1368 | { 1369 | "params": [ 1370 | "$interval" 1371 | ], 1372 | "type": "time" 1373 | }, 1374 | { 1375 | "params": [ 1376 | "null" 1377 | ], 1378 | "type": "fill" 1379 | } 1380 | ], 1381 | "measurement": "speedtest", 1382 | "query": "SELECT mean(\"value\") FROM \"speedtest\" WHERE \"metric\" = 'upload' AND $timeFilter GROUP BY time($interval) fill(null)", 1383 | "refId": "C", 1384 | "resultFormat": "time_series", 1385 | "select": [ 1386 | [ 1387 | { 1388 | "params": [ 1389 | "value" 1390 | ], 1391 | "type": "field" 1392 | }, 1393 | { 1394 | "params": [], 1395 | "type": "mean" 1396 | } 1397 | ] 1398 | ], 1399 | "tags": [ 1400 | { 1401 | "key": "metric", 1402 | "operator": "=", 1403 | "value": "upload" 1404 | } 1405 | ] 1406 | } 1407 | ], 1408 | "timeFrom": null, 1409 | "timeShift": null, 1410 | "title": "Speedtest Stats", 1411 | "tooltip": { 1412 | "shared": true, 1413 | "value_type": "cumulative" 1414 | }, 1415 | "type": "graph", 1416 | "x-axis": true, 1417 | "y-axis": true, 1418 | "y_formats": [ 1419 | "bps", 1420 | "ms" 1421 | ] 1422 | } 1423 | ], 1424 | "title": "New row" 1425 | }, 1426 | { 1427 | "collapse": false, 1428 | "editable": true, 1429 | "height": "250px", 1430 | "panels": [ 1431 | { 1432 | "aliasColors": {}, 1433 | "bars": false, 1434 | "datasource": "Main Home DB", 1435 | "decimals": 1, 1436 | "editable": true, 1437 | "error": false, 1438 | "fill": 1, 1439 | "grid": { 1440 | "leftLogBase": 1, 1441 | "leftMax": null, 1442 | "leftMin": null, 1443 | "rightLogBase": 1, 1444 | "rightMax": null, 1445 | "rightMin": null, 1446 | "threshold1": null, 1447 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 1448 | "threshold2": null, 1449 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 1450 | }, 1451 | "hideTimeOverride": false, 1452 | "id": 1, 1453 | "interval": ">120s", 1454 | "isNew": true, 1455 | "leftYAxisLabel": "", 1456 | "legend": { 1457 | "alignAsTable": true, 1458 | "avg": true, 1459 | "current": true, 1460 | "hideEmpty": false, 1461 | "hideZero": false, 1462 | "max": true, 1463 | "min": true, 1464 | "rightSide": false, 1465 | "show": true, 1466 | "total": false, 1467 | "values": true 1468 | }, 1469 | "lines": true, 1470 | "linewidth": 2, 1471 | "links": [], 1472 | "nullPointMode": "connected", 1473 | "percentage": false, 1474 | "pointradius": 5, 1475 | "points": false, 1476 | "renderer": "flot", 1477 | "rightYAxisLabel": "", 1478 | "seriesOverrides": [ 1479 | { 1480 | "alias": "Temperature", 1481 | "yaxis": 1 1482 | }, 1483 | { 1484 | "alias": "Relative Humidity", 1485 | "yaxis": 2 1486 | } 1487 | ], 1488 | "span": 4, 1489 | "stack": false, 1490 | "steppedLine": false, 1491 | "targets": [ 1492 | { 1493 | "alias": "Temperature", 1494 | "dsType": "influxdb", 1495 | "groupBy": [ 1496 | { 1497 | "params": [ 1498 | "$interval" 1499 | ], 1500 | "type": "time" 1501 | }, 1502 | { 1503 | "params": [ 1504 | "null" 1505 | ], 1506 | "type": "fill" 1507 | } 1508 | ], 1509 | "measurement": "server_stack_temp", 1510 | "query": "SELECT mean(\"value\") FROM \"server_stack_temp\" WHERE $timeFilter GROUP BY time($interval) fill(null)", 1511 | "refId": "A", 1512 | "resultFormat": "time_series", 1513 | "select": [ 1514 | [ 1515 | { 1516 | "params": [ 1517 | "value" 1518 | ], 1519 | "type": "field" 1520 | }, 1521 | { 1522 | "params": [], 1523 | "type": "mean" 1524 | } 1525 | ] 1526 | ], 1527 | "tags": [] 1528 | }, 1529 | { 1530 | "alias": "Relative Humidity", 1531 | "dsType": "influxdb", 1532 | "groupBy": [ 1533 | { 1534 | "params": [ 1535 | "$interval" 1536 | ], 1537 | "type": "time" 1538 | }, 1539 | { 1540 | "params": [ 1541 | "null" 1542 | ], 1543 | "type": "fill" 1544 | } 1545 | ], 1546 | "measurement": "server_stack_humidity", 1547 | "query": "SELECT mean(\"value\") FROM \"server_stack_humidity\" WHERE $timeFilter GROUP BY time($interval) fill(null)", 1548 | "refId": "B", 1549 | "resultFormat": "time_series", 1550 | "select": [ 1551 | [ 1552 | { 1553 | "params": [ 1554 | "value" 1555 | ], 1556 | "type": "field" 1557 | }, 1558 | { 1559 | "params": [], 1560 | "type": "mean" 1561 | } 1562 | ] 1563 | ], 1564 | "tags": [] 1565 | } 1566 | ], 1567 | "timeFrom": null, 1568 | "timeShift": null, 1569 | "title": "Basement Temp/Humidity", 1570 | "tooltip": { 1571 | "shared": true, 1572 | "value_type": "cumulative" 1573 | }, 1574 | "transparent": false, 1575 | "type": "graph", 1576 | "x-axis": true, 1577 | "y-axis": true, 1578 | "y_formats": [ 1579 | "farenheit", 1580 | "humidity" 1581 | ] 1582 | }, 1583 | { 1584 | "aliasColors": {}, 1585 | "bars": false, 1586 | "datasource": "Main Home DB", 1587 | "decimals": 2, 1588 | "editable": true, 1589 | "error": false, 1590 | "fill": 1, 1591 | "grid": { 1592 | "leftLogBase": 1, 1593 | "leftMax": null, 1594 | "leftMin": null, 1595 | "rightLogBase": 1, 1596 | "rightMax": null, 1597 | "rightMin": null, 1598 | "threshold1": null, 1599 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 1600 | "threshold2": null, 1601 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 1602 | }, 1603 | "id": 7, 1604 | "interval": ">90s", 1605 | "isNew": true, 1606 | "leftYAxisLabel": "", 1607 | "legend": { 1608 | "alignAsTable": true, 1609 | "avg": true, 1610 | "current": true, 1611 | "max": true, 1612 | "min": true, 1613 | "show": true, 1614 | "sortDesc": true, 1615 | "total": false, 1616 | "values": true 1617 | }, 1618 | "lines": true, 1619 | "linewidth": 2, 1620 | "links": [], 1621 | "nullPointMode": "connected", 1622 | "percentage": false, 1623 | "pointradius": 5, 1624 | "points": false, 1625 | "renderer": "flot", 1626 | "rightYAxisLabel": "Load", 1627 | "seriesOverrides": [ 1628 | { 1629 | "alias": "Input Voltage", 1630 | "yaxis": 1 1631 | }, 1632 | { 1633 | "alias": "Output Voltage", 1634 | "yaxis": 1 1635 | }, 1636 | { 1637 | "alias": "Load Watts", 1638 | "yaxis": 2 1639 | } 1640 | ], 1641 | "span": 4, 1642 | "stack": false, 1643 | "steppedLine": false, 1644 | "targets": [ 1645 | { 1646 | "alias": "Input Voltage", 1647 | "dsType": "influxdb", 1648 | "groupBy": [ 1649 | { 1650 | "params": [ 1651 | "$interval" 1652 | ], 1653 | "type": "time" 1654 | }, 1655 | { 1656 | "params": [ 1657 | "null" 1658 | ], 1659 | "type": "fill" 1660 | } 1661 | ], 1662 | "measurement": "ups_stats", 1663 | "query": "SELECT mean(\"value\") FROM \"ups_stats\" WHERE \"ups\" = 'primary_stack' AND \"metric\" = 'involts' AND $timeFilter GROUP BY time($interval) fill(null)", 1664 | "refId": "A", 1665 | "resultFormat": "time_series", 1666 | "select": [ 1667 | [ 1668 | { 1669 | "params": [ 1670 | "value" 1671 | ], 1672 | "type": "field" 1673 | }, 1674 | { 1675 | "params": [], 1676 | "type": "mean" 1677 | } 1678 | ] 1679 | ], 1680 | "tags": [ 1681 | { 1682 | "key": "ups", 1683 | "operator": "=", 1684 | "value": "primary_stack" 1685 | }, 1686 | { 1687 | "condition": "AND", 1688 | "key": "metric", 1689 | "operator": "=", 1690 | "value": "involts" 1691 | } 1692 | ] 1693 | }, 1694 | { 1695 | "alias": "Output Voltage", 1696 | "dsType": "influxdb", 1697 | "groupBy": [ 1698 | { 1699 | "params": [ 1700 | "$interval" 1701 | ], 1702 | "type": "time" 1703 | }, 1704 | { 1705 | "params": [ 1706 | "null" 1707 | ], 1708 | "type": "fill" 1709 | } 1710 | ], 1711 | "measurement": "ups_stats", 1712 | "query": "SELECT mean(\"value\") FROM \"ups_stats\" WHERE \"ups\" = 'primary_stack' AND \"metric\" = 'outvolts' AND $timeFilter GROUP BY time($interval) fill(null)", 1713 | "refId": "B", 1714 | "resultFormat": "time_series", 1715 | "select": [ 1716 | [ 1717 | { 1718 | "params": [ 1719 | "value" 1720 | ], 1721 | "type": "field" 1722 | }, 1723 | { 1724 | "params": [], 1725 | "type": "mean" 1726 | } 1727 | ] 1728 | ], 1729 | "tags": [ 1730 | { 1731 | "key": "ups", 1732 | "operator": "=", 1733 | "value": "primary_stack" 1734 | }, 1735 | { 1736 | "condition": "AND", 1737 | "key": "metric", 1738 | "operator": "=", 1739 | "value": "outvolts" 1740 | } 1741 | ] 1742 | }, 1743 | { 1744 | "alias": "Load Watts", 1745 | "dsType": "influxdb", 1746 | "groupBy": [ 1747 | { 1748 | "params": [ 1749 | "$interval" 1750 | ], 1751 | "type": "time" 1752 | }, 1753 | { 1754 | "params": [ 1755 | "null" 1756 | ], 1757 | "type": "fill" 1758 | } 1759 | ], 1760 | "measurement": "ups_stats", 1761 | "query": "SELECT mean(\"value\") FROM \"ups_stats\" WHERE \"ups\" = 'primary_stack' AND \"metric\" = 'loadwatt' AND $timeFilter GROUP BY time($interval) fill(null)", 1762 | "refId": "C", 1763 | "resultFormat": "time_series", 1764 | "select": [ 1765 | [ 1766 | { 1767 | "params": [ 1768 | "value" 1769 | ], 1770 | "type": "field" 1771 | }, 1772 | { 1773 | "params": [], 1774 | "type": "mean" 1775 | } 1776 | ] 1777 | ], 1778 | "tags": [ 1779 | { 1780 | "key": "ups", 1781 | "operator": "=", 1782 | "value": "primary_stack" 1783 | }, 1784 | { 1785 | "condition": "AND", 1786 | "key": "metric", 1787 | "operator": "=", 1788 | "value": "loadwatt" 1789 | } 1790 | ] 1791 | } 1792 | ], 1793 | "timeFrom": null, 1794 | "timeShift": null, 1795 | "title": "UPS Voltage/Load", 1796 | "tooltip": { 1797 | "shared": true, 1798 | "value_type": "cumulative" 1799 | }, 1800 | "type": "graph", 1801 | "x-axis": true, 1802 | "y-axis": true, 1803 | "y_formats": [ 1804 | "volt", 1805 | "watt" 1806 | ] 1807 | }, 1808 | { 1809 | "aliasColors": {}, 1810 | "bars": false, 1811 | "datasource": "Main Home DB", 1812 | "editable": true, 1813 | "error": false, 1814 | "fill": 1, 1815 | "grid": { 1816 | "leftLogBase": 1, 1817 | "leftMax": null, 1818 | "leftMin": null, 1819 | "rightLogBase": 1, 1820 | "rightMax": null, 1821 | "rightMin": null, 1822 | "threshold1": null, 1823 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 1824 | "threshold2": null, 1825 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 1826 | }, 1827 | "id": 8, 1828 | "interval": ">90s", 1829 | "isNew": true, 1830 | "leftYAxisLabel": "", 1831 | "legend": { 1832 | "alignAsTable": true, 1833 | "avg": true, 1834 | "current": true, 1835 | "max": true, 1836 | "min": true, 1837 | "show": true, 1838 | "total": false, 1839 | "values": true 1840 | }, 1841 | "lines": true, 1842 | "linewidth": 2, 1843 | "links": [], 1844 | "nullPointMode": "connected", 1845 | "percentage": false, 1846 | "pointradius": 5, 1847 | "points": false, 1848 | "renderer": "flot", 1849 | "rightYAxisLabel": "Runtime", 1850 | "seriesOverrides": [ 1851 | { 1852 | "alias": "Battery Capacity", 1853 | "yaxis": 1 1854 | }, 1855 | { 1856 | "alias": "Load Percent", 1857 | "yaxis": 1 1858 | }, 1859 | { 1860 | "alias": "Estimated Runtime", 1861 | "yaxis": 2 1862 | } 1863 | ], 1864 | "span": 4, 1865 | "stack": false, 1866 | "steppedLine": false, 1867 | "targets": [ 1868 | { 1869 | "alias": "Battery Capacity", 1870 | "dsType": "influxdb", 1871 | "groupBy": [ 1872 | { 1873 | "params": [ 1874 | "$interval" 1875 | ], 1876 | "type": "time" 1877 | }, 1878 | { 1879 | "params": [ 1880 | "null" 1881 | ], 1882 | "type": "fill" 1883 | } 1884 | ], 1885 | "measurement": "ups_stats", 1886 | "query": "SELECT mean(\"value\") FROM \"ups_stats\" WHERE \"ups\" = 'primary_stack' AND \"metric\" = 'capacity' AND $timeFilter GROUP BY time($interval) fill(null)", 1887 | "refId": "A", 1888 | "resultFormat": "time_series", 1889 | "select": [ 1890 | [ 1891 | { 1892 | "params": [ 1893 | "value" 1894 | ], 1895 | "type": "field" 1896 | }, 1897 | { 1898 | "params": [], 1899 | "type": "mean" 1900 | } 1901 | ] 1902 | ], 1903 | "tags": [ 1904 | { 1905 | "key": "ups", 1906 | "operator": "=", 1907 | "value": "primary_stack" 1908 | }, 1909 | { 1910 | "condition": "AND", 1911 | "key": "metric", 1912 | "operator": "=", 1913 | "value": "capacity" 1914 | } 1915 | ] 1916 | }, 1917 | { 1918 | "alias": "Estimated Runtime", 1919 | "dsType": "influxdb", 1920 | "groupBy": [ 1921 | { 1922 | "params": [ 1923 | "$interval" 1924 | ], 1925 | "type": "time" 1926 | }, 1927 | { 1928 | "params": [ 1929 | "null" 1930 | ], 1931 | "type": "fill" 1932 | } 1933 | ], 1934 | "measurement": "ups_stats", 1935 | "query": "SELECT mean(\"value\") FROM \"ups_stats\" WHERE \"ups\" = 'primary_stack' AND \"metric\" = 'runtime' AND $timeFilter GROUP BY time($interval) fill(null)", 1936 | "refId": "C", 1937 | "resultFormat": "time_series", 1938 | "select": [ 1939 | [ 1940 | { 1941 | "params": [ 1942 | "value" 1943 | ], 1944 | "type": "field" 1945 | }, 1946 | { 1947 | "params": [], 1948 | "type": "mean" 1949 | } 1950 | ] 1951 | ], 1952 | "tags": [ 1953 | { 1954 | "key": "ups", 1955 | "operator": "=", 1956 | "value": "primary_stack" 1957 | }, 1958 | { 1959 | "condition": "AND", 1960 | "key": "metric", 1961 | "operator": "=", 1962 | "value": "runtime" 1963 | } 1964 | ] 1965 | }, 1966 | { 1967 | "alias": "Load Percent", 1968 | "dsType": "influxdb", 1969 | "groupBy": [ 1970 | { 1971 | "params": [ 1972 | "$interval" 1973 | ], 1974 | "type": "time" 1975 | }, 1976 | { 1977 | "params": [ 1978 | "null" 1979 | ], 1980 | "type": "fill" 1981 | } 1982 | ], 1983 | "measurement": "ups_stats", 1984 | "query": "SELECT mean(\"value\") FROM \"ups_stats\" WHERE \"ups\" = 'primary_stack' AND \"metric\" = 'loadpercent' AND $timeFilter GROUP BY time($interval) fill(null)", 1985 | "refId": "B", 1986 | "resultFormat": "time_series", 1987 | "select": [ 1988 | [ 1989 | { 1990 | "params": [ 1991 | "value" 1992 | ], 1993 | "type": "field" 1994 | }, 1995 | { 1996 | "params": [], 1997 | "type": "mean" 1998 | } 1999 | ] 2000 | ], 2001 | "tags": [ 2002 | { 2003 | "key": "ups", 2004 | "operator": "=", 2005 | "value": "primary_stack" 2006 | }, 2007 | { 2008 | "condition": "AND", 2009 | "key": "metric", 2010 | "operator": "=", 2011 | "value": "loadpercent" 2012 | } 2013 | ] 2014 | } 2015 | ], 2016 | "timeFrom": null, 2017 | "timeShift": null, 2018 | "title": "UPS Capacity/Load/Runtime", 2019 | "tooltip": { 2020 | "shared": true, 2021 | "value_type": "cumulative" 2022 | }, 2023 | "type": "graph", 2024 | "x-axis": true, 2025 | "y-axis": true, 2026 | "y_formats": [ 2027 | "percent", 2028 | "m" 2029 | ] 2030 | } 2031 | ], 2032 | "title": "New row" 2033 | } 2034 | ], 2035 | "time": { 2036 | "from": "now-1h", 2037 | "to": "now" 2038 | }, 2039 | "timepicker": { 2040 | "now": true, 2041 | "refresh_intervals": [ 2042 | "5s", 2043 | "10s", 2044 | "30s", 2045 | "1m", 2046 | "5m", 2047 | "15m", 2048 | "30m", 2049 | "1h", 2050 | "2h", 2051 | "1d" 2052 | ], 2053 | "time_options": [ 2054 | "5m", 2055 | "15m", 2056 | "1h", 2057 | "6h", 2058 | "12h", 2059 | "24h", 2060 | "2d", 2061 | "7d", 2062 | "30d" 2063 | ] 2064 | }, 2065 | "templating": { 2066 | "list": [] 2067 | }, 2068 | "annotations": { 2069 | "list": [] 2070 | }, 2071 | "refresh": "1m", 2072 | "schemaVersion": 8, 2073 | "version": 86, 2074 | "links": [] 2075 | } 2076 | -------------------------------------------------------------------------------- /esxmon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #This script gets the current memory and CPU usage for the 4 | #main ESXi server. It's hacky at best but it works. 5 | 6 | #The time we are going to sleep between readings 7 | sleeptime=30 8 | 9 | #Prepare to start the loop and warn the user 10 | echo "Press [CTRL+C] to stop..." 11 | while : 12 | do 13 | 14 | #Let's start with the "easy" one, get the CPU usage 15 | cpu1=`snmpget -v 2c -c public 192.168.9.26 HOST-RESOURCES-MIB::hrProcessorLoad.1 -Ov` 16 | cpu2=`snmpget -v 2c -c public 192.168.9.26 HOST-RESOURCES-MIB::hrProcessorLoad.2 -Ov` 17 | cpu3=`snmpget -v 2c -c public 192.168.9.26 HOST-RESOURCES-MIB::hrProcessorLoad.3 -Ov` 18 | cpu4=`snmpget -v 2c -c public 192.168.9.26 HOST-RESOURCES-MIB::hrProcessorLoad.4 -Ov` 19 | 20 | #Strip out the value from the SNMP query 21 | cpu1=$(echo $cpu1 | cut -c 10-) 22 | cpu2=$(echo $cpu2 | cut -c 10-) 23 | cpu3=$(echo $cpu3 | cut -c 10-) 24 | cpu4=$(echo $cpu4 | cut -c 10-) 25 | 26 | #Now lets get the hardware info from the remote host 27 | hwinfo=$(ssh -t root@192.168.9.26 "esxcfg-info --hardware") 28 | 29 | #Lets try to find the lines we are looking for 30 | while read -r line; do 31 | #Check if we have the line we are looking for 32 | if [[ $line == *"Kernel Memory"* ]] 33 | then 34 | kmemline=$line 35 | fi 36 | if [[ $line == *"-Free."* ]] 37 | then 38 | freememline=$line 39 | fi 40 | #echo "... $line ..." 41 | done <<< "$hwinfo" 42 | 43 | #Remove the long string of .s 44 | kmemline=$(echo $kmemline | tr -s '[.]') 45 | freememline=$(echo $freememline | tr -s '[.]') 46 | 47 | #Lets parse out the memory values from the strings 48 | #First split on the only remaining . in the strings 49 | IFS='.' read -ra kmemarr <<< "$kmemline" 50 | kmem=${kmemarr[1]} 51 | IFS='.' read -ra freememarr <<< "$freememline" 52 | freemem=${freememarr[1]} 53 | #Now break it apart on the space 54 | IFS=' ' read -ra kmemarr <<< "$kmem" 55 | kmem=${kmemarr[0]} 56 | IFS=' ' read -ra freememarr <<< "$freemem" 57 | freemem=${freememarr[0]} 58 | 59 | #Now we can finally calculate used percentage 60 | used=$((kmem - freemem)) 61 | used=$((used * 100)) 62 | pcent=$((used / kmem)) 63 | 64 | echo "CPU1: $cpu1%" 65 | echo "CPU2: $cpu2%" 66 | echo "CPU3: $cpu3%" 67 | echo "CPU4: $cpu4%" 68 | echo "Memory Used: $pcent%" 69 | 70 | #Write the data to the database 71 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "esxi_stats,host=esxi1,type=cpu_usage,cpu_number=1 value=$cpu1" 72 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "esxi_stats,host=esxi1,type=cpu_usage,cpu_number=2 value=$cpu2" 73 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "esxi_stats,host=esxi1,type=cpu_usage,cpu_number=3 value=$cpu3" 74 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "esxi_stats,host=esxi1,type=cpu_usage,cpu_number=4 value=$cpu4" 75 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "esxi_stats,host=esxi1,type=memory_usage value=$pcent" 76 | 77 | #Wait for a bit before checking again 78 | sleep "$sleeptime" 79 | 80 | done 81 | -------------------------------------------------------------------------------- /example-daemon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # chkconfig: 2345 90 90 3 | # description: custom-esxi 4 | ### BEGIN INIT INFO 5 | # Provides: custom-esxi 6 | # Required-Start: network 7 | # Required-Stop: network 8 | # Default-Start: 2 3 4 5 9 | # Default-Stop: 0 1 6 10 | # Description: Start the program 11 | ### END INIT INFO 12 | 13 | ### Fill in these bits: 14 | START_CMD="/var/www/scripts/esxmon.sh > /var/log/custom-esxi.log 2>&1 &" 15 | NAME="custom-esxi" 16 | PGREP_STRING="/var/www/scripts/esxmon.sh" 17 | PID_FILE="/var/run/custom-esxi/custom-esxi.pid" 18 | USER="root" 19 | 20 | ### No further muckin' about needed! 21 | 22 | #CUR_USER=`whoami` 23 | CUR_USER="root" 24 | 25 | killproc() { 26 | pkill -u $USER -f $PGREP_STRING 27 | } 28 | 29 | start_daemon() { 30 | eval "$*" 31 | } 32 | 33 | log_success_msg() { 34 | echo "$*" 35 | logger "$_" 36 | } 37 | 38 | log_failure_msg() { 39 | echo "$*" 40 | logger "$_" 41 | } 42 | 43 | check_proc() { 44 | pgrep -u $USER -f $PGREP_STRING >/dev/null 45 | } 46 | 47 | start_script() { 48 | if [ "${CUR_USER}" != "root" ] ; then 49 | log_failure_msg "$NAME can only be started as 'root'." 50 | exit -1 51 | fi 52 | 53 | check_proc 54 | if [ $? -eq 0 ]; then 55 | log_success_msg "$NAME is already running." 56 | exit 0 57 | fi 58 | 59 | [ -d /var/run/$NAME ] || (mkdir /var/run/$NAME ) 60 | 61 | # make go now 62 | start_daemon /bin/su $USER -c "$START_CMD" 63 | 64 | # Sleep for a while to see if anything cries 65 | sleep 5 66 | check_proc 67 | 68 | if [ $? -eq 0 ]; then 69 | log_success_msg "Started $NAME." 70 | else 71 | log_failure_msg "Error starting $NAME." 72 | exit -1 73 | fi 74 | } 75 | 76 | stop_script() { 77 | if [ "${CUR_USER}" != "root" ] ; then 78 | log_failure_msg "You do not have permission to stop $NAME." 79 | exit -1 80 | fi 81 | 82 | check_proc 83 | if [ $? -eq 0 ]; then 84 | killproc -p $PID_FILE >/dev/null 85 | 86 | # Make sure it's dead before we return 87 | until [ $? -ne 0 ]; do 88 | sleep 1 89 | check_proc 90 | done 91 | 92 | check_proc 93 | if [ $? -eq 0 ]; then 94 | log_failure_msg "Error stopping $NAME." 95 | exit -1 96 | else 97 | log_success_msg "Stopped $NAME." 98 | fi 99 | else 100 | log_failure_msg "$NAME is not running or you don't have permission to stop it" 101 | fi 102 | } 103 | 104 | check_status() { 105 | check_proc 106 | if [ $? -eq 0 ]; then 107 | log_success_msg "$NAME is running." 108 | else 109 | log_failure_msg "$NAME is stopped." 110 | exit -1 111 | fi 112 | } 113 | 114 | case "$1" in 115 | start) 116 | start_script 117 | ;; 118 | stop) 119 | stop_script 120 | ;; 121 | restart) 122 | stop_script 123 | start_script 124 | ;; 125 | status) 126 | check_status 127 | ;; 128 | *) 129 | echo "Usage: $0 {start|stop|restart|status}" 130 | exit 1 131 | esac 132 | 133 | exit 0 134 | -------------------------------------------------------------------------------- /inet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #This script get the current bandwidth usage for both the main 4 | #Internet interface as well as the kids/guest interface and 5 | #writes them to the InfluxDB instance running on this machine. 6 | 7 | #The time we are going to sleep between readings 8 | #Also used to calculate the current usage on the interface 9 | #30 seconds seems to be ideal, any more frequent and the data 10 | #gets really spikey. Since we are calculating on total octets 11 | #you will never loose data by setting this to a larger value. 12 | sleeptime=30 13 | 14 | #We need to get a baseline for the traffic before starting the loop 15 | #otherwise we have nothing to base out calculations on. 16 | 17 | #Get in and out octets 18 | oldin=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifInOctets.4 -Ov` 19 | oldout=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifOutOctets.4 -Ov` 20 | kidsoldin=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifInOctets.3 -Ov` 21 | kidsoldout=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifOutOctets.3 -Ov` 22 | 23 | #Strip out the value from the string 24 | oldin=$(echo $oldin | cut -c 12-) 25 | oldout=$(echo $oldout | cut -c 12-) 26 | kidsoldin=$(echo $kidsoldin | cut -c 12-) 27 | kidsoldout=$(echo $kidsoldout | cut -c 12-) 28 | 29 | #Prepare to start the loop and warn the user 30 | echo "Press [CTRL+C] to stop..." 31 | while : 32 | do 33 | #We need to wait between readings to have somthing to compare to 34 | sleep "$sleeptime" 35 | 36 | #Get in and out octets 37 | in=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifInOctets.4 -Ov` 38 | out=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifOutOctets.4 -Ov` 39 | kidsin=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifInOctets.3 -Ov` 40 | kidsout=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifOutOctets.3 -Ov` 41 | 42 | #Strip out the value from the string 43 | in=$(echo $in | cut -c 12-) 44 | out=$(echo $out | cut -c 12-) 45 | kidsin=$(echo $kidsin | cut -c 12-) 46 | kidsout=$(echo $kidsout | cut -c 12-) 47 | 48 | #Get the difference between the old and current 49 | diffin=$((in - oldin)) 50 | diffout=$((out - oldout)) 51 | kidsdiffin=$((kidsin - kidsoldin)) 52 | kidsdiffout=$((kidsout - kidsoldout)) 53 | 54 | #Calculate the bytes-per-second 55 | inbps=$((diffin / sleeptime)) 56 | outbps=$((diffout / sleeptime)) 57 | kidsinbps=$((kidsdiffin / sleeptime)) 58 | kidsoutbps=$((kidsdiffout / sleeptime)) 59 | 60 | #Seems we need some basic data validation - can't have values less than 0! 61 | if [[ $inbps -lt 0 || $outbps -lt 0 || $kidsinbps -lt 0 || $kidsoutbps -lt 0 ]] 62 | then 63 | #There is an issue with one or more readings, get fresh ones 64 | #then wait for the next loop to calculate again. 65 | echo "We have a problem...moving to plan B" 66 | 67 | #Get in and out octets 68 | oldin=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifInOctets.4 -Ov` 69 | oldout=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifOutOctets.4 -Ov` 70 | kidsoldin=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifInOctets.3 -Ov` 71 | kidsoldout=`snmpget -v 2c -c public 192.168.9.1 IF-MIB::ifOutOctets.3 -Ov` 72 | 73 | #Strip out the value from the string 74 | oldin=$(echo $oldin | cut -c 12-) 75 | oldout=$(echo $oldout | cut -c 12-) 76 | kidsoldin=$(echo $kidsoldin | cut -c 12-) 77 | kidsoldout=$(echo $kidsoldout | cut -c 12-) 78 | else 79 | #Output the current traffic 80 | echo "Main current inbound traffic: $inbps bps" 81 | echo "Main current outbound traffic: $outbps bps" 82 | echo "Kids/Guest current inbound traffic: $kidsinbps bps" 83 | echo "Kids/Guest current outbound traffic: $kidsoutbps bps" 84 | 85 | #Write the data to the database 86 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=sophosutm,interface=eth2,direction=inbound value=$inbps" 87 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=sophosutm,interface=eth2,direction=outbound value=$outbps" 88 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=sophosutm,interface=eth1,direction=inbound value=$kidsinbps" 89 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=sophosutm,interface=eth1,direction=outbound value=$kidsoutbps" 90 | 91 | #Move the current variables to the old ones 92 | oldin=$in 93 | oldout=$out 94 | kidsoldin=$kidsin 95 | kidsoldout=$kidsout 96 | fi 97 | 98 | done 99 | -------------------------------------------------------------------------------- /ping.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #The time we are going to sleep between readings 4 | sleeptime=30 5 | 6 | #Google DNS is a good choice for host and it's anycasted to 7 | #a nearby server. You may want to modify this though based 8 | #on your location 9 | host="8.8.8.8" 10 | 11 | #How many pings are we going to send 12 | number="20" 13 | 14 | #How long are we going to wait between pings 15 | #Keep in mind only superusers (root) can use a time 16 | #value of 200ms or less!! 17 | wait="0.25" 18 | 19 | #Prepare to start the loop and warn the user 20 | echo "Press [CTRL+C] to stop..." 21 | while : 22 | do 23 | 24 | #Lets ping the host! 25 | results=$(ping -c $number -i $wait -q $host) 26 | 27 | #We need to get ONLY lines 4 and 5 from the results 28 | #The rest isn't needed for ourpurposes 29 | counter=0 30 | while read -r line; do 31 | ((counter++)) 32 | if [ $counter = 4 ] 33 | then 34 | line4="$line" 35 | fi 36 | if [ $counter = 5 ] 37 | then 38 | line5="$line" 39 | fi 40 | done <<< "$results" 41 | 42 | echo "$line4" 43 | echo "$line5" 44 | 45 | #Parse out the 2 lines 46 | #First we need to get the packet loss 47 | IFS=',' read -ra arrline4 <<< "$line4" #Split the line based on a , 48 | loss=${arrline4[2]} #Get just the 3rd element containing the loss 49 | IFS='%' read -ra lossnumber <<< "$loss" #Split the thrid element based on a % 50 | lossnumber=$(echo $lossnumber | xargs) #Remove the leading whitespace 51 | 52 | #Now lets get the min/avg/max/mdev 53 | IFS=' = ' read -ra arrline5 <<< "$line5" #Split the lines based on a = 54 | numbers=${arrline5[2]} #Get the right side containing the actual numbers 55 | IFS='/' read -ra numbersarray <<< "$numbers" #Break out all the numbers based on a / 56 | #Get the individual values from the array 57 | min=${numbersarray[0]} 58 | avg=${numbersarray[1]} 59 | max=${numbersarray[2]} 60 | mdev=${numbersarray[3]} 61 | 62 | #Write the data to the database 63 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ping,host=8.8.8.8,measurement=loss value=$lossnumber" 64 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ping,host=8.8.8.8,measurement=min value=$min" 65 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ping,host=8.8.8.8,measurement=avg value=$avg" 66 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ping,host=8.8.8.8,measurement=max value=$max" 67 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ping,host=8.8.8.8,measurement=mdev value=$mdev" 68 | 69 | #Wait for a bit before checking again 70 | sleep "$sleeptime" 71 | 72 | done 73 | 74 | -------------------------------------------------------------------------------- /speedtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE 4 | #NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE 5 | #NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE 6 | #This script requires speedtest-cli to function!!!!!!!!!!!!!!!!!!!!!!! 7 | 8 | #The time we are going to sleep between readings 9 | sleeptime=60 10 | 11 | #Prepare to start the loop and warn the user 12 | echo "Press [CTRL+C] to stop..." 13 | while : 14 | do 15 | 16 | #Store the speedtest results into a variable 17 | results=$(speedtest-cli --simple) 18 | 19 | #echo "$results" 20 | 21 | #Lets try to find the lines we are looking for 22 | while read -r line; do 23 | #Check if we have the line we are looking for 24 | if [[ $line == *"Ping"* ]] 25 | then 26 | ping=$line 27 | fi 28 | if [[ $line == *"Download"* ]] 29 | then 30 | download=$line 31 | fi 32 | if [[ $line == *"Upload"* ]] 33 | then 34 | upload=$line 35 | fi 36 | done <<< "$results" 37 | 38 | echo "$ping" 39 | echo "$download" 40 | echo "$upload" 41 | 42 | #Break apart the results based on a space 43 | IFS=' ' read -ra arrping <<< "$ping" 44 | ping=${arrping[1]} 45 | IFS=' ' read -ra arrdownload <<< "$download" 46 | download=${arrdownload[1]} 47 | IFS=' ' read -ra arrupload <<< "$upload" 48 | upload=${arrupload[1]} 49 | 50 | #Convet to mbps 51 | download=`echo - | awk "{print $download * 1048576}"` 52 | upload=`echo - | awk "{print $upload * 1048576}"` 53 | #download=$((download * 1048576)) 54 | #upload=$((upload * 1048576)) 55 | 56 | echo "$ping" 57 | echo "$download" 58 | echo "$upload" 59 | 60 | #Write to the database 61 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "speedtest,metric=ping value=$ping" 62 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "speedtest,metric=download value=$download" 63 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "speedtest,metric=upload value=$upload" 64 | 65 | #Wait for a bit before checking again 66 | sleep "$sleeptime" 67 | 68 | done 69 | -------------------------------------------------------------------------------- /sump_monitor.py: -------------------------------------------------------------------------------- 1 | #Import the required modules 2 | import RPi.GPIO as GPIO 3 | import time 4 | import requests 5 | import math 6 | 7 | #Setup the GPIO 8 | GPIO.setmode(GPIO.BCM) 9 | 10 | #Define the TRIG and ECO pins - these are labeled on the sensor 11 | TRIG = 23 12 | ECHO = 24 13 | 14 | #Number of readings we are going to take to avoid issues 15 | numreadings = 7 16 | 17 | #Alert that we are starting the measurement 18 | print "Distance Measurement In Progress" 19 | 20 | #Loop based on the above number 21 | distancearray=[] 22 | count = 0 23 | while (count < numreadings): 24 | #Setup the two pins for reading 25 | GPIO.setup(TRIG,GPIO.OUT) 26 | GPIO.setup(ECHO,GPIO.IN) 27 | 28 | GPIO.output(TRIG, False) 29 | print "Waiting For Sensor To Settle" 30 | time.sleep(2) 31 | 32 | GPIO.output(TRIG, True) 33 | time.sleep(0.00001) 34 | GPIO.output(TRIG, False) 35 | 36 | while GPIO.input(ECHO)==0: 37 | pulse_start = time.time() 38 | 39 | while GPIO.input(ECHO)==1: 40 | pulse_end = time.time() 41 | 42 | pulse_duration = pulse_end - pulse_start 43 | 44 | distance = pulse_duration * 17150 45 | 46 | distance = round(distance, 2) 47 | 48 | print "Distance:",distance,"cm" 49 | 50 | distancearray.append(distance) 51 | 52 | count = count + 1 53 | 54 | #Get the half of the reading number and round up 55 | mid = numreadings / 2 56 | mid = int(math.ceil(mid)) 57 | 58 | #Sort the array 59 | distancearray.sort() 60 | 61 | #Just for debugging 62 | print distancearray 63 | print distancearray[mid] 64 | 65 | #Put the middle value back into the distance variable 66 | distance = distancearray[mid] 67 | 68 | #Write the data to the influxdn instance 69 | data = 'environment,host=rpi1,location=basement,type=sumppump value=' + str(distance) 70 | print data 71 | output = requests.post('http://192.168.9.42:8086/write?db=home', data=data) 72 | print output 73 | 74 | #Release connections to the GPIO pins 75 | GPIO.cleanup() 76 | -------------------------------------------------------------------------------- /switch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #This script get the current bandwidth usage for core network 4 | #links in the LAN 5 | #Port 1 = Trunk to Upstairs Zyxel 6 | #Port 2 = 2TB NAS 7 | #Port 9 = VM1 VM Trunk 8 | #Port 14 = QNAP NAS iSCSI 9 | 10 | #The time we are going to sleep between readings 11 | #Also used to calculate the current usage on the interface 12 | #30 seconds seems to be ideal, any more frequent and the data 13 | #gets really spikey. Since we are calculating on total octets 14 | #you will never loose data by setting this to a larger value. 15 | sleeptime=30 16 | 17 | #We need to get a baseline for the traffic before starting the loop 18 | #otherwise we have nothing to base out calculations on. 19 | 20 | #Get in and out octets 21 | oldin1=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.1 -Ov` 22 | oldin2=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.2 -Ov` 23 | oldin9=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.9 -Ov` 24 | oldin14=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.14 -Ov` 25 | oldout1=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.1 -Ov` 26 | oldout2=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.2 -Ov` 27 | oldout9=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.9 -Ov` 28 | oldout14=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.14 -Ov` 29 | 30 | #Strip out the value from the string 31 | oldin1=$(echo $oldin1 | cut -c 12-) 32 | oldin2=$(echo $oldin2 | cut -c 12-) 33 | oldin9=$(echo $oldin9 | cut -c 12-) 34 | oldin14=$(echo $oldin14 | cut -c 12-) 35 | oldout1=$(echo $oldout1 | cut -c 12-) 36 | oldout2=$(echo $oldout2 | cut -c 12-) 37 | oldout9=$(echo $oldout9 | cut -c 12-) 38 | oldout14=$(echo $oldout14 | cut -c 12-) 39 | 40 | #Prepare to start the loop and warn the user 41 | echo "Press [CTRL+C] to stop..." 42 | while : 43 | do 44 | #We need to wait between readings to have somthing to compare to 45 | sleep "$sleeptime" 46 | 47 | #Get in and out octets 48 | in1=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.1 -Ov` 49 | in2=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.2 -Ov` 50 | in9=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.9 -Ov` 51 | in14=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.14 -Ov` 52 | out1=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.1 -Ov` 53 | out2=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.2 -Ov` 54 | out9=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.9 -Ov` 55 | out14=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.14 -Ov` 56 | 57 | #Strip out the value from the string 58 | in1=$(echo $in1 | cut -c 12-) 59 | in2=$(echo $in2 | cut -c 12-) 60 | in9=$(echo $in9 | cut -c 12-) 61 | in14=$(echo $in14 | cut -c 12-) 62 | out1=$(echo $out1 | cut -c 12-) 63 | out2=$(echo $out2 | cut -c 12-) 64 | out9=$(echo $out9 | cut -c 12-) 65 | out14=$(echo $out14 | cut -c 12-) 66 | 67 | #Get the difference between the old and current 68 | diffin1=$((in1 - oldin1)) 69 | diffin2=$((in2 - oldin2)) 70 | diffin9=$((in9 - oldin9)) 71 | diffin14=$((in14 - oldin14)) 72 | diffout1=$((out1 - oldout1)) 73 | diffout2=$((out2 - oldout2)) 74 | diffout9=$((out9 - oldout9)) 75 | diffout14=$((out14 - oldout14)) 76 | 77 | #Calculate the bytes-per-second 78 | inbps1=$((diffin1 / sleeptime)) 79 | inbps2=$((diffin2 / sleeptime)) 80 | inbps9=$((diffin9 / sleeptime)) 81 | inbps14=$((diffin14 / sleeptime)) 82 | outbps1=$((diffout1 / sleeptime)) 83 | outbps2=$((diffout2 / sleeptime)) 84 | outbps9=$((diffout9 / sleeptime)) 85 | outbps14=$((diffout14 / sleeptime)) 86 | 87 | #Seems we need some basic data validation - can't have values less than 0! 88 | if [[ $inbps1 -lt 0 || $outbps1 -lt 0 || $inbps2 -lt 0 || $outbps2 -lt 0 || $inbps9 -lt 0 || $outbps9 -lt 0 || $inbps14 -lt 0 || $outbps14 -lt 0 ]] 89 | then 90 | #There is an issue with one or more readings, get fresh ones 91 | #then wait for the next loop to calculate again. 92 | echo "We have a problem...moving to plan B" 93 | 94 | #Get in and out octets 95 | oldin1=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.1 -Ov` 96 | oldin2=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.2 -Ov` 97 | oldin9=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.9 -Ov` 98 | oldin14=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifInOctets.14 -Ov` 99 | oldout1=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.1 -Ov` 100 | oldout2=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.2 -Ov` 101 | oldout9=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.9 -Ov` 102 | oldout14=`snmpget -v 2c -c public 192.168.9.15 IF-MIB::ifOutOctets.14 -Ov` 103 | 104 | #Strip out the value from the string 105 | oldin1=$(echo $oldin1 | cut -c 12-) 106 | oldin2=$(echo $oldin2 | cut -c 12-) 107 | oldin9=$(echo $oldin9 | cut -c 12-) 108 | oldin14=$(echo $oldin14 | cut -c 12-) 109 | oldout1=$(echo $oldout1 | cut -c 12-) 110 | oldout2=$(echo $oldout2 | cut -c 12-) 111 | oldout9=$(echo $oldout9 | cut -c 12-) 112 | oldout14=$(echo $oldout14 | cut -c 12-) 113 | else 114 | #Output the current traffic 115 | echo "Port 1 Inbound Traffic: $inbps1 Bps" 116 | echo "Port 1 Outbound Traffic: $outbps1 Bps" 117 | echo "Port 2 Inbound Traffic: $inbps2 Bps" 118 | echo "Port 2 Outbound Traffic: $outbps2 Bps" 119 | echo "Port 9 Inbound Traffic: $inbps9 Bps" 120 | echo "Port 9 Outbound Traffic: $outbps9 Bps" 121 | echo "Port 14 Inbound Traffic: $inbps14 Bps" 122 | echo "Port 14 Outbound Traffic: $outbps14 Bps" 123 | 124 | #Write the data to the database 125 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=zyxel1,interface=gig1,direction=inbound value=$inbps1" 126 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=zyxel1,interface=gig1,direction=outbound value=$outbps1" 127 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=zyxel1,interface=gig2,direction=inbound value=$inbps2" 128 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=zyxel1,interface=gig2,direction=outbound value=$outbps2" 129 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=zyxel1,interface=gig9,direction=inbound value=$inbps9" 130 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=zyxel1,interface=gig9,direction=outbound value=$outbps9" 131 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=zyxel1,interface=gig14,direction=inbound value=$inbps14" 132 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "network_traffic,host=zyxel1,interface=gig14,direction=outbound value=$outbps14" 133 | 134 | #Move the current variables to the old ones 135 | oldin1=$in1 136 | oldin2=$in2 137 | oldin9=$in9 138 | oldin14=$in14 139 | oldout1=$out1 140 | oldout2=$out2 141 | oldout9=$out9 142 | oldout14=$out14 143 | fi 144 | 145 | done 146 | -------------------------------------------------------------------------------- /temp_readings.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright (c) 2014 Adafruit Industries 4 | # Author: Tony DiCola 5 | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | import Adafruit_DHT 24 | import requests 25 | import time 26 | 27 | # Sensor should be set to Adafruit_DHT.DHT11, 28 | # Adafruit_DHT.DHT22, or Adafruit_DHT.AM2302. 29 | sensor = Adafruit_DHT.DHT22 30 | 31 | # Example using a Beaglebone Black with DHT sensor 32 | # connected to pin P8_11. 33 | #pin = 'P8_11' 34 | 35 | # Example using a Raspberry Pi with DHT sensor 36 | # connected to GPIO23. 37 | pin = 4 38 | 39 | # Try to grab a sensor reading. Use the read_retry method which will retry up 40 | # to 15 times to get a sensor reading (waiting 2 seconds between each retry). 41 | humidity, temperature = Adafruit_DHT.read_retry(sensor, pin) 42 | 43 | #Convert the temp to F 44 | temperature = 9.0/5.0 * temperature + 32 45 | 46 | #Round the temp 47 | #temperature = str(round(temperature, 1)) 48 | 49 | #Current timestamp 50 | timestamp = time.time() 51 | 52 | # Note that sometimes you won't get a reading and 53 | # the results will be null (because Linux can't 54 | # guarantee the timing of calls to read the sensor). 55 | # If this happens try again! 56 | if humidity is not None and temperature is not None: 57 | #Write the data to the database 58 | #data = 'server_stack_temp,host=rpi1,location=basement value=' + str(temperature) + ' ' + str(timestamp) 59 | data = 'server_stack_temp,host=rpi1,location=basement value=' + str(temperature) 60 | print data 61 | output = requests.post('http://192.168.9.42:8086/write?db=home', data=data) 62 | print output 63 | data = 'server_stack_humidity,host=rpi1,location=basement value=' + str(humidity) 64 | print data 65 | output = requests.post('http://192.168.9.42:8086/write?db=home', data=data) 66 | print output 67 | 68 | #Output the data to the screen 69 | print 'Temp={0:0.1f}*F Humidity={1:0.1f}%'.format(temperature, humidity) 70 | else: 71 | print 'Failed to get reading. Try again!' 72 | -------------------------------------------------------------------------------- /upsmon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #This script gets the current power information 4 | #from the main UPS 5 | 6 | #The time we are going to sleep between readings 7 | sleeptime=30 8 | 9 | #Prepare to start the loop and warn the user 10 | echo "Press [CTRL+C] to stop..." 11 | while : 12 | do 13 | 14 | #Get the current dump of the stats 15 | upsstats=`pwrstat -status` 16 | 17 | #Lets try to find the lines we are looking for 18 | while read -r line; do 19 | #Check if we have the line we are looking for 20 | if [[ $line == *"State."* ]] 21 | then 22 | state=$line 23 | fi 24 | if [[ $line == *"Power Supply by"* ]] 25 | then 26 | supply=$line 27 | fi 28 | if [[ $line == *"Utility Voltage"* ]] 29 | then 30 | involts=$line 31 | fi 32 | if [[ $line == *"Output Voltage"* ]] 33 | then 34 | outvolts=$line 35 | fi 36 | if [[ $line == *"Battery Capacity"* ]] 37 | then 38 | capacity=$line 39 | fi 40 | if [[ $line == *"Remaining Runtime"* ]] 41 | then 42 | runtime=$line 43 | fi 44 | if [[ $line == *"Load."* ]] 45 | then 46 | load=$line 47 | fi 48 | if [[ $line == *"Line Interaction"* ]] 49 | then 50 | interaction=$line 51 | fi 52 | done <<< "$upsstats" 53 | 54 | #Remove the long string of .s 55 | state=$(echo $state | tr -s '[.]') 56 | supply=$(echo $supply | tr -s '[.]') 57 | involts=$(echo $involts | tr -s '[.]') 58 | outvolts=$(echo $outvolts | tr -s '[.]') 59 | capacity=$(echo $capacity | tr -s '[.]') 60 | runtime=$(echo $runtime | tr -s '[.]') 61 | load=$(echo $load | tr -s '[.]') 62 | interaction=$(echo $interaction | tr -s '[.]') 63 | 64 | #Lets parse out thevalues from the strings 65 | #First split on the . 66 | IFS='.' read -ra statearr <<< "$state" 67 | state=${statearr[1]} 68 | IFS='.' read -ra supplyarr <<< "$supply" 69 | supply=${supplyarr[1]} 70 | IFS='.' read -ra involtsarr <<< "$involts" 71 | involts=${involtsarr[1]} 72 | IFS='.' read -ra outvoltsarr <<< "$outvolts" 73 | outvolts=${outvoltsarr[1]} 74 | IFS='.' read -ra capacityarr <<< "$capacity" 75 | capacity=${capacityarr[1]} 76 | IFS='.' read -ra runtimearr <<< "$runtime" 77 | runtime=${runtimearr[1]} 78 | IFS='.' read -ra loadarr <<< "$load" 79 | load=${loadarr[1]} 80 | IFS='.' read -ra interactionarr <<< "$interaction" 81 | interaction=${interactionarr[1]} 82 | 83 | #We need an extra split for the load 84 | IFS='(' read -ra loadarr <<< "$load" 85 | loadwatt=${loadarr[0]} 86 | loadpercent=${loadarr[1]} 87 | 88 | #Remove unneeded spaces 89 | state=$(echo $state | xargs) 90 | supply=$(echo $supply | xargs) 91 | involts=$(echo $involts | xargs) 92 | outvolts=$(echo $outvolts | xargs) 93 | capacity=$(echo $capacity | xargs) 94 | runtime=$(echo $runtime | xargs) 95 | loadwatt=$(echo $loadwatt | xargs) 96 | loadpercent=$(echo $loadpercent | xargs) 97 | interaction=$(echo $interaction | xargs) 98 | 99 | #Now we just strip off some of the unneeded 100 | #info from the end of the strings 101 | involts=${involts::-2} 102 | outvolts=${outvolts::-2} 103 | runtime=${runtime::-4} 104 | capacity=${capacity::-2} 105 | loadwatt=${loadwatt::-5} 106 | loadpercent=${loadpercent::-3} 107 | 108 | echo "$state" 109 | echo "$supply" 110 | echo "$involts" 111 | echo "$outvolts" 112 | echo "$runtime" 113 | echo "$capacity" 114 | echo "$loadwatt" 115 | echo "$loadpercent" 116 | echo "$interaction" 117 | 118 | #Finally we can write it to the database 119 | #curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ups_stats,ups=primary_stack,metric=state value=$state" 120 | #curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ups_stats,ups=primary_stack,metric=supply value=$supply" 121 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ups_stats,ups=primary_stack,metric=involts value=$involts" 122 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ups_stats,ups=primary_stack,metric=outvolts value=$outvolts" 123 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ups_stats,ups=primary_stack,metric=runtime value=$runtime" 124 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ups_stats,ups=primary_stack,metric=capacity value=$capacity" 125 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ups_stats,ups=primary_stack,metric=loadwatt value=$loadwatt" 126 | curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ups_stats,ups=primary_stack,metric=loadpercent value=$loadpercent" 127 | #curl -i -XPOST 'http://localhost:8086/write?db=home' --data-binary "ups_stats,ups=primary_stack,metric=interaction value=$interaction" 128 | 129 | #Wait for a bit before checking again 130 | sleep "$sleeptime" 131 | 132 | done 133 | --------------------------------------------------------------------------------