Skip to content

Instantly share code, notes, and snippets.

Avatar

Slavek Kabrda bkabrda

  • Datadog
  • Czech Republic
View GitHub Profile
View gethostagentlist.py
import requests, json, csv
api_key = '<apikey>'
application_key = '<appkey>'
url = "https://app.datadoghq.com/reports/v2/overview?api_key="+api_key+"&application_key="+application_key+"&window=3h&metrics=avg%3Asystem.cpu.idle%2Cavg%3Aaws.ec2.cpuutilization%2Cavg%3Avsphere.cpu.usage%2Cavg%3Aazure.vm.processor_total_pct_user_time%2Cavg%3Asystem.cpu.iowait%2Cavg%3Asystem.load.norm.15&with_apps=true&with_sources=true&with_aliases=true&with_meta=true&with_mute_status=true&with_tags=true"
headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8'}
r = requests.get(url,headers=headers)
print("status:", r.status_code)
@bkabrda
bkabrda / gist:c565ac6677167f8c43b103691b985c5c
Created Feb 7, 2020
terraform destroy issue when using data source to initialize provider
View gist:c565ac6677167f8c43b103691b985c5c
2020/02/07 12:03:03 [INFO] Terraform version: 0.12.20
2020/02/07 12:03:03 [INFO] Go runtime version: go1.12.13
2020/02/07 12:03:03 [INFO] CLI args: []string{"/Users/slavek.kabrda/programming/go/bin/terraform", "destroy"}
2020/02/07 12:03:03 [DEBUG] Attempting to open CLI config file: /Users/slavek.kabrda/.terraformrc
2020/02/07 12:03:03 Loading CLI configuration from /Users/slavek.kabrda/.terraformrc
2020/02/07 12:03:03 [INFO] CLI command args: []string{"destroy"}
2020/02/07 12:03:03 [DEBUG] New state was assigned lineage "2e408cc9-ce80-47a9-b5f4-7e499d9f58be"
2020/02/07 12:03:03 [DEBUG] checking for provider in "."
2020/02/07 12:03:03 [DEBUG] checking for provider in "/Users/slavek.kabrda/programming/go/bin"
2020/02/07 12:03:03 [WARN] found legacy provider "terraform-provider-datadog"
View petition.py
import requests
p = requests.get('https://petition.parliament.uk/petitions/131215.json').json()
tuples = [(x['name'], x['signature_count'])
for x in p['data']['attributes']['signatures_by_country']]
tuples = sorted(tuples, key=lambda x: x[1])
counted = 0
for t in tuples:
counted += t[1]
@bkabrda
bkabrda / a.spec
Created Dec 9, 2013
Proposal for generating scl-specific macros automatically
View a.spec
# To try, install python27-macros and rpmbuild -bp this spec
# Then see what it prints
# Uncomment this to get unversioned %%python_datadir macro
# %%python27_make_default_macros
Name: a
Version: 1
Release: 1%{?dist}
Summary: a
View scl_source
#!/bin/bash
help="usage: source scl_source <action> [<collection> ...]
Enable one or more collections in the current shell.
Options:
-h, --help display this help and exit"
if [ $1 = "-h" -o $1 = "--help" ]; then
View gist:5387908
<class '__main__.PyFrameObjectPtr'>
266240
<class '__main__.PyCodeObjectPtr'>
269227008
<class '__main__.PyUnicodeObjectPtr'>
269227008
<class '__main__.PyUnicodeObjectPtr'>
67916800
<class '__main__.PyTupleObjectPtr'>
134484992
View gist:5387906
<class '__main__.PyFrameObjectPtr'>
266240
<class '__main__.PyCodeObjectPtr'>
269227008
<class '__main__.PyUnicodeObjectPtr'>
269227008
<class '__main__.PyUnicodeObjectPtr'>
67916800
<class '__main__.PyTupleObjectPtr'>
134484992
@bkabrda
bkabrda / gist:5202929
Created Mar 20, 2013
PyGitHub python3 failures
View gist:5202929
running test
running build_py
running egg_info
writing /builddir/build/BUILD/python3-python-github-1.11.1-3.fc20/build/lib/PyGithub.egg-info/PKG-INFO
writing top-level names to /builddir/build/BUILD/python3-python-github-1.11.1-3.fc20/build/lib/PyGithub.egg-info/top_level.txt
writing dependency_links to /builddir/build/BUILD/python3-python-github-1.11.1-3.fc20/build/lib/PyGithub.egg-info/dependency_links.txt
reading manifest file '/builddir/build/BUILD/python3-python-github-1.11.1-3.fc20/build/lib/PyGithub.egg-info/SOURCES.txt'
writing manifest file '/builddir/build/BUILD/python3-python-github-1.11.1-3.fc20/build/lib/PyGithub.egg-info/SOURCES.txt'
running build_ext
testAttributes (github.tests.AuthenticatedUser.AuthenticatedUser) ... ok
@bkabrda
bkabrda / gist:3009644
Created Jun 28, 2012
Bundler distro mode
View gist:3009644
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 4df3ffb..9d88560 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -353,3 +353,13 @@ module Bundler
end
end
+
+if ENV['BUNDLER_DISTRO'].nil? || ! ENV['BUNDLER_DISTRO'].empty?
@bkabrda
bkabrda / gist:2987130
Created Jun 25, 2012
fog test failures
View gist:2987130
Skipping tests for newservers due to lacking credentials (add some to '~/.fog' to run them)
Skipping tests for xenserver due to lacking credentials (add some to '~/.fog' to run them)
Skipping tests for libvirt due to missing `ruby-libvirt` gem.
Vcloud::Compute | disk_requests (vcloud) ####
Vcloud::Compute | vdcs (vcloud) ##
Vcloud::Compute | vapp (vcloud) ##
Vcloud::Compute | organization (vcloud) ##
Vcloud::Compute | organizations (vcloud) ##
Vcloud::Compute | servers (vcloud) ##