ui features, failure reasons (generic), help view generated from Wiki

pull/792/head
hunterlong 2020-08-18 12:39:55 -07:00
parent 304bb27c9a
commit 3067bc085a
32 changed files with 545 additions and 79 deletions

1
.gitignore vendored
View File

@ -38,3 +38,4 @@ tmp
/frontend/cypress/screenshots/
/frontend/cypress/videos/
services.yml
statping.wiki

View File

@ -1,3 +1,11 @@
# 0.90.64 (08-18-2020)
- Modified max-width for container to 1012px, larger UI
- Added failure sparklines in the Services list view
- Added "Update Available" alert on the top of Settings if new version is available
- Added Version and Github Commit hash to left navigation on Settings page
- Added "reason" for failures (will be used for more custom notification messages) [regex, lookup, timeout, connection, close, status_code]
- Added Help page that will be generated from Statping's Wiki repo
# 0.90.63 (08-17-2020)
- Modified build process to use xgo for all arch builds
- Modified Statping's Push Notifications server notifier to match with Firebase/gorush params

View File

@ -29,10 +29,10 @@ var (
func init() {
stopped = make(chan bool, 1)
core.New(VERSION)
core.New(VERSION, COMMIT)
utils.InitEnvs()
configs.Version = VERSION
configs.Commit = COMMIT
utils.Params.Set("VERSION", VERSION)
utils.Params.Set("COMMIT", COMMIT)
rootCmd.AddCommand(versionCmd)
rootCmd.AddCommand(updateCmd)
@ -161,7 +161,7 @@ func InitApp() error {
// start routine to delete old records (failures, hits)
go database.Maintenance()
// init Sentry error monitoring (its useful)
utils.SentryInit(&VERSION, core.App.AllowReports.Bool)
utils.SentryInit(core.App.AllowReports.Bool)
core.App.Setup = true
core.App.Started = utils.Now()
return nil

View File

@ -71,13 +71,11 @@ func (t *TimeVar) ToValues() ([]*TimeValue, error) {
// GraphData will return all hits or failures
func (g *GroupQuery) GraphData(by By) ([]*TimeValue, error) {
dbQuery := g.db.MultipleSelects(
g.db = g.db.MultipleSelects(
g.db.SelectByTime(g.Group),
by.String(),
).Group("timeframe").Order("timeframe", true)
g.db = dbQuery
caller, err := g.ToTimeValue()
if err != nil {
return nil, err
@ -116,27 +114,26 @@ func (g *GroupQuery) ToTimeValue() (*TimeVar, error) {
func (t *TimeVar) FillMissing(current, end time.Time) ([]*TimeValue, error) {
timeMap := make(map[string]int64)
var validSet []*TimeValue
dur := t.g.Group
for _, v := range t.data {
timeMap[v.Timeframe] = v.Amount
}
for {
currentStr := types.FixedTime(current, t.g.Group)
for {
var amount int64
if timeMap[currentStr] != 0 {
amount = timeMap[currentStr]
}
validSet = append(validSet, &TimeValue{
Timeframe: currentStr,
Amount: amount,
})
current = current.Add(t.g.Group)
if current.After(end) {
break
}
current = current.Add(dur)
currentStr = types.FixedTime(current, t.g.Group)
}
return validSet, nil

View File

@ -21,7 +21,7 @@
"@fortawesome/vue-fontawesome": "^0.1.9",
"@sentry/browser": "^5.20.1",
"@sentry/integrations": "^5.20.1",
"apexcharts": "^3.15.0",
"apexcharts": "^3.6.6",
"axios": "^0.19.1",
"codemirror-colorpicker": "^1.9.66",
"core-js": "^3.6.5",
@ -29,8 +29,9 @@
"js-beautify": "^1.11.0",
"querystring": "^0.2.0",
"sass": "^1.26.10",
"semver": "^7.3.2",
"vue": "^2.6.11",
"vue-apexcharts": "^1.5.2",
"vue-apexcharts": "^1.6.0",
"vue-clipboard2": "^0.3.1",
"vue-codemirror": "^4.0.6",
"vue-cookies": "^1.7.0",
@ -75,6 +76,7 @@
"expect": "^25.1.0",
"file-loader": "^5.0.2",
"friendly-errors-webpack-plugin": "~1.7",
"github-wikito-converter": "^1.5.2",
"html-webpack-plugin": "^4.0.0-beta.11",
"jsdom": "^16.2.0",
"jsdom-global": "^3.0.2",

View File

@ -270,6 +270,10 @@ class Api {
}
}
async github_release() {
return fetch('https://api.github.com/repos/statping/statping/releases/latest').then(response => response.json())
}
async allActions(...all) {
await axios.all([all])
}

View File

@ -105,6 +105,11 @@ A:HOVER {
color: $group-list-title;
}
.chart_list_tooltip {
height: 30px;
font-size: 6pt;
}
.container {
padding-top: 20px;
padding-bottom: 25px;

View File

@ -2,7 +2,7 @@
$background-color: #EAEAEA;
$container-color: #ffffff;
$text-color: #2a2a2a;
$max-width: 860px;
$max-width: 1012px;
$title-color: #4e4e4e;
$description-color: #828282;
$subtitle-color: #747474;

View File

@ -9,6 +9,7 @@
<th scope="col">{{$t('username')}}</th>
<th scope="col">{{$t('type')}}</th>
<th scope="col" class="d-none d-md-table-cell">{{ $t('last_login') }}</th>
<th scope="col" class="d-none d-md-table-cell">Scopes</th>
<th scope="col"></th>
</tr>
</thead>
@ -22,6 +23,7 @@
</span>
</td>
<td class="d-none d-md-table-cell">{{niceDate(user.updated_at)}}</td>
<td class="d-none d-md-table-cell">{{user.scopes}}</td>
<td class="text-right">
<div class="btn-group">
<a @click.prevent="editUser(user, edit)" href="#" class="btn btn-outline-secondary edit-user">

View File

@ -9,8 +9,18 @@
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col" class="d-none d-md-table-cell">Status</th>
<th scope="col" class="d-none d-md-table-cell">Visibility</th>
<th scope="col" class="d-none d-md-table-cell">{{ $t('group') }}</th>
<th scope="col" class="d-none d-md-table-cell" style="width: 130px">
Failures
<div class="btn-group float-right" role="group">
<a @click="list_timeframe='3h'" type="button" class="small" :class="{'text-success': list_timeframe==='3h', 'text-muted': list_timeframe!=='3h'}">3h</a>
<a @click="list_timeframe='12h'" type="button" class="small" :class="{'text-success': list_timeframe==='12h', 'text-muted': list_timeframe!=='12h'}">12h</a>
<a @click="list_timeframe='24h'" type="button" class="small" :class="{'text-success': list_timeframe==='24h', 'text-muted': list_timeframe!=='24h'}">24h</a>
<a @click="list_timeframe='7d'" type="button" class="small" :class="{'text-success': list_timeframe==='7d', 'text-muted': list_timeframe!=='7d'}">7d</a>
</div>
</th>
<th scope="col"></th>
</tr>
</thead>
@ -21,6 +31,11 @@
<font-awesome-icon icon="bars" class="mr-3"/>
</span> {{service.name}}
</td>
<td class="d-none d-md-table-cell">
<span class="badge text-uppercase" :class="{'badge-success': service.online, 'badge-danger': !service.online}">
{{service.online ? $t('online') : $t('offline')}}
</span>
</td>
<td class="d-none d-md-table-cell">
<span class="badge text-uppercase" :class="{'badge-primary': service.public, 'badge-secondary': !service.public}">
{{service.public ? $t('public') : $t('private')}}
@ -31,6 +46,9 @@
<span class="badge badge-secondary">{{serviceGroup(service)}}</span>
</div>
</td>
<td class="d-none d-md-table-cell">
<ServiceSparkList :service="service" :timeframe="list_timeframe"/>
</td>
<td class="text-right">
<div class="btn-group">
<button :disabled="loading" v-if="$store.state.admin" @click.prevent="goto({path: `/dashboard/edit_service/${service.id}`, params: {service: service} })" class="btn btn-sm btn-outline-secondary">
@ -53,18 +71,70 @@
<script>
import Api from "../../API";
import ServiceSparkList from "@/components/Service/ServiceSparkList";
const draggable = () => import(/* webpackChunkName: "dashboard" */ 'vuedraggable')
const ToggleSwitch = () => import(/* webpackChunkName: "dashboard" */ '../../forms/ToggleSwitch');
export default {
name: 'ServicesList',
components: {
ServiceSparkList,
ToggleSwitch,
draggable
},
data() {
return {
loading: false,
list_timeframe: "12h",
chartOpts: {
chart: {
type: 'bar',
height: 50,
sparkline: {
enabled: true
},
},
xaxis: {
type: 'numeric',
},
showPoint: false,
fullWidth:true,
chartPadding: {top: 0,right: 0,bottom: 0,left: 0},
stroke: {
curve: 'straight'
},
fill: {
opacity: 0.8,
},
yaxis: {
min: 0
},
plotOptions: {
bar: {
colors: {
ranges: [{
from: 0,
to: 1,
color: '#39c10a'
}, {
from: 2,
to: 90,
color: '#e01a1a'
}]
},
},
},
tooltip: {
theme: false,
enabled: false,
},
title: {
enabled: false,
},
subtitle: {
enabled: false,
}
}
}
},
computed: {

View File

@ -0,0 +1,46 @@
const serviceSparkLine = {
chart: {
type: 'bar',
height: 50,
sparkline: {
enabled: true
},
},
stroke: {
curve: 'straight'
},
fill: {
opacity: 0.3,
},
yaxis: {
min: 0
},
colors: ['#b3bdc3'],
tooltip: {
theme: false,
enabled: false,
},
title: {
text: this.title,
offsetX: 0,
style: {
fontSize: '28px',
cssClass: 'apexcharts-yaxis-title'
}
},
subtitle: {
text: this.subtitle,
offsetX: 0,
style: {
fontSize: '14px',
cssClass: 'apexcharts-yaxis-title'
}
}
}
export default {
ServiceList: serviceSparkLine
}

View File

@ -1,10 +1,13 @@
<template>
<footer>
<div v-if="!core.footer" class="footer text-center mb-4 p-2">
<a href="https://github.com/statping/statping" target="_blank">
Statping {{core.version}} made with <font-awesome-icon icon="heart" class="text-danger"/>
</a> |
<div class="d-block small text-dim">
<div class="d-block">
<router-link :to="$store.state.admin ? '/dashboard' : '/login'">{{$t('top_nav.dashboard')}}</router-link>
</div>
<a class="mt-3" href="https://github.com/statping/statping" target="_blank">Statping</a> v{{core.version}}
made with <font-awesome-icon icon="heart" class="text-danger"/>
</div>
</div>
<div v-else class="footer text-center mb-4 p-2" v-html="core.footer"></div>
</footer>
@ -21,6 +24,9 @@
computed: {
core() {
return this.$store.getters.core
},
commit() {
return this.$store.getters.core.commit.slice(0,8)
}
}
}

View File

@ -0,0 +1,162 @@
<template>
<div class="text-center" style="width:210px" v-if="!loaded">
<font-awesome-icon icon="circle-notch" class="h-25 text-dim" spin/>
</div>
<apexchart v-else width="240" height="30" type="bar" :options="chartOpts" :series="data"></apexchart>
</template>
<script>
import Api from "@/API";
const timeoptions = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' };
export default {
name: "ServiceSparkList",
props: {
service: {
required: true,
type: Object,
},
timeframe: {
required: true,
type: String,
}
},
data() {
return {
data: null,
loaded: false,
chartOpts: {
chart: {
type: 'bar',
height: 50,
sparkline: {
enabled: true
},
animations: {
enabled: false,
},
},
xaxis: {
type: 'datetime',
},
showPoint: false,
fullWidth:true,
chartPadding: {top: 0,right: 0,bottom: 0,left: 0},
stroke: {
curve: 'straight'
},
fill: {
opacity: 0.4,
},
yaxis: {
min: 0,
max: 5,
},
plotOptions: {
bar: {
colors: {
ranges: [{
from: 0,
to: 1,
color: '#cfcfcf'
}, {
from: 2,
to: 3,
color: '#f58e49'
}, {
from: 3,
to: 20,
color: '#e01a1a'
}, {
from: 21,
to: Infinity,
color: '#9b0909'
}]
},
},
},
tooltip: {
theme: false,
enabled: true,
custom: ({series, seriesIndex, dataPointIndex, w}) => {
let val = series[seriesIndex][dataPointIndex];
let ts = w.globals.seriesX[seriesIndex][dataPointIndex];
const dt = new Date(ts).toLocaleDateString("en-us", timeoptions)
let ago = `${(dataPointIndex-12) * -1} hours ago`
if ((dataPointIndex-12) * -1 === 0) {
ago = `Current hour`
}
return `<div class="chart_list_tooltip">${val-1} Failures<br>${dt}</div>`
},
fixed: {
enabled: true,
position: 'topLeft',
offsetX: 0,
offsetY: 0,
},
x: {
formatter: (value) => { return value },
},
y: {
show: false
},
},
title: {
enabled: false,
},
subtitle: {
enabled: false,
}
}
}
},
mounted() {
this.loadFailures()
},
watch: {
timeframe(o, n) {
this.loaded = false
this.loadFailures()
this.loaded = true
}
},
methods: {
convertChartData(data) {
if (!data) {
return []
}
let arr = []
data.forEach((d, k) => {
arr.push({
x: d.timeframe,
y: d.amount+1,
})
})
return arr
},
async loadFailures() {
this.loaded = false
let start = 43200
let group = "12h"
if (this.timeframe === "3h") {
start = 10800
group = "5m"
} else if (this.timeframe === "12h") {
start = 43200
group = "1h"
} else if (this.timeframe === "24h") {
start = 86400
group = "2h"
} else if (this.timeframe === "7d") {
start = 86400 * 7
group = "24h"
}
const data = await Api.service_failures_data(this.service.id, this.toUnix(this.nowSubtract(start)), this.toUnix(this.now()), group, true)
this.loaded = true
this.data = [{data: this.convertChartData(data)}]
}
},
}
</script>

View File

@ -3,6 +3,13 @@
<div class="row">
<div class="col-md-3 col-sm-12 mb-4 mb-md-0">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<div v-if="version_below" class="alert small text-center mt-0 pt-0 pb-0">
Update {{github.tag_name}} Available
<a href="https://github.com/statping/statping/releases/latest" class="btn btn-sm text-success mt-2">Download</a>
<a href="https://github.com/statping/statping/blob/master/CHANGELOG.md" class="btn btn-sm text-dim mt-2">Changelog</a>
</div>
<h6 class="text-muted">{{ $t('settings.main') }}</h6>
<a @click.prevent="changeTab" class="nav-link" v-bind:class="{active: liClass('v-pills-home-tab')}" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">
@ -48,9 +55,10 @@
<font-awesome-icon icon="code-branch" class="mr-3"/> {{$t('settings.repo')}}
</a>
<div class="row justify-content-center mt-2">
<github-button href="https://github.com/statping/statping" data-icon="octicon-star" data-show-count="true" aria-label="Star Statping on GitHub">Star</github-button>
</div>
<span class="small text-dim text-center mt-5">Statping v{{core.version}}<br>
<a class="small text-muted no-decoration" v-if="core.commit" v-bind:href="`https://github.com/statping/statping/commit/${core.commit}`">{{core.commit.slice(0,8)}}</a>
</span>
</div>
@ -116,8 +124,8 @@
<script>
import Api from '../API';
import GithubButton from 'vue-github-button'
import Variables from "@/components/Dashboard/Variables";
const semver = require('semver')
const CoreSettings = () => import(/* webpackChunkName: "dashboard" */ '@/forms/CoreSettings')
const FormIntegration = () => import(/* webpackChunkName: "dashboard" */ '@/forms/Integration')
@ -130,7 +138,6 @@
name: 'Settings',
components: {
Variables,
GithubButton,
OAuth,
Cache,
ThemeEditor,
@ -141,6 +148,7 @@
data() {
return {
tab: "v-pills-home-tab",
github: null,
}
},
computed: {
@ -149,6 +157,12 @@
},
notifiers() {
return this.$store.getters.notifiers
},
version_below() {
if (!this.github) {
return false
}
return semver.gt(semver.coerce(this.github.tag_name), this.core.version)
}
},
mounted() {
@ -164,6 +178,14 @@
const n = await Api.notifiers()
this.$store.commit('setNotifiers', n)
this.cache = await Api.cache()
await this.getGithub()
},
async getGithub() {
try {
this.github = await Api.github_release()
} catch(e) {
console.error(e)
}
},
changeTab(e) {
this.tab = e.target.id

View File

@ -6,6 +6,7 @@ const DashboardServices = () => import(/* webpackChunkName: "dashboard" */ '@/co
const DashboardMessages = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardMessages')
const EditService = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/EditService')
const Logs = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Logs')
const Help = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Help')
const Settings = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Settings')
const Login = () => import(/* webpackChunkName: "index" */ '@/pages/Login')
const Service = () => import(/* webpackChunkName: "index" */ '@/pages/Service')
@ -158,7 +159,7 @@ const routes = [
}
},{
path: 'help',
component: Logs,
component: Help,
meta: {
requiresAuth: true,
title: 'Statping - Help',

View File

@ -2034,7 +2034,7 @@ anymatch@~3.1.1:
normalize-path "^3.0.0"
picomatch "^2.0.4"
apexcharts@^3.15.0:
apexcharts@^3.6.6:
version "3.20.0"
resolved "https://registry.yarnpkg.com/apexcharts/-/apexcharts-3.20.0.tgz#768bb963d2bd87abe3a37a6ee35c7fc7d43bbfb7"
integrity sha512-DuQ9SlFPJBJwamYudzwf/Z6KMaIRUhnVBQk/TBa3mXzN2SwS3GgGz7V39OS1GfcPlPUTTy8vXv91M8pYmfFkCg==
@ -2176,6 +2176,11 @@ async@^2.6.2:
dependencies:
lodash "^4.17.14"
async@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/async/-/async-1.0.0.tgz#f8fc04ca3a13784ade9e1641af98578cfbd647a9"
integrity sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=
asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
@ -2338,6 +2343,11 @@ bluebird@3.7.2, bluebird@^3.1.1, bluebird@^3.5.1, bluebird@^3.5.5:
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
bluebird@^2.9.34:
version "2.11.0"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1"
integrity sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=
bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.4.0:
version "4.11.9"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828"
@ -2381,6 +2391,11 @@ boolbase@^1.0.0, boolbase@~1.0.0:
resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24=
bootstrap@^3.3.7:
version "3.4.1"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-3.4.1.tgz#c3a347d419e289ad11f4033e3c4132b87c081d72"
integrity sha512-yN5oZVmRCwe5aKwzRj6736nSmKDX7pLYwsXiCj/EYmo16hODaBiT4En5btW/jhBF/seV+XMx3aYwukYC3A49DA==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
@ -3104,6 +3119,11 @@ colorette@^1.2.1:
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b"
integrity sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==
colors@1.0.x:
version "1.0.3"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
integrity sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=
combined-stream@^1.0.6, combined-stream@~1.0.6:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
@ -3116,7 +3136,7 @@ commander@2.17.x:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==
commander@^2.18.0, commander@^2.19.0, commander@^2.20.0:
commander@^2.18.0, commander@^2.19.0, commander@^2.20.0, commander@^2.8.1:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
@ -3622,6 +3642,11 @@ cssstyle@^2.2.0:
dependencies:
cssom "~0.3.6"
cycle@1.0.x:
version "1.0.3"
resolved "https://registry.yarnpkg.com/cycle/-/cycle-1.0.3.tgz#21e80b2be8580f98b468f379430662b046c34ad2"
integrity sha1-IegLK+hYD5i0aPN5QwZisEbDStI=
cyclist@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
@ -3643,6 +3668,15 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"
datauri@^1.0.5:
version "1.1.0"
resolved "https://registry.yarnpkg.com/datauri/-/datauri-1.1.0.tgz#c6184ff6b928ede4e41ccc23ab954c7839c4fb39"
integrity sha512-0q+cTTKx7q8eDteZRIQLTFJuiIsVing17UbWTPssY4JLSMaYsk/VKpNulBDo9NSgQWcvlPrkEHW8kUO67T/7mQ==
dependencies:
image-size "^0.6.2"
mimer "^0.3.2"
semver "^5.5.0"
date-fns@^2.9.0:
version "2.15.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.15.0.tgz#424de6b3778e4e69d3ff27046ec136af58ae5d5f"
@ -3756,7 +3790,7 @@ default-gateway@^5.0.5:
dependencies:
execa "^3.3.0"
defaults@^1.0.3:
defaults@^1.0.2, defaults@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=
@ -4635,6 +4669,11 @@ extsprintf@^1.2.0:
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f"
integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8=
eyes@0.1.x:
version "0.1.8"
resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0"
integrity sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=
fast-deep-equal@^3.1.1:
version "3.1.3"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
@ -4950,6 +4989,16 @@ from@~0:
resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe"
integrity sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=
fs-extra@^0.23.1:
version "0.23.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.23.1.tgz#6611dba6adf2ab8dc9c69fab37cddf8818157e3d"
integrity sha1-ZhHbpq3yq43Jxp+rN83fiBgVfj0=
dependencies:
graceful-fs "^4.1.2"
jsonfile "^2.1.0"
path-is-absolute "^1.0.0"
rimraf "^2.2.8"
fs-extra@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
@ -5060,6 +5109,25 @@ github-buttons@^2.8.0:
resolved "https://registry.yarnpkg.com/github-buttons/-/github-buttons-2.14.0.tgz#32ce381651091accda09217cd7a6e4c77f91e222"
integrity sha512-rAwKwFOiWoyhb3g5ZyXjI3XXprAa36jCd0tm467aEUYtiDZkqEXkepuzNg9LryLbnuLRQmcifIPTxLUBnuYpXQ==
github-wikito-converter@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/github-wikito-converter/-/github-wikito-converter-1.5.2.tgz#ae78bfdcdee86dc0137064d585543c59dbe47cc1"
integrity sha512-m7CcUUovtUCH5kwxmClxDnC0Q/QgepGr1SCZpyqIjshxTBdx1o7mKOmKboMQzdbXk/8DRLZ1Bbc1h3cKWx2IRw==
dependencies:
bluebird "^2.9.34"
bootstrap "^3.3.7"
commander "^2.8.1"
datauri "^1.0.5"
defaults "^1.0.2"
fs-extra "^0.23.1"
highlight.js "^9.12.0"
jquery "^2.1.4"
marked "^0.3.6"
node-dir "^0.1.9"
open "0.0.5"
winston "^1.0.1"
wkhtmltopdf "^0.1.5"
glob-parent@5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.0.tgz#5f4c1d1e748d30cd73ad2944b3577a81b081e8c2"
@ -5372,7 +5440,7 @@ hex-color-regex@^1.1.0:
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==
highlight.js@^9.6.0:
highlight.js@^9.12.0, highlight.js@^9.6.0:
version "9.18.3"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.3.tgz#a1a0a2028d5e3149e2380f8a865ee8516703d634"
integrity sha512-zBZAmhSupHIl5sITeMqIJnYCDfAEc3Gdkqj65wC1lpI468MMQeeQkhcIAvk+RylAkxrCcI9xy9piHiXeQ1BdzQ==
@ -5650,6 +5718,11 @@ ignore@^5.1.1, ignore@^5.1.4, ignore@^5.1.8:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57"
integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==
image-size@^0.6.2:
version "0.6.3"
resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.6.3.tgz#e7e5c65bb534bd7cdcedd6cb5166272a85f75fb2"
integrity sha512-47xSUiQioGaB96nqtp5/q55m0aBQSQdyIloMOc/x+QVTDZLNmXE892IIDrJ0hM1A5vcNUDD5tDffkSP5lCaIIA==
import-cwd@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9"
@ -6188,7 +6261,7 @@ isobject@^3.0.0, isobject@^3.0.1:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
isstream@~0.1.2:
isstream@0.1.x, isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=
@ -6250,6 +6323,11 @@ jest-worker@^25.4.0:
merge-stream "^2.0.0"
supports-color "^7.0.0"
jquery@^2.1.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-2.2.4.tgz#2c89d6889b5eac522a7eea32c14521559c6cbf02"
integrity sha1-LInWiJterFIqfuoywUUhVZxsvwI=
js-beautify@^1.11.0, js-beautify@^1.6.12:
version "1.11.0"
resolved "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.11.0.tgz#afb873dc47d58986360093dcb69951e8bcd5ded2"
@ -6395,6 +6473,13 @@ json5@^2.1.1, json5@^2.1.2:
dependencies:
minimist "^1.2.5"
jsonfile@^2.1.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
integrity sha1-NzaitCi4e72gzIO1P6PWM6NcKug=
optionalDependencies:
graceful-fs "^4.1.6"
jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
@ -6749,6 +6834,11 @@ markdown-table@^2.0.0:
dependencies:
repeat-string "^1.0.0"
marked@^0.3.6:
version "0.3.19"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790"
integrity sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==
mathml-tag-names@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3"
@ -6913,6 +7003,11 @@ mime@^2.3.1, mime@^2.4.4:
resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.6.tgz#e5b407c90db442f2beb5b162373d07b69affa4d1"
integrity sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==
mimer@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/mimer/-/mimer-0.3.2.tgz#0b83aabdf48eaacfd2e093ed4c0ed3d38eda8073"
integrity sha512-N6NcgDQAevhP/02DQ/epK6daLy4NKrIHyTlJcO6qBiYn98q+Y4a/knNsAATCe1xLS2F0nEmJp+QYli2s8vKwyQ==
mimic-fn@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
@ -7222,6 +7317,13 @@ no-case@^3.0.3:
lower-case "^2.0.1"
tslib "^1.10.0"
node-dir@^0.1.9:
version "0.1.17"
resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.17.tgz#5f5665d93351335caabef8f1c554516cf5f1e4e5"
integrity sha1-X1Zl2TNRM1yqvvjxxVRRbPXx5OU=
dependencies:
minimatch "^3.0.2"
node-environment-flags@1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.6.tgz#a30ac13621f6f7d674260a54dede048c3982c088"
@ -7496,6 +7598,11 @@ onetime@^5.1.0:
dependencies:
mimic-fn "^2.1.0"
open@0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc"
integrity sha1-QsPhjslUZra/DcQvOilFw/DK2Pw=
open@^6.3.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/open/-/open-6.4.0.tgz#5c13e96d0dc894686164f18965ecfe889ecfc8a9"
@ -7954,6 +8061,11 @@ pkg-dir@^4.1.0:
dependencies:
find-up "^4.0.0"
pkginfo@0.3.x:
version "0.3.1"
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21"
integrity sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=
pnp-webpack-plugin@^1.6.4:
version "1.6.4"
resolved "https://registry.yarnpkg.com/pnp-webpack-plugin/-/pnp-webpack-plugin-1.6.4.tgz#c9711ac4dc48a685dabafc86f8b6dd9f8df84149"
@ -9185,6 +9297,11 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
semver@^7.3.2:
version "7.3.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
send@0.17.1:
version "0.17.1"
resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"
@ -9335,6 +9452,11 @@ simple-swizzle@^0.2.2:
dependencies:
is-arrayish "^0.3.1"
slang@>=0.2:
version "0.3.0"
resolved "https://registry.yarnpkg.com/slang/-/slang-0.3.0.tgz#13af75b4f0c018c6a8193d704f65b23be4fbabdc"
integrity sha1-E691tPDAGMaoGT1wT2WyO+T7q9w=
slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
@ -9601,6 +9723,11 @@ stable@^0.1.8:
resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf"
integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==
stack-trace@0.0.x:
version "0.0.10"
resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0"
integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=
stack-utils@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.2.tgz#33eba3897788558bebfc2db059dc158ec36cebb8"
@ -10691,7 +10818,7 @@ vm-browserify@^1.0.1:
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==
vue-apexcharts@^1.5.2:
vue-apexcharts@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/vue-apexcharts/-/vue-apexcharts-1.6.0.tgz#c7d3afd93f712433d404e5ceeb4e3aa65f422af2"
integrity sha512-sT6tuVTLBwfH3TA7azecDNS/W70bmz14ZJI7aE7QIqcG9I6OywyH7x3hcOeY1v1DxttI8Svc5RuYj4Dd+A5F4g==
@ -11201,6 +11328,26 @@ wide-align@1.1.3:
dependencies:
string-width "^1.0.2 || 2"
winston@^1.0.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/winston/-/winston-1.1.2.tgz#68edd769ff79d4f9528cf0e5d80021aade67480c"
integrity sha1-aO3Xaf951PlSjPDl2AAhqt5nSAw=
dependencies:
async "~1.0.0"
colors "1.0.x"
cycle "1.0.x"
eyes "0.1.x"
isstream "0.1.x"
pkginfo "0.3.x"
stack-trace "0.0.x"
wkhtmltopdf@^0.1.5:
version "0.1.6"
resolved "https://registry.yarnpkg.com/wkhtmltopdf/-/wkhtmltopdf-0.1.6.tgz#e9db84eb10d4ee50a40f4c3a7f58ca3d5d365ec4"
integrity sha1-6duE6xDU7lCkD0w6f1jKPV02XsQ=
dependencies:
slang ">=0.2"
word-wrap@~1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"

View File

@ -90,7 +90,7 @@ func apiCoreHandler(w http.ResponseWriter, r *http.Request) {
}
app.UseCdn = null.NewNullBool(c.UseCdn.Bool)
app.AllowReports = null.NewNullBool(c.AllowReports.Bool)
utils.SentryInit(nil, app.AllowReports.Bool)
utils.SentryInit(app.AllowReports.Bool)
err = app.Update()
returnJson(core.App, w, r)
}

View File

@ -32,7 +32,7 @@ func init() {
utils.InitLogs()
source.Assets()
dir = utils.Directory
core.New("test")
core.New("test", "testcommithere")
}
func TestFailedHTTPServer(t *testing.T) {

View File

@ -101,7 +101,7 @@ func apiServicePatchHandler(w http.ResponseWriter, r *http.Request) {
}
if !req.Online {
services.RecordFailure(service, issueDefault)
services.RecordFailure(service, issueDefault, "trigger")
} else {
services.RecordSuccess(service)
}

View File

@ -110,7 +110,7 @@ func (w *webhooker) sendHttpWebhook(body string) (*http.Response, error) {
req.Header.Add("Content-Type", "application/json")
}
req.Header.Set("User-Agent", "Statping")
req.Header.Set("Statping-Version", utils.Version)
req.Header.Set("Statping-Version", utils.Params.GetString("VERSION"))
resp, err := client.Do(req)
if err != nil {
return nil, err

View File

@ -21,11 +21,6 @@ import (
"github.com/statping/statping/types/users"
)
var (
Version string
Commit string
)
func (d *DbConfig) ResetCore() error {
if d.Db.HasTable("core") {
return nil
@ -126,7 +121,7 @@ func (d *DbConfig) MigrateDatabase() error {
}
}
log.Infof("Migrating App to version: %s (%s)", Version, Commit)
log.Infof("Migrating App to version: %s (%s)", utils.Params.GetString("VERSION"), utils.Params.GetString("COMMIT"))
if err := tx.Table("core").AutoMigrate(&core.Core{}); err.Error() != nil {
tx.Rollback()
log.Errorln(fmt.Sprintf("Statping Database could not be migrated: %v", tx.Error()))
@ -137,7 +132,7 @@ func (d *DbConfig) MigrateDatabase() error {
return err
}
d.Db.Table("core").Model(&core.Core{}).Update("version", Version)
d.Db.Table("core").Model(&core.Core{}).Update("version", utils.Params.GetString("VERSION"))
log.Infoln("Statping Database Tables Migrated")

View File

@ -57,6 +57,8 @@ func Select() (*Core, error) {
if utils.Params.GetString("API_SECRET") != "" {
App.ApiSecret = utils.Params.GetString("API_SECRET")
}
App.Version = utils.Params.GetString("VERSION")
App.Commit = utils.Params.GetString("COMMIT")
return App, q.Error()
}

View File

@ -41,7 +41,8 @@ func Samples() error {
MigrationId: utils.Now().Unix(),
Language: utils.Params.GetString("LANGUAGE"),
OAuth: oauth,
Version: utils.Version,
Version: utils.Params.GetString("VERSION"),
Commit: utils.Params.GetString("COMMIT"),
}
return core.Create()

View File

@ -10,9 +10,10 @@ var (
App *Core
)
func New(version string) {
func New(version, commit string) {
App = new(Core)
App.Version = version
App.Commit = commit
App.Started = utils.Now()
}
@ -28,6 +29,7 @@ type Core struct {
Footer null.NullString `gorm:"column:footer" json:"footer"`
Domain string `gorm:"not null;column:domain" json:"domain"`
Version string `gorm:"column:version" json:"version"`
Commit string `gorm:"-" json:"commit"`
Language string `gorm:"column:language" json:"language"`
Setup bool `gorm:"-" json:"setup"`
MigrationId int64 `gorm:"column:migration_id" json:"migration_id,omitempty"`

View File

@ -22,6 +22,7 @@ func Example() Failure {
Service: 1,
Checkin: 0,
PingTime: 48309,
Reason: "status_code",
CreatedAt: utils.Now(),
}
}
@ -34,6 +35,7 @@ func Samples() error {
f1 := &Failure{
Service: i,
Issue: "Server failure",
Reason: "lookup",
CreatedAt: utils.Now().Add(-time.Duration(3*i) * 86400),
}
if err := f1.Create(); err != nil {
@ -42,7 +44,8 @@ func Samples() error {
f2 := &Failure{
Service: i,
Issue: "Server failure",
Issue: "Regex failed to match the response",
Reason: "regex",
CreatedAt: utils.Now().Add(-time.Duration(5*i) * 12400),
}
if err := f2.Create(); err != nil {

View File

@ -2,11 +2,6 @@ package failures
import "time"
const (
limitedFailures = 32
limitedHits = 32
)
// Failure is a failed attempt to check a service. Any a service does not meet the expected requirements,
// a new Failure will be inserted into Db.
type Failure struct {
@ -18,6 +13,7 @@ type Failure struct {
Service int64 `gorm:"index;column:service" json:"-"`
Checkin int64 `gorm:"index;column:checkin" json:"-"`
PingTime int64 `gorm:"column:ping_time" json:"ping"`
Reason string `gorm:"column:reason" json:"reason,omitempty"`
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
}

View File

@ -94,7 +94,7 @@ func CheckIcmp(s *Service, record bool) (*Service, error) {
dur, err := utils.Ping(s.Domain, s.Timeout)
if err != nil {
if record {
RecordFailure(s, fmt.Sprintf("Could not send ICMP to service %v, %v", s.Domain, err))
RecordFailure(s, fmt.Sprintf("Could not send ICMP to service %v, %v", s.Domain, err), "lookup")
}
return s, err
}
@ -118,7 +118,7 @@ func CheckGrpc(s *Service, record bool) (*Service, error) {
dnsLookup, err := dnsCheck(s)
if err != nil {
if record {
RecordFailure(s, fmt.Sprintf("Could not get IP address for GRPC service %v, %v", s.Domain, err))
RecordFailure(s, fmt.Sprintf("Could not get IP address for GRPC service %v, %v", s.Domain, err), "lookup")
}
return s, err
}
@ -137,13 +137,13 @@ func CheckGrpc(s *Service, record bool) (*Service, error) {
}
if err != nil {
if record {
RecordFailure(s, fmt.Sprintf("Dial Error %v", err))
RecordFailure(s, fmt.Sprintf("Dial Error %v", err), "connection")
}
return s, err
}
if err := conn.Close(); err != nil {
if record {
RecordFailure(s, fmt.Sprintf("%v Socket Close Error %v", strings.ToUpper(s.Type), err))
RecordFailure(s, fmt.Sprintf("%v Socket Close Error %v", strings.ToUpper(s.Type), err), "close")
}
return s, err
}
@ -165,7 +165,7 @@ func CheckTcp(s *Service, record bool) (*Service, error) {
dnsLookup, err := dnsCheck(s)
if err != nil {
if record {
RecordFailure(s, fmt.Sprintf("Could not get IP address for TCP service %v, %v", s.Domain, err))
RecordFailure(s, fmt.Sprintf("Could not get IP address for TCP service %v, %v", s.Domain, err), "lookup")
}
return s, err
}
@ -189,7 +189,7 @@ func CheckTcp(s *Service, record bool) (*Service, error) {
conn, err := net.DialTimeout(s.Type, domain, time.Duration(s.Timeout)*time.Second)
if err != nil {
if record {
RecordFailure(s, fmt.Sprintf("Dial Error: %v", err))
RecordFailure(s, fmt.Sprintf("Dial Error: %v", err), "tls")
}
return s, err
}
@ -203,7 +203,7 @@ func CheckTcp(s *Service, record bool) (*Service, error) {
conn, err := tls.DialWithDialer(dialer, s.Type, domain, tlsConfig)
if err != nil {
if record {
RecordFailure(s, fmt.Sprintf("Dial Error: %v", err))
RecordFailure(s, fmt.Sprintf("Dial Error: %v", err), "tls")
}
return s, err
}
@ -232,7 +232,7 @@ func CheckHttp(s *Service, record bool) (*Service, error) {
dnsLookup, err := dnsCheck(s)
if err != nil {
if record {
RecordFailure(s, fmt.Sprintf("Could not get IP address for domain %v, %v", s.Domain, err))
RecordFailure(s, fmt.Sprintf("Could not get IP address for domain %v, %v", s.Domain, err), "lookup")
}
return s, err
}
@ -284,7 +284,7 @@ func CheckHttp(s *Service, record bool) (*Service, error) {
content, res, err = utils.HttpRequest(s.Domain, s.Method, contentType, headers, data, timeout, s.VerifySSL.Bool, customTLS)
if err != nil {
if record {
RecordFailure(s, fmt.Sprintf("HTTP Error %v", err))
RecordFailure(s, fmt.Sprintf("HTTP Error %v", err), "request")
}
return s, err
}
@ -301,14 +301,14 @@ func CheckHttp(s *Service, record bool) (*Service, error) {
}
if !match {
if record {
RecordFailure(s, fmt.Sprintf("HTTP Response Body did not match '%v'", s.Expected))
RecordFailure(s, fmt.Sprintf("HTTP Response Body did not match '%v'", s.Expected), "regex")
}
return s, err
}
}
if s.ExpectedStatus != res.StatusCode {
if record {
RecordFailure(s, fmt.Sprintf("HTTP Status Code %v did not match %v", res.StatusCode, s.ExpectedStatus))
RecordFailure(s, fmt.Sprintf("HTTP Status Code %v did not match %v", res.StatusCode, s.ExpectedStatus), "status_code")
}
return s, err
}
@ -347,7 +347,7 @@ func AddNotifier(n ServiceNotifier) {
}
// RecordFailure will create a new 'Failure' record in the database for a offline service
func RecordFailure(s *Service, issue string) {
func RecordFailure(s *Service, issue, reason string) {
s.LastOffline = utils.Now()
fail := &failures.Failure{
@ -356,6 +356,7 @@ func RecordFailure(s *Service, issue string) {
PingTime: s.PingTime,
CreatedAt: utils.Now(),
ErrorCode: s.LastStatusCode,
Reason: reason,
}
log.WithFields(utils.ToFields(fail, s)).
Warnln(fmt.Sprintf("Service %v Failing: %v | Lookup in: %v", s.Name, issue, humanMicro(fail.PingTime)))

View File

@ -269,7 +269,7 @@ func runNotifyTests(t *testing.T, notif *exampleNotifier, tests ...notifyTest) {
if test.OnSuccess {
RecordSuccess(test.Service)
} else {
RecordFailure(test.Service, "test issue")
RecordFailure(test.Service, "test issue", "lookup")
}
assert.Equal(t, test.ExpectedSuccess, notif.success)

View File

@ -24,11 +24,11 @@ func InitEnvs() {
Log.Errorln(err)
defaultDir = "."
}
Params.Set("VERSION", Version)
Params.SetDefault("DISABLE_HTTP", false)
Params.SetDefault("STATPING_DIR", defaultDir)
Params.SetDefault("GO_ENV", "production")
Params.SetDefault("DEBUG", false)
Params.SetDefault("DEMO_MODE", false)
Params.SetDefault("DB_CONN", "")
Params.SetDefault("DISABLE_LOGS", false)
Params.SetDefault("USE_ASSETS", false)

View File

@ -21,7 +21,6 @@ var (
LastLines []*logRow
LockLines sync.Mutex
VerboseMode int
Version string
allowReports bool
)
@ -30,21 +29,15 @@ const (
errorReporter = "https://ddf2784201134d51a20c3440e222cebe@sentry.statping.com/4"
)
func SentryInit(v *string, allow bool) {
func SentryInit(allow bool) {
allowReports = allow
if v != nil {
if *v == "" {
*v = "development"
}
Version = *v
}
goEnv := Params.GetString("GO_ENV")
allowReports := Params.GetBool("ALLOW_REPORTS")
if allow || goEnv == "test" || allowReports {
if err := sentry.Init(sentry.ClientOptions{
Dsn: errorReporter,
Environment: goEnv,
Release: Version,
Release: Params.GetString("VERSION"),
AttachStacktrace: true,
}); err != nil {
Log.Errorln(err)
@ -70,7 +63,7 @@ func SentryLogEntry(entry *Logger.Entry) {
e := sentry.NewEvent()
e.Message = entry.Message
e.Tags = sentryTags()
e.Release = Version
e.Release = Params.GetString("VERSION")
e.Contexts = entry.Data
sentry.CaptureEvent(e)
}

View File

@ -174,7 +174,7 @@ func HttpRequest(endpoint, method string, contentType interface{}, headers []str
}
// set default headers so end user can overwrite them if needed
req.Header.Set("User-Agent", "Statping")
req.Header.Set("Statping-Version", Version)
req.Header.Set("Statping-Version", Params.GetString("VERSION"))
if contentType != nil {
req.Header.Set("Content-Type", contentType.(string))
}

View File

@ -1 +1 @@
0.90.63
0.90.64