I need to check for a file on a smb share using regex for the front of the name "usertracking" the last part of the name changes with day and time. Also I only want it to error if it is older then 240 minutes since it was last motified could I do this with "check_file_age"
Also I am not good with regex so could you tell me how I would use it for this plugin
Or can you recommend another plugin to use ?
SMB file check if it exisits
Re: SMB file check if it exisits
Hi btayl ,
The "check_file_age" only works with just one file.
If you use regrex in your filename search, which will match multiple files and the "check_file_age" can not handle that.
You can create a custom script with a for loop but that can be ran with a cron job, not Nagios XI:
Here's an example of the one that would work, if the filename contain only just date:
Regards,
Vinh
The "check_file_age" only works with just one file.
If you use regrex in your filename search, which will match multiple files and the "check_file_age" can not handle that.
You can create a custom script with a for loop but that can be ran with a cron job, not Nagios XI:
Code: Select all
for x in `ls -1 /root/usertrack*`; do /usr/local/nagios/libexec/check_file_age -w 60 -c 600 -i -f ${x}; done
FILE_AGE CRITICAL: /root/usertracking18012021 is 3393 seconds old and 0 bytes | age=3393s;60;600 size=0B;0;0;0
FILE_AGE CRITICAL: /root/usertracking_18012021_11:00:22 is 1542 seconds old and 0 bytes | age=1542s;60;600 size=0B;0;0;0
FILE_AGE CRITICAL: /root/usertracking_18012021_11:00:29 is 1535 seconds old and 0 bytes | age=1535s;60;600 size=0B;0;0;0
Code: Select all
# /usr/local/nagios/libexec/check_file_age -w 60 -c 600 -f "~/usertracking`date +%d%m%Y`" -i
FILE_AGE CRITICAL: /root/usertracking18012021 is 2973 seconds old and 0 bytes | age=2973s;60;600 size=0B;0;0;0
Vinh
Re: SMB file check if it exisits
Does check_file_age do cif/smb shares ?
Re: SMB file check if it exisits
Hi btayl,
Looks like this is writen in Perl and mostly runs on local Linux server.
It checks a file's size and modification time to make sure it's not empty.
From what I can see, this might not works for Samba if your samba Linux filesystem is NOT mounted when the script is running.
You can check the Nagios Community Exchange URL (below):
https://exchange.nagios.org/index.php?o ... word=samba
Regards,
Vinh
Looks like this is writen in Perl and mostly runs on local Linux server.
It checks a file's size and modification time to make sure it's not empty.
From what I can see, this might not works for Samba if your samba Linux filesystem is NOT mounted when the script is running.
You can check the Nagios Community Exchange URL (below):
https://exchange.nagios.org/index.php?o ... word=samba
Regards,
Vinh