prometheus-community / node-exporter-textfile-collector-scripts

Scripts for node-exporter's textfile collector
Apache License 2.0
512 stars 191 forks source link

nvme_metrics.sh does not write in given file #137

Closed cgaugel closed 1 year ago

cgaugel commented 1 year ago

The nvme_metrics.sh script does not write to my log file. The file is empty. Other scripts are working - what am I missing?

My file is located in /root/nvme_metrics.sh:

-rwxr-xr-x 1 root root 3700 Mar 7 11:26 nvme_metrics.sh

My Crontab:

* * * * * /bin/bash /root/nvme_metrics.sh > /var/lib/node_exporter/textfile_collector/disk_health.prom

My target file:

-rw-r--r-- 1 root root 0 Mar 7 11:54 /var/lib/node_exporter/textfile_collector/disk_health.prom

The syslog when the cronjob was executed:

Mar 7 11:55:01 ebay CRON[807]: (root) CMD (/bin/bash /root/nvme_metrics.sh > /var/lib/node_exporter/textfile_collector/disk_health.prom)

Ii also tried the following crontabs:

* * * * * /bin/bash /root/nvme_metrics.sh | sponge /var/lib/node_exporter/textfile_collector/disk_health.prom * * * * * /bin/bash /root/nvme_metrics.sh | tee /var/lib/node_exporter/textfile_collector/disk_health.prom

Anyone else facing the same problem? I am running Debian 10:

Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster

cgaugel commented 1 year ago

I found it. I had to change the nvme command in the shell script to use the absolute path like

/usr/sbin/nvme list -o json instead of nvme list -o json

Impact123 commented 1 year ago

Another way is to modify PATH for your cron job.