Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gqgmc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kevin Lyda
gqgmc
Commits
627cd475
There was a problem fetching the pipeline summary.
Commit
627cd475
authored
8 years ago
by
Kevin Lyda
Browse files
Options
Downloads
Patches
Plain Diff
Add a sleep cycle param.
parent
f1988a53
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/gqgmcd/main.go
+2
-1
2 additions, 1 deletion
cmd/gqgmcd/main.go
config/config.go
+2
-0
2 additions, 0 deletions
config/config.go
server/metrics/metrics.go
+2
-2
2 additions, 2 deletions
server/metrics/metrics.go
with
6 additions
and
3 deletions
cmd/gqgmcd/main.go
+
2
−
1
View file @
627cd475
...
@@ -23,6 +23,7 @@ var device = flag.String("device", "/dev/gqgmc", "Device for Geiger Counter")
...
@@ -23,6 +23,7 @@ var device = flag.String("device", "/dev/gqgmc", "Device for Geiger Counter")
var
model
=
flag
.
String
(
"model"
,
"gqgmc"
,
"Model of Geiger Counter"
)
var
model
=
flag
.
String
(
"model"
,
"gqgmc"
,
"Model of Geiger Counter"
)
var
templateDir
=
flag
.
String
(
"template-dir"
,
"templates"
,
"Template directory"
)
var
templateDir
=
flag
.
String
(
"template-dir"
,
"templates"
,
"Template directory"
)
var
staticDir
=
flag
.
String
(
"static-dir"
,
"static"
,
"Static files directory"
)
var
staticDir
=
flag
.
String
(
"static-dir"
,
"static"
,
"Static files directory"
)
var
sleepCycle
=
flag
.
Int64
(
"sleep-cycle"
,
5
,
"Seconds to sleep per cycle."
)
var
cfg
=
flag
.
String
(
"config"
,
"gqgmc.conf"
,
"Config file"
)
var
cfg
=
flag
.
String
(
"config"
,
"gqgmc.conf"
,
"Config file"
)
func
main
()
{
func
main
()
{
...
@@ -39,6 +40,6 @@ func main() {
...
@@ -39,6 +40,6 @@ func main() {
p
.
Register
()
p
.
Register
()
m
:=
metrics
.
Register
(
gc
)
m
:=
metrics
.
Register
(
gc
)
go
m
.
Gather
()
go
m
.
Gather
(
c
.
SleepCycle
)
log
.
Fatal
(
http
.
ListenAndServe
(
c
.
ListenAddress
,
nil
))
log
.
Fatal
(
http
.
ListenAndServe
(
c
.
ListenAddress
,
nil
))
}
}
This diff is collapsed.
Click to expand it.
config/config.go
+
2
−
0
View file @
627cd475
...
@@ -19,6 +19,7 @@ type Config struct {
...
@@ -19,6 +19,7 @@ type Config struct {
Model
string
`mapstructure:"model"`
Model
string
`mapstructure:"model"`
TemplateDir
string
`mapstructure:"template_dir"`
TemplateDir
string
`mapstructure:"template_dir"`
StaticDir
string
`mapstructure:"static_dir"`
StaticDir
string
`mapstructure:"static_dir"`
SleepCycle
int64
`mapstructure:"sleep_cycle"`
}
}
func
setDefaults
()
{
func
setDefaults
()
{
...
@@ -27,6 +28,7 @@ func setDefaults() {
...
@@ -27,6 +28,7 @@ func setDefaults() {
viper
.
BindPFlag
(
"model"
,
pflag
.
Lookup
(
"model"
))
viper
.
BindPFlag
(
"model"
,
pflag
.
Lookup
(
"model"
))
viper
.
BindPFlag
(
"template_dir"
,
pflag
.
Lookup
(
"template-dir"
))
viper
.
BindPFlag
(
"template_dir"
,
pflag
.
Lookup
(
"template-dir"
))
viper
.
BindPFlag
(
"static_dir"
,
pflag
.
Lookup
(
"static-dir"
))
viper
.
BindPFlag
(
"static_dir"
,
pflag
.
Lookup
(
"static-dir"
))
viper
.
BindPFlag
(
"sleep_cycle"
,
pflag
.
Lookup
(
"sleep-cycle"
))
}
}
// ReadConfig reads the client configuration from a file into a Config struct.
// ReadConfig reads the client configuration from a file into a Config struct.
...
...
This diff is collapsed.
Click to expand it.
server/metrics/metrics.go
+
2
−
2
View file @
627cd475
...
@@ -69,7 +69,7 @@ func Register(gc geiger.Counter) *Metrics {
...
@@ -69,7 +69,7 @@ func Register(gc geiger.Counter) *Metrics {
}
}
// Gather loop to gather metrics
// Gather loop to gather metrics
func
(
m
*
Metrics
)
Gather
()
{
func
(
m
*
Metrics
)
Gather
(
sleep
int64
)
{
var
(
var
(
cpm
,
cps
uint16
cpm
,
cps
uint16
volts
int16
volts
int16
...
@@ -97,6 +97,6 @@ func (m *Metrics) Gather() {
...
@@ -97,6 +97,6 @@ func (m *Metrics) Gather() {
m
.
volts
.
WithLabelValues
(
m
.
gc
.
Serial
())
.
Observe
(
float64
(
volts
))
m
.
volts
.
WithLabelValues
(
m
.
gc
.
Serial
())
.
Observe
(
float64
(
volts
))
}
}
m
.
errs
.
WithLabelValues
(
m
.
gc
.
Serial
())
.
Set
(
float64
(
errCt
))
m
.
errs
.
WithLabelValues
(
m
.
gc
.
Serial
())
.
Set
(
float64
(
errCt
))
time
.
Sleep
(
5
*
time
.
Second
)
time
.
Sleep
(
time
.
Duration
(
sleep
)
*
time
.
Second
)
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment