Mailinglist Archive: yast-commit (883 mails)

< Previous Next >
[yast-commit] rest-service : branch, master, updated.
  • From: git version control <git@xxxxxxxxxxxxxxxx>
  • Date: Fri, 03 Jul 2009 12:07:43 +0200
  • Message-id: <E1MMfgF-0000pt-34@xxxxxxxxxxxxxxxx>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "YaST web service".

The branch, master has been updated
via 85c30f654261f5e9f2a31df97468f828df77f270 (commit)
via d84f858b0d1d3c09d3bcd0953f9ad41c79fd3c8e (commit)
via 21ab651d22999131e3d958f657650250bf26fceb (commit)
from 609660883c049471d8c5e23ed4c50eb55991fe2b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 85c30f654261f5e9f2a31df97468f828df77f270
Author: Bjoern Geuken <bgeuken@xxxxxxx>
Date: Fri Jul 3 12:06:20 2009 +0200

Revert "status module: fixed hardcoded datapath"

This reverts commit d84f858b0d1d3c09d3bcd0953f9ad41c79fd3c8e.

Conflicts:

commit d84f858b0d1d3c09d3bcd0953f9ad41c79fd3c8e
Author: Bjoern Geuken <bgeuken@xxxxxxx>
Date: Fri Jul 3 12:04:13 2009 +0200

status module: fixed hardcoded datapath

commit 21ab651d22999131e3d958f657650250bf26fceb
Author: Bjoern Geuken <bgeuken@xxxxxxx>
Date: Fri Jul 3 11:22:37 2009 +0200

status modul: initial checkin
requires collectd and rrdtool

-----------------------------------------------------------------------

Summary of changes and diff:
.../app/controllers/.status_controller.rb.swp | Bin 0 -> 12288 bytes
.../status/app/controllers/status_controller.rb | 45 ++++++++
plugins/status/app/models/.status.rb.swp | Bin 0 -> 20480 bytes
plugins/status/app/models/status.rb | 111 ++++++++++++++++++++
plugins/status/app/views/status/show.html.erb | 2 +
plugins/status/app/views/status/show.xml.erb | 2 +
plugins/status/config/resources/status.yml | 3 +
.../package/org.opensuse.yast.system.status.policy | 24 ++++
.../package/yast2-webservice-status.spec} | 14 ++--
9 files changed, 194 insertions(+), 7 deletions(-)
create mode 100644 plugins/status/app/controllers/.status_controller.rb.swp
create mode 100644 plugins/status/app/controllers/status_controller.rb
create mode 100644 plugins/status/app/models/.status.rb.swp
create mode 100644 plugins/status/app/models/status.rb
create mode 100644 plugins/status/app/views/status/show.html.erb
create mode 100644 plugins/status/app/views/status/show.xml.erb
create mode 100644 plugins/status/config/resources/status.yml
create mode 100644
plugins/status/package/org.opensuse.yast.system.status.policy
copy plugins/{securities/package/yast2-webservice-security.spec =>
status/package/yast2-webservice-status.spec} (88%)

diff --git a/plugins/status/app/controllers/.status_controller.rb.swp
b/plugins/status/app/controllers/.status_controller.rb.swp
new file mode 100644
index 0000000..25b72c7
Binary files /dev/null and
b/plugins/status/app/controllers/.status_controller.rb.swp differ
diff --git a/plugins/status/app/controllers/status_controller.rb
b/plugins/status/app/controllers/status_controller.rb
new file mode 100644
index 0000000..f3e3416
--- /dev/null
+++ b/plugins/status/app/controllers/status_controller.rb
@@ -0,0 +1,45 @@
+include ApplicationHelper
+
+require 'scr'
+
+class StatusController < ApplicationController
+ before_filter :login_required
+
+ public
+ # POST /status
+ # POST /status.xml
+ def create
+ end
+
+ # GET /status
+ # GET /status.xml
+ def index
+ show
+ end
+
+ # GET /status/1
+ # GET /status/1.xml
+ def show
+ unless permission_check("org.opensuse.yast.system.status.read")
+ render ErrorResult.error(403, 1, "no permission") and return
+ else
+ @status = Status.new
+ @status.collect_data("11:13,07/03/2009", "11:14,07/03/2009", %w{cpu
memory disk})
+# @status.collect_data(params[:start], params[:stop], params[:data])
+ #logger.debug "SHOW: #{@status.inspect}"
+ end
+ end
+
+ # PUT /status/1
+ # PUT /status/1.xml
+ def update
+ unless permission_check("org.opensuse.yast.system.status.read")
+ render ErrorResult.error(403, 1, "no permission") and return
+ else
+ @status = Status.new
+ @status.collect_data(params[:start], params[:stop], params[:data])
+ #logger.debug "SHOW: #{@status.inspect}"
+ end
+ end
+
+end
diff --git a/plugins/status/app/models/.status.rb.swp
b/plugins/status/app/models/.status.rb.swp
new file mode 100644
index 0000000..4c5c55c
Binary files /dev/null and b/plugins/status/app/models/.status.rb.swp differ
diff --git a/plugins/status/app/models/status.rb
b/plugins/status/app/models/status.rb
new file mode 100644
index 0000000..5f7196c
--- /dev/null
+++ b/plugins/status/app/models/status.rb
@@ -0,0 +1,111 @@
+class Status
+ require 'scr'
+
+ def to_xml(options = {})
+ xml = options[:builder] ||= Builder::XmlMarkup.new(options)
+ xml.instruct! unless options[:skip_instruct]
+ xml.status do
+ xml.tag!(:cpu, @cpu)
+ xml.tag!(:memory, @memory)
+ end
+ end
+
+ def initialize
+ @scr = Scr.instance
+ @health_status = nil
+ @data = Hash.new
+ @cpu=""
+ @memory=""
+ @timestamp = Time.now #nil
+# @collectd_base_dir = "/var/lib/collectd/"
+ @datapath = set_datapath
+ end
+
+ def start_collectd
+ cmd = @scr.execute(["collectd"])
+ @timestamp = Time.now
+ end
+
+ def stop_collectd
+ cmd = @scr.execute(["killall", "collectd"])
+ @timestamp = nil
+ end
+
+ def set_datapath(path=nil)
+ default = "/var/lib/collectd/"
+ unless path.nil?
+ @datapath = path.chomp("/")
+ else # set default path
+ host = @scr.execute(["hostname"])
+ domain = @scr.execute(["domainname"])
+ @datapath = "#{default}#{host[:stdout].strip}.#{domain[:stdout].strip}"
+ end
+ @datapath
+ end
+
+ def reset_datapath(path)
+ @datapath = "/var/lib/collectd/#{host}"
+ end
+
+ def available_metrics
+ metrics = Hash.new
+ cmd = Scr.instance.execute(["ls", "#{@datapath}"])
+ cmd[:stdout].split(" ").each do |l|
+ files = Scr.instance.execute(["ls", "#{@datapath}#{l}"])
+ metrics["#{l}"] = { :rrds => files[:stdout].split(" ")}
+ end
+ metrics
+ end
+
+ def available_metric_files
+ cmd = @scr.execute(["ls", "#{@datapath}.."])
+ lines = cmd[:stdout].split "\n"
+ end
+
+ def update
+ end
+
+ def determine_status
+ end
+
+ def draw_graph(heigth=nil, width=nil)
+ end
+
+ #wieviele cpus?
+ def collect_data(start=Time.now, stop=Time.now, data = %w{cpu memory disk})
+# def collect_data(start="16:18,07/02/2009", stop="16:19,07/02/2009",
data=%w{cpu memory disk})
+ unless @timestamp.nil?
+ data.each do |d|
+ case d
+ when "cpu"
+# @cpu = fetch_metric("cpu-0/cpu-idle.rrd", "16:18,07/02/2009",
"16:19,07/02/2009")
+ @cpu = fetch_metric("/cpu-0/cpu-idle.rrd", start, stop)
+ when "memory"
+# @memory = fetch_metric("memory/memory-free.rrd",
"16:18,07/02/2009", "16:19,07/02/2009")
+ @memory = fetch_metric("/memory/memory-free.rrd", start, stop)
+ when "disk"
+ #fetch_metric
+ end
+ end
+ end
+ end
+
+ def fetch_metric(rrdfile, start=Time.now, stop=Time.now)#, heigth=nil,
width=nil)
+ sum = 0.0
+ counter = 1
+ cmd = @scr.execute(["rrdtool", "fetch", "#{@datapath}#{rrdfile}",
"AVERAGE",\
+ "--start"," #{start}", "--end", "
#{stop}"])
+ lines = cmd[:stdout].split "\n"
+ lines.each do |l|
+ l.to_s.strip
+ unless l.blank? or l.include?("value")
+ pair = l.split ":"
+ unless pair[1].include?("nan") # no valid measurement
+ sum += pair[1].to_f
+ counter += 1
+ end
+ end
+ end
+ sum/(counter-1)
+ end
+end
diff --git a/plugins/status/app/views/status/show.html.erb
b/plugins/status/app/views/status/show.html.erb
new file mode 100644
index 0000000..2cc15b8
--- /dev/null
+++ b/plugins/status/app/views/status/show.html.erb
@@ -0,0 +1,2 @@
+<%= @status.to_xml( :root => "status", :dasherize => false ) -%>
+
diff --git a/plugins/status/app/views/status/show.xml.erb
b/plugins/status/app/views/status/show.xml.erb
new file mode 100644
index 0000000..2cc15b8
--- /dev/null
+++ b/plugins/status/app/views/status/show.xml.erb
@@ -0,0 +1,2 @@
+<%= @status.to_xml( :root => "status", :dasherize => false ) -%>
+
diff --git a/plugins/status/config/resources/status.yml
b/plugins/status/config/resources/status.yml
new file mode 100644
index 0000000..c20721b
--- /dev/null
+++ b/plugins/status/config/resources/status.yml
@@ -0,0 +1,3 @@
+interface: org.opensuse.yast.system.status
+controller: status
+singular: true
diff --git a/plugins/status/package/org.opensuse.yast.system.status.policy
b/plugins/status/package/org.opensuse.yast.system.status.policy
new file mode 100644
index 0000000..913953d
--- /dev/null
+++ b/plugins/status/package/org.opensuse.yast.system.status.policy
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC
+ "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd";>
+<policyconfig>
+
+ <vendor>YaST Webservice Project</vendor>
+ <vendor_url>http://en.opensuse.org/YAST</vendor_url>
+
+<!--
+Rights for status
+-->
+
+ <action id="org.opensuse.yast.system.status.read">
+ <description>Reading status information</description>
+ <message>Authentication is required to read status settings</message>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>no</allow_active>
+ </defaults>
+ </action>
+
+</policyconfig>
+
diff --git a/plugins/securities/package/yast2-webservice-security.spec
b/plugins/status/package/yast2-webservice-status.spec
similarity index 88%
copy from plugins/securities/package/yast2-webservice-security.spec
copy to plugins/status/package/yast2-webservice-status.spec
index d994246..9a2e76d 100644
--- a/plugins/securities/package/yast2-webservice-security.spec
+++ b/plugins/status/package/yast2-webservice-status.spec
@@ -1,5 +1,5 @@
#
-# spec file for package yast2-webservice-security (Version 0.1)
+# spec file for package yast2-webservice-status (Version 0.1)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
@@ -9,23 +9,23 @@
#


-Name: yast2-webservice-security
-PreReq: yast2-webservice
-Provides:
yast2-webservice:/srv/www/yastws/app/controllers/security_controller.rb
+Name: yast2-webservice-status
+PreReq: yast2-webservice collectd rrdtool
+Provides:
yast2-webservice:/srv/www/yastws/app/controllers/status_controller.rb
License: MIT
Group: Productivity/Networking/Web/Utilities
Autoreqprov: on
Version: 0.0.1
Release: 0
-Summary: YaST2 - Webservice - Security
+Summary: YaST2 - Webservice - Status
Source: www.tar.bz2
-Source1: org.opensuse.yast.system.security.policy
+Source1: org.opensuse.yast.system.status.policy
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch

#
%define pkg_user yastws
-%define plugin_name security
+%define plugin_name status
#




hooks/post-receive
--
YaST web service
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >