Git Product home page Git Product logo

connection-test-exporter's Introduction

Connection Test Exporter

A quick utility I wrote to test my internet connection, and record a log of when it was up or down.

*** Now with prometheus metrics support! ***

By default it attempts to connect by default to bbc.co.uk, and will export a number of metrics to prometheus as it does so, along with writing out some cool output to your terminal. It can also write a log to a directory in your home folder. It should work on all platforms supported by the go compiler, but has only been tested on Windows 10 for now, as that's the PC I have that's connected by ethernet directly to my home router.

Build

go build

Requires

Some kind of emoji font installed because I like being able to spot the dropped connections at a glance in the output.

Run

PS C:\Users\point\Documents\Development\connection-test> connection-test 
[info] 2022/06/03 10:08:18.456512 main.go:108: script invoked using log file: C:\Users\point\connection-tests\Fri-3-Jun-2022.log
[info] 2022/06/03 10:08:18.666002 main.go:55: ๐Ÿ‘ Connection to https://bbc.co.uk was a success, status code: 200
[info] 2022/06/03 10:08:20.795040 main.go:55: ๐Ÿ‘ Connection to https://bbc.co.uk was a success, status code: 200
[info] 2022/06/03 10:08:22.844687 main.go:55: ๐Ÿ‘ Connection to https://bbc.co.uk was a success, status code: 200
[info] 2022/06/03 10:08:24.896820 main.go:55: ๐Ÿ‘ Connection to https://bbc.co.uk was a success, status code: 200
[info] 2022/06/03 10:08:26.949276 main.go:55: ๐Ÿ‘ Connection to https://bbc.co.uk was a success, status code: 200

Example log output:

[error] 2022/06/03 00:48:00.811478 main.go:46: Get "https://bbc.co.uk": dial tcp: lookup bbc.co.uk: no such host
[error] 2022/06/03 00:48:00.811478 main.go:55: ๐Ÿ˜ก Connection to https://bbc.co.uk was a fail, response nil
[error] 2022/06/03 00:48:09.872935 main.go:46: Get "https://bbc.co.uk": dial tcp: lookup bbc.co.uk: no such host
[error] 2022/06/03 00:48:09.872935 main.go:55: ๐Ÿ˜ก Connection to https://bbc.co.uk was a fail, response nil
[error] 2022/06/03 00:48:11.879708 main.go:46: Get "https://bbc.co.uk": dial tcp: lookup bbc.co.uk: no such host
[error] 2022/06/03 00:48:11.879708 main.go:55: ๐Ÿ˜ก Connection to https://bbc.co.uk was a fail, response nil
[info] 2022/06/03 10:08:18.456512 main.go:108: script invoked using log file: C:\Users\point\connection-tests\Fri-3-Jun-2022.log
[info] 2022/06/03 10:08:18.666002 main.go:55: ๐Ÿ‘ Connection to https://bbc.co.uk was a success, status code: 200
[info] 2022/06/03 10:08:20.795040 main.go:55: ๐Ÿ‘ Connection to https://bbc.co.uk was a success, status code: 200

FAQs

Why not just use the blackbox exporter?

Good question - because I wanted to write something myself.

connection-test-exporter's People

Contributors

linuxad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.