Ignore Mount Regular Expression

I’d like to know if anyone can assist me in constructing a regular expression pattern which would match the string below?

D:\\ Label: Serial Number 16714a97

I’ve tried many things such as…

This doesn’t work as it won’t match
$config['ignore_mount_regexp'][] = "/D:/\/\ Label: Serial Number 16714a97/";

This works, however it will eliminate any occurrence of the drive letter “D:” on all of the systems which I’m monitoring
$config['ignore_mount_regexp'][] = "/^.*D:.*/";

This doesn’t work either
$config['ignore_mount_regexp'][] = "/^.*D:\/\/* Label: Serial Number 16714a97.*$/

Nope!
$config['ignore_mount_regexp'][] = "/^.*D:\\ Label: Serial Number 16714a97.*$/

Negative!
$config['ignore_mount_regexp'][] = "/^.*D:\\\\ Label: Serial Number 16714a97.*$/

I feel like the config.php file does not like having the double \\ & I’ve tried to escape that as well and I’m still having issues with this. Where is it that I’m going wrong on this?

Any assistance would be greatly appreciated

Instead of going for the whole line, why dont you try to regexp only the serial number?

First of all, thanks you for reaching out to me about my issue and trying to help me resolve them. Our environment has many servers which nearly consume the entire disk for various purposes related to the software running on them, I’m trying to “exclude” these disks so that I can have a “cleaner” installation for sending alerts on disks that I’d like to monitor for usage.

I tried your suggestion today and I didn’t have any luck. Here is what I tried to match and what I used to perform the task at hand.

String to match with the regular expression:
E:\\ Label: Serial Number b0b0e581

Expression used:
$config['ignore_mount_regexp'][] = "/^b0b0e581/";

I’m still having issues with this, so if anyone out there would like to let me know what procedures to take to possibly match the string above I’d greatly appreciate it as I can use that format to match the many others we have.

Regards,
Scott Nerone

This is just php regular expression matching so use https://www.phpliveregex.com/ to test.

if your regexp begins with ^ means the string starts with that and is not your case. Try without ^

Woot woot!! Thanks so much for the help, I suppose since I wasn’t using a regexp engine/builder that wasn’t for PHP was the reason that it wasn’t working. I really appreciate you providing some guidance for me as well as any others who may be scanning the community for some information pertaining to this.

String to match:
D:\\ Label: Serial Number b0b0e581

Regular Expression verbiage in config.php file:
$config['ignore_mount_regexp'][] = "/(.*)b0b0e581(.*)/";

Update Command:
./discovery.php -h "IP ADDRESS/HOSTNAME"

Thanks,
Scott Nerone

1 Like