mehdy / keepalived-exporter

Prometheus Keepalived exporter
GNU General Public License v3.0
115 stars 37 forks source link

"Failed to open /tmp/keepalived.stats" #74

Closed arkaditya closed 3 years ago

arkaditya commented 3 years ago

keeplaived version 1.3.5 - 1.3.9 (one host in 1.3.9 and 2 other in 1.3.5).

I have deployed keepalived-exporter as a service using the keepalived-exporter binary from the tar file on our keepalived/haproxy hosts.

systemctl status keepalived-exporter
● keepalived-exporter.service - Keepalived Exporter
   Loaded: loaded (/usr/lib/systemd/system/keepalived-exporter.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-06-29 17:03:58 UTC; 5h 18min ago
 Main PID: 3750 (keepalived-expo)
   CGroup: /system.slice/keepalived-exporter.service
           └─3750 /usr/local/bin/keepalived-exporter
journalctl -u keepalived-exporter

Jun 29 15:45:41 welktx08labidms-l-fr-idms-00-hap-000 keepalived-exporter[6378]: time="2021-06-29T15:45:41Z" level=error msg="Failed to open /tmp/keepalived.stats" er
ror="open /tmp/keepalived.stats: no such file or directory"
Jun 29 15:45:41 welktx08labidms-l-fr-idms-00-hap-000 keepalived-exporter[6378]: time="2021-06-29T15:45:41Z" level=error msg="No data found to be exported" error="ope
n /tmp/keepalived.stats: no such file or directory"
Jun 29 15:46:11 welktx08labidms-l-fr-idms-00-hap-000 keepalived-exporter[6378]: time="2021-06-29T15:46:11Z" level=error msg="Failed to open /tmp/keepalived.stats" er
ror="open /tmp/keepalived.stats: no such file or directory"

/tmp permission: drwxrwxrwt. 10 root root 243 Jun 29 22:21 tmp

Because of this missing keepalived.data file, we are not able to get the keepalived metrics even when the scrape is happening on correct port using endpoints.

curl http://localhost:9165/metrics | grep keepalived
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6240    0  6240    0     0   324k      0 --:--:-- --:--:-- --:--:--  338k
# HELP keepalived_up Status
# TYPE keepalived_up gauge
keepalived_up 0

The keepalived service is up and running

sudo systemctl status keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
   Loaded: loaded (/usr/lib/systemd/system/keepalived.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-06-29 21:45:04 UTC; 46min ago
  Process: 22086 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 22087 (keepalived)
   CGroup: /system.slice/keepalived.service
           ├─22087 /usr/sbin/keepalived -D
           ├─22088 /usr/sbin/keepalived -D
           └─22089 /usr/sbin/keepalived -D

The leepalived servers do not have killall binary

ls -lrt /usr/sbin/kill*
-rwxr-xr-x. 1 root root 23728 Jun  9  2014 /usr/sbin/killall5
clwluvw commented 3 years ago

Hi,

Would you please also share your keepalived -v and keepalived-exporter --version output and the options you are passing to the exporter?

arkaditya commented 3 years ago
$ keepalived-exporter --version
INFO[0000] Keepalived Exporter                           build_time="2021-03-06_21:06:21_+0330" commit=4c95fa6 version=1.2.0
keepalived -v
Keepalived v1.3.5 (03/19,2017), git commit v1.3.5-6-g6fa32f2

Copyright(C) 2001-2017 Alexandre Cassen, <acassen@gmail.com>

Build options:  PIPE2 LIBNL3 RTA_ENCAP RTA_EXPIRES RTA_PREF RTA_VIA FRA_OIFNAME FRA_SUPPRESS_PREFIXLEN FRA_TUN_ID RTAX_CC_ALGO RTAX_QUICKACK LIBIPTC LIBIPSET_DYNAMIC LVS LIBIPVS_NETLINK VRRP VRRP_AUTH VRRP_VMAC SOCK_NONBLOCK SOCK_CLOEXEC FIB_ROUTING INET6_ADDR_GEN_MODE SNMP_V3_FOR_V2 SNMP SNMP_KEEPALIVED SNMP_CHECKER SNMP_RFC SNMP_RFCV2 SNMP_RFCV3 SO_MARK

I added some verbose statements to collector module and rebuild the exporter. Debug logs:

time="2021-07-01T16:49:46Z" level=info msg="Listening on address: :9165"
 keepalived-exporter[13575]: time="2021-07-01T16:50:12Z" level=info msg="DEBUG: " keepalivedUp : =1.0
 keepalived-exporter[13575]: time="2021-07-01T16:50:12Z" level=error msg="Failed to open /tmp/keepalived.stats" error="open /tmp/keepalived.stats: no such file or directory"
 keepalived-exporter[13575]: time="2021-07-01T16:50:12Z" level=info msg="DEBUG: " VRRPStats Size=0
 keepalived-exporter[13575]: time="2021-07-01T16:50:12Z" level=error msg="No data found to be exported" error="open /tmp/keepalived.stats: no such file or directory"
clwluvw commented 3 years ago

What arguments are you passing to the keepalived-exporter when running it?

Please paste the full keepalived -v output and what's your OS?

arkaditya commented 3 years ago

We are using CentOs7 and I am not passing any arguments when running the keepalived-exporter

arkaditya commented 3 years ago

Closing the issue, as it was due to SELINUX=enforcing in etc/selinux/config. Setting it to disabled , getting the metrics.


keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: " keepalivedUp : =1.0
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: " VRRPStats Size=1
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->AdvertRcvd =2
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->AdvertSent  =297
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->BecomeMaster  =1
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->ReleaseMaster =1
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->PacketLenErr =0
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->AdvertIntervalErr =0
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->IPTTLErr  =0
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->InvalidTypeRcvd  =0
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->AddrListErr  =0
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->InvalidAuthType  =0
keepalived-exporter[13575]: time="2021-07-01T18:35:12Z" level=info msg="DEBUG: "  VRRPStats->AuthTypeMismatch  =0
owoNA commented 1 year ago

Why don't i have these two files With your operator