carbolymer / mtr-monitor

Simple MTR runner with grafana and influxdb on board
65 stars 16 forks source link

I don't want use docker #4

Open pangqiss1986 opened 5 years ago

pangqiss1986 commented 5 years ago

dear: THE mtr monitor is very good!.BUT I don't want to use docker. Now I install influxdb.How can I create database ,tables,column? and THE save_data.py hava you python2 ? Thank you!

carbolymer commented 5 years ago

check available options here: https://github.com/carbolymer/mtr-monitor/blob/master/mtr-monitor.sh#L10

You don't need to create schema in influxdb. Everything is done in https://github.com/carbolymer/mtr-monitor/blob/master/save_data.py

You just need to set correct port and host in mtr-monitor.sh

pangqiss1986 commented 5 years ago

this is my mtr-monitor.sh

!/bin/bash

number of pings sent

CYCLES=30

inverval between MTR tests in seconds

INTERVAL=30 MTR_HOSTS=("114.114.114.114")

if you need to change it, change also in influx-cli.sh

INFLUXDB_HOST="localhost" INFLUXDB_PORT=8086

END OF CONFIG

function monitor_mtr() { for MTR_HOST in "${MTR_HOSTS[@]}"; do ( mtr --report --json --report-cycles $CYCLES $MTR_HOST | ./save_data.py --host $INFLUXDB_HOST --port $INFLUXDB_PORT ) & done }

which mtr &>/dev/null if [ $? -eq 1 ]; then echo "mtr is not available on this system - it is required for this script to work" exit 1 fi

while true; do monitor_mtr sleep $INTERVAL done

THE save_data.py must use python3?

carbolymer commented 5 years ago

looks fine, and yes you should use python 3

pangqiss1986 commented 5 years ago

THANK YOU!

pangqiss1986 commented 5 years ago

sorry,I have two question.... NO.1: (py3) [root@localhost mtr]# ./mtr-monitor.sh mtr: unrecognized option '--json' mtr: unrecognized option '--json' mtr: unrecognized option '--json' mtr: unrecognized option '--json' Traceback (most recent call last): File "./save_data.py", line 65, in main() File "./save_data.py", line 38, in main mtr_result = json.load(sys.stdin) File "/usr/local/lib/python3.6/json/init.py", line 299, in load parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) File "/usr/local/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

NO.2 grafana version is 6.1.4 THE grafana_dashboard_mtr.json import is Templating init failed Datasource named ${DS_TBD_INFLUX MTR} was not found

can you help me...thank!!!

carbolymer commented 5 years ago
  1. which mtr version you have? you need >=0.87

  2. You need to setup datasource manually in grafana

pangqiss1986 commented 5 years ago

the grafana_dashboard_mtr.json import is not support grafana6.1.4.....

teesa-git commented 5 years ago

@pangqiss1986 @carbolymer The same quessiton No.1