2017-11-09 2 views
0

파이썬에서 rrdtool 라이브러리를 사용하고 있습니다. 같은 python 스크립트가 하루 만에 데이터를 반환했지만 갑자기 생성 된 튜플 안에 None 개체가 반환됩니다. rrd 파일이 수정되지 않았습니다. 리턴 된 타입은 튜플과 심지어 rrdinfo가 인쇄되는 경우입니다. 제 시간에 여유를 가지고 조사하십시오.rrdtool 가져 오기 반환 없음 객체

import sys 
    import pprint 
    sys.path.append('/opt/plexus-srv/rrdtool-1.4.9/lib64/python2.6/site- 
    packages') 
    import rrdtool 
    rrd_file = sys.argv[1] 
    rrd_info = rrdtool.info(rrd_file) 

    data = rrdtool.fetch(rrd_file,"AVERAGE") 
    print(type(data)) 
    pp = pprint.PrettyPrinter(indent =4) 
    pp.pprint(data) 
    pp.pprint(rrd_info) 

출력은 다음과 같습니다

<type 'tuple'> 
('sum',) 
1510142400 
[(None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,)] 
    { 'ds[sum].index': 0L, 
    'ds[sum].last_ds': '99.3', 
    'ds[sum].max': None, 
    'ds[sum].min': None, 
    'ds[sum].minimal_heartbeat': 120L, 
    'ds[sum].type': 'GAUGE', 
    'ds[sum].unknown_sec': 0L, 
    'ds[sum].value': 1290.8999999999999, 
    'filename': '/home/u43555766/aad/plexus/rrdsample/testing/cpu/cpu_idle.rrd', 
    'header_size': 1416L, 
    'last_update': 1510030543L, 
    'rra[0].cdp_prep[0].unknown_datapoints': 0L, 
    'rra[0].cdp_prep[0].value': None, 
    'rra[0].cf': 'AVERAGE', 
    'rra[0].cur_row': 49L, 
    'rra[0].pdp_per_row': 1L, 
    'rra[0].rows': 490L, 
    'rra[0].xff': 0.5, 
    'rra[1].cdp_prep[0].unknown_datapoints': 0L, 
    'rra[1].cdp_prep[0].value': 198.78666666666669, 
    'rra[1].cf': 'AVERAGE', 
    'rra[1].cur_row': 2264L, 
    'rra[1].pdp_per_row': 4L, 
    'rra[1].rows': 2890L, 
    'rra[1].xff': 0.5, 
    'rra[2].cdp_prep[0].unknown_datapoints': 0L, 
    'rra[2].cdp_prep[0].value': 198.78666666666669, 
    'rra[2].cf': 'AVERAGE', 
    'rra[2].cur_row': 873L, 
    'rra[2].pdp_per_row': 20L, 
    'rra[2].rows': 2026L, 
    'rra[2].xff': 0.5, 
    'rra[3].cdp_prep[0].unknown_datapoints': 0L, 
    'rra[3].cdp_prep[0].value': 22058.293333333328, 
    'rra[3].cf': 'AVERAGE', 
    'rra[3].cur_row': 387L, 
    'rra[3].pdp_per_row': 240L, 
    'rra[3].rows': 754L, 
    'rra[3].xff': 0.5, 
    'rra[4].cdp_prep[0].unknown_datapoints': 0L, 
    'rra[4].cdp_prep[0].value': 117354.74000000028, 
    'rra[4].cf': 'AVERAGE', 
    'rra[4].cur_row': 214L, 
    'rra[4].pdp_per_row': 5760L, 
    'rra[4].rows': 375L, 
    'rra[4].xff': 0.5, 
    'rrd_version': '0003', 
    'step': 15L} 

답변

1

질문에 대한 가장 확실한 대답은 반환 할 데이터가없는 것입니다.

RRD 파일에 데이터를 추가했는지 여부는 사용자가 말하지 않습니다. 'fetch'호출에는 해상도, 시작 또는 종료를 지정하는 매개 변수가 없으므로 기본값은 1 일로 끝나고 5 분 후에 종료됩니다. 당신은 RRA와 일치하지만, 거기에 데이터가 있는지 알 수 없습니다.

제공 한 데이터를 보면 1510142400 시간에 가져 오기를 실행하고 있지만 RRD 마지막 업데이트는 약 31 시간 더 일찍 1510030543에 있었던 것으로 보입니다. 아마 마지막 날에 데이터가 없습니까?

명령 줄에서 'rrdtool fetch'및 'rrdtool dump'를 실행하고 데이터가 저장되어 있는지 그리고 생각한 시간 동안인지 확인하십시오. 어쩌면 'fetch'에 추가 매개 변수를 전달하여 step, start 및 end를 지정할 수 있습니다.

0

나는 rrdtool을 처음 사용하므로 데이터 수집을위한 시작 시간을 놓쳤다는 것을 알지 못했습니다. 이 파일은 며칠 전 서버로 제공됩니다. 가져 오기 명령에 '-s'시간이 없어서 None Object가 인쇄되었습니다. '-s'에 '-96h'를 추가하면 데이터가 인쇄됩니다. @ steve-shipway 덕분에