summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xnoprml/noprml.lua31
-rwxr-xr-xnopsyncd/nopsyncd.lua21
2 files changed, 52 insertions, 0 deletions
diff --git a/noprml/noprml.lua b/noprml/noprml.lua
new file mode 100755
index 0000000..963f667
--- /dev/null
+++ b/noprml/noprml.lua
@@ -0,0 +1,31 @@
+#!/usr/bin/lua
+
+local queue_name = "/rhnop"
+
+mq = require "luamq"
+
+local p = assert(io.popen("/bin/date --utc '+%s %N'" , 'r'))
+local time = assert(p:read('*l'))
+p:close()
+local s, ns = assert(string.match(time, "([0-9]+) ([0-9]+)"))
+
+timestamp = s*1000 + math.floor(ns/1000000)
+
+if #arg < 4 then
+ io.stderr:write("too few parameters")
+ os.exit(1)
+end
+
+local q, err = mq.create(queue_name, "wo")
+if q == nil then
+ io.stderr:write("creation of message queue failed: " .. err)
+ os.exit(1)
+end
+
+local result, err = mq.send(q, timestamp .. " " .. arg[1] .. " " .. arg[2] .. " " .. arg[3] .. " " .. arg[4], 0)
+if result == nil then
+ io.stderr:write("sending message failed: " .. err)
+ os.exit(2)
+end
+
+mq.close(q) \ No newline at end of file
diff --git a/nopsyncd/nopsyncd.lua b/nopsyncd/nopsyncd.lua
new file mode 100755
index 0000000..5ac1acb
--- /dev/null
+++ b/nopsyncd/nopsyncd.lua
@@ -0,0 +1,21 @@
+#!/usr/bin/lua
+
+local queue_name = "/rhnop"
+
+mq = require "luamq"
+
+local q, err = mq.create(queue_name, "ro")
+if q == nil then
+ io.stderr:write("creation of message queue failed: " .. err .. "\n")
+ os.exit(1)
+end
+
+while true do
+ local msg, prio = mq.receive(q)
+ if msg == nil then
+ io.stderr:write("recv error: " .. prio .. "\n")
+ os.exit(2)
+ end
+
+ print("received message '" .. msg .. "' with prio: " .. prio)
+end