node_exporter/collector
Christian Hoffmann 36e3b2a923 textfile: use opened file's mtime as timestamp (#1326)
Previously, the node_textfile_mtime_seconds metric was based on the
Fileinfo.ModTime() of the ioutil.ReadDir() return value. This is based
on lstat() and therefore has unintended consequences for symlinks
(modification time of the symlink instead of the symlink target is
returned). It is also racy as the lstat() is performed before reading
the file.

This commit changes the node_textfile_mtime_seconds metric to be based
on a fresh Stat() call on the open file.  This eliminates the race and
works as expected for symlinks. Fixes #1324.

Signed-off-by: Christian Hoffmann <mail@hoffmann-christian.info>
2019-04-18 17:47:04 +02:00
..
fixtures Expose /proc/pressure (#1261) 2019-04-18 12:19:20 +02:00
fixtures_hidepid/proc Add fallback for missing /proc/1/mounts (#1172) 2018-11-30 14:01:55 +01:00
arp_linux.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
bcache_linux.go Fix spelling mistakes found by codespell 2018-04-09 18:27:17 +02:00
bonding_linux.go Bond: Monitor bond mii_status not link operstate (#1124) 2019-02-10 11:00:04 +01:00
bonding_linux_test.go Rearrange fixtures to match "real" proc and sys. 2015-09-28 13:56:22 +00:00
boot_time_bsd.go collector: implement node_boot_time_seconds for OpenBSD/NetBSD/Darwin 2018-04-15 08:26:46 +00:00
boot_time_solaris.go Add kstat-based Solaris metrics (#1197) 2019-01-12 13:33:56 +01:00
buddyinfo.go Early init of procfs (#1315) 2019-04-10 18:16:12 +02:00
collector.go collector: export NodeCollector for documentation purposes 2018-10-26 15:42:00 -04:00
conntrack_linux.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
cpu_common.go Fix some golint issues (#927) 2018-04-29 14:34:47 +02:00
cpu_darwin.go Fix some golint issues (#927) 2018-04-29 14:34:47 +02:00
cpu_dragonfly.go Check BSD's mib which accounts for swap size (#1149) 2018-11-17 11:02:54 +01:00
cpu_dragonfly_test.go Add test 2016-09-28 09:10:05 +02:00
cpu_freebsd.go Fix for #945, cpu temperature is signed. (#965) 2018-06-07 15:01:25 +02:00
cpu_linux.go Early init of procfs (#1315) 2019-04-10 18:16:12 +02:00
cpu_openbsd.go Fix staticcheck ST1003 warnings (#1249) 2019-02-05 07:46:50 +01:00
cpu_solaris.go collector/cpu: split cpu freq metrics into separate collector (#1253) 2019-02-19 17:22:54 +01:00
cpufreq_linux.go Early init of procfs (#1315) 2019-04-10 18:16:12 +02:00
cpufreq_solaris.go collector/cpu: split cpu freq metrics into separate collector (#1253) 2019-02-19 17:22:54 +01:00
devstat_dragonfly.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
devstat_freebsd.c Add missing license headers 2017-01-05 06:18:34 +01:00
devstat_freebsd.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
devstat_freebsd.h Add missing license headers 2017-01-05 06:18:34 +01:00
diskstats_common.go Add diskstats collector for OpenBSD (#1250) 2019-02-06 11:36:22 +01:00
diskstats_darwin.go Add diskstats collector for OpenBSD (#1250) 2019-02-06 11:36:22 +01:00
diskstats_linux.go Add diskstats collector for OpenBSD (#1250) 2019-02-06 11:36:22 +01:00
diskstats_linux_test.go Update diskstats for linux kernel 4.19 (#1109) 2018-10-15 17:24:28 +02:00
diskstats_openbsd.go Add diskstats collector for OpenBSD (#1250) 2019-02-06 11:36:22 +01:00
drbd_linux.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
edac_linux.go collector: use path/filepath for handling file paths (#1245) 2019-02-05 16:37:27 +01:00
entropy_linux.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
exec_bsd.go collector: implement node_boot_time_seconds for OpenBSD/NetBSD/Darwin 2018-04-15 08:26:46 +00:00
filefd_linux.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
filefd_linux_test.go Fix scanner usage without error handling 2017-02-28 16:04:25 -04:00
filesystem_bsd.go Fix lint issues on filesystem BSD implementation 2017-03-22 21:48:12 -03:00
filesystem_common.go Use /proc/mounts instead of statfs(2) for ro state (#1002) 2018-07-16 15:56:27 +02:00
filesystem_freebsd.go Fix memory corruption when number of filesystems > 16 (#900) 2018-04-16 12:39:15 +02:00
filesystem_linux.go Add fallback for missing /proc/1/mounts (#1172) 2018-11-30 14:01:55 +01:00
filesystem_linux_test.go Add fallback for missing /proc/1/mounts (#1172) 2018-11-30 14:01:55 +01:00
helper.go Delete unused code 2017-02-28 17:20:16 -04:00
hwmon_linux.go collector: use path/filepath for handling file paths (#1245) 2019-02-05 16:37:27 +01:00
infiniband_linux.go Collect additional common Infiniband counters (#1120) 2018-10-30 21:54:09 +01:00
infiniband_linux_test.go infiniband: Handle iWARP* RDMA modules N/A (#974) 2018-10-04 15:05:59 +02:00
interrupts_common.go Make metrics better follow guidelines (#787) 2018-01-17 17:55:55 +01:00
interrupts_linux.go Use lowercase cpu label name in interrupts (#849) 2018-03-08 15:04:49 +01:00
interrupts_linux_test.go Fix off by one in Linux interrupts collector (#721) 2017-11-02 09:59:46 +01:00
interrupts_openbsd.go Use lowercase cpu label name in interrupts (#849) 2018-03-08 15:04:49 +01:00
ipvs_linux.go Early init of procfs (#1315) 2019-04-10 18:16:12 +02:00
ipvs_linux_test.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
ksmd_linux.go collector: use path/filepath for handling file paths (#1245) 2019-02-05 16:37:27 +01:00
kvm_bsd.c Move FreeBSD/DragonflyBSD out of meminfo add kvm. (#547) 2018-01-04 12:23:26 +01:00
kvm_bsd.go Move FreeBSD/DragonflyBSD out of meminfo add kvm. (#547) 2018-01-04 12:23:26 +01:00
kvm_bsd.h Move FreeBSD/DragonflyBSD out of meminfo add kvm. (#547) 2018-01-04 12:23:26 +01:00
loadavg.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
loadavg_freebsd.go Fix build tags of loadavg collector 2017-07-20 15:13:58 -04:00
loadavg_linux.go collector: support 1,5,15m load averages for all unices 2015-10-31 06:04:24 -07:00
loadavg_linux_test.go Add load5 and load15 to linux load metric 2015-10-17 13:07:39 +00:00
loadavg_solaris.go Add kstat-based Solaris metrics (#1197) 2019-01-12 13:33:56 +01:00
loadavg_unix.go Explicitly check for the rc 3 in call to getloadavg(). Reorder logic. 2017-05-14 13:07:54 +02:00
logind_linux.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
logind_linux_test.go Fix all open go lint and vet issues 2017-02-28 13:05:38 -04:00
mdadm_linux.go Fix mdadm collector issues (#985) 2018-07-02 12:38:20 +02:00
mdadm_linux_test.go Fix mdadm collector issues (#985) 2018-07-02 12:38:20 +02:00
meminfo.go Correctly cast Darwin memory info (#1060) 2018-09-07 22:27:52 +02:00
meminfo_darwin.go update to host_statistics64 for Darwin meminfo (#1183) 2018-12-06 16:47:20 +01:00
meminfo_linux.go Make metrics better follow guidelines (#787) 2018-01-17 17:55:55 +01:00
meminfo_linux_test.go Make metrics better follow guidelines (#787) 2018-01-17 17:55:55 +01:00
meminfo_numa_linux.go collector: use path/filepath for handling file paths (#1245) 2019-02-05 16:37:27 +01:00
meminfo_numa_linux_test.go Add Linux NUMA "numastat" metrics (#249) 2016-10-12 13:07:49 +02:00
meminfo_openbsd.go Use swpginuse instead of swpgonly in meminfo_openbsd (#813) 2018-02-16 11:34:41 +01:00
memory_bsd.go Check BSD's mib which accounts for swap size (#1149) 2018-11-17 11:02:54 +01:00
mountstats_linux.go Enable nfs protocol (#998) 2018-07-24 00:47:12 +02:00
netclass_linux.go Early init of procfs (#1315) 2019-04-10 18:16:12 +02:00
netdev_bsd.go Compile netdev on dragonfly (#314) 2016-09-27 21:44:13 +01:00
netdev_bsd_test.go Compile netdev on dragonfly (#314) 2016-09-27 21:44:13 +01:00
netdev_common.go Add full make to CircleCI (#761) 2017-12-21 16:24:23 +01:00
netdev_darwin.go Add netdev collector for darwin 2016-12-29 19:17:15 +01:00
netdev_linux.go Fix /proc/net/dev/ interface name handling 2018-04-18 12:53:59 +02:00
netdev_linux_test.go Fix /proc/net/dev/ interface name handling 2018-04-18 12:53:59 +02:00
netdev_openbsd.go Do a make format run. 2015-12-18 14:08:52 +00:00
netstat_linux.go netstat: Add TCP In/Out Segs (#1185) 2018-12-08 12:16:02 +01:00
netstat_linux_test.go Add parsing /proc/net/snmp6 file for netstat-linux (#615) 2017-07-08 20:16:35 +02:00
nfs_linux.go Cleanup NFS metrics (#834) 2018-02-21 07:25:41 +01:00
nfsd_linux.go Cleanup NFS metrics (#834) 2018-02-21 07:25:41 +01:00
ntp.go Update Makefile.common (#1220) 2019-01-04 15:58:53 +00:00
paths.go collector: use path/filepath for handling file paths (#1228) 2019-01-21 17:44:55 +01:00
paths_test.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
pressure_linux.go Expose /proc/pressure (#1261) 2019-04-18 12:19:20 +02:00
processes_linux.go Early init of procfs (#1315) 2019-04-10 18:16:12 +02:00
processes_linux_test.go Early init of procfs (#1315) 2019-04-10 18:16:12 +02:00
qdisc_linux.go Fix some golint issues (#927) 2018-04-29 14:34:47 +02:00
runit.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
sockstat_linux.go Replace --collectors.enabled with per-collector flags (#640) 2017-09-28 15:06:26 +02:00
sockstat_linux_test.go Add parsing /proc/net/snmp6 file for netstat-linux (#615) 2017-07-08 20:16:35 +02:00
stat_linux.go Early init of procfs (#1315) 2019-04-10 18:16:12 +02:00
supervisord.go Update Makefile.common (#1220) 2019-01-04 15:58:53 +00:00
sysctl_bsd.go collector: implement node_boot_time_seconds for OpenBSD/NetBSD/Darwin 2018-04-15 08:26:46 +00:00
systemd_linux.go Update systemd blacklist (#1255) 2019-02-17 17:57:15 +01:00
systemd_linux_test.go Systemd refactor (#1254) 2019-02-11 23:27:21 +01:00
tcpstat_linux.go collector: add bounds check and test for tcpstat collector (#1134) 2018-10-27 09:21:36 +02:00
tcpstat_linux_test.go collector: add bounds check and test for tcpstat collector (#1134) 2018-10-27 09:21:36 +02:00
textfile.go textfile: use opened file's mtime as timestamp (#1326) 2019-04-18 17:47:04 +02:00
textfile_test.go Treat custom textfile metric timestamps as errors (#769) 2018-02-27 19:43:38 +01:00
time.go Add _seconds suffix to node_time. (#823) 2018-02-14 16:59:08 +00:00
timex.go collector/timex: remove cgo dependency (#1079) 2018-09-20 11:51:34 +02:00
uname.go collector: Implement uname collector for FreeBSD (#1239) 2019-02-05 17:39:24 +01:00
uname_freebsd.go collector: Implement uname collector for FreeBSD (#1239) 2019-02-05 17:39:24 +01:00
uname_linux.go collector: Implement uname collector for FreeBSD (#1239) 2019-02-05 17:39:24 +01:00
vmstat_linux.go Update fixtures 2018-03-29 22:00:02 +01:00
wifi_linux.go Add receive/transmit bytes total metric (wifi collector). (#1150) 2018-11-19 19:15:54 +01:00
xfs_linux.go xfs: expose correct fields, fix metric names 2017-10-20 18:41:51 -04:00
zfs.go updates for zfsonlinux 0.7.5 (#779) 2018-02-16 15:46:31 +01:00
zfs_linux.go Update Makefile.common (#1220) 2019-01-04 15:58:53 +00:00
zfs_linux_test.go updates for zfsonlinux 0.7.5 (#779) 2018-02-16 15:46:31 +01:00
zfs_solaris.go Add kstat-based Solaris metrics (#1197) 2019-01-12 13:33:56 +01:00