×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to check for a service present or not?

How to check for a service present or not?

How to check for a service present or not?

(OP)
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.

RE: How to check for a service present or not?

(OP)
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?

RE: How to check for a service present or not?

(OP)
So, there is nobody here that know how to check if a service is installed or not? That is hard to believe.

RE: How to check for a service present or not?

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...

 

RE: How to check for a service present or not?

(OP)
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.

RE: How to check for a service present or not?

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.

RE: How to check for a service present or not?

(OP)
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.

RE: How to check for a service present or not?

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...

RE: How to check for a service present or not?

(OP)
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.

RE: How to check for a service present or not?

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?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close