Last active
          August 29, 2015 14:24 
        
      - 
      
 - 
        
Save pmint93/98389d04050256b19242 to your computer and use it in GitHub Desktop.  
    Delete rabbitMQ queues by name matching
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | // Author: pmint93 | |
| function run(virtual_host, mask, auth){ | |
| var trs = $('.updatable table.list tbody tr'); | |
| var queues = trs.each(function(i, v){ | |
| var name = $(v).find('td').eq(1).text(); | |
| console.log(name); | |
| if(name.match(mask)){ | |
| $.ajax({ | |
| method: 'GET', | |
| url: '/api/queues/'+virtual_host+'/'+name+'?lengths_age=60&lengths_incr=5&msg_rates_age=60&msg_rates_incr=5', | |
| // url: '/api/queues/pancake.fbqueue/wait_0005_min', | |
| headers: { 'Authorization': auth }, | |
| success: function(response){ | |
| var c = confirm('DELETE: ' + virtual_host + '/' + name + ':' + response.arguments['x-dead-letter-routing-key'] + '?'); | |
| if(c){ | |
| $.ajax({ | |
| type: 'DELETE', | |
| url: '/api/queues/'+virtual_host+'/'+name+'?lengths_age=60&lengths_incr=5&msg_rates_age=60&msg_rates_incr=5', | |
| headers: { 'Authorization': auth }, | |
| success: function(response){ | |
| console.log('deleted', response); | |
| }, | |
| error: function(err){ | |
| console.log('error', err); | |
| } | |
| }) | |
| } | |
| }, | |
| error: function(err){ | |
| console.log(err); | |
| } | |
| }) | |
| } | |
| }) | |
| } | |
| run('pancake.fbqueue', new RegExp('^wait_'), 'Basic cGFuY2FrZV9tY19vbmU6ZmFudGFzZWVvQHRo'); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment