Textlog - JMX

Need new test, action, option? Post request here.
Post Reply
rsteffen
Posts: 2
Joined: Tue Feb 26, 2008 9:33 am

Textlog - JMX

Post by rsteffen »

Hello together,
i hope anybody can help me? - With my JMX-Java Program i can access to our SAP Web Application Server. The Java-Program save the result into a textfile. Do you have a ShellScript for HM in VBScript that can pick out the value and compare it with a threshold? - We need this solution to have a report. At the moment we have set in the Java-Program a threshold and write the result out in the textfile: "ok" or "bad". This is not a good solution. We use in the HM the file compare function, but then we have only a info whether the value ist good or bad. With a ShellScript we could have a reporting ;-)

- Thanks in advance

Best Regards,
Ralf
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

We do not have "cooked" solution for this particula issue. However, I do not think it is a big problem to write such a script. If you search through this forum with "shell script file" keywords, you will wind a lot of useful examples.
Could you provide a piece of log to parse?

Regards,
Max
rsteffen
Posts: 2
Joined: Tue Feb 26, 2008 9:33 am

Post by rsteffen »

Hello Max,

yes, you have right. I wrote this shell script in HM:


--------------------------------------

Dim fso, datei, aVar , intValue
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set datei = fso.OpenTextFile("\\139.3.202.234\J2EE\dedussv-ep001_Application_ActiveThreadsCount.txt")

Do Until datei.AtEndOfStream
aVar = datei.ReadLine

Loop
Datei.Close

intValue = CInt(aVar)


rem WScript.StdOut.Write aVar
WScript.StdOut.Write intValue

--------------------------------------

In the script monitor i got the result from the textfile, but in the HM i got now the following error-message:

Error: Invalid result ( 8 )

The result is ok, but what i do make wrong. What must i do to get the value in the shell script test method? - I set the point: params to: intValue.

Use warning status -> ("%Reply%">"10")


Best Regards,
Ralf
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Shell Script should return special formatted string, not just a number (like scriptres:Ok:300).
Please check "Requirements to the script:" section of the manual
http://www.ks-soft.net/hostmon.eng/mfra ... hellscript

Regards
Alex
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

rsteffen wrote:What must i do to get the value in the shell script test method? - I set the point: params to: intValue.
Use warning status -> ("%Reply%">"10")
I think, you should perform comparison operation right in the script. I slightly modified the script, now it should work for you:

Code: Select all

Option Explicit

const statusAlive       = "scriptRes:Host is alive:"
const statusDead        = "scriptRes:No answer:"
const statusUnknown     = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk          = "scriptRes:Ok:"
const statusBad         = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:" 

Dim fso, datei, aVar , intValue 
Set fso = WScript.CreateObject("Scripting.FileSystemObject") 
Set datei = fso.OpenTextFile("\\139.3.202.234\J2EE\dedussv-ep001_Application_ActiveThreadsCount.txt") 

Do Until datei.AtEndOfStream 
aVar = datei.ReadLine 

Loop 
Datei.Close 

intValue = CInt(aVar) 

if intValue > 10 then
   WScript.StdOut.Write( statusBad & IntValue)
else
   WScript.StdOut.Write( statusOk & IntValue)   
end if        
Also, I do not think it is a good idea to hardcode file name and threshold in the script body. You may modify this script using "WScript.Arguments" object to pass these values as a parameters into the script ;-)

Regards,
Max
Post Reply