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 codecs | |
import logging | |
import os | |
logger = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0]) | |
# NOTE: Python 3.x doesn't have a `unicode()` built-in function. |
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 json | |
import gzip | |
import logging | |
import os | |
logger = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0]) | |
def write_gzip_file(path, data, overwrite_existing=False, compression_level=9): |
____ ___ ____ ____ _ _ ___ __ __ _____ ____
| _ \_ _/ ___| / ___| | / \ |_ _| \/ | ____| _ \
| | | | |\___ \| | | | / _ \ | || |\/| | _| | |_) |
| |_| | | ___) | |___| |___ / ___ \ | || | | | |___| _ <
|____/___|____/ \____|_____/_/ \_\___|_| |_|_____|_| \_\
This is meant as one real-world example of setting up the SignalFx SmartAgent and is not intended to be a replacement for the official documentation. Please make sure that you have read the Kubernetes setup instructions available at https://github.com/signalfx/signalfx-agent/blob/master/docs/kubernetes-setup.md. I am not responsible if you don't read the documentation, you screw something up, or something spontaneously combusts.
25-Apr-2018 13:33:27 [World Community Grid] Temporarily failed upload of MCM1_0141526_9856_0_r1232334159_0: transient HTTP error
(that's not very helpful...)
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 logging.config | |
import time | |
TZ_NAME = time.tzname[0] if not time.localtime().tm_isdst else time.tzname[1] | |
# Alternatively, convert the localtime to UTC/GMT but if you use this then update | |
# the logging formatter because this example is using the local timezone. | |
# logging_handler.formatter.converter = time.gmtime | |
# This is kept separate as it can be used to apply a default log level to your | |
# loggers otherwise you can use a method to change this to debug and apply the |
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 locale | |
def convert_number_to_human_readable_string(data, fmt=None, grouping=True, **kwargs): | |
"""Convert number to human-readable string based on locale. Additional kwargs passed to locale.format(). | |
:param data: Some kind of number. | |
:type data: int, float, long | |
:param fmt: (optional) Number format. (default: None) | |
:param grouping: (optional) Take grouping into account. (default: True) | |
:type grouping: bool |
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 datetime | |
import decimal | |
import json | |
import re | |
class CustomJSONEncoder(json.JSONEncoder): | |
"""Custom JSON encoder that does things that shouldn't need to be done.""" | |
def default(self, obj): |
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
""" | |
Disclaimer | |
========== | |
This has been designed as a solution for a specific task, or set of tasks, by the code author which is outside | |
the locus of SignalFx supportability. This code is provided as-is and if any support is needed then it should | |
be provided by the original code author on a best-effort only basis; it cannot be supported through break/fix | |
support channels. | |
Synopsis |
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 StringIO | |
from selenium import webdriver | |
from PIL import Image | |
# Install instructions | |
# | |
# npm install phantomjs | |
# sudo apt-get install libjpeg-dev | |
# pip install selenium pillow |