Discover Java Framework with version on Linux Server

utente
Giga Expert

Hi All,

I want create a custom probe and sensors, to identify on the linux server the existence of Java Framework and the version of this component.

The identification of Java Framework is based on the discovery of at least one process with name java;

This create a CI on CMDB (Generic Application Form) relate it with the linux server.

After that it triggered a probe that execute the SSH Command:

  • java -version

and the result of the command execution will be analyzed by script on the Sensor

But if I will test the Probe, I have this result:

find_real_file.png

find_real_file.png

The output of the command is empty (I see only the closure tag)

and the very result is in the "warm"

Why it ?

I think that in this case the sensor doesn't   work because it doesn't   have data for work..

1 ACCEPTED SOLUTION

utente
Giga Expert

Hi all,


I have found the solution the execute the command "java -version" and to have an output.


It's sufficient add at the probe, a new probe parameter "must_sudo" with value "true".


Now the result of the command will be present in the output file.



Regards,



Vincenzo




find_real_file.png


View solution in original post

8 REPLIES 8

utente
Giga Expert

Hi all,


I have found the solution the execute the command "java -version" and to have an output.


It's sufficient add at the probe, a new probe parameter "must_sudo" with value "true".


Now the result of the command will be present in the output file.



Regards,



Vincenzo




find_real_file.png


tim_broberg
ServiceNow Employee
ServiceNow Employee

Haha. When you add must_sudo it generally runs the probe in a terminal. For whatever inscrutable reason, in my experience, running in a terminal causes stderr to come out on stdout instead.



I don't know if this behavior of terminals is guaranteed universal, not will I promise that we will always use a terminal when must_sudo is set when the sudoers config has !requiretty.



If you can get the stderr redirected, that would be a preferable approach, but if it works, it works. If it stops working some day, those are the things to check for.


Hi Tim,


Wooow, So the problem is waiting around the corner hahaha


It's very interesting and I think this is a little problem that can generate a big problems, because it strange that the command was execute in both case, but in the first case it generated a wrong xml output (i don't know why).


I would expect that the command wasn't execute without sudo...



Thanks for the help Tim


Hi Vincenzo,



Can you consider publishing your probe with overall configuration on service now share ?


https://share.servicenow.com/app.do#/category/discovery_probe?startRow=30&sort_parameter=title&filte...=



I found it interesting and would like to have the probe code and configuration



Thanks in advance.


Guillaume