Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- user="xxxxxxx"
- host="hoge.foo.bar.com"
- password="secret"
- port=12345
- threshold=1.5
- from="hoge@foo.bar.com"
- to=["bar@hoge.honya.com"].to_java("String")
- newJSch.withSession(user,host,:password=>password,:port=>port) {|session|
- session.exec("w") {|is|
- @load_average = is.gets.gsub(/.+load average: /, "").split(",").collect{|num|num.to_f}
- }
- }
- if @load_average[2] >= threshold
- if defined?(MailSupport)
- msg = createJisMailMessage
- msg.subject = "監視アラート from matoi"
- msg.text = "#{host}の 15分平均CPU使用率が#{threshold}を超過(#{@load_average[2]})"
- msg.from = from
- msg.to = to
- sendMailMessage(msg)
- end
- end
- @load_average[2].to_s.toByteArray.download("text/plain")
Add Comment
Please, Sign In to add comment