Skip to content

Commit

Permalink
update mod and add logrotate
Browse files Browse the repository at this point in the history
  • Loading branch information
likexian committed Feb 28, 2019
1 parent 7f8a987 commit 8d38067
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 18 deletions.
5 changes: 5 additions & 0 deletions doc/CHANGS-ZH.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.102.2 Beta 版本的变更 2019-02-28

- 修正:增加日志滚动支持


0.102.1 Beta 版本的变更 2019-02-28

- 修正:数据目录所有者自动修改为 daemon 用户
Expand Down
5 changes: 5 additions & 0 deletions doc/CHANGS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Changes with Stat Hub 0.102.2 Beta 2019-02-28

- Bugfix: add logrotate support


Changes with Stat Hub 0.102.1 Beta 2019-02-28

- Bugfix: chown data dir to daemon user
Expand Down
8 changes: 4 additions & 4 deletions service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cd $BASEDIR

start() {
echo "starting"
if [ ! -f $PID ]; then
if [ ! -f $PIDFILE ]; then
./stathub -c conf/stathub.conf
echo "ok"
echo "----------------------------------------------------"
Expand All @@ -24,9 +24,9 @@ start() {

stop() {
echo "stopping"
if [ -f $PID ]; then
kill -9 `cat $PID`
rm -rf $PID
if [ -f $PIDFILE ]; then
kill -9 `cat $PIDFILE`
rm -rf $PIDFILE
echo "ok"
fi
}
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION="0.102.1"
VERSION="0.102.2"
STATHUB_URL="https://github.com/likexian/stathub-go/releases/download/v${VERSION}"

BASEDIR="/usr/local/stathub"
Expand Down
4 changes: 2 additions & 2 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/likexian/stathub-go

require (
github.com/likexian/daemon-go v0.0.0-20190221033618-0592c546bf05
github.com/likexian/host-stat-go v0.0.0-20190216111529-8a8a9b671efc
github.com/likexian/logger-go v0.0.0-20190226031613-ce60a16be240
github.com/likexian/host-stat-go v0.0.0-20190228023633-df00c4c0fa03
github.com/likexian/logger-go v0.0.0-20190228122243-d1e1433d7f31
github.com/likexian/simplejson-go v0.0.0-20190215071240-f9f264a657d1
)
2 changes: 2 additions & 0 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func main() {

if DEBUG {
SERVER_LOGGER = logger.New(os.Stderr, logger.DEBUG)
} else {
SERVER_LOGGER.SetSizeRotate(3, 100*1024*1024)
}

showVersion := flag.Bool("v", false, "show current version")
Expand Down
18 changes: 9 additions & 9 deletions src/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func GetStat(id string, name string) (result string, err error) {

hostInfo, err := hoststat.GetHostInfo()
if err != nil {
SERVER_LOGGER.Debug("get host info failed: %s", err.Error())
SERVER_LOGGER.ErrorOnce("get host info failed: %s", err.Error())
}
stat.OSRelease = hostInfo.Release + " " + hostInfo.OSBit

Expand All @@ -57,27 +57,27 @@ func GetStat(id string, name string) (result string, err error) {

cpuInfo, err := hoststat.GetCPUInfo()
if err != nil {
SERVER_LOGGER.Debug("get cpu info failed: %s", err.Error())
SERVER_LOGGER.ErrorOnce("get cpu info failed: %s", err.Error())
}
stat.CPUName = cpuInfo.ModelName
stat.CPUCore = cpuInfo.CoreCount

cpuStat, err := hoststat.GetCPUStat()
if err != nil {
SERVER_LOGGER.Debug("get cpu stat failed: %s", err.Error())
SERVER_LOGGER.ErrorOnce("get cpu stat failed: %s", err.Error())
}
stat.CPURate = Round(100-cpuStat.IdleRate, 2)

memStat, err := hoststat.GetMemStat()
if err != nil {
SERVER_LOGGER.Debug("get mem stat failed: %s", err.Error())
SERVER_LOGGER.ErrorOnce("get mem stat failed: %s", err.Error())
}
stat.MemRate = memStat.MemRate
stat.SwapRate = memStat.SwapRate

diskStat, err := hoststat.GetDiskStat()
if err != nil {
SERVER_LOGGER.Debug("get disk stat failed: %s", err.Error())
SERVER_LOGGER.ErrorOnce("get disk stat failed: %s", err.Error())
}
diskTotal := uint64(0)
diskUsed := uint64(0)
Expand All @@ -92,7 +92,7 @@ func GetStat(id string, name string) (result string, err error) {

ioStat, err := hoststat.GetIOStat()
if err != nil {
SERVER_LOGGER.Debug("get io stat failed: %s", err.Error())
SERVER_LOGGER.ErrorOnce("get io stat failed: %s", err.Error())
}
diskRead := uint64(0)
diskWrite := uint64(0)
Expand All @@ -105,7 +105,7 @@ func GetStat(id string, name string) (result string, err error) {

netStat, err := hoststat.GetNetStat()
if err != nil {
SERVER_LOGGER.Debug("get net stat failed: %s", err.Error())
SERVER_LOGGER.ErrorOnce("get net stat failed: %s", err.Error())
}
netWrite := uint64(0)
netRead := uint64(0)
Expand All @@ -120,13 +120,13 @@ func GetStat(id string, name string) (result string, err error) {

uptimeStat, err := hoststat.GetUptimeStat()
if err != nil {
SERVER_LOGGER.Debug("get uptime stat failed: %s", err.Error())
SERVER_LOGGER.ErrorOnce("get uptime stat failed: %s", err.Error())
}
stat.Uptime = uint64(uptimeStat.Uptime)

loadStat, err := hoststat.GetLoadStat()
if err != nil {
SERVER_LOGGER.Debug("get load stat failed: %s", err.Error())
SERVER_LOGGER.ErrorOnce("get load stat failed: %s", err.Error())
}
stat.Load = fmt.Sprintf("%.2f %.2f %.2f", loadStat.LoadNow, loadStat.LoadPre, loadStat.LoadFar)

Expand Down
2 changes: 1 addition & 1 deletion src/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package main

// variable for tpl file
var (
TPL_REVHEAD = "faa6343"
TPL_REVHEAD = "7f8a987"
TPL_CERT = map[string]string{}
TPL_STATIC = map[string]string{}
TPL_TEMPLATE = map[string]string{}
Expand Down
2 changes: 1 addition & 1 deletion src/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package main

// Version returns package version
func Version() string {
return "0.102.1"
return "0.102.2"
}

// Author returns package author
Expand Down

0 comments on commit 8d38067

Please sign in to comment.