1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933
|
// Copyright 2017 The Prometheus Authors
// Licensed 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.
//go:build !nomountstats
// +build !nomountstats
package collector
import (
"fmt"
"log/slog"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs"
)
var (
// 64-bit float mantissa: https://en.wikipedia.org/wiki/Double-precision_floating-point_format
float64Mantissa uint64 = 9007199254740992
)
type mountStatsCollector struct {
// General statistics
NFSAgeSecondsTotal *prometheus.Desc
// Byte statistics
NFSReadBytesTotal *prometheus.Desc
NFSWriteBytesTotal *prometheus.Desc
NFSDirectReadBytesTotal *prometheus.Desc
NFSDirectWriteBytesTotal *prometheus.Desc
NFSTotalReadBytesTotal *prometheus.Desc
NFSTotalWriteBytesTotal *prometheus.Desc
NFSReadPagesTotal *prometheus.Desc
NFSWritePagesTotal *prometheus.Desc
// Per-operation statistics
NFSOperationsRequestsTotal *prometheus.Desc
NFSOperationsTransmissionsTotal *prometheus.Desc
NFSOperationsMajorTimeoutsTotal *prometheus.Desc
NFSOperationsSentBytesTotal *prometheus.Desc
NFSOperationsReceivedBytesTotal *prometheus.Desc
NFSOperationsQueueTimeSecondsTotal *prometheus.Desc
NFSOperationsResponseTimeSecondsTotal *prometheus.Desc
NFSOperationsRequestTimeSecondsTotal *prometheus.Desc
// Transport statistics
NFSTransportBindTotal *prometheus.Desc
NFSTransportConnectTotal *prometheus.Desc
NFSTransportIdleTimeSeconds *prometheus.Desc
NFSTransportSendsTotal *prometheus.Desc
NFSTransportReceivesTotal *prometheus.Desc
NFSTransportBadTransactionIDsTotal *prometheus.Desc
NFSTransportBacklogQueueTotal *prometheus.Desc
NFSTransportMaximumRPCSlots *prometheus.Desc
NFSTransportSendingQueueTotal *prometheus.Desc
NFSTransportPendingQueueTotal *prometheus.Desc
// Event statistics
NFSEventInodeRevalidateTotal *prometheus.Desc
NFSEventDnodeRevalidateTotal *prometheus.Desc
NFSEventDataInvalidateTotal *prometheus.Desc
NFSEventAttributeInvalidateTotal *prometheus.Desc
NFSEventVFSOpenTotal *prometheus.Desc
NFSEventVFSLookupTotal *prometheus.Desc
NFSEventVFSAccessTotal *prometheus.Desc
NFSEventVFSUpdatePageTotal *prometheus.Desc
NFSEventVFSReadPageTotal *prometheus.Desc
NFSEventVFSReadPagesTotal *prometheus.Desc
NFSEventVFSWritePageTotal *prometheus.Desc
NFSEventVFSWritePagesTotal *prometheus.Desc
NFSEventVFSGetdentsTotal *prometheus.Desc
NFSEventVFSSetattrTotal *prometheus.Desc
NFSEventVFSFlushTotal *prometheus.Desc
NFSEventVFSFsyncTotal *prometheus.Desc
NFSEventVFSLockTotal *prometheus.Desc
NFSEventVFSFileReleaseTotal *prometheus.Desc
NFSEventTruncationTotal *prometheus.Desc
NFSEventWriteExtensionTotal *prometheus.Desc
NFSEventSillyRenameTotal *prometheus.Desc
NFSEventShortReadTotal *prometheus.Desc
NFSEventShortWriteTotal *prometheus.Desc
NFSEventJukeboxDelayTotal *prometheus.Desc
NFSEventPNFSReadTotal *prometheus.Desc
NFSEventPNFSWriteTotal *prometheus.Desc
proc procfs.Proc
logger *slog.Logger
}
// used to uniquely identify an NFS mount to prevent duplicates
type nfsDeviceIdentifier struct {
Device string
Protocol string
MountAddress string
}
func init() {
registerCollector("mountstats", defaultDisabled, NewMountStatsCollector)
}
// NewMountStatsCollector returns a new Collector exposing NFS statistics.
func NewMountStatsCollector(logger *slog.Logger) (Collector, error) {
fs, err := procfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs: %w", err)
}
proc, err := fs.Self()
if err != nil {
return nil, fmt.Errorf("failed to open /proc/self: %w", err)
}
const (
// For the time being, only NFS statistics are available via this mechanism.
subsystem = "mountstats_nfs"
)
var (
labels = []string{"export", "protocol", "mountaddr"}
opLabels = []string{"export", "protocol", "mountaddr", "operation"}
)
return &mountStatsCollector{
NFSAgeSecondsTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "age_seconds_total"),
"The age of the NFS mount in seconds.",
labels,
nil,
),
NFSReadBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "read_bytes_total"),
"Number of bytes read using the read() syscall.",
labels,
nil,
),
NFSWriteBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "write_bytes_total"),
"Number of bytes written using the write() syscall.",
labels,
nil,
),
NFSDirectReadBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "direct_read_bytes_total"),
"Number of bytes read using the read() syscall in O_DIRECT mode.",
labels,
nil,
),
NFSDirectWriteBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "direct_write_bytes_total"),
"Number of bytes written using the write() syscall in O_DIRECT mode.",
labels,
nil,
),
NFSTotalReadBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "total_read_bytes_total"),
"Number of bytes read from the NFS server, in total.",
labels,
nil,
),
NFSTotalWriteBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "total_write_bytes_total"),
"Number of bytes written to the NFS server, in total.",
labels,
nil,
),
NFSReadPagesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "read_pages_total"),
"Number of pages read directly via mmap()'d files.",
labels,
nil,
),
NFSWritePagesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "write_pages_total"),
"Number of pages written directly via mmap()'d files.",
labels,
nil,
),
NFSTransportBindTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "transport_bind_total"),
"Number of times the client has had to establish a connection from scratch to the NFS server.",
labels,
nil,
),
NFSTransportConnectTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "transport_connect_total"),
"Number of times the client has made a TCP connection to the NFS server.",
labels,
nil,
),
NFSTransportIdleTimeSeconds: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "transport_idle_time_seconds"),
"Duration since the NFS mount last saw any RPC traffic, in seconds.",
labels,
nil,
),
NFSTransportSendsTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "transport_sends_total"),
"Number of RPC requests for this mount sent to the NFS server.",
labels,
nil,
),
NFSTransportReceivesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "transport_receives_total"),
"Number of RPC responses for this mount received from the NFS server.",
labels,
nil,
),
NFSTransportBadTransactionIDsTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "transport_bad_transaction_ids_total"),
"Number of times the NFS server sent a response with a transaction ID unknown to this client.",
labels,
nil,
),
NFSTransportBacklogQueueTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "transport_backlog_queue_total"),
"Total number of items added to the RPC backlog queue.",
labels,
nil,
),
NFSTransportMaximumRPCSlots: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "transport_maximum_rpc_slots"),
"Maximum number of simultaneously active RPC requests ever used.",
labels,
nil,
),
NFSTransportSendingQueueTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "transport_sending_queue_total"),
"Total number of items added to the RPC transmission sending queue.",
labels,
nil,
),
NFSTransportPendingQueueTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "transport_pending_queue_total"),
"Total number of items added to the RPC transmission pending queue.",
labels,
nil,
),
NFSOperationsRequestsTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "operations_requests_total"),
"Number of requests performed for a given operation.",
opLabels,
nil,
),
NFSOperationsTransmissionsTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "operations_transmissions_total"),
"Number of times an actual RPC request has been transmitted for a given operation.",
opLabels,
nil,
),
NFSOperationsMajorTimeoutsTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "operations_major_timeouts_total"),
"Number of times a request has had a major timeout for a given operation.",
opLabels,
nil,
),
NFSOperationsSentBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "operations_sent_bytes_total"),
"Number of bytes sent for a given operation, including RPC headers and payload.",
opLabels,
nil,
),
NFSOperationsReceivedBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "operations_received_bytes_total"),
"Number of bytes received for a given operation, including RPC headers and payload.",
opLabels,
nil,
),
NFSOperationsQueueTimeSecondsTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "operations_queue_time_seconds_total"),
"Duration all requests spent queued for transmission for a given operation before they were sent, in seconds.",
opLabels,
nil,
),
NFSOperationsResponseTimeSecondsTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "operations_response_time_seconds_total"),
"Duration all requests took to get a reply back after a request for a given operation was transmitted, in seconds.",
opLabels,
nil,
),
NFSOperationsRequestTimeSecondsTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "operations_request_time_seconds_total"),
"Duration all requests took from when a request was enqueued to when it was completely handled for a given operation, in seconds.",
opLabels,
nil,
),
NFSEventInodeRevalidateTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_inode_revalidate_total"),
"Number of times cached inode attributes are re-validated from the server.",
labels,
nil,
),
NFSEventDnodeRevalidateTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_dnode_revalidate_total"),
"Number of times cached dentry nodes are re-validated from the server.",
labels,
nil,
),
NFSEventDataInvalidateTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_data_invalidate_total"),
"Number of times an inode cache is cleared.",
labels,
nil,
),
NFSEventAttributeInvalidateTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_attribute_invalidate_total"),
"Number of times cached inode attributes are invalidated.",
labels,
nil,
),
NFSEventVFSOpenTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_open_total"),
"Number of times cached inode attributes are invalidated.",
labels,
nil,
),
NFSEventVFSLookupTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_lookup_total"),
"Number of times a directory lookup has occurred.",
labels,
nil,
),
NFSEventVFSAccessTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_access_total"),
"Number of times permissions have been checked.",
labels,
nil,
),
NFSEventVFSUpdatePageTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_update_page_total"),
"Number of updates (and potential writes) to pages.",
labels,
nil,
),
NFSEventVFSReadPageTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_read_page_total"),
"Number of pages read directly via mmap()'d files.",
labels,
nil,
),
NFSEventVFSReadPagesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_read_pages_total"),
"Number of times a group of pages have been read.",
labels,
nil,
),
NFSEventVFSWritePageTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_write_page_total"),
"Number of pages written directly via mmap()'d files.",
labels,
nil,
),
NFSEventVFSWritePagesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_write_pages_total"),
"Number of times a group of pages have been written.",
labels,
nil,
),
NFSEventVFSGetdentsTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_getdents_total"),
"Number of times directory entries have been read with getdents().",
labels,
nil,
),
NFSEventVFSSetattrTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_setattr_total"),
"Number of times directory entries have been read with getdents().",
labels,
nil,
),
NFSEventVFSFlushTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_flush_total"),
"Number of pending writes that have been forcefully flushed to the server.",
labels,
nil,
),
NFSEventVFSFsyncTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_fsync_total"),
"Number of times fsync() has been called on directories and files.",
labels,
nil,
),
NFSEventVFSLockTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_lock_total"),
"Number of times locking has been attempted on a file.",
labels,
nil,
),
NFSEventVFSFileReleaseTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_vfs_file_release_total"),
"Number of times files have been closed and released.",
labels,
nil,
),
NFSEventTruncationTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_truncation_total"),
"Number of times files have been truncated.",
labels,
nil,
),
NFSEventWriteExtensionTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_write_extension_total"),
"Number of times a file has been grown due to writes beyond its existing end.",
labels,
nil,
),
NFSEventSillyRenameTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_silly_rename_total"),
"Number of times a file was removed while still open by another process.",
labels,
nil,
),
NFSEventShortReadTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_short_read_total"),
"Number of times the NFS server gave less data than expected while reading.",
labels,
nil,
),
NFSEventShortWriteTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_short_write_total"),
"Number of times the NFS server wrote less data than expected while writing.",
labels,
nil,
),
NFSEventJukeboxDelayTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_jukebox_delay_total"),
"Number of times the NFS server indicated EJUKEBOX; retrieving data from offline storage.",
labels,
nil,
),
NFSEventPNFSReadTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_pnfs_read_total"),
"Number of NFS v4.1+ pNFS reads.",
labels,
nil,
),
NFSEventPNFSWriteTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "event_pnfs_write_total"),
"Number of NFS v4.1+ pNFS writes.",
labels,
nil,
),
proc: proc,
logger: logger,
}, nil
}
func (c *mountStatsCollector) Update(ch chan<- prometheus.Metric) error {
mounts, err := c.proc.MountStats()
if err != nil {
return fmt.Errorf("failed to parse mountstats: %w", err)
}
mountsInfo, err := c.proc.MountInfo()
if err != nil {
return fmt.Errorf("failed to parse mountinfo: %w", err)
}
// store all seen nfsDeviceIdentifiers for deduplication
deviceList := make(map[nfsDeviceIdentifier]bool)
for idx, m := range mounts {
// For the time being, only NFS statistics are available via this mechanism
stats, ok := m.Stats.(*procfs.MountStatsNFS)
if !ok {
continue
}
var mountAddress string
if idx < len(mountsInfo) {
// The mount entry order in the /proc/self/mountstats and /proc/self/mountinfo is the same.
miStats := mountsInfo[idx]
mountAddress = miStats.SuperOptions["addr"]
}
for k := range stats.Transport {
deviceIdentifier := nfsDeviceIdentifier{m.Device, stats.Transport[k].Protocol, mountAddress}
i := deviceList[deviceIdentifier]
if i {
c.logger.Debug("Skipping duplicate device entry", "device", deviceIdentifier)
break
}
deviceList[deviceIdentifier] = true
c.updateNFSStats(ch, stats, m.Device, stats.Transport[k].Protocol, mountAddress)
}
}
return nil
}
func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, s *procfs.MountStatsNFS, export, protocol, mountAddress string) {
labelValues := []string{export, protocol, mountAddress}
ch <- prometheus.MustNewConstMetric(
c.NFSAgeSecondsTotal,
prometheus.CounterValue,
s.Age.Seconds(),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSReadBytesTotal,
prometheus.CounterValue,
float64(s.Bytes.Read),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSWriteBytesTotal,
prometheus.CounterValue,
float64(s.Bytes.Write),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSDirectReadBytesTotal,
prometheus.CounterValue,
float64(s.Bytes.DirectRead),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSDirectWriteBytesTotal,
prometheus.CounterValue,
float64(s.Bytes.DirectWrite),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTotalReadBytesTotal,
prometheus.CounterValue,
float64(s.Bytes.ReadTotal),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTotalWriteBytesTotal,
prometheus.CounterValue,
float64(s.Bytes.WriteTotal),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSReadPagesTotal,
prometheus.CounterValue,
float64(s.Bytes.ReadPages),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSWritePagesTotal,
prometheus.CounterValue,
float64(s.Bytes.WritePages),
labelValues...,
)
for i := range s.Transport {
ch <- prometheus.MustNewConstMetric(
c.NFSTransportBindTotal,
prometheus.CounterValue,
float64(s.Transport[i].Bind),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTransportConnectTotal,
prometheus.CounterValue,
float64(s.Transport[i].Connect),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTransportIdleTimeSeconds,
prometheus.GaugeValue,
float64(s.Transport[i].IdleTimeSeconds%float64Mantissa),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTransportSendsTotal,
prometheus.CounterValue,
float64(s.Transport[i].Sends),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTransportReceivesTotal,
prometheus.CounterValue,
float64(s.Transport[i].Receives),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTransportBadTransactionIDsTotal,
prometheus.CounterValue,
float64(s.Transport[i].BadTransactionIDs),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTransportBacklogQueueTotal,
prometheus.CounterValue,
float64(s.Transport[i].CumulativeBacklog),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTransportMaximumRPCSlots,
prometheus.GaugeValue,
float64(s.Transport[i].MaximumRPCSlotsUsed),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTransportSendingQueueTotal,
prometheus.CounterValue,
float64(s.Transport[i].CumulativeSendingQueue),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSTransportPendingQueueTotal,
prometheus.CounterValue,
float64(s.Transport[i].CumulativePendingQueue),
labelValues...,
)
}
for _, op := range s.Operations {
opLabelValues := []string{export, protocol, mountAddress, op.Operation}
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsRequestsTotal,
prometheus.CounterValue,
float64(op.Requests),
opLabelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsTransmissionsTotal,
prometheus.CounterValue,
float64(op.Transmissions),
opLabelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsMajorTimeoutsTotal,
prometheus.CounterValue,
float64(op.MajorTimeouts),
opLabelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsSentBytesTotal,
prometheus.CounterValue,
float64(op.BytesSent),
opLabelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsReceivedBytesTotal,
prometheus.CounterValue,
float64(op.BytesReceived),
opLabelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsQueueTimeSecondsTotal,
prometheus.CounterValue,
float64(op.CumulativeQueueMilliseconds%float64Mantissa)/1000.0,
opLabelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsResponseTimeSecondsTotal,
prometheus.CounterValue,
float64(op.CumulativeTotalResponseMilliseconds%float64Mantissa)/1000.0,
opLabelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsRequestTimeSecondsTotal,
prometheus.CounterValue,
float64(op.CumulativeTotalRequestMilliseconds%float64Mantissa)/1000.0,
opLabelValues...,
)
}
ch <- prometheus.MustNewConstMetric(
c.NFSEventInodeRevalidateTotal,
prometheus.CounterValue,
float64(s.Events.InodeRevalidate),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventDnodeRevalidateTotal,
prometheus.CounterValue,
float64(s.Events.DnodeRevalidate),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventDataInvalidateTotal,
prometheus.CounterValue,
float64(s.Events.DataInvalidate),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventAttributeInvalidateTotal,
prometheus.CounterValue,
float64(s.Events.AttributeInvalidate),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSOpenTotal,
prometheus.CounterValue,
float64(s.Events.VFSOpen),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSLookupTotal,
prometheus.CounterValue,
float64(s.Events.VFSLookup),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSAccessTotal,
prometheus.CounterValue,
float64(s.Events.VFSAccess),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSUpdatePageTotal,
prometheus.CounterValue,
float64(s.Events.VFSUpdatePage),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSReadPageTotal,
prometheus.CounterValue,
float64(s.Events.VFSReadPage),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSReadPagesTotal,
prometheus.CounterValue,
float64(s.Events.VFSReadPages),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSWritePageTotal,
prometheus.CounterValue,
float64(s.Events.VFSWritePage),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSWritePagesTotal,
prometheus.CounterValue,
float64(s.Events.VFSWritePages),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSGetdentsTotal,
prometheus.CounterValue,
float64(s.Events.VFSGetdents),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSSetattrTotal,
prometheus.CounterValue,
float64(s.Events.VFSSetattr),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSFlushTotal,
prometheus.CounterValue,
float64(s.Events.VFSFlush),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSFsyncTotal,
prometheus.CounterValue,
float64(s.Events.VFSFsync),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSLockTotal,
prometheus.CounterValue,
float64(s.Events.VFSLock),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventVFSFileReleaseTotal,
prometheus.CounterValue,
float64(s.Events.VFSFileRelease),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventTruncationTotal,
prometheus.CounterValue,
float64(s.Events.Truncation),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventWriteExtensionTotal,
prometheus.CounterValue,
float64(s.Events.WriteExtension),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventSillyRenameTotal,
prometheus.CounterValue,
float64(s.Events.SillyRename),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventShortReadTotal,
prometheus.CounterValue,
float64(s.Events.ShortRead),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventShortWriteTotal,
prometheus.CounterValue,
float64(s.Events.ShortWrite),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventJukeboxDelayTotal,
prometheus.CounterValue,
float64(s.Events.JukeboxDelay),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventPNFSReadTotal,
prometheus.CounterValue,
float64(s.Events.PNFSRead),
labelValues...,
)
ch <- prometheus.MustNewConstMetric(
c.NFSEventPNFSWriteTotal,
prometheus.CounterValue,
float64(s.Events.PNFSWrite),
labelValues...,
)
}
|