Created
January 23, 2013 23:45
-
-
Save johnskopis/4615873 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open-uri' | |
require 'mysql2' | |
#for vmta in mailgate actions newsletters backqueue invitations wish-solicitations action-updates transactions; do for mta in pmta01 pmta03; do for domain in aol yahoo gmail hotmail comcast bellsouth att sbcglobal; do echo -n "&target="; cat tpl | sed -e "s/%VMTA%/$vmta/g" -e "s/%MTA%/$mta/g" -e "s/%DOMAIN%/$domain/g" -e '/\n/d' | while read line ; do echo -n "$line";done ;done; done; echo '&colorList=A4A4A4%2CFFFFFF%2C5858FA%2C08088A%2C088A08%2C58FA58%2CB40404%2CF78181&lineMode=connected&minXStep=10&from=-7days&width=1600&height=800';done > /tmp/render | |
#alias(divideSeries(transformNull(email.%MTA%.%VMTA%.%DOMAIN%.delivered,1),sumSeries(email.%MTA%.%VMTA%.%DOMAIN%.bounced,transformNull(email.%MTA%.%VMTA%.%DOMAIN%.delivered,1))),\\\"%DOMAIN%\\\") | |
mysql2 = Mysql2::Client.new( | |
:host => 'sfdb01.prod.causes.com', | |
:username => 'graphite', | |
:database => 'graphite', | |
:password => 'secret' | |
) | |
#%w[mailgate actions newsletters backqueue invitations wish-solicitations action-updates transactions].each do |vmta| | |
%w[invitations].each do |vmta| | |
update = Hash.new | |
render = [] | |
%w[aol yahoo gmail hotmail comcast att sbcglobal other].each do |domain| | |
render << %q{&target=alias(summarize(sumSeries(email.*.%{vmta}.%{domain}.delivered), "1hour"),"%{domain}")} % { | |
:vmta => vmta, | |
:domain => domain | |
} | |
end | |
uri = "http://graphite.prod.causes.com/render?%s%s" % [ | |
URI.encode(render.join('')), | |
# "&uniqueLegend=true&title=#{vmta}%20deliverability&hideLegend=false&colorList=FFF000%25FFFF00%25FFFFFF%252C5858FA%252C08088A%252C088A08%252C58FA58%252CB40404%252CF78181&lineMode=connected&minXStep=10&from=-7days&width=1600&height=800%0A" | |
"&uniqueLegend=true&title=#{vmta}%20deliverability&hideLegend=false&lineMode=connected&minXStep=10&from=-7days&width=1600&height=800%0A" | |
] | |
sql = %Q{INSERT INTO account_mygraph (profile_id,name,url) VALUES (3,'#{mysql2.escape vmta}','#{mysql2.escape uri}')} | |
puts sql | |
# mysql2.query(sql) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment