check_logfiles - Howto check logfile with random direcotry - nagios

I want to monitor a logfile. The directory is created everyday.
The path is as follows:
"C:\Program Files (x86)\Parallels\Plesk\PMM\logs\backup-2020-03-28-23-00-09-939\backup.log"
The problem is the timestamp in directory name.
How must the config file be defined to check this directory?
Best regards
Steve

if you only monitor that the file exists, you could try to make a plugin in bash, perl, python, etc that monitor the directory using the date as a variable name of the folder where the log file exists.

Related

.bat file that deletes 2 specific files on a specific directory

As the tile says. I need a .bat file to automatically delete 2 files on my C on a specific directory everytime I execute it.
I'm noob and don't know the commands :(
Try this :
del "C:\TEST\*.TXT"
For this example it will delete all files under TEST Folder with the .TXT extension so it depends on the extensions of the files , you can merely mention their names with their right extensions and it will work !
(Save the command in a .bat file and execute it as Administrator)

Using FTP.exe and mget to download files and directories from an FTP directory

I am trying to set up an automatic download of the files from a FTP directory on a scheduled basis. The solution I have come up with is to create a batch file that will be ran by windows task scheduler. The batch file is as follows (so far)
prompt
open ftp://xx.xx.xx.xx
myuser
mypassword
lcd C:\localdir
cd /remotedir/
mget *
quit
The problem is that this does not get everything in the specified directory. Only the loose files in the directory such as a .zip or .txt file. I have searched the questions here to no avail. So how can I get mget to not only download loose files in the root directory but also download the sub-directories and containing files (keeping the structure intact)?
Just answering this in case anyone else has a similar issue. The ftp.exe was a bust but I found out it is fairly easy using WinSCP just create a scheduled task in task scheduler and use the options section for command line parameters
Instructions for creating download script with WinSCP:
http://winscp.net/eng/docs/guide_automation
Instructions for scheduling WinSCP transfer task:
http://winscp.net/eng/docs/guide_schedule
WinSCP downloads directories recursively by default.

System cannot find the file specified while copying through CMD

In my C program, I execute a system command to copy files from my downloads folder to a folder in desktop, the program works on .mp3 files.
The problem is that my program copies all the .mp3 files successfully from other folders except a specific folder for a reason I don't know why. I Checked the command being executed and it shows no syntax or file name errors.
The command that causes (system cannot find the file specified) error:
system("copy \"C:\\Users\\Mac\\Downloads\\test\\01 Andrew Bayer - Counting The Points.mp3\"
\"c:\\users\\Mac\\desktop\\AVB\"");
Please help me to spot the reason that causes this error in spite that the file name and path of the file is correct, and only the files in this folder(test) causes this error.
Note:
The files I'm trying to copy are downloaded from a torrent, if this may help.
A few thoughts:
Perhaps the path to your file is too long. Try to copy the folder to the root of your disk and retry the command. Or use subst to connect a drive letter to a path.
There could be an issue with NTFS rights. Go to the security settings of the Downloads folder. Check the permissions and enable the checkbox option to replace security on all subfolders and files (remove explicitly set permissons of the child items).
Try renaming the file to A.mp3, I'm not sure if it is possible, but the file name could contain weird unicode characters?

how do i change an elivated batch files directory to the location of the batch file

Can anyone tell me how to change an elevated batch files directory to the location of the batch file? I am trying to make a program and it won’t work unless it is elevated and it has files it needs in the save folder. Can anyone help?
I think what you are referring to is when you 'Run as Administrator' the current directory changes and you can't reference folders/files unless you use the full path. To set the curent directory to the directory of the batch file add this line near the beginning of your bat file (before your reference any folders/files).
pushd "%~dp0"

Executing the .msi from batch file in same location

We need to run a .msi file from batch file which is working fine if the path of .msi file is hard coded in batch file. Is there any way to get the path of .msi file dynamically as the batch file and .msi file exist at same folder location? It will really solve the purpose as thses needs to be copied to multiple servers...
%~dp0install.msi
%~dp0 gives you the path of your bat-file.
(note, that the last backslash is already included.
try #echo %~dp0 in your batch-file)
If the batch file and msi file are in the same folder then no path at all is needed. The batch file defaults to the current directory - and will write the log file to the current directory.
This is only an issue if the batch file is launched from a network drive.

Resources