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
[program:bosun] | |
command=/bosun/bosun -c /data/bosun.toml | |
stdout_logfile=/var/log/bosun.out.log | |
stderr_logfile=/var/log/bosun.err.log | |
autostart=true | |
autorestart=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
# Hostname will be used when links are created in templates (i.e. acknowledge links) | |
#Hostname = "bosun.example.com" | |
# The HTTP IP and Port to Listen on. Default is ":8070" | |
#HTTPListen = ":8080" | |
# Alert checks are run by default every CheckFrequency * DefaultRunEvery. RunEvery can be overridden | |
# by indivdual alerts. Defaults are "5m" and 1 | |
CheckFrequency = "1m" | |
DefaultRunEvery = 5 |
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
public static async Task Time(Func<Task> action, EventGauge gauge) | |
{ | |
Stopwatch stopwatch = new Stopwatch(); | |
stopwatch.Start(); | |
await action.Invoke(); | |
stopwatch.Stop(); | |
gauge.Record(stopwatch.Elapsed.TotalMilliseconds, DateTime.Now); | |
} |
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
await Time(async () => | |
{ | |
await GetWeather(); | |
}, _timer); |
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
_timer = _collector.CreateMetric<EventGauge>("GetWeather", "time taken", "measures time taken to get weather from api"); |
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
static MetricsCollector _collector; | |
_collector = new MetricsCollector(new BosunOptions(ex => Handle(ex)) | |
{ | |
MetricsNamePrefix = "TestApp.", | |
BosunUrl = new System.Uri("http://192.168.1.5:8070"), | |
PropertyToTagName = NameTransformers.CamelToLowerSnakeCase, | |
ThrowOnPostFail = true, | |
DefaultTags = new Dictionary<string, string>{ {"host", NameTransformers.Sanitize(Environment.MachineName.ToLower())}, | |
{ "client", "home" }, } |
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
//Returns time taken for execution of synchronous code | |
var syncTime = Metricity.Timings.Time(() => | |
{ | |
SyncMethod(); | |
}); | |
//Returns time taken for execution of asynchronous code | |
var asyncTime = Metricity.Timings.Time(async () => | |
{ | |
await ASyncMethod(); |
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
string stringFromSQL = "0x6100730064006600"; | |
List<byte> byteList = new List<byte>(); | |
string hexPart = stringFromSQL.Substring(2); | |
for (int i = 0; i < hexPart.Length / 2; i++) | |
{ | |
string hexNumber = hexPart.Substring(i * 2, 2); | |
byteList.Add((byte)Convert.ToInt32(hexNumber, 16)); | |
} |
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
public static class ListExtentions | |
{ | |
public static IEnumerable Cartesian(this IEnumerable<IEnumerable> items) | |
{ | |
var slots = items | |
// initialize enumerators | |
.Select(x => x.GetEnumerator()) | |
// get only those that could start in case there is an empty collection | |
.Where(x => x.MoveNext()) | |
.ToArray(); |
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 bash | |
# ---------------------------------------------------------------------------------- | |
# Script for checking the temperature reported by the ambient temperature sensor, | |
# and if deemed to high send the raw IPMI command to enable dynamic fan control. | |
# | |
# Requires ipmitool – apt-get install ipmitool | |
# Tested on Ubuntu 17.04 | |
# ---------------------------------------------------------------------------------- |