Xpath. Evaluate - Documentation for Bmc Discovery 11.3
If Process. Cmd Matches Regex '^\W:' Then // *Filepath_Info_Start // Filepath_Windows: = ". Config" // Reason: = "To Get Database Details" // When: = "Only If...
if process.cmd matches regex '^\w:' then
// *filepath_info_start
// filepath_windows := "<process.cmd>.config"
// reason := "To get database details"
// when := "Only if trigger process has fully qualified path"
// *filepath_info_end
config_file := discovery.fileGet(host, '%process.cmd%.config');
if config_file and config_file.content then
config_file_content_xpath := xpath.openDocument(config_file.content);
db_name_list := xpath.evaluate(config_file_content_xpath, raw '/configuration/dataConfiguration/@defaultDatabase');
if db_name_list then
db_name := db_name_list[0];
db_connection_list := xpath.evaluate(config_file_content_xpath, '/configuration/connectionStrings/add[@name="%db_name%"]/@connectionString');
if db_connection_list then
db_connection := db_connection_list[0];
db_host := regex.extract(db_connection, regex 'Data Source=([^\\]+)\\', raw '\1');
db_instance := regex.extract(db_connection, regex 'Data Source=[^\\]+\\([^;]+);', raw '\1');
if db_host and db_instance then
if db_host = '(local)' then
db_host := 'localhost';
end if;
db_server_sis := SearchFunctions.getSoftwareNodes(host, node_address := db_host,
software_type := "Microsoft SQL Server",
instance := db_instance, db_name := db_name);
if size(db_server_sis) = 1 then
model.uniquerel.Communication(Client := si_node, Server := db_server_sis[0]);
end if;
end if;
end if;
end if;
xpath.closeDocument(config_file_content_xpath);
end if;
end if;