Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check for a service present or not?

Status
Not open for further replies.

MrHaugen

ISP
Apr 22, 2010
8
NO
Hello

Our HP SIM agents refuses to install if not SNMP is ready and running. I've been trying whit lots of different Queries to get collections of servers which do not have the SNMP component installed.

I have a query to check if the service is present AND running, but I can not manage to get a collections of the servers that do not have the service at all (no SNMP components installed).

Do you have any suggestions of what I'm doing wrong here? I tried this one, which obviously failed:

select SMS_R_System.ResourceID,SMS_R_System.ResourceType,SMS_R_System.Name,SMS_R_System.SMSUniqueIdentifier,SMS_R_System.ResourceDomainORWorkgroup,SMS_R_System.Client from SMS_R_System inner join SMS_G_System_SERVICE on SMS_G_System_SERVICE.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SERVICE.Name != "SNMP Service"


Not exactly sure what servers is picked up, but it is definitely most of the servers. It should be the other way around, as most have the service installed.
 
Darn. I just thought of a possible reason now. The example above will probably return true if it finds any services which is names something else than "SNMP Service". Which is basically all windows servers.

Anyone got a suggestion to find the servers with this missing service?
 
So, there is nobody here that know how to check if a service is installed or not? That is hard to believe.
 
i can give you a script to run on a server to determine that.

what is your goal? to apply something to a bunch of servers whcih dont have SNMP service running? e.g. start the service, so your following HP SIM package will install correctly?

if i was you i wouldnt concern yourself with creating a collection of machines which dont have criteria X.

i would approach the issue as this:

1. create a task sequence called 'HP SIM Agent Installation'
2. the first task in the TS reference a pacakge called 'MyCompany Server Config', which has a binary in it called service_properties.vbs. this script shoudl be called and passed /servicename:SNMPService /startup:auto /state:running. your script is clever enough to target the service and set it up accordingly
3. your next task in the taskseq would call you 'HP SIM V5.6 EN' package and call the install program / setup.exe etc.

you can then target all you services with the same TS.

i am all for only applying a package / TS to only the machines it applies to. however, all your packages should be able to handle being launched on the wrong platforms / situations anyway so...

 
Thanks for the replay.

The goal here is to figure out who is missing the SNMP component completely. Not "not running", but not installed. Without the SNMP component, the HP SIM program will not install.

We have a script today, which have installed the SNMP service, and applied the correct settings on most of our servers. There is some servers that the service will not install on though. For unknown reasons.

We have routines to apply SNMP at server installation now, so I'd like to just do the manual install of SNMP on the few old servers that is left, instead of using hours of tracking down the problem as of why our vbs script fails.


That is why I would like to know which servers do not have the SNMP service (which points to the fact that the compoent is intalled) or the comonent it self is installed. We CAN of-course starte the auto install of HP SIM, and install SNMP manually on the servers that fail there, BUT the HP software seems to be a bit dumb. It tends to stop completely if one of the servers in the sequence fails.
 
i would still just apply your SNMP package to all machines. i take it you have packaged it in such a way that it wont have a negative impact when applying on machines which already have it installed and configured correctly? i still see no harm in running this package on all machines.
 
The problem with applying SNMP to all servers is that our method today (script with auto install of the components) is not reliable. There is a few servers here and there that can not install it.

We COULD install the HP SIM agents on all servers and find out who is missing SNMP by checking which install fails. The only problem is that the HP SIM installation sequence seems to be aborted every time it hits a server without SNMP.

I'm sure we could also make a MSI installation package of the SNMP component and setting, but there's just so long since I did that. It would take a lot of time I think.

So, our most time effective solution would be to manually installing SNMP on the rest of the servers. Their not many, BUT I need to figure out which one it is first....


Isn't there a smart way of simply checking for SNMP? Components installed under add remove programs or the service it self.
 
an MSI is a little overkill, its not a product in its own right you are simply turning on a Windows component.

a bit of a complex example including SNMP trap configuration

contents of snmp.txt:
[NetOptionalComponents]
SNMP = 1

[SNMP]
Accept_CommunityName = GLOBALNTSRV:Read_Create
Any_Host = No
Community_Name = GLOBALNTSRV
Contact_Name = "Platform Computing"
Limit_Host = localhost,trap_url
Location = build_location
Send_Authentication = No
Service = Applications, Internet, End-to-End
Traps = trap_url


command line:
sysocmgr /i:"%windir%\inf\sysoc.inf" /u:"%windir%\snmp.txt" /q /r


author a vbscript with some logic like:
blnInstalled = False
'is SNMP enabled? check the service?
For Each aService In colServices
If aService.Name = "snmp" Then
blnInstalled = True
End If
Next
If blnInstalled = False Then
FSO.CopyFile strCurrentFolder & "\snmp.txt", %windir%\snmp.txt, True
WshShell.Run "the command line above"
End If

then target all your machines to run the script...
 
Thanks for the effort mate. I can test out the script later when I have the time. Though, I don't think it will change a thing. It's very similar to the one I'm already using.

Still looking for a way to find whose few darn servers with missing SNMP component.
 
How many servers are in your domain? I mean if you don't have too many couldn't you just login to each one and check if the service is installed and continue?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top