Discovery pattern extension for MySQL

Sofia1994
Tera Contributor

Hello all, I need a help with extended pattern "My SQL server On Windows and Linux".

 

I created an application credentials for MySQL database and used them in pattern:

Sofia1994_0-1669210326508.png

Then I need the following commandline to connect to MySQL:

Sofia1994_1-1669210380029.png

And I got the error: 

Error MySQL.png

I checked that username is right in error message.

 

If I tried this: "mysql -u" + "$$username$$" + " -p" + "$$password$$" + "--skip-column-names -e \"SHOW DATABASES;\""

I got another error:

Error MySQL 2.png

Database administrator checked the strings on their side and it works fine for them:

  1. RDP to the Midserver
  2. Launch a putty session and connect to the discovered server (used same ssh private key as the one entered in ServiceNow credentials)
  3. Execute the query from command line : mysql –u username –ppassword ….

And he got the list of database. 

 

Can you please help me why this error can be? Maybe we need additional rights or something else. 

10 REPLIES 10

SiD2
ServiceNow Employee
ServiceNow Employee

Hi @Sofia1994 

 

Hey, that null error comes when the command couldn't bring in any result or empty response.

 

The command syntax is incorrect and you have to use "echo $$username$$" directly as $$ is internally replaced as variable but here it should be kind of string only.

 

Still as suggested in my recent post try that approach and see if commands work, else would request to raise SNOW case as its difficult to troubleshoot here.

 

Please mark Helpful / Accept Solution so that it helps others with similar questions.

Sofia1994
Tera Contributor

Hi @SiD2 ,

 

Thank you for your help. I've found the string which should work, and it worked. I received answer two days ago with this commandline: 

"mysql -u " + "$$username$$" + " -p" + "$$password$$" + " --skip-column-names --silent -e \"SHOW DATABASES\""

 

But now it stopped to work and I checked "$$username$$" with echo. It stopped to work (I checked it before and I showed username).

Sofia1994_0-1669885495969.png

If I put usual string, it works:

Sofia1994_1-1669885533404.png

 

 

SiD2
ServiceNow Employee
ServiceNow Employee

Hi @Sofia1994 

 

Good that you got the command to work in the first place per suggestions, I hope when you say it worked, you meant from the pattern.

Now this could be a different issue and if this is resolved, you can successfully proceed with your extension section.

 

Like I said in my last post, this null error comes when there is no or empty response for a pattern step. We can debug this by checking ECC Queue soon after you click test step and can share the screenshot, this is something we also observe many times but no solution found yet.

 

Now my next question is why do you need this echo step with username when actual step is working. If you didn't try that way, please check now.

 

Please mark Helpful / Accept Solution so that it helps others with similar questions.

Sofia1994
Tera Contributor

Hello @SiD2 ,

 

Thank you for your help. I checked Queue and found that step "change user" doesn't work, but it doesn't work only in debug mode.

I did "quick discovery" and received answer, parsed and generated payload. And it looks fine.

But I see the following error in log:

Sofia1994_0-1669968694784.png

But I created relationship step in pattern:

Sofia1994_3-1669968861688.png

I checked relationship in CI manager:

Sofia1994_4-1669968882127.png

On step relationship I see the following in log, maybe it is the reason? But mysql database instance CI was updated.

Sofia1994_5-1669968971248.png

 

 

Manuel Stimac
Mega Sage

Hi @Sofia1994,
Some guesses from me:

  1. At the Linux Server there is a "limit" for large responses. Like when you send a command and the response will be more than 255 lines (or so) it will ask "Are you sure you want to display all (Y/N)?" Discovery is not able to get further then. (There is a setting on several OS to disable this question for certain users)
  2. Is the Linux user really root? Or just allowed to execute certain commands "as root". This can cause Problems at commands with "su" at the beginning.

 

If this answer helps you please mark it as Helpful/Solution.
Thanks & Regards - Manuel 

 


If my answer helped you, please mark it as Helpful/Solution.
Thanks & many Regards - Manuel