الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

node_exporter

The Prometheus exporter for Linux hosts: CPU, memory, disks, file systems, network and systemd metrics on port 9100.

المستوى
خدمة DevSecOps
المجموعة
المراقبة والسجلات
يحتاج root
للتغييرات
الحزمة
node_exporter

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

node_exporter runs on every server and shows hardware and OS metrics at http://HOST:9100/metrics. Prometheus scrapes it. Collectors can be turned on or off (--collector.systemd, --no-collector.wifi). The textfile collector reads *.prom files, so your own scripts (backup age, certificate expiry) can add metrics.

In Kubernetes, kube-prometheus-stack installs it as a DaemonSet. Windows uses windows_exporter.

طريقة الكتابة

node_exporter [--collector.NAME] [--no-collector.NAME] [--web.listen-address=:9100]

الأجزاء الرئيسية

Important metrics

node_cpu_seconds_total
CPU time per mode (idle, user, system, iowait).
node_memory_MemAvailable_bytes
Memory that apps can still use.
node_filesystem_avail_bytes
Free space per mount.
node_disk_io_time_seconds_total
Disk busy time.
node_network_receive_bytes_total
Network traffic.
node_load1 / node_load5
Load average.
node_systemd_unit_state
State of systemd units (with --collector.systemd).
node_textfile_*
Your own metrics from the textfile collector.

الخيارات 6

الأكثر استخدامًا

Flags

--web.listen-address=:9100
Address and port.
--web.config.file=FILE
TLS and basic auth.
--collector.systemd
Turn on systemd unit metrics.
--collector.textfile.directory=DIR
Folder with *.prom files.
--no-collector.NAME
Turn a collector off.
--collector.filesystem.mount-points-exclude=REGEX
Skip some mounts.

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Install from EPEL or the release tarball

    dnf install -y golang-github-prometheus-node-exporter
    systemctl enable --now prometheus-node-exporter
    curl -s localhost:9100/metrics | head
  2. 2Run it as a hardened systemd service

    cat /etc/systemd/system/node_exporter.service
    [Service]
    User=node_exporter
    ExecStart=/usr/local/bin/node_exporter --collector.systemd --collector.textfile.directory=/var/lib/node_exporter
    NoNewPrivileges=yes
    ProtectSystem=strict
    ProtectHome=yes
    ReadOnlyPaths=/
  3. 3Allow only the Prometheus server

    firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.20.0.5/32 port port=9100 protocol=tcp accept'
    firewall-cmd --reload
  4. 4Check key numbers by hand

    curl -s localhost:9100/metrics | grep -E '^node_memory_MemAvailable_bytes|^node_load1 '
    curl -s localhost:9100/metrics | grep 'node_filesystem_avail_bytes{.*mountpoint="/"'
  5. 5Add your own metric with the textfile collector

    cat /usr/local/bin/backup-metric.sh
    #!/bin/bash
    echo "backup_last_success_timestamp_seconds $(date +%s)" > /var/lib/node_exporter/backup.prom.$$
    mv /var/lib/node_exporter/backup.prom.$$ /var/lib/node_exporter/backup.prom
  6. 6Alert when the backup is older than 26 hours

    cat rules/backup.yml
    groups:
      - name: backup
        rules:
          - alert: BackupTooOld
            expr: time() - backup_last_success_timestamp_seconds > 26*3600
  7. 7Scrape it from Prometheus

    cat prometheus.yml
    scrape_configs:
      - job_name: node
        static_configs: [{ targets: ["web1:9100", "web2:9100"] }]
  8. 8Protect it with TLS and basic auth

    cat /etc/node_exporter/web.yml
    tls_server_config: { cert_file: /etc/node_exporter/node.crt, key_file: /etc/node_exporter/node.key }
    basic_auth_users: { prometheus: "$2y$10$examplebcrypthashonly000000000000000000000000000000" }
  9. 9See failed systemd units as metrics

    curl -s localhost:9100/metrics | grep 'node_systemd_unit_state{.*state="failed"} 1'
  10. 10Check the exporter itself

    curl -s localhost:9100/metrics | grep node_exporter_build_info

انتبه

  • Metrics show host names, kernel versions and mount points — do not expose port 9100 to the internet.
  • Write textfile metrics atomically (temp file + mv), or Prometheus may read half a file.

الملفات

/var/lib/node_exporter/*.prom
Textfile collector files (path is your choice).

نصائح للحفظ

  • Use the "Node Exporter Full" Grafana dashboard (ID 1860) as a start.

رموز الخروج

0Clean stop.
1Error at start (bad flag, port in use).

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man node_exporter