Shows the number of results returned by a query to ServiceNow
Add the following to your Gemfile
gem 'rs_service_now'
<% content_for :title do %>Unassigned tasks<% end %> | |
<div class="gridster"> | |
<ul> | |
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"> | |
<div data-id="unassigned_tasks" data-view="Meter" data-title="Unassigned tasks in our team" data-min="0" data-max="25"></div> | |
</li> | |
</ul> | |
</div> |
require 'rs_service_now' | |
def update_count(sn, table, query) | |
result = sn._request table, query | |
result.count | |
end | |
SCHEDULER.every("10m", first_in: '1s') do | |
config_file = File.dirname(File.expand_path(__FILE__)) + '/../config/servicenow.yml' | |
config = YAML::load(File.open(config_file)) | |
user = config["user"] | |
password = config["password"] | |
instance = config["instance"] | |
proxy = config["proxy"] | |
sn = RsServiceNow::Record.new(user, password, instance, proxy) | |
if config["queries"].nil? | |
puts "No Service-Now queries found" | |
else | |
config["queries"].each_pair do |data_id, query_config| | |
send_event(data_id, { value: update_count(sn, query_config["table"], query_config["query"])}) | |
end | |
end | |
end |
instance: myservicenowinstance | |
user: username | |
password: password | |
proxy: http://optional_proxy:8080 | |
queries: | |
unassigned_tasks: | |
table: "task_list" | |
query: "active=true^assigned_toISEMPTY^assignment_group=myteamssysid" |