From fdaabc7081521eb96cd9c6b2a9585045b94289f6 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 2 Jan 2013 00:15:04 +0000 Subject: Replaced one io.popen with modelfunctions.run_executable and removed two others --- rrdtool-model.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rrdtool-model.lua b/rrdtool-model.lua index d625ebc..2a52102 100644 --- a/rrdtool-model.lua +++ b/rrdtool-model.lua @@ -112,9 +112,9 @@ end function rrd_info(self, path, userid) local success, errtxt if (validfilename(path)) then - local f = io.popen( "/usr/bin/rrdtool info ".. tostring(path) .. " 2>&1" ) - success = f:read("*a") or "" - f:close() + success, errtxt = modelfunctions.run_executable({"rrdtool", "info", path}, true) + else + errtxt = "Invalid filename" end return cfe({ value=success, label="rrdtool info ".. tostring(path) , errtxt=errtxt }) end @@ -159,9 +159,7 @@ If you specify path, it should be " .. tostring(databases) .."/" local cmd = "/usr/bin/rrdtool create ".. format.escapespecialcharacters(path) .. " " .. format.escapespecialcharacters(start) .. format.escapespecialcharacters(step) .. tostring(string.gsub(format.dostounix(format.escapespecialcharacters(configfile.value.ds.value)),"\n", " \\\n")) .. " " .. tostring(string.gsub(format.dostounix(format.escapespecialcharacters(configfile.value.rra.value)),"\n", " \\\n")) - local f = io.popen("date") - local createdate = f:read("*l") or "" - f:close() + local createdate = os.date() local cmd_descr = "#!/bin/sh\n# " .. tostring(createdate) .. "\n# This file can be used to recreate '" .. tostring(path) .. "'\n\n" .. string.gsub(string.gsub(cmd," RRA", " \\\nRRA")," DS", " \\\nDS") local filedetails={} @@ -235,9 +233,7 @@ function view_graph(self, graph_grp, graph_id) local cmd = "/usr/bin/rrdtool graph /usr/share/acf/www" .. tostring(filename) .. " " - local f = io.popen("date") - local imagedate = f:read("*l") or "" - f:close() + local imagedate = os.date() cmd = cmd .. tostring(settings.value) .. " --title '" .. tostring(settings.label) .. " - " .. tostring(settings.descr) .. "' -W '" .. tostring(imagedate) .. "'" settings.cmd_query = cmd -- cgit v1.2.3