1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 01:57:02 +00:00

Add expvar JSON @ /debug/vars

Counters include:
 - Uptime
 - SMTP connections
 - SMTP connections (current)
 - SMTP messages delivered
This commit is contained in:
James Hillyerd
2012-10-23 09:51:30 -07:00
parent 16a68000d3
commit 5833bb0701
4 changed files with 32 additions and 3 deletions

View File

@@ -4,6 +4,7 @@
package main
import (
"expvar"
"flag"
"fmt"
"github.com/jhillyerd/inbucket/config"
@@ -11,10 +12,13 @@ import (
"github.com/jhillyerd/inbucket/smtpd"
"github.com/jhillyerd/inbucket/web"
"os"
"time"
)
var help = flag.Bool("help", false, "Displays this help")
var startTime = time.Now()
func main() {
flag.Parse()
if *help {
@@ -49,4 +53,10 @@ func init() {
fmt.Fprintln(os.Stderr, "Usage of inbucket [options] <conf file>:")
flag.PrintDefaults()
}
expvar.Publish("uptime", expvar.Func(uptime))
}
func uptime() interface{} {
return time.Since(startTime) / time.Second
}