예제 #1
0
func main() {
	const dbfile = "/home/caglar/raspik/raspik.rrd"

	g := rrd.NewGrapher()

	g.SetVLabel("System Swap")
	g.SetSize(800, 300)

	g.SetWatermark(time.Now().Format(time.RFC822))
	g.SetAltAutoscaleMax()
	g.SetSlopeMode()

	g.SetInterlaced()
	g.SetImageFormat("PNG")

	g.Def("total", dbfile, "TotalSwap", "AVERAGE")
	g.Def("used", dbfile, "UsedSwap", "AVERAGE")
	g.Def("free", dbfile, "FreeSwap", "AVERAGE")

	g.VDef("totalAverage", "total,AVERAGE")
	g.VDef("usedAverage", "used,AVERAGE")
	g.VDef("freeAverage", "free,AVERAGE")

	g.CDef("totalModified", "total,UN,totalAverage,total,IF")
	g.CDef("usedModified", "used,UN,usedAverage,used,IF")
	g.CDef("freeModified", "free,UN,freeAverage,free,IF")

	g.CDef("usedModifiedNeg", "0,usedModified,-")

	g.Line(2, "totalModified", "FF0000", "Total Swap")
	g.Area("usedModifiedNeg", "0000FF", "Used Swap")
	g.Area("freeModified", "00FF00", "Free Swap")

	g.HRule("0", "000000")

	now := time.Now()
	g.SetTitle("Last 24 Hours")
	_, err := g.SaveGraph("/home/caglar/raspik/systemswap24h.png", now.Add(-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}

	g.SetTitle("Last Week")
	_, err = g.SaveGraph("/home/caglar/raspik/systemswap7d.png", now.Add(7*-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}

	g.SetTitle("Last Month")
	_, err = g.SaveGraph("/home/caglar/raspik/systemswap30d.png", now.Add(30*-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}

	g.SetTitle("Last Year")
	_, err = g.SaveGraph("/home/caglar/raspik/systemswap365d.png", now.Add(365*-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}
}
예제 #2
0
func main() {
	const dbfile = "/home/caglar/raspik/raspik.rrd"

	g := rrd.NewGrapher()

	g.SetVLabel("System Load")
	g.SetSize(800, 300)

	g.SetWatermark(time.Now().Format(time.RFC822))
	g.SetAltAutoscaleMax()
	g.SetSlopeMode()

	g.SetInterlaced()
	g.SetImageFormat("PNG")

	g.Def("1min", dbfile, "One", "AVERAGE")
	g.Def("5min", dbfile, "Five", "AVERAGE")
	g.Def("15min", dbfile, "Fifteen", "AVERAGE")

	// get the average
	g.VDef("1minAverage", "1min,AVERAGE")
	g.VDef("5minAverage", "5min,AVERAGE")
	g.VDef("15minAverage", "15min,AVERAGE")

	// use the average if the value is UN
	g.CDef("1minModified", "1min,UN,1minAverage,1min,IF")
	g.CDef("5minModified", "5min,UN,5minAverage,5min,IF")
	g.CDef("15minModified", "15min,UN,15minAverage,15min,IF")

	g.Line(1, "1minModified", "33cc33", "1 Min Load Avg")
	g.Line(1, "5minModified", "ff0000", "5 Min Load Avg")
	g.Line(1, "15minModified", "0000ff", "15 Min Load Avg")

	now := time.Now()

	g.SetTitle("Last 24 Hours")
	_, err := g.SaveGraph("/home/caglar/raspik/systemload24h.png", now.Add(-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}

	g.SetTitle("Last Week")
	_, err = g.SaveGraph("/home/caglar/raspik/systemload7d.png", now.Add(7*-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}

	g.SetTitle("Last Month")
	_, err = g.SaveGraph("/home/caglar/raspik/systemload30d.png", now.Add(30*-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}

	g.SetTitle("Last Year")
	_, err = g.SaveGraph("/home/caglar/raspik/systemload365d.png", now.Add(365*-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}

}
예제 #3
0
func main() {
	const dbfile = "/home/caglar/raspik/raspik.rrd"

	g := rrd.NewGrapher()

	g.SetVLabel("System Memory")
	g.SetSize(800, 300)

	g.SetWatermark(time.Now().Format(time.RFC822))
	g.SetAltAutoscaleMax()
	g.SetSlopeMode()

	g.SetInterlaced()
	g.SetImageFormat("PNG")

	g.Def("total", dbfile, "TotalRam", "AVERAGE")
	g.Def("free", dbfile, "FreeRam", "AVERAGE")
	g.Def("shared", dbfile, "SharedRam", "AVERAGE")
	g.Def("buffer", dbfile, "BufferRam", "AVERAGE")

	g.VDef("totalAverage", "total,AVERAGE")
	g.VDef("freeAverage", "free,AVERAGE")
	g.VDef("sharedAverage", "shared,AVERAGE")
	g.VDef("bufferAverage", "buffer,AVERAGE")

	g.CDef("totalModified", "total,UN,totalAverage,total,IF")
	g.CDef("freeModified", "free,UN,freeAverage,free,IF")
	g.CDef("sharedModified", "shared,UN,sharedAverage,shared,IF")
	g.CDef("bufferModified", "buffer,UN,bufferAverage,buffer,IF")

	g.Line(1, "totalModified", "33cc33", "Total Ram")
	g.Line(1, "freeModified", "ff0000", "Free Ram")
	g.Line(1, "sharedModified", "0000ff", "Shared Ram")
	g.Line(1, "bufferModified", "996633", "Buffer")

	now := time.Now()
	g.SetTitle("Last 24 Hours")
	_, err := g.SaveGraph("/home/caglar/raspik/systemmem24h.png", now.Add(-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}

	g.SetTitle("Last Week")
	_, err = g.SaveGraph("/home/caglar/raspik/systemmem7d.png", now.Add(7*-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}

	g.SetTitle("Last Month")
	_, err = g.SaveGraph("/home/caglar/raspik/systemmem30d.png", now.Add(30*-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}

	g.SetTitle("Last Year")
	_, err = g.SaveGraph("/home/caglar/raspik/systemmem365d.png", now.Add(365*-24*time.Hour), now)
	if err != nil {
		log.Fatal(err)
	}
}