Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
2cc855a1
Commit
2cc855a1
authored
Apr 27, 2018
by
Carl Bergquist
Committed by
bergquist
Apr 27, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into notification-service-refactor2
parents
44b0f15a
a8eed9d3
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
68 additions
and
75 deletions
+68
-75
pkg/cmd/grafana-server/server.go
+1
-7
pkg/plugins/dashboard_importer_test.go
+3
-3
pkg/plugins/dashboards_test.go
+3
-2
pkg/plugins/dashboards_updater.go
+2
-6
pkg/plugins/datasource_plugin.go
+1
-1
pkg/plugins/plugins.go
+41
-32
pkg/plugins/plugins_test.go
+6
-3
pkg/plugins/update_checker.go
+6
-19
public/app/core/utils/kbn.ts
+2
-2
public/app/plugins/panel/graph/graph.ts
+3
-0
No files found.
pkg/cmd/grafana-server/server.go
View file @
2cc855a1
...
...
@@ -25,7 +25,6 @@ import (
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/login"
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/setting"
...
...
@@ -34,6 +33,7 @@ import (
// self registering services
_
"github.com/grafana/grafana/pkg/extensions"
_
"github.com/grafana/grafana/pkg/plugins"
_
"github.com/grafana/grafana/pkg/services/alerting"
_
"github.com/grafana/grafana/pkg/services/cleanup"
_
"github.com/grafana/grafana/pkg/services/notifications"
...
...
@@ -74,12 +74,6 @@ func (g *GrafanaServerImpl) Start() error {
login
.
Init
()
social
.
NewOAuthService
()
pluginManager
,
err
:=
plugins
.
NewPluginManager
(
g
.
context
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to start plugins. error: %v"
,
err
)
}
g
.
childRoutines
.
Go
(
func
()
error
{
return
pluginManager
.
Run
(
g
.
context
)
})
if
err
:=
provisioning
.
Init
(
g
.
context
,
setting
.
HomePath
,
setting
.
Cfg
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to provision Grafana from config. error: %v"
,
err
)
}
...
...
pkg/plugins/dashboard_importer_test.go
View file @
2cc855a1
package
plugins
import
(
"context"
"io/ioutil"
"testing"
...
...
@@ -91,10 +90,11 @@ func pluginScenario(desc string, t *testing.T, fn func()) {
setting
.
Cfg
=
ini
.
Empty
()
sec
,
_
:=
setting
.
Cfg
.
NewSection
(
"plugin.test-app"
)
sec
.
NewKey
(
"path"
,
"../../tests/test-app"
)
err
:=
initPlugins
(
context
.
Background
())
So
(
err
,
ShouldBeNil
)
pm
:=
&
PluginManager
{}
err
:=
pm
.
Init
()
So
(
err
,
ShouldBeNil
)
Convey
(
desc
,
fn
)
})
}
pkg/plugins/dashboards_test.go
View file @
2cc855a1
package
plugins
import
(
"context"
"testing"
"github.com/grafana/grafana/pkg/bus"
...
...
@@ -18,7 +17,9 @@ func TestPluginDashboards(t *testing.T) {
setting
.
Cfg
=
ini
.
Empty
()
sec
,
_
:=
setting
.
Cfg
.
NewSection
(
"plugin.test-app"
)
sec
.
NewKey
(
"path"
,
"../../tests/test-app"
)
err
:=
initPlugins
(
context
.
Background
())
pm
:=
&
PluginManager
{}
err
:=
pm
.
Init
()
So
(
err
,
ShouldBeNil
)
...
...
pkg/plugins/dashboards_updater.go
View file @
2cc855a1
package
plugins
import
(
"time"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
)
...
...
@@ -11,10 +9,8 @@ func init() {
bus
.
AddEventListener
(
handlePluginStateChanged
)
}
func
updateAppDashboards
()
{
time
.
Sleep
(
time
.
Second
*
5
)
plog
.
Debug
(
"Looking for App Dashboard Updates"
)
func
(
pm
*
PluginManager
)
updateAppDashboards
()
{
pm
.
log
.
Debug
(
"Looking for App Dashboard Updates"
)
query
:=
m
.
GetPluginSettingsQuery
{
OrgId
:
0
}
...
...
pkg/plugins/datasource_plugin.go
View file @
2cc855a1
...
...
@@ -76,7 +76,7 @@ func composeBinaryName(executable, os, arch string) string {
return
fmt
.
Sprintf
(
"%s_%s_%s%s"
,
executable
,
os
,
strings
.
ToLower
(
arch
),
extension
)
}
func
(
p
*
DataSourcePlugin
)
ini
tBackendPlugin
(
ctx
context
.
Context
,
log
log
.
Logger
)
error
{
func
(
p
*
DataSourcePlugin
)
star
tBackendPlugin
(
ctx
context
.
Context
,
log
log
.
Logger
)
error
{
p
.
log
=
log
.
New
(
"plugin-id"
,
p
.
Id
)
err
:=
p
.
spawnSubProcess
()
...
...
pkg/plugins/plugins.go
View file @
2cc855a1
...
...
@@ -11,8 +11,10 @@ import (
"path/filepath"
"reflect"
"strings"
"time"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
)
...
...
@@ -39,30 +41,12 @@ type PluginManager struct {
log
log
.
Logger
}
func
NewPluginManager
(
ctx
context
.
Context
)
(
*
PluginManager
,
error
)
{
err
:=
initPlugins
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
PluginManager
{
log
:
log
.
New
(
"plugins"
),
},
nil
func
init
()
{
registry
.
RegisterService
(
&
PluginManager
{})
}
func
(
p
*
PluginManager
)
Run
(
ctx
context
.
Context
)
error
{
<-
ctx
.
Done
()
for
_
,
p
:=
range
DataSources
{
p
.
Kill
()
}
p
.
log
.
Info
(
"Stopped Plugins"
,
"reason"
,
ctx
.
Err
())
return
ctx
.
Err
()
}
func
initPlugins
(
ctx
context
.
Context
)
error
{
func
(
pm
*
PluginManager
)
Init
()
error
{
pm
.
log
=
log
.
New
(
"plugins"
)
plog
=
log
.
New
(
"plugins"
)
DataSources
=
map
[
string
]
*
DataSourcePlugin
{}
...
...
@@ -76,7 +60,7 @@ func initPlugins(ctx context.Context) error {
"app"
:
AppPlugin
{},
}
plog
.
Info
(
"Starting plugin search"
)
p
m
.
log
.
Info
(
"Starting plugin search"
)
scan
(
path
.
Join
(
setting
.
StaticRootPath
,
"app/plugins"
))
// check if plugins dir exists
...
...
@@ -99,13 +83,6 @@ func initPlugins(ctx context.Context) error {
}
for
_
,
ds
:=
range
DataSources
{
if
ds
.
Backend
{
err
:=
ds
.
initBackendPlugin
(
ctx
,
plog
)
if
err
!=
nil
{
plog
.
Error
(
"Failed to init plugin."
,
"error"
,
err
,
"plugin"
,
ds
.
Id
)
}
}
ds
.
initFrontendPlugin
()
}
...
...
@@ -113,8 +90,40 @@ func initPlugins(ctx context.Context) error {
app
.
initApp
()
}
go
StartPluginUpdateChecker
()
go
updateAppDashboards
()
return
nil
}
func
(
pm
*
PluginManager
)
startBackendPlugins
(
ctx
context
.
Context
)
error
{
for
_
,
ds
:=
range
DataSources
{
if
ds
.
Backend
{
if
err
:=
ds
.
startBackendPlugin
(
ctx
,
plog
);
err
!=
nil
{
pm
.
log
.
Error
(
"Failed to init plugin."
,
"error"
,
err
,
"plugin"
,
ds
.
Id
)
}
}
}
return
nil
}
func
(
pm
*
PluginManager
)
Run
(
ctx
context
.
Context
)
error
{
pm
.
startBackendPlugins
(
ctx
)
pm
.
updateAppDashboards
()
pm
.
checkForUpdates
()
ticker
:=
time
.
NewTicker
(
time
.
Minute
*
10
)
for
{
select
{
case
<-
ticker
.
C
:
pm
.
checkForUpdates
()
case
<-
ctx
.
Done
()
:
break
}
}
// kil backend plugins
for
_
,
p
:=
range
DataSources
{
p
.
Kill
()
}
return
nil
}
...
...
pkg/plugins/plugins_test.go
View file @
2cc855a1
package
plugins
import
(
"context"
"path/filepath"
"testing"
...
...
@@ -15,7 +14,9 @@ func TestPluginScans(t *testing.T) {
Convey
(
"When scanning for plugins"
,
t
,
func
()
{
setting
.
StaticRootPath
,
_
=
filepath
.
Abs
(
"../../public/"
)
setting
.
Cfg
=
ini
.
Empty
()
err
:=
initPlugins
(
context
.
Background
())
pm
:=
&
PluginManager
{}
err
:=
pm
.
Init
()
So
(
err
,
ShouldBeNil
)
So
(
len
(
DataSources
),
ShouldBeGreaterThan
,
1
)
...
...
@@ -30,7 +31,9 @@ func TestPluginScans(t *testing.T) {
setting
.
Cfg
=
ini
.
Empty
()
sec
,
_
:=
setting
.
Cfg
.
NewSection
(
"plugin.nginx-app"
)
sec
.
NewKey
(
"path"
,
"../../tests/test-app"
)
err
:=
initPlugins
(
context
.
Background
())
pm
:=
&
PluginManager
{}
err
:=
pm
.
Init
()
So
(
err
,
ShouldBeNil
)
So
(
len
(
Apps
),
ShouldBeGreaterThan
,
0
)
...
...
pkg/plugins/update_checker.go
View file @
2cc855a1
...
...
@@ -26,23 +26,6 @@ type GithubLatest struct {
Testing
string
`json:"testing"`
}
func
StartPluginUpdateChecker
()
{
if
!
setting
.
CheckForUpdates
{
return
}
// do one check directly
go
checkForUpdates
()
ticker
:=
time
.
NewTicker
(
time
.
Minute
*
10
)
for
{
select
{
case
<-
ticker
.
C
:
checkForUpdates
()
}
}
}
func
getAllExternalPluginSlugs
()
string
{
var
result
[]
string
for
_
,
plug
:=
range
Plugins
{
...
...
@@ -56,8 +39,12 @@ func getAllExternalPluginSlugs() string {
return
strings
.
Join
(
result
,
","
)
}
func
checkForUpdates
()
{
log
.
Trace
(
"Checking for updates"
)
func
(
pm
*
PluginManager
)
checkForUpdates
()
{
if
!
setting
.
CheckForUpdates
{
return
}
pm
.
log
.
Debug
(
"Checking for updates"
)
pluginSlugs
:=
getAllExternalPluginSlugs
()
resp
,
err
:=
httpClient
.
Get
(
"https://grafana.com/api/plugins/versioncheck?slugIn="
+
pluginSlugs
+
"&grafanaVersion="
+
setting
.
BuildVersion
)
...
...
public/app/core/utils/kbn.ts
View file @
2cc855a1
...
...
@@ -596,7 +596,7 @@ kbn.valueFormats.radr = kbn.formatBuilders.decimalSIPrefix('R');
kbn.valueFormats.radsvh = kbn.formatBuilders.decimalSIPrefix('
Sv
/
h
');
// Concentration
kbn.valueFormats.
con
ppm = kbn.formatBuilders.fixedUnit('
ppm
');
kbn.valueFormats.ppm = kbn.formatBuilders.fixedUnit('
ppm
');
kbn.valueFormats.conppb = kbn.formatBuilders.fixedUnit('
ppb
');
kbn.valueFormats.conngm3 = kbn.formatBuilders.fixedUnit('
ng
/
m3
');
kbn.valueFormats.conngNm3 = kbn.formatBuilders.fixedUnit('
ng
/
Nm3
');
...
...
@@ -1101,7 +1101,7 @@ kbn.getUnitFormats = function() {
{
text: '
concentration
',
submenu: [
{ text: '
parts
-
per
-
million
(
ppm
)
', value: '
con
ppm
' },
{ text: '
parts
-
per
-
million
(
ppm
)
', value: '
ppm
' },
{ text: '
parts
-
per
-
billion
(
ppb
)
', value: '
conppb
' },
{ text: '
nanogram
per
cubic
metre
(
ng
/
m3
)
', value: '
conngm3
' },
{ text: '
nanogram
per
normal
cubic
metre
(
ng
/
Nm3
)
', value: '
conngNm3
' },
...
...
public/app/plugins/panel/graph/graph.ts
View file @
2cc855a1
...
...
@@ -634,6 +634,9 @@ function graphDirective(timeSrv, popoverSrv, contextSrv) {
function
configureAxisMode
(
axis
,
format
)
{
axis
.
tickFormatter
=
function
(
val
,
axis
)
{
if
(
!
kbn
.
valueFormats
[
format
])
{
throw
new
Error
(
`Unit '
${
format
}
' is not supported`
);
}
return
kbn
.
valueFormats
[
format
](
val
,
axis
.
tickDecimals
,
axis
.
scaledDecimals
);
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment