netdata_tsrelay.nim
changeset 4 f3d83bdd7877
parent 1 160338bb2822
child 5 a1276c3d39eb
equal deleted inserted replaced
3:f34855556f4d 4:f3d83bdd7877
   127         client.close
   127         client.close
   128     except OSError:
   128     except OSError:
   129         return
   129         return
   130 
   130 
   131     var samples = parse_data( raw_data )
   131     var samples = parse_data( raw_data )
       
   132     if samples.len == 0: return
       
   133 
       
   134     db.exec sql( "BEGIN" )
   132     for timestamp, sample in samples:
   135     for timestamp, sample in samples:
   133         var host = sample[ "hostname" ].get_str
   136         var host = sample[ "hostname" ].get_str
   134         sample.delete( "hostname" )
   137         sample.delete( "hostname" )
   135         db.exec sql( INSERT_SQL ), timestamp, host, sample
   138         db.exec sql( INSERT_SQL ), timestamp, host, sample
       
   139     db.exec sql( "COMMIT" )
   136 
   140 
   137 proc serverloop: void =
   141 proc serverloop: void =
   138     ## Open a database connection, bind to the listening socket,
   142     ## Open a database connection, bind to the listening socket,
   139     ## and start serving incoming netdata streams.
   143     ## and start serving incoming netdata streams.
   140     let db = open( "", "", "", conf.dbopts )
   144     let db = open( "", "", "", conf.dbopts )