# FreeBSD Version of the System Module has the Uptime Metricset Disabled

**URL:** https://discuss.elastic.co/t/freebsd-version-of-the-system-module-has-the-uptime-metricset-disabled/159437
**Category:** Beats
**Tags:** metricbeat
**Created:** [December 5, 2018, 12:51am UTC](https://discuss.elastic.co/t/freebsd-version-of-the-system-module-has-the-uptime-metricset-disabled/159437 "2018-12-05T00:51:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![rhclayto](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@rhclayto](https://discuss.elastic.co/u/rhclayto)
#### Post date: [December 5, 2018, 12:51am UTC](https://discuss.elastic.co/t/freebsd-version-of-the-system-module-has-the-uptime-metricset-disabled/159437/1 "2018-12-05T00:51:26Z")

</div>

I have noticed that the the FreeBSD version of metricbeat has the uptime metricset of the system module disabled (or not enabled) in the Go build tags for the metricset. Consequently, when building metricbeat on FreeBSD, the uptime metricset is not enabled & will throw errors if configured in the metricbeat configuration.

```auto
2018-12-05T00:02:02.391Z	ERROR	instance/beat.go:824	Exiting: 1 error: 1 error: metricset 'system/uptime' is not registered, metricset not found

```

Here is the go file for the uptime metricset:

```auto
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

// +build darwin linux openbsd windows

package uptime

import (
	"github.com/pkg/errors"

	"github.com/elastic/beats/libbeat/common"
	"github.com/elastic/beats/metricbeat/mb"
	"github.com/elastic/beats/metricbeat/mb/parse"
	sigar "github.com/elastic/gosigar"
)

func init() {
	mb.Registry.MustAddMetricSet("system", "uptime", New,
		mb.WithHostParser(parse.EmptyHostParser),
		mb.DefaultMetricSet(),
	)
}

// MetricSet for fetching an OS uptime metric.
type MetricSet struct {
	mb.BaseMetricSet
}

// New is a mb.MetricSetFactory that returns a new MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
	return &MetricSet{base}, nil
}

// Fetch fetches the uptime metric from the OS.
func (m *MetricSet) Fetch() (common.MapStr, error) {
	var uptime sigar.Uptime
	if err := uptime.Get(); err != nil {
		return nil, errors.Wrap(err, "failed to get uptime")
	}

	return common.MapStr{
		"duration": common.MapStr{
			"ms": int64(uptime.Length * 1000),
		},
	}, nil
}

```

is there any particular reason it's not enabled there? I see in gosigar's freebsd file sigar\_freebsd.go that there is an uptime function using FreeBSD's clock\_gettime sytem call:

```auto
func (self *Uptime) Get() error {
	ts := C.struct_timespec{}

	if _, err := C.clock_gettime(C.CLOCK_UPTIME, &ts); err != nil {
		return err
	}

	self.Length = float64(ts.tv_sec) + 1e-9*float64(ts.tv_nsec)

	return nil
}

```

I have enabled the build flag, built metricbeat on FreeBSD 11.2, run metricbeat, & get correct uptime events issued to logstash & stored in Elasticsearch.

```json
    {
  "_index": "metricbeat-6.5.0-2018.49",
  "_type": "doc",
  "_id": "AoLie2cBVPJTERvK4Rmi",
  "_version": 1,
  "_score": null,
  "_source": {
    "host": {
      "name": "freebsd-11-2"
    },
    "metricset": {
      "module": "system",
      "rtt": 39,
      "name": "uptime"
    },
    "system": {
      "uptime": {
        "duration": {
          "ms": 339442389
        }
      }
    },
    "@timestamp": "2018-12-05T01:02:04.564Z",
    "tags": [
      "beats_input_raw_event"
    ],
    "beat": {
      "hostname": "freebsd-11-2",
      "version": "6.5.0",
      "name": "freebsd-11-2"
    },
    "@version": "1"
  },
  "fields": {
    "@timestamp": [
      "2018-12-05T01:02:04.564Z"
    ]
  },
  "highlight": {
    "metricset.name": [
      "@kibana-highlighted-field@uptime@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1543971724564
  ]
}

```

Is this an oversight, or is there a deeper reason it's not enabled for FreeBSD?

---

<div class="post-metadata">

### Author: ![Kaiyan\_Sheng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kaiyan_sheng/32/38247_2.png) [@Kaiyan\_Sheng](https://discuss.elastic.co/u/Kaiyan_Sheng)
#### Post date: [December 5, 2018, 4:11am UTC](https://discuss.elastic.co/t/freebsd-version-of-the-system-module-has-the-uptime-metricset-disabled/159437/2 "2018-12-05T04:11:01Z")

</div>

Hello! I think by default, besides system module, everything else is disabled.

---

<div class="post-metadata">

### Author: ![rhclayto](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@rhclayto](https://discuss.elastic.co/u/rhclayto)
#### Post date: [December 5, 2018, 4:26am UTC](https://discuss.elastic.co/t/freebsd-version-of-the-system-module-has-the-uptime-metricset-disabled/159437/3 "2018-12-05T04:26:55Z")

</div>

I am referring to the uptime metricset, which is part of the system module. In the code, it's enabled for darwin linux openbsd, & windows, but not FreeBSD. I'm wondering why, since it appears to work fine, on FreeBSD 11 at any rate. If there isn't some underlying reason not to enable this for FreeBSD, then I believe this should be considered a bug.

---

<div class="post-metadata">

### Author: ![Kaiyan\_Sheng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kaiyan_sheng/32/38247_2.png) [@Kaiyan\_Sheng](https://discuss.elastic.co/u/Kaiyan_Sheng)
#### Post date: [December 5, 2018, 3:05pm UTC](https://discuss.elastic.co/t/freebsd-version-of-the-system-module-has-the-uptime-metricset-disabled/159437/4 "2018-12-05T15:05:51Z")

</div>

@rhclayto thanks for the explanation 🙂 I'm glad it works! I will create a github issue to make it be enabled by default.

---

<div class="post-metadata">

### Author: ![rhclayto](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@rhclayto](https://discuss.elastic.co/u/rhclayto)
#### Post date: [December 16, 2018, 2:10am UTC](https://discuss.elastic.co/t/freebsd-version-of-the-system-module-has-the-uptime-metricset-disabled/159437/5 "2018-12-16T02:10:21Z")

</div>

Thanks. Do you have a link to the Github issue? I'd like to follow it there. Or I can create an issue if you haven't already done so.

Edit:

Nevermind, found it: [https://github.com/elastic/beats/pull/9413](https://github.com/elastic/beats/pull/9413)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 13, 2019, 2:10am UTC](https://discuss.elastic.co/t/freebsd-version-of-the-system-module-has-the-uptime-metricset-disabled/159437/6 "2019-01-13T02:10:23Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
