Guest User

Untitled

a guest
Feb 12th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. # re-check every ten minutes
  2. SCHEDULER.every '10m', :first_in => 0 do |job|
  3.  
  4. require 'mysql'
  5.  
  6. # Make connection to LT Database
  7. con = Mysql.new 'LTSERVER', 'USERNAME', 'PASSWORD', 'labtech'
  8.  
  9. # Define SQL Query and get info
  10. rs = con.query("SELECT computers.Name AS ComputerName, clients.Name AS ClientName FROM computers, clients WHERE computers.LastContact <= DATE_ADD(NOW(), INTERVAL -30 DAY) AND (computers.ClientID = clients.ClientID) ORDER BY computers.LastContact LIMIT 10")
  11.  
  12. # Define variable as blank array
  13. agent_array = []
  14.  
  15. # Populate Array
  16. rs.each do |item|
  17.  
  18. agent_array << item
  19.  
  20. end
  21.  
  22. #Format Array Data
  23. agents_not_checking_in = agent_array.each_slice(1).map{|s| s.join(' @ ') }.join('<br/>')
  24.  
  25. # Send to widget
  26. send_event('agents_not_checking_in', { text: agents_not_checking_in })
  27. end
Advertisement
Add Comment
Please, Sign In to add comment