Skip to content

Instantly share code, notes, and snippets.

@patrobinson
Created March 23, 2015 12:40
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrobinson/4f3a62c052e7952c222d to your computer and use it in GitHub Desktop.
Save patrobinson/4f3a62c052e7952c222d to your computer and use it in GitHub Desktop.
ServiceNow Dashing config

ServiceNow dashing Meter

Shows the number of results returned by a query to ServiceNow

Usage

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment