Skip to content

Instantly share code, notes, and snippets.

View kstolte's full-sized avatar
:shipit:
Ahhhh `git push` it. Real good.

Keith Stolte kstolte

:shipit:
Ahhhh `git push` it. Real good.
View GitHub Profile
@kstolte
kstolte / VerifyTCPConnectionExists.cs
Last active October 30, 2017 15:04
There are many times when you are trying to connect to an service. Depending on what service you are trying to connect to, there may not be a short circuit when the Server is not available at all. The following will verify that the server is accepting connections on a specific port so that you can "ping" specifically to your intended use port. T…
using System.Net.Sockets;
private bool CheckForServer(string address, int port)
{
int timeout = 500;
var result = false;
try
{
using(var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
@kstolte
kstolte / AzureAlert2SlackWebTask.js
Created January 29, 2018 19:06
Webtask to have an Azure Alert be sent to a Slack Channel
var request = require('request');
module.exports = function (context, done) {
var recBody = context.body;
var rContext = recBody.context;
var rCondition = rContext.condition;
var icon = recBody.status === 'Activated' ? ':open_mouth:': ':party_parrot:';
var outText = `${rContext.resourceName} - ${rContext.name} - ${recBody.status} <${rContext.portalLink}|Click Here>
Condition: ${rCondition.metricName} ${rCondition.operator} ${rCondition.threshold} (${rCondition.metricUnit}) in the last ${rCondition.windowSize} minutes