- 浏览: 669632 次
- 性别:
- 来自: 中山
文章分类
最新评论
-
wuhuizhong:
jFinal支持Rest风格吗?可以想spring mvc那样 ...
在JFinal的Controller中接收json数据 -
wuhuizhong:
在jfinal中应如何获取前端ajax提交的Json数据?ht ...
在JFinal的Controller中接收json数据 -
wuhuizhong:
jfinal如何处理json请求的数据:问题: 在某些api接 ...
在JFinal的Controller中接收json数据 -
wuhuizhong:
Ubuntu14.04 安装 Oracle 11g R2 Ex ...
Oracle 11g release 2 XE on Ubuntu 14.04 -
alanljj:
这个很实用,已成功更新,谢过了!
odoo薪酬管理模块l10n_cn_hr_payroll
$ vi lib/tasks/notify.rake
require 'net/ssh' require 'net/sftp' def notify_rman(mails,result) htmlopen = %Q{<html> <head> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body topmargin="10" leftmargin="10" marginheight="0" marginwidth="0" bgcolor="#e0ffff" text="#000000"> <table height="23" width="100%" border="0" cellSpacing="0" cellPadding="0" bgcolor="#4a6bad"> <tr> <td align="left" style="font-family: Verdana, Arial; font-size:9pt;color:#f2f8ff">檢查RMAN備份結果(#{Time.now.strftime("%Y-%m-%d")})</td> <td align="right" style="font-family: Verdana, Arial; font-size:9pt;color:#f2f8ff"> </td> </tr> </table> <center> <table bgcolor="#f2f8ff" border="1" width="100%" style="border-collapse: collapse;font-size:12px" bordercolor="#666699"> <tr> <th>NO</th> <th>主機IP</th> <th>資料庫用途</th> <th>備份結果</th> <th align="left">檢查日誌信息</th> </tr>} htmlclose = %Q{</table> </center> </body> </html>} table = '' i = 0 result.each do |row| i += 1 if row[:data] =~ /successfully/ status = "成功" bgcolor = "#f2f8ff" else status = "失敗" bgcolor = "#ffffe0" end #body << "#{row[:ip]} : #{row[:data]}" table += "<tr><td bgcolor='#{bgcolor}'> #{i}</td> <td bgcolor='#{bgcolor}'>#{row[:ip]}</td> <td bgcolor='#{bgcolor}'>#{row[:notes]}</td> <td bgcolor='#{bgcolor}'>#{status}</td> <td bgcolor='#{bgcolor}'>#{row[:data]}</td></tr>" end table += "<tr><td colspan='4'><a href='http://172.18.60.39/oms' >點此登錄主機監控網站查看更多RMAN備份記錄</a></td></tr>" #body = %Q{ #{result.inspect}} html_body = %{ #{htmlopen} #{table} #{htmlclose}} Pony.mail( :to => mails, :from => 'DBA<huizhong.wu@pyzs.com.cn>', #:cc => 'Jamie Kao<jamie.kao@pousong.com.cn>', :subject => '[Oracle主機監控網站 ] 檢查RMAN備份結果', :html_body => html_body, :via => :smtp, :via_options => { :address => 'email.pyzs.com.cn', :port => 25, :enable_starttls_auto => true, :user_name => 'username', :password => 'password', :authentication => :login, :domain => "localhost.localdomain" # the HELO domain provided by the client to the server }) end namespace :notify do desc "Notify RMAN log" task :rmanlog do db = Sequel.connect('oracle://netzke_demo:practice@172.18.60.39:1521/test') sql = "select t.id,t.ip_address ip,t.notes,t.oracle pwd,t.rman_mk mk,t.rman_log logfile from hosts t where t.rman_mk = '1' order by t.ip_address" result = [] db[sql].each do |row| ssh_command = "tail -2 #{row[:logfile]}" output = '' Net::SSH.start(row[:ip], 'oracle', {:password => row[:pwd]}) do |ssh| #@log.info "ssh session open" # ssh to client channel = ssh.open_channel do |ch| #@log.info "executing '#{ssh_command}'" ch.exec ssh_command do |ch, success| unless success #@log.info "ssh command failed" raise "could not execute command: '#{ssh_command}'" end # "on_data" is called when the process writes something to stdout ch.on_data do |c, data| output += data #@log.info "#{row[:ip]}: #{data}" end # "on_extended_data" is called when the process writes something to stderr ch.on_extended_data do |c, type, data| output += data #@log.info "got stderr: #{data}" end ch.on_request "exit-status" do |c, data| #@log.info "process terminated with exit status: #{data.read_long.to_s}" end ch.on_close #{ @log.info "channel closed!" } end end # channel.wait #@log.info "ssh channel done" end result << {:ip => row[:ip], :notes => row[:notes], :data => output} end mails = ['WHZ<huizhong.wu@pyzs.com.cn>', 'LJP<jing.liu@pousong.com.cn>', 'LCL<lcl@pyzs.com.cn>', 'ZSH<zsh8@pousong.com.cn>', 'CH<david.chen@pyzs.com.cn>' ] #mails = ['WHZ<huizhong.wu@pyzs.com.cn>'] notify_rman(mails,result) end end
$ rake notify:rmanlog
常見問題:
1.不能連接被監控的主機,報錯:no route to host
发表评论
-
使用Torquebox在Windows下面进行Rails的部署
2013-12-16 07:16 1037一、安装Torquebox 参考:http://torqu ... -
ruby匹配中文的正则表达
2013-07-16 21:12 1864ruby1.9: /\p{Word}+/u 不限于 a ... -
Ruby On Rails, Thin and Nginx on Windows
2012-01-08 07:23 1792安装thin: gem install eventmachi ... -
搭建rubygem repository server
2011-11-14 13:06 982做rails开发通常需要gem i ... -
在 Heroku 安裝 Redmine (1.1-stable)
2011-11-13 09:59 1032Redmine 是一套好用的軟 ... -
Rails之记录用户操作数据库信息
2011-11-10 02:50 1144db/migrate/002_add_audit_trails ... -
Rails3部署到heroku
2011-11-10 02:47 673gem install heroku rails new m ... -
Rails Cache
2011-11-10 02:20 661Rails Cache http://www.slid ... -
How do I use ActiveSupport core extensions?
2011-11-07 17:04 453When I try to use 1.week.ago ... -
Redhat安裝 nokogiri 時要求升級 libxml2
2011-11-07 16:58 2214安裝 nokogiri 時出現以下錯誤信息: Install ... -
Compass Agile Enterprise Framework
2011-11-07 06:37 691设置: 1.Gemfile gem 'erp_agreem ... -
Linux下Rails 3.1安装sqlite3
2011-10-25 08:29 1111服务器系统是Red Hat 4.1.2-48。默认已安装sql ... -
Ubuntu Server 64bits 如何安装 ruby-oci8
2011-10-23 06:56 2986安装 Linux软件包 : sudo apt- ... -
将gem包打成jar包
2011-10-16 11:45 786http://www.intellij.org.cn/blog ... -
升級到 Rails 3.1,專案所要做的前置準備工作
2011-10-14 14:28 609http://wp.xdite.net/?p=3137 ... -
Ruby 调用Shell脚本
2011-10-13 15:13 2858// 第一种 用反引号将shell命令引起来,如果是sh ... -
Ruby通过SOAP调用webservice发送短信
2011-10-06 11:27 1571url = 'http://lxt.esms360.co ... -
Sending delayed email from devise
2011-09-27 14:39 614Alternatively, instead of using ... -
让邮件发送也变得有序
2011-09-27 14:10 547邮件发送应该是一个网站中不可或缺的功能,但如果同时触发了大量的 ... -
rails 3 中 生成pdf 2: email pdf 附件
2011-09-27 13:31 953ActionMailer in Rails 3 http:/ ...
相关推荐
Ruby on Rails 初体验--北大青鸟教师专题讲座PPT 想学Ruby的赶快下载看看。 Ruby--目前最快速开发工具
awesome-rails-gem-zh_CN, Rails 常用 Gem 列表 - Awesome Rails Gem 中文版
rails-hackernews-reddit-producthunt-clone, 黑客 news/reddit/social 链接分享网站 用 Rails 构建 Rails 上的 Reddit-Hackernews-ProductHunt克隆演示 这是一个 readme.md的Ruby on Rails 应用程序,模仿了 Hacker...
Scrum Poker in Rails5, docker-compose
rails-angular-postgres-and-bootstrap-second-edition 英文原版
Ruby on Rails Tutorial(3rd-1.0.2)适合初学者,详细。
rails3-mongoid-devise, 示例 Rails 3.2应用,带有数据 Mongoid,用于验证 Rails 4.1有关设计的Rails 4.1示例应用程序,请参见:rails设计有一个用于设计的教程:Rails 设计教程。类似示例和教程这是来自 RailsApps...
rails-documentation-2-0-2
rails-beginner-s-guide是Rails 指导手册,帮组学习了解rails开发
自述文件该自述文件通常会记录启动和运行应用程序所需的所有步骤。 您可能要讲的内容: Ruby版本系统依赖配置数据库创建数据库初始化如何运行测试套件服务(作业队列,缓存服务器,搜索引擎等) 部署说明...
rails-documentation-1-2-1.zip
rails-dev-box, 面向 Ruby on Rails 核心开发的虚拟机 用于 Ruby on Rails 核心开发的虚拟机简介注意:这个虚拟机不是为 Rails 应用程序开发而设计的,只是为。 这个项目自动设置开发环境,以便在 Ruby on Rails ...
rails-documentation-1-2-0-rc1.chm
upmin-admin 是一个为 Rails 应用开发的开源管理框架。用来管理 Rails 应用中各种对象(如 Model、View 和 Controller )。 标签:upmin
rails-react-components-源码.rar
rails-yelp-mvp-源码.rar
rails-builds-test-源码.rar
rails-development-environment-master.rar
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
Windows7_Cygwin_Git_RVM_Ruby1.9.3_Rails3_MongoD B_Nginx_Unicorn_Rspec_Guard_Spork(2-Ruby on Rails3 安装配置