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

cp2017-service-monitor

v0.0.4

Published

This node script represents a monitor of the service marketplace. It is part of the Cloud Prototyping Project at TU Berlin (ISE)

Downloads

21

Readme

Ethereum contract event listener

Build Status This little node script is part of the Cloud Prototyping Project at TU Berlin (ISE). It represents a monitor that randomly gets jobs from the Monitoring-Contract of the service marketplace. As soon as the monitor receives a job it starts monitoring the availability of a provided endpoint URL. After a certain time period has passed, the script writes back the result as percentage of of availability over the time period.

The project is based on this generic ethereum event listener: https://www.npmjs.com/package/ethereum-listener

Installation

At the moment there are two possibilities to run the CLI tool.

https://www.npmjs.com/package/cp2017-service-monitor

1. Run the script locally

First download the project from Github and navigate to the project directory. Then simply run:

$ node index.js

2. Install as global NPM package

Install the CLI tool as a global NPM packe by running:

$ npm install cp2017-service-monitor -g

Now you can easily start the script by typing:

$ cp2017-service-monitor

Getting started

1. Start ethereum client

To talk to an ethereum node from inside this monitoring script we use the web3.js library, which gives an convenient interface for the RPC methods. In order to make it work, you need to follow the following instructions.

Start your ethereum client with the --rpc flag. Because we are accessing the RPC interface from the monitoring-script, CORS will need to be enabled like: geth --rpc --rpcapi db,eth,net,web3,personal,shh --shh --rpccorsdomain "http://localhost:4200"

If you don't want to use the default port (8545), you can change the default HTTP-RPC port with: geth --rpc --rpcapi db,eth,net,web3,personal,shh --shh --rpccorsdomain "http://localhost:4200" --rpcport <portnumber>

2. Use the script

2.a Provide parameters

Here is an example how you can provide the information as arguments when starting the script:

$ cp2017-service-monitor --ethereumProvider="http://localhost:8545" --password="pw0" --contractAddress="7596bcd41d32d170c572349c47d6c3f78004dbd6" --contractAbi=contract-abi

Be aware that the --contractAbi parameter needs to get the address to a file in your file system (which contains the abi) instead of the ABI itself. Also make sure that you remove the prefix 0x of the contract address.

2.a Use interactive CLI

If you don't provide the parameters when starting the monitor, it will start an interactive CLI where you can pass all the parameters one after another. Start the script by $ cp2017-service-monitor. It will ask you for the address of your ethereum client and the password for the first user (the one at eth.accounts[0]). Then it asks for the contract address as well as for the contract abi.

Here is an example how to use the script with the CLI interface:

  ____                          _                   __  __                   _   _
 / ___|    ___   _ __  __   __ (_)   ___    ___    |  \/  |   ___    _ __   (_) | |_    ___    _ __
 \___ \   / _ \ | '__| \ \ / / | |  / __|  / _ \   | |\/| |  / _ \  | '_ \  | | | __|  / _ \  | '__|
  ___) | |  __/ | |     \ V /  | | | (__  |  __/   | |  | | | (_) | | | | | | | | |_  | (_) | | |
 |____/   \___| |_|      \_/   |_|  \___|  \___|   |_|  |_|  \___/  |_| |_| |_|  \__|  \___/  |_|

You did not provide the arguments (ethereumProvider, password, contractAddress, contractAbi).
? Enter your ethereum client address: http://localhost:8545
? Enter your ethereum user password: ***
? Enter the address of the contract that you want to listen to: 0xd6e3763357a75e106f84a8125c91f53aeced28e2
? Enter the ABI of the contract that you want to listen to: Received
Subscribing to newMonitorRecord
Subscribing to jobMonitorEvent
New monitoring jobs available
Asking the contract for a job: Get monitor request called
Transaction hash: 0x11b6f4270584fa0120b891d5dafdc6de37111ede21b9b1b534940c40c2a9a186
New job recieved. Index: 9
Start monitoring: http://localhost:3000/api/monitor