Skip to content

Commit

Permalink
rename fully the program
Browse files Browse the repository at this point in the history
  • Loading branch information
manos committed Apr 5, 2018
1 parent 44bfe09 commit 78c3e24
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM scratch
ADD ca-certificates.crt /etc/ssl/certs/
ADD pingdom2mysql-docker /
ENTRYPOINT ["/pingdom2mysql-docker"]
ADD pingdom2stats-docker /
ENTRYPOINT ["/pingdom2stats-docker"]
CMD ["--help"]
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
VERSION=$(shell git describe --tags)
DOCKER_REPO=""
pingdom2mysql: *.go
pingdom2stats: *.go
go build -ldflags "-X main.version=$(VERSION)"

version:
@echo $(VERSION)

run: pingdom2mysql
./pingdom2mysql --help
run: pingdom2stats
./pingdom2stats --help

pingdom2mysql-osx: *.go
pingdom2stats-osx: *.go
GOOS=darwin GOARCH=amd64 go build -o $@ -ldflags "-X main.VERSION=$(VERSION)"

pingdom2mysql-armv6: *.go
pingdom2stats-armv6: *.go
GOOS=linux GOARCH=arm GOARM=6 go build -o $@ -ldflags "-X main.VERSION=$(VERSION)"

pingdom2mysql-x86: *.go
pingdom2stats-x86: *.go
GOOS=linux GOARCH=386 go build -o $@ -ldflags "-X main.VERSION=$(VERSION)"

pingdom2mysql-amd64: *.go
pingdom2stats-amd64: *.go
GOOS=linux GOARCH=amd64 go build -o $@ -ldflags "-X main.VERSION=$(VERSION)"

pingdom2mysql-docker:
pingdom2stats-docker:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o $@ -ldflags "-X main.VERSION=$(VERSION)"
docker build --tag $(DOCKER_REPO)pingdom2mysql:$(VERSION) .
docker tag $(DOCKER_REPO)pingdom2mysql:$(VERSION) $(DOCKER_REPO)pingdom2mysql:latest
docker build --tag $(DOCKER_REPO)pingdom2stats:$(VERSION) .
docker tag $(DOCKER_REPO)pingdom2stats:$(VERSION) $(DOCKER_REPO)pingdom2stats:latest

build-all: pingdom2mysql-armv6 pingdom2mysql-osx pingdom2mysql-x86 pingdom2mysql-amd64
# pingdom2mysql-docker
build-all: pingdom2stats-armv6 pingdom2stats-osx pingdom2stats-x86 pingdom2stats-amd64
# pingdom2stats-docker


.PHONY: version run build-all pingdom2mysql-docker
.PHONY: version run build-all pingdom2stats-docker
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# What
# What is it
Pulls data from Pingdom's API and pushes them to a mysql or postgres table.

# How to use
Expand All @@ -9,18 +9,19 @@ You can use mysql or postgres with the appropriate flags. The DSN for each are:
- Mysql: "username:password@(address)/dbname"
- postgres: "postgres://username:password@address:port/dbname?sslmode=disable"
- (sslmode can be disable, require, verify-ca, verify-full depending on your server configuration)
- for a postgres db you might need to use the --pgschema flag to define the schema. (default:"postgres")

## DB table
On first run, the user must create the table. They can do that manually or by running:
`pingdom2mysql --inittable --mysqlurl="username:password@(address)/dbname"` (mysql)
`pingdom2stats --inittable --mysqlurl="username:password@(address)/dbname"` (mysql)
or
`pingdom2mysql --inittable --pgurl="postgres://username:password@address:port/dbname?sslmode=disable"` (postgres)
`pingdom2stats --inittable --pgurl="postgres://username:password@address:port/dbname?sslmode=disable"` (postgres)
in order to create the table (and check the DB connection)

## Adding checks
For every check that it's added, run with `--addcheck` in order to add the appropriate columns to the table.
**Attention!** For very big tables this might take some time.
`pingdom2mysql --addcheck --checkid=$YOUR_CHECK_ID --mysqlurl="username:password@(address)/dbname"`
`pingdom2stats --addcheck --checkid=$YOUR_CHECK_ID --mysqlurl="username:password@(address)/dbname"`
Two new columns will be created with the name of the check and the check result fields. So your table will look like this:
```
mysql> describe summary_performances;
Expand All @@ -41,15 +42,15 @@ Add it to a job scheduler like cron or chronos. I prefer to run it every 20 hour

- The program should be used like this:
```
pingdom2mysql --appkey=$YOURAPPKEY --checkid=$CHECKID --email=$ACCOUNTMAIL --pass=$ACCOUNTPASSWORD --mysqlurl="$DBUSER:$DBPASS@($DBIP:$DBPORT)/$DBNAME" --output="mysql"
pingdom2stats --appkey=$YOURAPPKEY --checkid=$CHECKID --email=$ACCOUNTMAIL --pass=$ACCOUNTPASSWORD --mysqlurl="$DBUSER:$DBPASS@($DBIP:$DBPORT)/$DBNAME" --output="mysql"
```
You might want to use `--output="console"` first to see the data that will end up in your database.

## Running in docker
For running it inside docker create the docker image by running
`make pingdom2mysql-docker` and then run it like
`make pingdom2stats-docker` and then run it like (mysql example)
```
docker run --rm pingdom2mysql --appkey=$YOURAPPKEY --checkid=$CHECKID --email=$ACCOUNTMAIL --pass=$ACCOUNTPASSWORD --mysqlurl="$DBUSER:$DBPASS@($DBIP:$DBPORT)/$DBNAME" --output="mysql"
docker run --rm pingdom2stats --appkey=$YOURAPPKEY --checkid=$CHECKID --email=$ACCOUNTMAIL --pass=$ACCOUNTPASSWORD --mysqlurl="$DBUSER:$DBPASS@($DBIP:$DBPORT)/$DBNAME" --output="mysql"
```

## Pulling the historical data from Pingdom
Expand All @@ -58,21 +59,17 @@ You would need to add the configuration variables, lines 4-9 of `fetch_history`.

# Usage information
```
./pingdom2mysql --help
Using Pingdom's API as described in: https://www.pingdom.com/resources/api
Version: v0.2.2-4-g690a40b
Usage: pingdom2mysql [options]
All options are required (but some have defaults):
./pingdom2stats --help
--addcheck
Add new check into the mysql table, requires --mysqlurl, --checkid
Add new check into the mysql table, requires a data store, --checkid
--appkey string
Appkey for pingdom's API
--checkid string
ID of the check, aka the domain are we checking.
--email string
Pingdom's API configured e-mail account
--from value
from which (Unix)time we are asking, default 24 hours ago which is (default 1522841253)
from which (Unix)time we are asking, default 24 hours ago which is (default 1522878124)
--inittable
Initialize the table, requires --mysqlurl
--mysqlurl string
Expand All @@ -82,9 +79,12 @@ All options are required (but some have defaults):
Output destination (console, db) (default "console")
--pass string
password for pingdom's API
--pgschema string
Postgres schema (default "postgres")
--pgurl string
postgres connection in DSN, like: postgres://username:password@address:port/dbname?sslmode=disable.
Cannot use together with --mysqlurl
--to value
until which (Unix)time we are asking, default now which is (default 1522927653)
until which (Unix)time we are asking, default now which is (default 1522964524)
Using Pingdom's API as described in: https://www.pingdom.com/resources/api Version: v0.3.1 Usage: pingdom2stats [options] Most options are required (and some have defaults):
```
2 changes: 1 addition & 1 deletion fetch_history
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ then
echo "curl -u $USER:$PASS -H "app-key: $APPKEY" https://api.pingdom.com/api/2.0/checks/ | jq ."
fi
while [ $COUNTER -lt $NOW ]; do
./pingdom2mysql --appkey=${APPKEY} --email=${EMAIL} --pass=${PASS} --${DBTYPE}=${DBURL} ${SCHEMA} --output=${OUTPUT} --checkid=${CHECKID} --from=$(($COUNTER - $DAYINSECONDS)) --to=$COUNTER
./pingdom2stats --appkey=${APPKEY} --email=${EMAIL} --pass=${PASS} --${DBTYPE}=${DBURL} ${SCHEMA} --output=${OUTPUT} --checkid=${CHECKID} --from=$(($COUNTER - $DAYINSECONDS)) --to=$COUNTER
let COUNTER=COUNTER+$DAYINSECONDS
done
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ func init() {
flag.StringVar(&Config.pgurl, "pgurl", "", "postgres connection in DSN, like: postgres://username:password@address:port/dbname?sslmode=disable.\n\tCannot use together with --mysqlurl")
flag.StringVar(&Config.pgschema, "pgschema", "postgres", "Postgres schema")
flag.BoolVar(&Config.inittable, "inittable", false, "Initialize the table, requires --mysqlurl ")
flag.BoolVar(&Config.addcheck, "addcheck", false, "Add new check into the mysql table, requires --mysqlurl, --checkid ")
flag.BoolVar(&Config.addcheck, "addcheck", false, "Add new check into the mysql table, requires a data store,--checkid ")

flag.Usage = func() {
fmt.Println("Using Pingdom's API as described in: https://www.pingdom.com/resources/api")
fmt.Printf("Version: %s\nUsage: pingdom2mysql [options]\nAll options are required (but some have defaults):\n", version)
fmt.Printf("Version: %s\nUsage: pingdom2stats [options]\nMost options are required (and some have defaults):\n", version)
flag.PrintDefaults()
}
flag.Parse()
Expand Down

0 comments on commit 78c3e24

Please sign in to comment.