Skip to content

Commit

Permalink
Update Readme files
Browse files Browse the repository at this point in the history
  • Loading branch information
sanathp committed Sep 15, 2015
1 parent 9380203 commit 1314b0b
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 43 deletions.
102 changes: 80 additions & 22 deletions Config.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Writing a Config File
## Writing a Config File

A config file should be written in json format (Other formats will be added in future).
Config file shouuld be in JSON format (Support for other formats will be added in future).

## Pattern
```
Expand Down Expand Up @@ -39,13 +39,13 @@ A config file should be written in json format (Other formats will be added in f
"meanResponseCount":5
//A notification will be triggered if mean response time of last 5 requests is less than given response time. Default value is 10
},
//By default the server runs on port 7321.You can define your custom port number as below
//By default the server runs on port 7321.You can define your custom port number as below
"port":3215
}
```
Sample config file here --url
[Click here](https://github.com/sanathp/StatusOK/blob/master/sample_config.json) to view the Sample config file.

## Requests

Expand Down Expand Up @@ -97,24 +97,26 @@ You can monitor all types of REST apis or websites as below

### Request parameters

url : url of the api
requestType : Http Request Type in all capital letters eg. GET PUT POST DELETE
headers : a list of key value pairs which will be added to header of a request
formParams : a list of key value pairs which will be added to body of the request . By deafult
content type is application/x-www-form-urlencoded . for apllication/json content type add "Content-Type":"application/json" to headers
urlParams : a list of key value pais which will be appended to url .
eg: http://google.com?name= statusok

checkEvery : time in seconds .
responseCode : expected response code when a request is performed .Default values is 200.If response code is not equal then an error notification is triggered.
responseTime : expected response time in milliseconds. when mean response time is below this value a notification is triggered.
| Paramter | Descriition |
| ------------- |:-------------:|
| url | url of the api|
| requestType | Http Request Type in all capital letters eg. GET PUT POST DELETE |
| headers | a list of key value pairs which will be added to header of a request|
| formParams | a list of key value pairs which will be added to body of the request . By deafult content type is application/x-www-form-urlencoded . for apllication/json content type add "Content-Type":"application/json" to headers|
| urlParams | a list of key value pais which will be appended to url .eg: http://google.com?name= statusok|
|checkEvery|time interval in seconds.If the value is 120,a request will be sent to given url every 2 minutes|
|responseCode|expected response code when a request is performed .Default values is 200.If response code is not equal then an error notification is triggered.|
|responseTime| expected response time in milliseconds. when mean response time is below this value a notification is triggered|


## Notifications

Notifications will be triggered when mean response time is below given response time for a request or when an error is occured
Notifications will be triggered when mean response time is below given response time for a request or when an error is occured . Currently the below clients are supported to receive notifications.

To recieve notifications to your Slack Channel add below block to your config file with your mailgun details
### Slack

To recieve notifications to your Slack Channel,add below block to your config file with your slack details

```
"slack":{
Expand All @@ -125,7 +127,8 @@ To recieve notifications to your Slack Channel add below block to your config fi
```

To recieve notifications to your email using smtp server add below block to your config file with your mailgun details
### E-Mail
To recieve notifications to your email using smtp server,add below block to your config file with your smtp server details.

```
"mail":{
Expand All @@ -138,8 +141,9 @@ To recieve notifications to your email using smtp server add below block to your
}
```
### Mailgun

To recieve notifications to your email Using Mailgun add below block to your config file with your mailgun details
To recieve notifications to your email Using Mailgun add below block to your config file with your mailgun details.

```
"mailGun":{
Expand All @@ -149,8 +153,8 @@ To recieve notifications to your email Using Mailgun add below block to your con
"publicApiKey":"your publick api key"
}
```

To recieve notifications to any http Endpoint add below block to your config file with your mailgun details. Notification will be sent as a value to parameter "message"
### Http EndPoint
To recieve notifications to any http Endpoint add below block to your config file with request details. Notification will be sent as a value to parameter "message"

```
"httpEndPoint":{
Expand All @@ -162,14 +166,68 @@ To recieve notifications to any http Endpoint add below block to your config fil
}
}
```
### Write Your own Notification Client

To receive notifications to your custom client .write a .go file with the below methods to notify package.
If you want to recieve Notifications to any other clients. Write a struct with below methods and add the Struct to NotificationTypes in notify.go file .

```
GetClientName() string
Initialize() error
SendResponseTimeNotification(notification ResponseTimeNotification) error
SendErrorNotification(notification ErrorNotification) error
```
If you have written a new notification client which is useful to others, feel free to create a pull request.

## Database

Save Requests response time information and error information to your database by adding db details to config file. Currently only Influxdb 0.9.3+ is supported,adding support for any other database is very easy.

### Influx Db 0.9.3+

Install Influx db using the below commands.

```
wget http://influxdb.s3.amazonaws.com/influxdb_0.9.3_amd64.deb
dpkg -i influxdb_0.9.3_amd64.deb
/etc/init.d/influxdb start
```
Default username,password is empty and port is 8086.Add influxDb details as below inside database parameter to your config file.

```
"influxDb":{
"host":"localhost",
"port":8086,
"databaseName":"statusok",
"username":"",
"password":""
}
```

To visualize data in influxdb you need to install grafana.

![alt text](https://github.com/sanathp/StatusOK/raw/master/screenshots/graphana.png "Graphana Screenshot")

Run below commands to install grafana.

```
wget https://grafanarel.s3.amazonaws.com/builds/grafana_2.1.3_amd64.deb
apt-get update
apt-get install -y adduser libfontconfig
dpkg -i grafana_2.1.3_amd64.deb
service grafana-server start
```
Create a new Dahsboard to view graphs as mentioned here http://docs.grafana.org/datasources/influxdb .

### Save Data to any other Database

Write a struct with below methods and add the Struct to DatabaseTypes in database.go file.

```
Initialize() error
GetDatabaseName() string
AddRequestInfo(requestInfo RequestInfo) error
AddErrorInfo(errorInfo ErrorInfo) error
```

Add your object to NotificationTypes struct in notify.go file --url
If you have written structs to support any new database, feel free to create a pull request.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Donot use this Dockerfile.This is not ready yet.

# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang
Expand Down
38 changes: 17 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Monitor Your Website and Apis from your computer.Get Notified through slack or email when your server is down or response time more than expected.


## Simple Setup to monitor your website and recieve a notitification to Gmail when your website is down
## Simple Setup

Simple Setup to monitor your website and recieve a notitification to Gmail when your website is down

Step 1: Write a config.json with the url information
```
Expand Down Expand Up @@ -50,18 +52,12 @@ $ kill %jobnumber

![alt text](https://github.com/sanathp/StatusOK/raw/master/screenshots/graphana.png "Graphana Screenshot")


Install Infulxdb - url

Install Grafana - url
Install Infulxdb

write config file with influx db deatails as below

run statusok --config config.json

open Grafana db and create dashboard from influxdb data as mentioned here -- url
--write url own detailed explanation ?


## Database :

Expand All @@ -79,28 +75,28 @@ mail
mailgun
http endpoint

### Write your own notification client




complete details on how to setup .


## Contribution

feel free to pull requests.

if you have written extension for some othe database . or written notification for any other client . you can generate a pull request .


## TODO

Feel free to Create pull requests.Write Test cases for the functionalities you have written.if you have written extension for some othe database . or written notification for any other client .

## License

Copyright 2015 Sanath Kumar Pasumarthy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

## License
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License



Expand Down

0 comments on commit 1314b0b

Please sign in to comment.