Welcome to OCS Inventory NG community support, where you can ask questions and receive answers from other members of the community.

Please ask questions only in English or French.

Release 2.12.3 available

The official documentation can be found on http://wiki.ocsinventory-ng.org. Read it before asking your question.

Prevent OcsService.exe file from disappearing

Hi,

on a growing number of our machines, the agent stops sending the inventory to the server because at some point the OCS Service can't be launched anymore after the file OCSService.exe disappears for some mysterious reason.

The installation is fine at this point because I can just copy the missing file back and it can be restarted again.

For more context, we're running the v2.10.1 agent and the v2.12.1 server and the issue happens to machines that are not always on our LAN (WFH laptops, etc.) and hence often they will not be able to contact the OCS server.

So is there a way to prevent the OCSService from disappearing in this context?
And what's a best practice to do the inventory of remote machines with OCS?

Thanks
in OCS Inventory NG agent for Windows by (420 points)

10 Answers

+1 vote
hy, this is not normal. I think this only happens if a antivirus solution knocks out ocs-inventory or some users with adminrights just uninstall the agent. You should make a antivirus exclusion for ocs-onventory.

Kind regards
by (24.2k points)
0 votes
@sokatra
Thanks for your reply but I don't think that your suggestions are related to my issue : what I seeing seems so random that it can't be explained by any action from AV (it will show anyway on the AV console) or an admin user (many affected users don't have admin rights and even the ones who do, it doesn't make sense to delete just the OCS service if they wanted to get rid of it).
by (420 points)
0 votes
The service use the program OcsServices.exe. This provide 2 actions : one for inventorying hardware and software, one for download and install packages.

Due the service run under System Account, it's very powerfull for executing any package even a destructive package. So Antivirus Softwares could consider OcsServices.exe as malicious.

So if the service is down due antivirus action against OcsServices.exe, that is OcsServices is stopped ... there is no inventory launched.

The only way is (provided by Sokatra) : configure your antivirus as OCSServices is authorized ...

NB : I recommend any users (even IT people) as NOT LOCAL ADMIN
by (19.9k points)
0 votes
@Jacquesh

As I said before, I'm 100% sure that it's not the AV who is deleting/disabling the OCS service. We're using CrowdStrike and we've been seeing this behavious with Symantec aswell and none of these two AVs ever flagged OCS or logged any action on it.

Moreover, this behavious isn't consistent : we're loosing at random at most 3% of our machines each month. It doesn't make sense to be the AV who is doing this.

Finally, it is definitely NOT the users fault : this odd behaviour happened even to my own machine !
by (420 points)
0 votes
You can consider Antivirus and EDR (like CrowdStrike) as equivalent : OCSservices.exe could execute dangerous actions : execution of package (using system account) could install any dangerous software. All solutions have a white list for authorized programs !

So, I suggest look logs from your Antivirus, logs from your EDR, and also logs from events Windows : I suppose Windows monitor any services looking if service's program is running or not ?
by (19.9k points)
0 votes
Bon, je vais répondre en français pour que ça soit plus clair : ce n'est pas un problème d'AV ou d'EDR !

Je gère ce serveur OCS avec des centaines de machines dessus depuis OCS 2.0.x et je n'ai eu ce comportement bizarre que très récemment (depuis la v2.9 ou 2.8). Et encore une fois, ce qui est incompréhensible et qui ne peut être expliqué par un AV ou un EDR est que je perds 5 à 10 machines par mois seulement et il n'y a rien de commun entre ces machines (pas de packages déployés, pas de groupe commun, etc.).

Pour les event Windows, difficile à suivre vu que l'absence d'inventaire d'une machine ne signifie pas forcément que son agent a un problème (utilisateur en congé, en remote sans VPN activé, etc.). De ce que j'ai vu jusqu'ici c'est que le service OCS disparaît sans générer d'erreurs spécifiques.

Bref, merci pour vos réponses et votre temps. Je suis preneur d'autres idées. La piste AV et EDR est close pour moi.
by (420 points)
edited by
0 votes
La logique est la suivante :

- à l'install de l'agent, un service est créé 'OCS Inventory Service' : démarrage auto, compte 'Système local' (équivalent à Administrateur local), programme associé 'c:\program files\OCS Inventory Agent\OcsServices.exe'. Donc le programme tourne en arrière plan et en permanence.

- ce programme exécute 2 tâches : la tâche d'inventaire (sur Windows, selon un rythme à peu près aléatoire dans la journée, ~3-4 fois /jour en moyenne), la tâche de download de packages et exécution des packages (quand il y en a associé à ce hardware).

S'il n' a plus d'inventaire : soit le programme ne tourne pas (= le service est arrêté) soit la transmission est bloquée. Dans tous les cas, il faut regarder le log dans '%programdata%\OCS Inventory NG\Agent'.

Pour que s'arrête OCSServices.exe, il faut vraiment quelque chose de spécial (et qui ait le pouvoir d'arrêter un programme lancé en tant que 'Système', le plus normal et usuel, et compte tenu du type de programme, semble être un antivirus ou un EDR. C'est mon point de vue.

NB : à l'install, on définit l'url d'inventaire (http[s]://serveurocs.domaine.xx/ocsinventory). si le PC ne résout pas l'url ou n'atteint pas le serveur, il n'y a pas d'inventaire !

NB : Quand on veut savoir si l'agent fonctionne, on doit vérifier le log dans le dossier indiqué. Quand on veut savoir si le serveur OCS fonctionne, on doit vérifier le log apache et le log activity.log

NB : j'ai travaillé plus de 7 mois à mettre à jour un serveur OCS dans une société sur lequel s'inventoriait environ 8.000 pc ou serveurs par jour (et sur lequel se déployaient des dizaines de packages). Il n'y avait pas ce que vous décrivez ...
by (19.9k points)
0 votes

OCSService ne s'arrête pas, il disparaît !
Ceci se manifeste soit par la disparition pure et simple du fichier OCSService.exe ce qui empêche le service de se lancer, soit par la disparition du service OCS de la liste des services Windows (donc désinstallation du service mais l'agent reste installé).

PS. Cher @jacquesh, comme vous êtes à priori dans le domaine, j'imagine que vous connaissez déjà ce sentiment d'être face à quelqu'un qui assume que vous ignorez jusqu'aux fondamentaux du sujet de la discussion ? Ce n'est pas très agréable et ça fait perdre du temps pour tout le monde... Partons svp du principe que je comprends très bien comment fonctionne OCS, merci :)

by (420 points)
edited by
0 votes
Un problème bien décrit est un programme résolu à 50%.

Les lecteurs font avec ce qu'ils lisent, et les 'trous' de description les obligent à faire des hypothèses. Si vous estimez être incompris ou mal compris, vous devez aussi prendre votre responsabilité dans la compréhension de VOTRE problème ... parce c'est vous qui décrivez ! Par ailleurs si Sokatra et moi, qui sont actifs, imaginons le même type d'outils, ce n'est peut-être pas par hasard. Mais nous ne sommes pas à votre place ...

Si le fichier OCSServices.exe est supprimé (rien de moins), c'est qu'un programme d'abord arrête l'exécution puis supprime. Ce programme doit être admin local pour pouvoir faire cela (pour l'arrêt et pour l'emplacement). Perso, je ne vois que des outils anti-virus ou EDR pour faire cela. Maintenant si vous voulez savoir qui et quoi, testez chaque minute l'existence du fichier et les pgm qui tournent, et peut-être vous trouverez ce qui cloche ...
Sinon 'attrib +r' peut éviter la suppression éventuellement ... NB : quand OCSServices.exe tourne tous les fichiers de conf et log dans le dossier sous %programdata% sont verrouillés et non modifiables.
by (19.9k points)
0 votes
what can also happen is that someone often presses the power button on a computer. If you do this a few times, windows offers to roll back the windows state to a previous state. then windows may roll back the state to a state when ocs inventory was not installed.
Please have a look at the reliabilty report or search for events that indicate that the previous state has been restored. We have some users who think they can shut down their computer faster by holding down the power button.
With antivirus and EDR solutions you often have to look carefully. There are sometimes different logs for different actions of the virus scanner. For example, it may be that the virus scanner only intervenes when a package is distributed via ocs-inventory because it considers the action to be the act of a virus. It may even be that the Defender is active in parts even though you have another virus scanner. The Defender may then only intervene for certain actions without this being logged in the standard virus scanner.

Best regards

Sokatra
by (24.2k points)
 
Powered by Question2Answer
...