npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-serverstatusbot

v1.0.0

Published

A NodeJS bot to alert server downtime

Downloads

5

Readme

Node ServerStatusBot

ServerStatusBot is a Slack bot that alters you when a web server goes down.

Inspired by lmammino's NorrisBot

Why?

Want to get a notification in Slack when a server/API HTTP response changes, but don't want to use a fancy tool like New Relic?

Installation

$ npm install -g serverstatusbot

Support

This bot is using ES2015 syntax, so might not work as desired on NodeJS builds pre-V6. As you can see from this support guide ES2015 is about 50% for V5 and below, but should work nonetheless.

Running ServerStatusBot

To run the ServerStatusBot you must have an API token to authenticate the bot on your slack channel. Once you get it (instructions on the next paragraph) you just have to run:

$ BOT_API_KEY=your_slack_API_key CHANNEL=server-status HOSTS=https://jimmycann.com,http://google.com serverstatusbot

Getting the API token for your Slack channel

To allow the ServerStatusBot to connect your Slack channel you must provide him an API key. To retrieve it you need to add a new Bot in your Slack organization by visiting the following url: https://yourorganization.slack.com/services/new/bot, where yourorganization must be substituted with the name of your organization (e.g. https://loige.slack.com/services/new/bot). Ensure you are logged to your Slack organization in your browser and you have the admin rights to add a new bot.

You will find your API key under the field API Token, copy it in a safe place and get ready to use it.

Configuration

ServerStatusBot is configurable through environment variables. There are several variable available:

| PROCESS_ENV variable | Description | Notes | |----------------------|-------------|-------| | BOT_API_KEY | Your Slack API key (Mandatory) | | | BOT_NAME | The name of your bot. Will default to 'serverstatusbot' (Optional) | | | CHANNEL | The Slack channel to use. Will default to 'server-status' (Optional) | | | HOSTS | A comma-delimted list of hosts to check (no spaces, include protocol). Will default to 'https://google.com' (Optional) | Make sure you add 'http://' https://' to the start (eg. http://google.com,https://yahoo.com) | | INTERVAL | Time in milliseconds between each check. Will default to 1000 (Optional) | Best not to go under 1000ms due to Slack API's rate limits |

Command example

If you downloaded the source code of the bot you can run it with:

$ BOT_API_KEY=your_slack_API_key CHANNEL=server-status HOSTS=https://jimmycann.com,http://google.com node bin/bot.js

Bugs and improvements

Feel free to open an issue or submit a PR. Your feedback makes me a better programmer!

Origins

I wanted a quick project I could do for fun in a day, and also solve a problem. Instead of manually checking my personal website to make sure nothing has gone horribly, horribly wrong, I can now just let Slack tell me there's a problem.

Code inspiration comes from lmammino's NorrisBot. A very detailed article has been published to explain every single line of code for norrisbot. It also explains you how to deploy the bot on a free Heroku instance.

License

Licensed under MIT License. ©2016 Jimmy Cann