openwisp / openwrt-openwisp-monitoring

OpenWRT monitoring agent for openwisp-monitoring
https://openwisp.io/docs/dev/openwrt-monitoring-agent/
GNU General Public License v3.0
23 stars 20 forks source link

[refactor] Use utility function for calling popen() properly #61

Open nemesifier opened 3 years ago

nemesifier commented 3 years ago

It would be good to create a utility function which does the read, close and returning of the output when using io.popen().

This would also ensure that whoever will put their hands on this code will keep reusing our function and avoid messing it up again by forgetting to close a pipe.

devkapilbansal commented 3 years ago

The current problem I am facing with this is that if we create a function in monitoring_utils.lua and load it, then the io defined in first table, TestNeighbor or TestInterface is getting used by the next one, i.e. TestNetJSON

Opened a thread here:- https://www.luaforum.com/threads/not-able-to-mock-io-library.505/

Saurabh-Mokashi commented 2 years ago

Hi, would like to contribute to this issue