Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/scollector: process_linux process start_time and uptime #1087

Merged
merged 1 commit into from
Jun 22, 2015

Conversation

d10v
Copy link
Contributor

@d10v d10v commented Jun 19, 2015

Calculate process start time and uptime from file stat data of /proc/ directory.

P.S. Chose this because it's way simpler than querying uptime, getconf CLK_TCK , parsing stat and jiffies. There were times when /proc/<pid> stat data was modifiable but that's fixed now.

Review on Reviewable

@@ -104,6 +110,8 @@ func linuxProcMonitor(w *WatchedProc, md *opentsdb.MultiDataPoint) error {
Add(md, "linux.proc.io_bytes", io[4], opentsdb.TagSet{"type": "read"}.Merge(tags), metadata.Counter, metadata.Bytes, descLinuxProcIoBytesRead)
Add(md, "linux.proc.io_bytes", io[5], opentsdb.TagSet{"type": "write"}.Merge(tags), metadata.Counter, metadata.Bytes, descLinuxProcIoBytesWrite)
Add(md, "linux.proc.num_fds", len(fds), tags, metadata.Gauge, metadata.Files, descLinuxProcFd)
Add(md, "linux.proc.start_time", start_ts, tags, metadata.Gauge, metadata.Timestamp, descLinuxProcStartTS)
Add(md, "linux.proc.uptime", timestamp-start_ts, tags, metadata.Gauge, metadata.Second, descLinuxProcUptime)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the uptime of the program. It is the uptime of the program since scollector has been running. I don't see the value of this metric, since one can always just subtract the start time and a timestamp to figure out uptime.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I'm wrong. timestamp is updated to be now. But use now() to get it because it's race-free.

@d10v d10v force-pushed the process-linux-starttime branch from a6363d9 to d49b92f Compare June 19, 2015 21:52
@@ -91,6 +97,8 @@ func linuxProcMonitor(w *WatchedProc, md *opentsdb.MultiDataPoint) error {
}
}
}
start_ts := file_status.ModTime().Unix()
now := time.Now().Unix()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use now() for this:

func now() (t int64) {

@d10v d10v force-pushed the process-linux-starttime branch from d49b92f to 9fe0b0d Compare June 22, 2015 10:14
maddyblue added a commit that referenced this pull request Jun 22, 2015
cmd/scollector: process_linux process start_time and uptime
@maddyblue maddyblue merged commit ab5e827 into bosun-monitor:master Jun 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants