Server Management - Systems Insight Manager
1820753 Members
3575 Online
109627 Solutions
New Discussion юеВ

Re: Custom Commands

 
Mark Kempe
Advisor

Custom Commands

Help Please

I am trying to setup a custom command that will kickoff a VBscript. I want the script to recieve the %DEVICENAME% environment variable as a command line argument. An email is then sent displaying the variable.

Here is what I have.

test.bat
c:\testvar.vbs %DEVICENAME%

test2.bat
c:\testvar.vbs %1%

testvar.vbs
Var1 = WScript.Arguments.Item(0)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "mark.kempe@mycompany.com"
objEmail.To = "mark.kempe@mycompany.com"
objEmail.Subject = "Test email"
objEmail.Textbody = "Variable 1 is " & Var1
objEmail.Send

both batch files work fine from the command prompt using regular environment variables. However, if I run either as a custom command, it stays in a pending state with status "Running 0%" and no email is received. Also I have tried to run the script alone as a custom command with the same pending state.

What am I doing wrong?

Thank you

19 REPLIES 19
Tim McGue
Regular Advisor

Re: Custom Commands

The first thing I would try would be to eliminate the batch file and eliminate the variable. You can call the vbscript directly from the custom command. Change the command line to something like this:

cscript.exe "C:\Program Files\HP\testvar.vbs" //nologo

Then remove the use of the variable. Make sure it can send you an e-mail all by itself. If the e-mail fails try something more generic like write a text file. It is possible your SIM run as account doesn't have permission to send e-mail.

Finally to bring the variable back in you can do that within vbscript. It would go something like this:

Set WshShell = WScript.CreateObject("WScript.Shell")

Var1 = WshShell.ExpandEnvironmentStrings("%DEVICENAME%")

I hope this helps,
Tim
Mark Kempe
Advisor

Re: Custom Commands

Great, Thanks Tim

I will try it out today.
Mark Kempe
Advisor

Re: Custom Commands

Well, I tried it Tim. I removed the batch jobs and added the var lines you gave me and used the %temp% var for testing. running the script from the command line works fine. When I run it as a custom command, it just sits there in a state "Pending" and never seems to run.

I did another test using notepad.exe. I saw the process start on the Insight Server. looked at the Task results and it showed "Pending" and "Running 0%". I killed the process and the task results still showed "Pending" and "Running 0%".

At this point, I am pretty sure there isn't a problem with the script. It looks like I am having a problem running custom commands.

Any ideas?
David Claypool
Honored Contributor

Re: Custom Commands

Mark:

any chance you were part of the beta program and are running that code rather than the release code? There was a problem in the beta that resulted in the "Running 0%" like you say and it was corrected upon release.
Mark Kempe
Advisor

Re: Custom Commands

Hi David

I am pretty sure it is the production release. I didn't install it. We are running Build C.04.00.00 and Build date of 2003-12-12 17:32.

I have not checked if there are any SP's or patches for this release yet.
David Claypool
Honored Contributor

Re: Custom Commands

Yes, that's the correct one. Personally, I haven't experienced the 0% problem on the release code.
Mark Kempe
Advisor

Re: Custom Commands

Anyone else have any suggestions?
Daniel Hamberg
New Member

Re: Custom Commands

I've got the exact same problem! And I haven't been able to solve it yet, but I've got some more information for you all:

In my case it has to do with SSH Host Keys because when ever I try a Custom Command I get two error messages in the Eventlog on the CMS:

Did not receive identification string from 192.168.60.143.

and

Received disconnect from 192.168.60.143: 9: The host key supplied was not valid.

The IP-address in the messages is the CMS's address, on which the command is to be executed on.
Mark Kempe
Advisor

Re: Custom Commands

OK. Baby steps first. I need help figuring out why this is not working. I have a batch file on my insight server that is one line:

cc.bat - located in the root of c:\

its content is:
echo test > test.txt

of course no problems when I run it from the command line.

I setup a custom command to run c:\cc.bat. No parameters or switches.

When it runs, I get "Running 0%" and a state of "Pending" also, the task can not be killed. The only way of getting rid of it is by rebooting the server.

I would really appreciate some advise from one of the experts. Please direct me where to look to troubleshoot this issue.
Rob Buxton
Honored Contributor

Re: Custom Commands

Mark,
With the Custom Commands they do login using SSH, so you may want to check things there.

By any chance is the account you installed HPSIM under different from the one you're now logging in to HPSIM?
If so, try deleting the Custom Command and recreating it under the Account HPSIM was installed under.

You might also want to check the passwd file on your CMS Server. c:\Program Files\OpenSSH\etc and verify that there are at least two entries in there, one for Administrator and one for the Account IM was installed in, probably your Domain Admin Account. If there is no entry for Administrator try adding it via the mxagentconfig utility.

I had fun and games with Custom Commands when I created them using my account. Especially where the Event Notification task had the Run Under as my account, once I changed them back to the Domain Admin Account it all worked okay.
Mark Kempe
Advisor

Re: Custom Commands

I have verified that my account and the account used to install insight are in the password file. when I run the command, I get an eventlog message:

The description for Event ID ( 0 ) in Source ( sshd ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. The following information is part of the event: sshd : PID 8756 : Received disconnect from 199.199.199.99: 9: The host key supplied was not valid.

I have tried running the command logged in as myself and the account used to do the install. Both accounts are domain admins. Neither work.
Pat Wilson
Valued Contributor

Re: Custom Commands

I would like to see the fix for this eventlog error (sshd). I am seeing the same error.
Daniel Hamberg
New Member

Re: Custom Commands

Well, I've been researching on my own a bit and what I found was that the Custom Commands get the "run-as" username from the user adding the command. But since the SSH Daemon doesn't like "domain\user" logins it fails to execute the command. My solution was to change the username in the database.

I still get the message "The host key supplied was not valid." and I believe that it comes from the initial commands that is run when starting SIM but I haven't been able to find where the default username used when login via SSH is stated.
Mark Kempe
Advisor

Re: Custom Commands

Is anyone from HP reading these forums? I would like to think that if a company is going to include a third party tool to interact so closely with their product they would have better support for it. It seems that if a program is going to add an entry to the event log then someone should be able to tell me why the entry was made and how to fix it. Please don't get me wrong, I do appreciate the help I have recieved from the posts above. I have seen other threads like this one regarding OpenSSH and all of the answers either suggest logging in with the account used to do the install or reload OpenSSH. Neither have worked in my case. Can someone "Please" answer these questions:

What process is failing that generates the eventlog message?

What Host Key file is being checked?

Can this Host Key be refreshed or replaced?


It is becoming critical that I get this process working. If we can not get it working, my company will have no other choice but to resort to using other third party tools to monitor our HP equipment such as Patrol or Unicenter. I would prefer to stay with HPSIM but, I, like the rest of you, have a job to do and I am spending way to much time on this issue.

Thank you.
Rob Buxton
Honored Contributor

Re: Custom Commands

Mark,
I can confirm that what you're trying to do will work. That's probably not what you wanted to hear as it points to something awry with your setup.

Here's what I did.
Set up test.bat using the command you gave.
I saved this to d:\perl_scripts\test.bat on the CMS Server.
First I tried setting up the Custom Command while logged in under my account, when running this it failed with the MXAuthentication Error which I cannot get around.
Note: I only select the CMS Server to run the command against, during the Scheduling part.
I then deleted the Custom Command.
I then logged into the account SIM was installed under, recreated the Custom Command as above and reran. This time it worked fine.
Have you tried logging in to the Server using the SSH Utility (or Putty) if you have it to test OpenSSH is working?
Maybe try moving the test command away from the root to a specified directory.
Mark Kempe
Advisor

Re: Custom Commands

Thanks for the quick reply Rob

From the CMS, logged in as the domain admin account used to install HPSIM and the reinstallation of OpenSSH, I am able to open a command prompt and run ssh. I supply the username and password for the installation account. It connects successfully(to itself) and I am able to run the batch job from the command prompt. I then Exit the ssh. I opened HPSIM while still logged in and created a new custom command. when I ran the command(against itself) I get the same results "running 0%" status "pending" and an entry in the eveltlog showing "invalid host key" and the task can not be killed. Back to the same old spot.


Rob Buxton
Honored Contributor

Re: Custom Commands

What account did you log into HPSIM?

I had to create the custom command under the account I installed HPSIM in, not the account in HPSIM I created for myself.
Just to check, did you limit the number of devices the batch file was to run against?

Also, check that the Administrator User is is the passwd file. When I reinstalled OpenSSH this got removed and I had to add it via the mkpasswd command and update the keys via the mxagentconfig utility.

You might want to try regenerating the OpenSSH Keys for the Domain Account IM was installed in, I cannot recall the exact procedure but it involved renaming some files in the .ssh directory of the home directory and rerunning the mxagentconfig utility for each account.
Mark Kempe
Advisor

Re: Custom Commands

Rob
I am logged into both the server and HPSIM as the account used to install HPSIM. The account "Administrator" is not in the passwd file. I am reading about the Key generator now. It isn't too clear on what key it is looking for.

Does it want the key from

Insight Manager:
D:\program files\Systems Insight Manager\config\sshtools\.dtfSshKey

SSH client:
D:\program files\OpenSSH\etc

or

the user home dir \.ssh\


Rob Buxton
Honored Contributor

Re: Custom Commands

Get hold of the Readme file to double check what I'm saying, but I found that not having the Administrator account is required.

Use the mxpasswd to generate a Local Administrator Account in the passwd file.

Then from a command prompt on the SIM Server, run mxagentconfig and enter the Local Administrator Account and Password.

This should generate the .ssh directory and key files in this under the home directory, by default that should be c:\documents and settings\administrator.

If, like me, you've reinstalled OpenSSH, this account doesn't get regenerated in the SSH Structure and does seem to be required.
It fixed a couple of demons for me.