Inventory signature for MySQL on Linux

I am working on identifying MySQL installations on Debian servers and I have 1 of 5 reporting that it is installed.

The specific signature has the guid 31e15170-287a-11e6-a68b-005056aed5cf and the signature identifies the following

                            <Variable name=\"IS_INSTALLED\">
                                            <Compare type=\"string\" relation=\"ne\">
                                                            <VectorToScalar>
                                                                            <Vector filter=\"*MySQL Server 5.7*\">
                                                                                            <ValueOf value=\"$(file_read)\"/>
                                                                            </Vector>
                                                            </VectorToScalar>
                                                            <ValueOf value=\"\" />
                                            </Compare>
                            </Variable>
                            <Condition withVariable=\"IS_INSTALLED\">
                                            <Action onValue=\"false\" do=\"SKIP\"/>
                            </Condition>
                            </Instance>

So it is looking for the β€œmy_config.h” file and does find it on the system in /usr/include/mysql.

Using the command : apt-file search my_config.h

I get the following results: libdar-dev: /usr/include/dar/libdar_my_config.h libmariadb-client-lgpl-dev: /usr/include/mariadb/my_config.h libmysqlclient-dev: /usr/include/mysql/my_config.h

The system that reports does have the libmysqlclient-dev package, but the others do not. According to my SME, this is not required for MySQL, so it should not be using this as the identifier

I am trying to determine which is the correct file to use, so I am hoping someone here in the community can assist.

Thanks

Martin

Hi Martin,

Do not see the full signature here, no link to my_config.h.

You can use example below:

Comparing file content with a given regular expression:

<MultipleInstance>
	<Iterator name="INSTALL_PATH" export="true">
		<FindFilePathEx name="Version.xml"/>
	</Iterator>
	<Instance>
		<Variable name="file_read" export="false">
			<ReadFile path="$(INSTALL_PATH)Version.xml"/>
		</Variable>
		<Variable name="IS_INSTALLED">
			<Compare type="string" relation="ne">
				<VectorToScalar>
					<Vector filter="*qualitystage??version=?8.7*">
						<ValueOf value="$(file_read)"/>
					</Vector>
				</VectorToScalar>
				<ValueOf value="" />
			</Compare>
		</Variable>
		<Condition withVariable="IS_INSTALLED">
			<Action onValue="false" do="SKIP"/>
		</Condition>
	</Instance>
</MultipleInstance>
  1. The file_read variable gets the content of the Version.xml file returned by the ReadFile operand.
  2. The expression that should be searched in the specific file content is used as a filter.
  3. The filtered file_read variable is compared with an empty string using the β€žnot equal" (β€žne") relation which indicates that the product will be detected (IS_INSTALLED varaible set to true) only if the expression is found.
  4. The condition listed at the end ensures exiting the signature once the
    product was not found.

Hope that helps.

Regards,
Andrzej

1 Like

Hi Andrzej,

Sorry for the delayed response, got busy and did not get back to this.

Here is the signature again

<MultipleInstance>
<Iterator name=\"INSTALL_PATH\" export=\"true\">
	<FindFilePathEx name=\"my_config.h\"/>
</Iterator><Instance>
<Variable name=\"file_read\" export=\"false\">
	<ReadFile path=\"$(INSTALL_PATH)my_config.h\"/>
</Variable>
<Variable name=\"IS_INSTALLED\">
	<Compare type=\"string\" relation=\"ne\">
		<VectorToScalar>
			<Vector filter=\"*MySQL Server 5.7*\">
				<ValueOf value=\"$(file_read)\"/>
			</Vector>
		</VectorToScalar>
		<ValueOf value=\"\" />
	</Compare>
</Variable>
<Condition withVariable=\"IS_INSTALLED\">
	<Action onValue=\"false\" do=\"SKIP\"/>
</Condition>
</Instance>

Here is a screenshot of what I see

Also did a dump of the dpkg for mysql from 2 systems that should both report that 5.7 is installed.

System reporting MySQL installed
dpkg-query -l β€˜mysql’ | grep ii
ii libdbd-mysql-perl 4.028-2+deb8u2 amd64 Perl5 database interface to the MySQL database
ii libmysqlclient-dev 5.7.19-1debian8 amd64 MySQL development headers
ii libmysqlclient18:amd64 5.5.58-0+deb8u1 amd64 MySQL database client library
ii libmysqlclient20:amd64 5.7.19-1debian8 amd64 MySQL shared client libraries
ii libmysqld-dev 5.7.19-1debian8 amd64 MySQL embedded server library
ii mysql-apt-config 0.8.1-1 all Auto configuration for MySQL APT Repo.
ii mysql-client 5.7.19-1debian8 amd64 MySQL Client meta package depending on latest version
ii mysql-common 5.7.19-1debian8 amd64 MySQL Common
ii mysql-community-client 5.7.19-1debian8 amd64 MySQL Client
ii mysql-community-server 5.7.19-1debian8 amd64 MySQL Server
ii mysql-server 5.7.19-1debian8 amd64 MySQL Server meta package depending on latest version
ii php5-mysqlnd 5.6.30+dfsg-0+deb8u1 amd64 MySQL module for php5 (Native Driver)

System reporting MySQL is not installed
dpkg-query -l β€˜mysql’ | grep ii
ii libdbd-mysql-perl 4.028-2+deb8u2 amd64 Perl5 database interface to the MySQL database
ii libmysqlclient18:amd64 5.5.58-0+deb8u1 amd64 MySQL database client library
ii mysql-apt-config 0.8.8-1 all Auto configuration for MySQL APT Repo.
ii mysql-client 5.7.20-1debian8 amd64 MySQL Client meta package depending on latest version
ii mysql-common 5.7.20-1debian8 amd64 MySQL Common
ii mysql-community-client 5.7.20-1debian8 amd64 MySQL Client
ii mysql-community-server 5.7.20-1debian8 amd64 MySQL Server
ii mysql-server 5.7.20-1debian8 amd64 MySQL Server meta package depending on latest version
ii mysqltcl 3.052-1 amd64 interface to the MySQL database for the Tcl language