summaryrefslogtreecommitdiff
path: root/rhnop-client/nopsysstated
diff options
context:
space:
mode:
Diffstat (limited to 'rhnop-client/nopsysstated')
-rwxr-xr-xrhnop-client/nopsysstated71
1 files changed, 0 insertions, 71 deletions
diff --git a/rhnop-client/nopsysstated b/rhnop-client/nopsysstated
deleted file mode 100755
index d303cbe..0000000
--- a/rhnop-client/nopsysstated
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/lua
---
--- rhnop
---
--- Copyright (C) 2011-2014 Christian Pointner <equinox@helsinki.at>
---
--- This file is part of rhnop.
---
--- rhnop is free software: you can redistribute it and/or modify
--- it under the terms of the GNU General Public License as published by
--- the Free Software Foundation, either version 3 of the License, or
--- any later version.
---
--- rhnop is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License
--- along with rhnop. If not, see <http://www.gnu.org/licenses/>.
---
---
--- send now and next cart# and length to nopsyncd
--- this script should be called by the now/next macro cart
--- the arguments should be: now# nowlen next# nextlen
---
-
-require "socket"
-
-package.path = package.path .. ";_rhnoplibdir_/?.lua"
-db = require "db"
-
-conffile = "nopsysstated.conf"
-conf = require "conf"
-
-db = assert(db.init(conf.db_db, conf.db_user, conf.db_pwd, conf.db_host, conf.db_port, conf.db_table))
-
-local sock = assert(socket.tcp())
-local ret, err = sock:connect(conf.host, conf.port)
-if ret == nil then
- print(err)
- return 1
-end
-print "connection established"
-
-local current_state, err = db:getLastSysState()
-if current_state == nil then
- print(err)
- return 1
-end
-print("current state according to db is " .. current_state)
-
-while true do
- local state = sock:receive('*l')
- if state == nil then break end
- if state ~= current_state then
- -- reading timestamp (milliseconds since epoch)
- 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]+)"))
- local timestamp = s .. string.format("%06d", math.floor(ns/1000))
-
- assert(db:updateSysState(timestamp, state))
- current_state = state
- end
-end
-
-sock:close()
-
-return 0