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
from amonagent.plugin import AmonPlugin | |
class MyCustomPlugin(AmonPlugin): | |
def collect(self): | |
""" | |
The agent collects and sends all the metrics defined in this function | |
""" | |
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
├── amonagent | |
│ ├── plugins | |
│ │ ├── apache | |
│ │ │ ├── apache.conf.example | |
│ │ │ ├── apache.py | |
│ │ │ ├── README.md | |
│ │ │ └── requirements.txt | |
│ └── plugins-enabled | |
│ └── apache.conf |
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
self.counter('opcounters.insert', 93) | |
self.counter('opcounters.update', 17) | |
self.counter('opcounters.command', 320) | |
self.counter('opcounters.getmore', 0) |
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
import random | |
adjs = [ | |
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark", | |
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter", | |
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue", | |
"billowing", "broken", "cold", "damp", "falling", "frosty", "green", | |
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old", | |
"red", "rough", "still", "small", "sparkling", "throbbing", "shy", | |
"wandering", "withered", "wild", "black", "young", "holy", "solitary", |
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
# https://djangosnippets.org/snippets/3011/ | |
# Sometimes you have context variables that are needed on many pages in a site, | |
# but not all. You only want them to be evaluated when actually needed, especially | |
# if they are expensive calculations that do DB queries etc. The pattern to use is | |
# shown: put a callable into the context, not the final value, and also wrap the | |
# callable with memoize_nullary. | |
# | |
# This solution uses the fact that the Django template language will detect and | |
# call any callables when they are referred to. So, if a template contains: | |
# |
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
import subprocess | |
import re | |
packages_for_upgrade = subprocess.Popen(["apt-get",'-q','-V', '-s', 'upgrade', '2>&1'], stdout=subprocess.PIPE, close_fds=True, | |
).communicate()[0] | |
upgrades_index = False | |
for index, line in enumerate(packages_for_upgrade.splitlines()): | |
if line.startswith('The following packages will be upgraded'): |
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
# Run in Docker | |
# docker run -v /home/martin/temp/:/var/scripts -i -t centos:latest python /var/scripts/packagecentos.py | |
import subprocess | |
import re | |
installed_packages_dict = {} | |
installed_packages = subprocess.Popen(["yum",'--color=never','list', 'installed'], stdout=subprocess.PIPE, close_fds=True, |
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
rm /usr/lib64/VBoxGuestAdditions | |
rm /usr/share/VBoxGuestAdditions | |
rm -rf /opt/VBoxGuestAdditions-4.3* |
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
/** @jsx React.DOM */ | |
var Notification = React.createClass({ | |
componentDidMount: function() { | |
setTimeout(function() { | |
React.unmountComponentAtNode(document.getElementById('react-container')); | |
}, 3000); | |
}, |
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
"use strict"; | |
var app = angular.module('RickshawApp', []) | |
.factory('RickshawDataService', function($http){ | |
return { | |
GetData: function() { | |
return $http.get('http://192.168.174.1:8080/data.json/?callback=JSON_CALLBACK') | |
.then(function(result) { | |
return result.data; | |
}); | |
} // get_data |
OlderNewer