unified dashboard

image this guide will provide you with information on how to have a unified dashboard using grafana. the items which are unified are as follows:

the base of this dashboard uses varken’s dashboard which has been heavily modified to suit my own needs and requirements. you will need to first install the following items before you begin.

jump straight to…

ssh commands required
majority of the ssh commands requires nano or vim. my choice of a terminal editor would be nano. to find out more how to use nano, visit the following page to get the basics. i had this installed on my macOS server.

look out for notes
notes are placed in the guides, these markers requires your attention.

report inaccuracies and errors
if something in this guide is inaccurate, wrong, or outdated, report it by scanning the qr code.


⚑ [pre-requisites]

this guide assumes that you have already installed the following into your systems:


πŸ‘¨πŸ»β€πŸ’» [configuring influxdb to accept opentsdb]

  1. launch your terminal.app and edit your influxdb:

     nano /usr/local/etc/influxdb.conf
  2. do a search for opentsdb using ctrl+w. once you locate that, enable it by uncommenting and amending the following information:

     [[opentsdb]]
         enabled = true
         bind-address = ip.of.your.macOS.influxdb:4242
         database = "opentsdb"       
  3. save the file and then restart your influxdb using the brew command:

     brew services restart influxdb
  4. create the opentsdb database in influx. type the following commands in sequence:

     influx
     create database opentsdb 
     show databases
  1. that’s the configuration for influxdb.

πŸ‘¨πŸ»β€πŸ’» [getting netdata to pipe data into influxdb]

  1. ssh into you device (synology/macOS) and then locate the netdata.conf file. this file is normally stored in the following directory:
  1. edit the netdata.conf using nano or vim:
    nano /usr/local/etc/netdata/netdata.conf
  1. include the following lines:

     [backend]
                 enabled = yes
                 type = opentsdb
                 destination = tcp:ip.address.of.macOS.influxdb:4242
  2. you will need to do the same for your synology netdata.conf file.

  3. restart netdata:

     killall netdata
     /opt/netdata/bin/netdata

πŸ‘¨πŸ»β€πŸ’» [setting up a opentsdb datasource in grafana]

  1. login to your grafana dashboard and add a new datasource.

  2. choose influxdb and add the following:

image

  1. add the datasource, if you had your influxdb.conf configured correctly, the save and test will produce a successful result.

πŸ‘¨πŸ»β€πŸ’» [configuring synologystats.sh]

  1. create the synobox database in influxdb. open a terminal.app and login to your macOS, type the following in sequence:

     influx
     create database synobox
     show databases
  1. login to your synology dsm and then enable snmp if you have not done so.
  1. ssh into your synology box and create a folder for the synology script.

     mkdir /volume1/synologyscript
  2. create the script using nano or vim.

     nano /volume1/synologyscript/synologystats.sh
  3. paste the following script and ensure that you replace public with your snmp trap name if you changed it. ipaddressofyournas refers to your synology ip and ipaddressofyourmacinfluxdb to your macOS influxdb ip. change numdrives=x to the number of drives that corresponds to the number of drives on your synology

#!/bin/bash

#This script pulls storage information from the Synology NAS

#The time we are going to sleep between readings
#Also used to calculate the current usage on the interface
#30 seconds seems to be ideal, any more frequent and the data
#gets really spikey.  Since we are calculating on total octets
#you will never loose data by setting this to a larger value.
sleeptime=30


get_drive_temps () {
    counter=0
    numdrives=10
    while [  $counter -lt $numdrives ]; do

        #Get Drive Name
        syno_drivename=`snmpwalk -v 2c -c public IPADDRESSOFYOURNAS 1.3.6.1.4.1.6574.2.1.1.2.$counter -Ov | cut -c 10-`
        syno_drivename=${syno_drivename::-1}
        syno_drivename=${syno_drivename// /_}

        #Get Health Status
        syno_healthstatus=`snmpwalk -v 2c -c public IPADDRESSOFYOURNAS 1.3.6.1.4.1.6574.2.1.1.5.$counter -Ov | cut -c 10-`

        #Get Health Status
        syno_drivetemps=`snmpwalk -v 2c -c public IPADDRESSOFYOURNAS 1.3.6.1.4.1.6574.2.1.1.6.$counter -Ov | cut -c 10-`

        echo "Drive Name: $syno_drivename"
        echo "Health Status: $syno_healthstatus"
        echo "Drive Temps: $syno_drivetemps"

        # write to database here
        curl -i -XPOST 'http://IPADDRESSOFYOURMACINFLUXDB:8086/write?db=synobox' --data-binary "storage_data,host=synology,diskname=$syno_drivename disktemperature=$syno_drivetemps"
        curl -i -XPOST 'http://IPADDRESSOFYOURMACINFLUXDB:8086/write?db=synobox' --data-binary "storage_data,host=synology,diskname=$syno_drivename diskstatus=$syno_healthstatus"

        let counter=counter+1
        done
    }

get_syno_temp () {
    COUNTER=0
    while [  $COUNTER -lt 4 ]; do
        #-- Synology NAS --
        #DS Temp
        syno_temperature=`snmpwalk -v 2c -c public IPADDRESSOFYOURNAS 1.3.6.1.4.1.6574.1.2 -Ov | cut -c 10-`

        echo "Synology Temperature: $syno_temperature"


        curl -i -XPOST 'http://IPADDRESSOFYOUMACINFLUXDB:8086/write?db=synobox' --data-binary "syno_temperature,host=synology,temperature=Synology_Temperature value=$syno_temperature"

        let COUNTER=COUNTER+1

    done
}
      
      
#Prepare to start the loop and warn the user
echo "Press [CTRL+C] to stop..."
while :
    do
        get_drive_temps
        get_syno_temp

        if [[ $syno_volblocksize -le 0 || $syno_volcapacity -le 0 || $syno_volused -le 0 ]];
then
        echo "Skip this datapoint - something went wrong with the read"
else
        #Output console data for future reference
        print_data
        write_data
fi

    if [[ $syno_temp -le 0 ]];
        then
        echo "Skip this datapoint - something went wrong with the read"
else
        #Output console data for future reference
        print_data
        write_data
fi

    #Sleep between readings
    sleep "$sleeptime"

done
  1. save the file.

  2. you will now need to make the file executable. use the following command:

     chmod a+x /volume1/synologyscript/synologystats.sh 
  3. to execute the file, you will need to run it via a ./ command. how i did it was to run it off my mac, via screen. first ssh into your macOS server and type the following:

     screen
  4. now still in the screen box, ssh into your macOS box.

     ssh -l admin synology.ip
  5. login as root using the sudo -i command and then navigate to the synologystats.sh script folder:

    cd /volume1/synologyscript/
  6. execute the script:

    ./synologystats.sh
  7. once done, on your keyboard, hold on ctrl and press a and d to detach. to bring up the screen again, type screen -r.


πŸ‘¨πŸ»β€πŸ’» [setting up synobox datasource in grafana]

  1. login to your grafana dashboard and add a new datasource.

  2. choose influxdb and add the following:

image

  1. done

πŸ‘¨πŸ»β€πŸ’» [configuring new panels with netdata and synobox and unifipoller]

  1. login to your grafana dashboard and load your current dashboard. create a copy of your existing dashboard.
  1. at the top pane, click on add panel, when presented with the new panel, click on + add panel

  2. from the drop down menu, choose the influxdb that you wish to utilise.

image

  1. choose the information from the queries below to configure what you want to get grafana to display. choose your visualisation, frequency, etc. once done, click on apply and save and your dashboard will be display these new items of your choice.

image

  1. have fun! 😊