-
Notifications
You must be signed in to change notification settings - Fork 84
enhance code by ntp status #298
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
base: main
Are you sure you want to change the base?
Conversation
I enhanced junos-exporter by handling JUNOS-command "show ntp status".
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good. I would love to see some tests for the parsing code and disable the feature by default. Then i would gladly merge it.
internal/config/config.go
Outdated
c.LSEnabled = false | ||
f := &c.Features | ||
f.Alarm = true | ||
f.NTP = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new features should not be enabled by default
pkg/features/ntp/collector.go
Outdated
ntpLeapDesc = prometheus.NewDesc(prefix+"leap", "Leap indicator (00=ok, 01: last minute with 61 seconds, 10: last minute with 59 seconds, 11: not syncronized)", l, nil) | ||
ntpPrecisionDesc = prometheus.NewDesc(prefix+"precision", "Clock precision (should be -20 to -22)", l, nil) | ||
ntpPollDesc = prometheus.NewDesc(prefix+"poll_interval", "Poll interval in seconds", l, nil) | ||
// ntpServerDesc = prometheus.NewDesc(prefix+"server_info", "NTP server info", append(l, "refid"), nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be removed if not needed
pkg/features/ntp/collector.go
Outdated
ch <- ntpLeapDesc | ||
ch <- ntpPrecisionDesc | ||
ch <- ntpPollDesc | ||
// ch <- ntpServerDesc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove, if not needed
pkg/features/ntp/collector.go
Outdated
exportMetric(ch, ntpPrecisionDesc, result.Precision, labels) | ||
exportMetric(ch, ntpPollDesc, result.PollInterval, labels) | ||
|
||
// ch <- prometheus.MustNewConstMetric( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove if not needed
Set default value for NTP to false
Delete comment lines
Hi Daniel,
Thank you for the respone.
Today I made the requested changes.
Best regards
Gerhard
From: Daniel Brendgen-Czerwonk ***@***.***>
Sent: Mittwoch, 10. September 2025 11:09
To: czerwonk/junos_exporter ***@***.***>
Cc: Gerhard Weber ***@***.***>; Author ***@***.***>
Subject: Re: [czerwonk/junos_exporter] enhance code by ntp status (PR #298)
Sie erhalten nicht häufig E-Mails von ***@***.******@***.***>. Erfahren Sie, warum dies wichtig ist<https://aka.ms/LearnAboutSenderIdentification>
SECURITY WARNING: This email is from an external source - be careful of attachments and links. Please report suspicious emails to ***@***.******@***.***>
@czerwonk requested changes on this pull request.
Looks pretty good. I would love to see some tests for the parsing code and disable the feature by default. Then i would gladly merge it.
________________________________
In internal/config/config.go<#298 (comment)>:
@@ -151,6 +152,7 @@ func setDefaultValues(c *Config) {
c.LSEnabled = false
f := &c.Features
f.Alarm = true
+ f.NTP = true
new features should not be enabled by default
________________________________
In pkg/features/ntp/collector.go<#298 (comment)>:
+ ntpPollDesc *prometheus.Desc
+
+// ntpServerDesc *prometheus.Desc
+)
+
+func init() {
+ l := []string{"target", "server"}
+ ntpStratumDesc = prometheus.NewDesc(prefix+"stratum", "NTP stratum level (0: reference clock, 1-15: hops to refernce clock, 16: not syncronized)", l, nil)
+ ntpOffsetDesc = prometheus.NewDesc(prefix+"offset", "Time offset in msec", l, nil)
+ ntpSysJitterDesc = prometheus.NewDesc(prefix+"system_jitter", "System jitter in msec", l, nil)
+ ntpClkJitterDesc = prometheus.NewDesc(prefix+"clock_jitter", "Clock jitter in msec", l, nil)
+ ntpRootDelayDesc = prometheus.NewDesc(prefix+"root_delay", "Root delay in msec", l, nil)
+ ntpLeapDesc = prometheus.NewDesc(prefix+"leap", "Leap indicator (00=ok, 01: last minute with 61 seconds, 10: last minute with 59 seconds, 11: not syncronized)", l, nil)
+ ntpPrecisionDesc = prometheus.NewDesc(prefix+"precision", "Clock precision (should be -20 to -22)", l, nil)
+ ntpPollDesc = prometheus.NewDesc(prefix+"poll_interval", "Poll interval in seconds", l, nil)
+ // ntpServerDesc = prometheus.NewDesc(prefix+"server_info", "NTP server info", append(l, "refid"), nil)
this should be removed if not needed
________________________________
In pkg/features/ntp/collector.go<#298 (comment)>:
+}
+
+func (c *ntpCollector) Name() string {
+ return "ntp"
+}
+
+func (c *ntpCollector) Describe(ch chan<- *prometheus.Desc) {
+ ch <- ntpStratumDesc
+ ch <- ntpOffsetDesc
+ ch <- ntpSysJitterDesc
+ ch <- ntpClkJitterDesc
+ ch <- ntpRootDelayDesc
+ ch <- ntpLeapDesc
+ ch <- ntpPrecisionDesc
+ ch <- ntpPollDesc
+ // ch <- ntpServerDesc
remove, if not needed
________________________________
In pkg/features/ntp/collector.go<#298 (comment)>:
+ if server == "" {
+ server = "unknown"
+ }
+
+ labels := append(labelValues, server)
+
+ exportMetric(ch, ntpStratumDesc, result.Stratum, labels)
+ exportMetric(ch, ntpOffsetDesc, result.Offset, labels)
+ exportMetric(ch, ntpSysJitterDesc, result.SysJitter, labels)
+ exportMetric(ch, ntpClkJitterDesc, result.ClkJitter, labels)
+ exportMetric(ch, ntpRootDelayDesc, result.RootDelay, labels)
+ exportMetric(ch, ntpLeapDesc, parseLeap(result.Leap), labels)
+ exportMetric(ch, ntpPrecisionDesc, result.Precision, labels)
+ exportMetric(ch, ntpPollDesc, result.PollInterval, labels)
+
+ // ch <- prometheus.MustNewConstMetric(
remove if not needed
—
Reply to this email directly, view it on GitHub<#298 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BT5DFABBW7I53NZSOA6ZGP33R7TBBAVCNFSM6AAAAACADDPPP6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTEMBVGE4DSMBUGI>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
[https://i0.wp.com/dirac.ac.uk/wp-content/uploads/2023/10/logicalis-logo-vector-2022.png?ssl=1]<https://www.Logicalis.de/>
Gerhard Weber
Principal Consultant
M: +49 15128463595
www.Logicalis.de<http://www.Logicalis.com> [https://www.navigant.in/assets/images/interaction-section-shape-img-1.png] <https://www.logicalis.de/>
Logicalis Connected GmbH • Brunnenweg 19 • 64331 Weiterstadt • DE Geschäftsführer: Jürgen Hatzipantelis, Stefan Höltken Sitz der Gesellschaft: Weiterstadt • Amtsgericht Darmstadt • HRB 9276 Umsatzsteuer-ID Nr.: DE 197 925 589
|
No description provided.