Anyone have a script already written to do basic tnspings? Would save me a lot of time if someone had one and could upload it to content exchange.
Thanks
Well I wrote my own and got it working. Pasted here for anyone else to use or modify. Just change the tnsname to what you want to ping, the temporary output file to something unique, and check the path to your tnsping. Returns status of up if it get's an OK result, and down if it gets anything else, plus the time in msecs to do the tnsping as a statistic. This was my first attempt at vbscript so don't make fun of me too much if it's ugly.
dim obj_shelldim obj_fso, str_output, str_record, int_strsearch, int_statistic, int_exitcodedim obj_regex, col_matchint_exitcode = 1set obj_FSO = CreateObject("Scripting.FileSystemObject")set obj_shell = wscript.createobject ("wscript.shell")set obj_regex = CreateObject ("VBScript.Regexp")obj_regex.pattern = "[0-9]+"obj_shell.run "cmd /c \oracle\OraClient10g\BIN\tnsping.exe ENTERTNSNAMEHERE > c:\temp\output.txt", 10, trueset str_output = obj_fso.opentextfile ("c:\temp\output.txt", 1, false)do until str_output.atendofstream str_record = str_output.readline int_strsearch = InStr(str_record, "OK ") if int_strsearch > 0 then int_exitcode = 0 set col_match = obj_regex.execute(str_record) if col_match.count > 0 then int_statistic = col_match(0) end if end ifloopwscript.echo "Statistic: " & int_statisticstr_output.closewscript.quit(int_exitcode)
I copied your script into a new Windows script monitor and it didn't work. I modified only the tnsname and output.txt location. I used a default user credential that can access all our servers. What else is there to check?
There's really not much to check or change, most of it is basic vbs. Have you tried making it an actual .vbs and running it form the command line on your APM server? Should give you more insight into what's happening than you get from testing it as a script monitor. Double check your Oracle path on your APM server to make sure that's where you have tnsping, double check the TNS name, double check your tnsnames.ora file on your APM server, double check the temp file location in both places in the script.
I rechecked the copy of your script and found I had a syntax error. It appears to be working! thanks for your help!