LowPowerLab Forum

Software support => Pi Gateway => Topic started by: Lensdigital on February 14, 2016, 08:46:36 PM

Title: Metric not graphing/logging for one of the nodes
Post by: Lensdigital on February 14, 2016, 08:46:36 PM
I have several "weather" nodes which send V (battery), C (temperature) and H (Humidity) data. One of the nodes stopped graphing battery values about 2 weeks ago (I just noticed today). Data is still coming in, but it won't get recorded to .bin file in DB, only for that node...
Option to turn on/off graph actually is missing in the GUI, I only have "Show on Dashboard" and "Delete" options. Is there any way to get Data Log option for this node?
I tried removing associated bin file (0005_V.bin) but it didn't help...
Title: Re: Metric not graphing/logging for one of the nodes
Post by: Felix on February 16, 2016, 11:07:09 AM
Quote from: Lensdigital on February 14, 2016, 08:46:36 PM
One of the nodes stopped graphing battery values about 2 weeks ago (I just noticed today).

V is not graphed by default.
Did you make any updates to your source code?
What else has changes since "it stopped graphing" ?
Title: Re: Metric not graphing/logging for one of the nodes
Post by: Lensdigital on February 16, 2016, 02:49:54 PM
Only thing I've done that day was change "logValue" to 2 on my Mailbox metric.
Mbox_open : { name:'MBox', regexp:/MBOX\:O/i, value:'OPENED', pin:1, graph:1, logValue:2, graphOptions:{ legendLbl:'Mailbox', lines: { show:false, fill:false }, points: { show: true, radius: 5, lineWidth:1 }, grid: { backgroundColor: {colors:['#000', '#03c', '#08c']}}, yaxis: { ticks: 0 }}},

I just tried changing V: metric, but it didn't do anything. Here's what I have:

//V : { name:'V', regexp:/(?:V?BAT|VOLTS|V)\:(\d\.\d+)v?/i, value:'', unit:'v'},
  V : { name:'V', regexp:/(?:V?BAT|VOLTS|V)\:(\d\.\d+)v?/i, value:'', unit:'v',pin:1, graph:1, graphValSuffix:'V', graphOptions:{ legendLbl:'Battery' }},
 


Strangely it works for other nodes...
Title: Re: Metric not graphing/logging for one of the nodes
Post by: Lensdigital on February 16, 2016, 03:13:47 PM
Hey I got something. After I stopped and started gateway (instead of pkill node), graph now shows up, but it won't update. I get this error in the log:

[02-16-16_15:11:27.379] [LOG]   post: /home/pi/gateway/data/db/0005_V.bin[1455653487,2.79]
[02-16-16_15:11:27.381] [LOG]      POST ERROR: undefined

I tried to "wash the slate clean" and removed 0005_V.bin file, hoping that system will create a fresh one. It kind of did, but first I got this error when I attempted to view graph:


[02-16-16_15:31:12.839] [ERROR] Missing error handler on `socket`.
[02-16-16_15:31:12.861] [ERROR] Error: ENOENT, no such file or directory '/home/pi/gateway/data/db/0005_V.bin'
    at Object.fs.openSync (fs.js:427:18)
    at Object.exports.getData (/home/pi/gateway/logUtil.js:30:11)
    at Socket.<anonymous> (/home/pi/gateway/gateway.js:343:27)
    at Socket.EventEmitter.emit (events.js:106:17)
    at Socket.onevent (/home/pi/gateway/node_modules/socket.io/lib/socket.js:330:8)
    at Socket.onpacket (/home/pi/gateway/node_modules/socket.io/lib/socket.js:290:12)
    at Client.ondecoded (/home/pi/gateway/node_modules/socket.io/lib/client.js:193:14)
    at Decoder.Emitter.emit (/home/pi/gateway/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/index.js:134:20)
    at Decoder.add (/home/pi/gateway/node_modules/socket.io/node_modules/socket.io-parser/index.js:247:12)
    at Client.ondata (/home/pi/gateway/node_modules/socket.io/lib/client.js:175:18)

After which whole gateway basically stopped working, until I restarted it.
I checked db folder and file did get created.
After restart it appears to be working! I lost previous data, but it's logging new data now. I guess that .db file got corrupted.
Felix if you interested I can send you the file.  Anyway in case someone has "misbihaving" node and wants to do a "lossy" reset do this:
1. Stop gateway (sudo stop gateway)
2. go to ~/gateway/data/db and move .bin file for metric that you want to reset out of this folder.
3. Start gateway (sudo start gateway) and wait for data to come in, or try viewing graph. Gateway will probably crash (will stop showing new updates on the web page).
4. Restart gateway (sudo stop gateway, sudo start gateway). Check that new .bin file got created.

There might be a better way to do this, but so far that's what I got :)
Title: Re: Metric not graphing/logging for one of the nodes
Post by: Felix on February 16, 2016, 04:23:47 PM
Hard to say what really happened, or actually why. The file was attempted to be opened. If you look at the openSync spec (https://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback) the 'r' mode will generate an exception if the file does not exist. If the file was there and you deleted it manually, that might have triggered it.

However I think this might be a bug, I have to look into it. I have to ensure the app would not crash even if the log gets deleted.
Thanks for posting the details, it helps.
Title: Re: Metric not graphing/logging for one of the nodes
Post by: Felix on February 17, 2016, 04:03:57 PM
Yup this was a bug. But it only would happen when you have an existing log, and manually delete the .bin file with the log data.
It is now fixed with v8.3 (https://github.com/LowPowerLab/RaspberryPi-Gateway/commit/5190620f0638103506091b86f5b89db91f586e0f).
Title: Re: Metric not graphing/logging for one of the nodes
Post by: Lensdigital on February 17, 2016, 04:10:31 PM
Quote from: Felix on February 17, 2016, 04:03:57 PM
Yup this was a bug. But it only would happen when you have an existing log, and manually delete the .bin file with the log data.
It is now fixed with v8.3 (https://github.com/LowPowerLab/RaspberryPi-Gateway/commit/5190620f0638103506091b86f5b89db91f586e0f).
Awesome! Thanks Felix!
Title: Re: Metric not graphing/logging for one of the nodes
Post by: mirko.ugolini on March 06, 2016, 01:54:14 AM
Hello Felix,

I have the same problem in metric and graph visualizzation:

I downloded  the last image than I upgraded  files using the last Githab v8.4

I build a Maibox Node  with ID 55

The strange thing is the the RSSI is updated  but the  metric and the graph is not:


LastOpen   47d2H
Motion   47d15h
Battery  47d2h



but how you can see from the attached  Log the gateway received the right metrics.

for debuggin I placed  console.log('UPDATENODE:', entry);   in   index.html


socket.on('UPDATENODE', function(entry) {
      console.log('UPDATENODE:', entry);
      updateNode(entry);
      refreshNodeListUI();
});


you can see the result in the console.png atthached


what is wrong?



Let me know Please,

Thanks in advance

Mirko
Title: Re: Metric not graphing/logging for one of the nodes
Post by: Felix on March 06, 2016, 07:21:43 PM
Mirko,
What does the message you send from the node look like?