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
| import subprocess | |
| def execute_command(command=None, stdin=None): | |
| proc = subprocess.Popen( | |
| command, | |
| stdin=subprocess.PIPE, | |
| stdout=subprocess.PIPE, | |
| stderr=subprocess.PIPE, | |
| text=True, | |
| ) |
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
| #!/usr/bin/env python3 | |
| import subprocess | |
| # This performs the equivalent of `ps -axm -o rss,comm | sort -rn -k 1 | head -n 20` | |
| number_of_entries = 20 | |
| cmd1 = ['/bin/ps', '-axm', '-o', 'rss,comm'] | |
| cmd2 = ['sort', '-rn', '-k', '1'] | |
| cmd3 = ['head', '-n', str(number_of_entries)] |
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
| package main | |
| import ( | |
| "archive/tar" | |
| "bytes" | |
| "context" | |
| "encoding/json" | |
| "fmt" | |
| "github.com/docker/docker/api/types" | |
| "github.com/docker/docker/client" |
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
| class ::Hash | |
| require "rexml/document" | |
| def to_xml(indent: nil, rootname: nil, output: nil, encoding: nil) | |
| indent = indent ? indent : 2 | |
| rootname = rootname ? rootname : "root" | |
| output = output == $stdout ? $stdout : nil | |
| encoding = encoding ? encoding : "UTF-8" | |
| xml = REXML::Document.new | |
| formatter = REXML::Formatters::Pretty.new(indent) | |
| formatter.compact = true |
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
| # Inside the chef template erb file we can do this: | |
| <%= "[mindadmin]" %> | |
| <% node[:splunk][:roles][:miniadmin].each do |key, value| %> | |
| <%= "#{key} = #{value}" %> | |
| <% end %> |
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
| #!/usr/bin/ruby | |
| require "hipchat" | |
| require "pp" | |
| hc = HipChat.new({ | |
| "token" => "MYTOKEN" | |
| }) | |
| hc.debug("on") |
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
| function status_fn_oor_state(jobId) { | |
| var status_fn_oor_state_cfg = { | |
| method: 'GET', | |
| on: { | |
| success: function(id, o) { | |
| var jsonString = o.responseText; | |
| rec = Y.JSON.parse(jsonString); | |
| rec.data = rec.result.output; | |
| rec.result.output = undefined; | |
| if(rec.result.status !== 'completed' && rec.result.status !== 'completed_with_map_errors' |