- edited description
Monit check file fails for character device files
Issue #793
new
I have a daemon which depends on the presence of a hardware device. If that hardware is not present, the daemon is not started and should not be monitored either. To solve this problem, I check for the presence of the device node as follows:
check file myservice-device with path /dev/mydevice
if does not exist then unmonitor
group devices
check process myservice with pidfile /var/run/myservice.pid
start program = "/etc/init.d/myservice start"
stop program = "/etc/init.d/myservice stop"
if does not exist for 2 cycles then restart
depends on myservice-device
group services
This works great for regular files (e.g. config files), but in this particular case the /dev/mydevice is a symlink to the actual device node:
# stat /dev/mydevice
File: /dev/mydevice -> ttyUSB1
Size: 7 Blocks: 0 IO Block: 4096 symbolic link
Device: 6h/6d Inode: 2904 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-11-23 06:40:23.296368326 +0000
Modify: 1970-01-01 00:00:08.124385375 +0000
Change: 1970-01-01 00:00:08.124385375 +0000
Birth: -
And that seems to cause the check to fail with "Invalid type":
# monit status myservice-device
Monit 5.23.0 uptime: 17h 23m
File 'myservice-device'
status Invalid type
monitoring status Monitored
monitoring mode active
on reboot start
permission 660
uid 0
gid 20
size 0 B
access timestamp Thu, 22 Nov 2018 15:01:45
change timestamp Thu, 01 Jan 1970 00:00:08
modify timestamp Thu, 22 Nov 2018 15:01:45
data collected Fri, 23 Nov 2018 08:22:34
Is there a way to let monit to follow the symlink?
Comments (5)
-
reporter -
reporter It seems the problem is not the symlink, but the fact that the file it references is a character device:
# stat /dev/ttyUSB1 File: /dev/ttyUSB1 Size: 0 Blocks: 0 IO Block: 4096 character special file Device: 6h/6d Inode: 2857 Links: 1 Device type: bc,1 Access: (0660/crw-rw----) Uid: ( 0/ root) Gid: ( 20/ dialout) Access: 2018-11-29 07:39:55.990000000 +0000 Modify: 2018-11-29 07:39:54.990000000 +0000 Change: 2018-11-28 14:22:15.990000000 +0000 Birth: -
-
reporter - attached 0001-Add-support-for-checking-character-files.patch
- changed title to Monit check file fails for character device files
The attached patch fixes the problem for me.
-
repo owner - marked as enhancement
-
When will this enhancement be a part of a release?
- Log in to comment