Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # re-check every ten minutes
- SCHEDULER.every '10m', :first_in => 0 do |job|
- require 'mysql'
- # Make connection to LT Database
- con = Mysql.new 'LTSERVER', 'USERNAME', 'PASSWORD', 'labtech'
- # Define SQL Query and get info
- 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")
- # Define variable as blank array
- agent_array = []
- # Populate Array
- rs.each do |item|
- agent_array << item
- end
- #Format Array Data
- agents_not_checking_in = agent_array.each_slice(1).map{|s| s.join(' @ ') }.join('<br/>')
- # Send to widget
- send_event('agents_not_checking_in', { text: agents_not_checking_in })
- end
Advertisement
Add Comment
Please, Sign In to add comment