-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5a73377
Showing
27 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
source "https://rubygems.org" | ||
|
||
# Declare your gem's dependencies in #{yourplugin}.gemspec. | ||
# Bundler will treat runtime dependencies like base dependencies, and | ||
# development dependencies will be added by default to the :development group. | ||
gemspec | ||
|
||
# assume jquery-rails will be used | ||
gem "jquery-rails" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Your plugin license! | ||
|
||
Copyright 2013 Amahi, http://www.amahi.org | ||
|
||
This software is licensed under the AGPL v3 | ||
https://www.gnu.org/licenses/agpl | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
= Amahi plugin SMART Status | ||
|
||
SMART Status for the Amahi platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env rake | ||
begin | ||
require 'bundler/setup' | ||
rescue LoadError | ||
puts 'You must `gem install bundler` and `bundle install` to run rake tasks' | ||
end | ||
begin | ||
require 'rdoc/task' | ||
rescue LoadError | ||
require 'rdoc/rdoc' | ||
require 'rake/rdoctask' | ||
RDoc::Task = Rake::RDocTask | ||
end | ||
|
||
RDoc::Task.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'Amahi Plugin' | ||
rdoc.options << '--line-numbers' | ||
rdoc.rdoc_files.include('README.rdoc') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end | ||
|
||
# APP_RAKEFILE = File.expand_path("../../../Rakefile", __FILE__) | ||
# load 'rails/tasks/engine.rake' | ||
|
||
Bundler::GemHelper.install_tasks | ||
|
||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.libs << 'test' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = false | ||
end | ||
|
||
|
||
task :default => :test |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "smart_statuses/smart_test_util.rb" | ||
|
||
class SmartStatusesController < ApplicationController | ||
before_action :admin_required | ||
|
||
def index | ||
@page_title = t('smart_status') | ||
unless use_sample_data? | ||
@tests = SmartTestUtil.stats | ||
else | ||
# NOTE: this is to get sample fake data in development | ||
@tests = SmartTestUtil.sample_stats | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ApplicationHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
- unless @tests.size>0 | ||
div.no-content | ||
strong | ||
| No devices found | ||
- else | ||
.settings-table#tests-table | ||
table.settings.table | ||
thead | ||
tr | ||
th.settings-col1= t 'model' | ||
th= t 'device' | ||
th | ||
= t 'health_check' | ||
tbody class="#{@tests.size}" | ||
- @tests.each do | test | | ||
tr class=cycle("odd", "even") | ||
td.settings-col1 = test[:model] | ||
td = test[:device] | ||
td | ||
span[style="color: #{test[:color]}"] | ||
= test[:health_check] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# human readable name (no localization supported yet) | ||
name: SmartStatus | ||
# class to be mounted | ||
class: SmartStatuses | ||
# root url where this plugin will be mounted | ||
url: /tab/smart_statuses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# plugin initialization | ||
t = Tab.new("smart_statuses", "smart_statuses", "/tab/smart_statuses") | ||
# add any subtabs with what you need. params are controller and the label, for example | ||
t.add("index", "details") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Localization in English | ||
|
||
'en': | ||
# put here your string symbols and translations | ||
hello_world: Hello World! (yay for the Amahi plugins!) | ||
smart_status: SMART Status | ||
health_check: Basic Health Check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SmartStatuses::Engine.routes.draw do | ||
# root of the plugin | ||
root :to => 'smart_statuses#index' | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
smartctl 6.5 2016-05-07 r4318 [x86_64-linux-4.16.16-200.fc27.x86_64] (local build) | ||
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org | ||
=== START OF READ SMART DATA SECTION === | ||
SMART overall-health self-assessment test result: PASSED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
smartctl 6.5 2016-05-07 r4318 [x86_64-linux-4.16.16-200.fc27.x86_64] (local build) | ||
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org | ||
=== START OF READ SMART DATA SECTION === | ||
SMART overall-health self-assessment test result: FAILED! | ||
Drive failure expected in less than 24 hours. SAVE ALL DATA. | ||
Failed Attributes: | ||
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE | ||
3 Spin_Up_Time 0x0007 001 001 011 Pre-fail Always FAILING_NOW 60340 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "smart_statuses/version" | ||
require "smart_statuses/engine" | ||
|
||
module SmartStatus | ||
class Lib | ||
# the code for your plugin library here | ||
# or inside lib/smart_statuses/whatever.rb and required here | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module SmartStatuses | ||
class Engine < ::Rails::Engine | ||
# NOTE: do not isolate the namespace unless you really really | ||
# want to adjust all your controllers views, etc., making Amahi's | ||
# platform hard to reach from here | ||
# isolate_namespace SmartStatus | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class SmartTestUtil | ||
class << self | ||
def stats | ||
@disks = DiskUtils.stats | ||
response = [] | ||
@disks.each_with_index do |disk, index| | ||
status = read_smart_status(create_file_and_get_path(disk[:device])) | ||
color = (status=="PASSED")? "green": "red"; | ||
response << { model: disk[:model], device: disk[:device], | ||
health_check: status, color: color } | ||
end | ||
return response | ||
end | ||
|
||
def create_file_and_get_path(device) | ||
# create the status file and return file path | ||
# need to implement for production | ||
get_sample_file_path(rand(2)) | ||
end | ||
|
||
def sample_stats | ||
@disks = SampleData.load('disks') | ||
response = [] | ||
@disks.each_with_index do |disk, index| | ||
status = read_smart_status(get_sample_file_path(index)) | ||
color = (status=="PASSED")? "green": "red"; | ||
response << { model: disk[:model], device: disk[:device], | ||
health_check: status, color: color } | ||
end | ||
return response | ||
end | ||
|
||
def get_sample_file_path(index) | ||
if index.blank? or index%2 == 0 | ||
Rails.root+Dir["plugins/*smart_statuses/db/sample-data/smartctl-output-sample1.txt"][0] | ||
else | ||
Rails.root+Dir["plugins/*smart_statuses/db/sample-data/smartctl-output-sample2.txt"][0] | ||
end | ||
end | ||
|
||
def read_smart_status(filepath) | ||
return nil unless File.exists?(filepath) | ||
IO.readlines(filepath)[3][50..-1] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module SmartStatus | ||
VERSION = "0.0.1" | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# desc "Explaining what the task does" | ||
# task :smart_statuses do | ||
# # Task goes here | ||
# end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
|
||
ENGINE_ROOT = File.expand_path('../..', __FILE__) | ||
ENGINE_PATH = File.expand_path('../../lib/smart_statuses/engine', __FILE__) | ||
require 'rails/all' | ||
require 'rails/engine/commands' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
$:.push File.expand_path("../lib", __FILE__) | ||
|
||
# Maintain your gem's version: | ||
require "smart_statuses/version" | ||
|
||
# Describe your gem and declare its dependencies: | ||
Gem::Specification.new do |s| | ||
s.name = "smart_statuses" | ||
s.version = SmartStatus::VERSION | ||
s.authors = "Sukhbir Singh" | ||
s.email = ["[email protected]"] | ||
s.homepage = "https://www.amahi.org/apps/smart-status" | ||
s.license = "AGPLv3" | ||
s.summary = %{Monitor the S.M.A.R.T. status of your drives with this Amahi plugin.} | ||
s.description = %{This is an Amahi 11 platform plugin that uses S.M.A.R.T. tools to monitor the status of all drives in an Amahi server.} | ||
|
||
s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE", "Rakefile", "README.rdoc"] | ||
s.test_files = Dir["test/**/*"] | ||
|
||
s.add_dependency "rails", "~> 3.2.12" | ||
s.add_dependency "jquery-rails" | ||
|
||
s.add_development_dependency "sqlite3" | ||
end | ||
|