summaryrefslogtreecommitdiffstats
path: root/squid-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'squid-model.lua')
-rw-r--r--squid-model.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/squid-model.lua b/squid-model.lua
new file mode 100644
index 0000000..c61a4e7
--- /dev/null
+++ b/squid-model.lua
@@ -0,0 +1,40 @@
+-- acf model for squid
+-- Copyright(c) 2007 A. Brodmann - Licensed under terms of GPL2
+module (..., package.seeall)
+
+get_status = function()
+
+ local retval = "stopped"
+
+ local ptr = io.popen( "/bin/pidof squid" )
+ local pid = ptr:read( "*a" )
+ ptr:close()
+ if pid ~= nil then
+ if #pid > 1 then
+ retval = "running"
+ end
+ end
+
+ return retval
+end
+
+service_control = function( control )
+
+ local retval = ""
+
+ local ptr = io.popen( "/etc/init.d/squid " .. control, "r" )
+ if ptr ~= nil then
+ local retmsg = ptr:read( "*a" )
+ ptr:close()
+ if retmsg ~= nil then
+ retval = retmsg
+ else
+ retval = "service_control(): Failed to read output from initscript!\n"
+ end
+ else
+ retval = "service_control(): Failed to start/stop/restart service!\n"
+ end
+
+ return retval
+end
+