Git Product home page Git Product logo

ocs-agent's Introduction

build Codacy Badge CodeFactor

Lite inventory agent

Small inventory agent compatible with OCS Inventory NG and GLPI. Builds and runs on linux and freebsd (and probably other unixes, too)

History

A couple of years ago, where I work, we started using OCS Inventory NG, which is a really useful application in enterprises. It allows system administrators to inventory servers and workstations, in order to plan obsolescenses and investments. We also started using Thinstation to recycle old computers as remote desktop terminals, by booting them via PXE. Unfortunately, the OCS Inventory Agent for Unix is written in Perl. The Perl interpreter was quite big for the time (~16MB) and couldn't be put into the Thinstation images without getting a performance hit on booting. Moreover, the agent doesn't work on a system with a read only filesystem (actually, the filesystem is read-write, but changes are lost when the terminal is powered off, since it's a in-RAM filesystem). So I decided to write a small agent in C++ to be able to inventory also those machines which I was not able to do with the official agent. The agent is not complete yet, but it can already produce an inventory of the machine and send it to the OCSInventory server, or save it locally. The compiled program weights around 500kb on disk, and only has zlib and openssl as dependency, which are already present on any Thinstation installation. It also uses tinyxml2, a very small and efficient XML parsing/writing library, linked statically into the executable.

This is not the official OCSInventory NG agent, which can be found here: https://github.com/OCSInventory-NG/UnixAgent

Usage

-h, --help                         Print usage
-c, --conf <config_file>           Specify configuration file
-s, --server <server>              Specify OCSInventory/GLPI server url
                                   If the server needs authentication, use the standard syntax <user>:<password>@<host>
    --format <format>              Specify the inventory format: FORMAT_OCS or FORMAT_GLPI
-l, --local <folder>               Save a local inventory in the specified file or folder
    --stdout                       Print inventory to stdout

-t, --tag <TAG>                    Specify tag. Will be ignored by server if a value already exists
    --nosoftware                   Do not retrieve installed software

    --agent-string <string>        Specify custom HTTP agent string

-d, --daemonize                    Detach from running terminal
-w, --wait <s>                     Wait for the specified amount of seconds before building the inventory

--logger <backend>                 Specify error log backend (STDERR / SYSLOG).
                                   Default is standard error if attached to a terminal, otherwise syslog. 
-v, --verbose                      Verbose mode
    --version                      Print version and exit

    --use-current-time-in-device-ID  Use current time in the device ID, instead of the BIOS Date.
                                     No need to use this option unless you know why you need it.

The -l and -s option are mutually exclusive.
If no server or output file is specified, either via the -s/-l option or via configuration file (option -c), the program will exit without doing anything.

Examples:
  Print inventory to standard output :
    ocsinventory-agent --stdout

  Send inventory to server http://ocsinventory-ng/ocsinventory :
    ocsinventory-agent --server http://ocsinventory-ng/ocsinventory

  Use the configuration file /etc/ocsinventory-ng.conf :
    ocsinventory-agent --conf /etc/ocsinventory-ng.conf

  Send inventory to server https://ocsinventory-ng/ocsinventory which requires http basic authentication :
    ocsinventory-agent --server https://user:password@ocsinventory-ng/ocsinventory

  Save a local inventory to /var/tmp/inventoryFile.xml :
    ocsinventory-agent --local /var/tmp/inventoryFile.xml

  Save a local inventory to /var/tmp/<device_id>.xml :
    ocsinventory-agent --local /var/tmp/

ocs-agent's People

Contributors

codacy-badger avatar jackburton79 avatar jonathan-orsel avatar mend-bolt-for-github[bot] avatar sqnoc avatar trentasis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ocs-agent's Issues

Should verify SSL certificate

Currently it does not verify if the SSL certificate of the server is valid. It should do that, and provide an option to ignore invalid/self signed certificates.

Help to build on old fedora computer

Hi Mr.

Do you know how can I do to make it works on old fedora computers? When i make sh setup.sh it say's THINSTATION_PATH: no such file or directory
SET_ENV: no such file or directory

The computers aren't thinstation but are old fedora computers of a NGO.

Can you help me?

Regards!

development

hy, we are delighted that this program exists ... will the development continue ?

Thanks for this fantastic minimalistic ocs-inventory agent

Kind regards

Ram value not correctly inventoried & agent version

Twuo questions

With added support to detect RAM slots is a great tool.
Only one issue, in ocs server inventory result is not the same value detected, for example:

We have a machine with 512 MB RAM, and in memory slots show correctly 512 but in table inventory result show 500MB

  1. It will be interesting taht in Inventory.cpp, exactly in

define USER_AGENT "OCS-NG_unified_unix_agent_v"

show as agent same string +git number to know version running

define USER_AGENT "OCS-NG_unified_unix_agent_v git #####"

Thanks

Request - Enhancement - use flag to bypass AssetTag <> Inventory Number import

Thanks for you job.
Using the agent with 10Zig thinclient we have these data for BIOS (see below).
The problem is that importing data in GLPI the value overwrite the value in the field "Inventory number".
This appen first time we launch the agent.
If we change manually the value imported from agent in GLPI the import will be locked by "lock system" of GLPI.

Having hundreds o thinclient we have to change the info manually for everyone after first import.

Is possibile modifiy the code to set a flag to enable or disable the import for field?
Below an example of the inventory generated from agent.
Thank you

############
<BIOS>
           <ASSETTAG>Chassis Asset Tag</ASSETTAG>
            <BDATE>09/23/2019</BDATE>
            <BMANUFACTURER>INSYDE Corp.</BMANUFACTURER>
            <BVERSION>V:3.4.21-08082019</BVERSION>
            <MMANUFACTURER>Type2 - Board Manufacturer</MMANUFACTURER>
            <MSN>Type2 - Board Serial Number</MSN>
            <SMANUFACTURER>10ZiG Technology</SMANUFACTURER>
           <SMODEL>4500</SMODEL>
           <SSN>xxxxxxxxxxxx</SSN>
           <TYPE>Notebook</TYPE>    
</BIOS> 

Problems with 1.5.1

Hi,

I'm testing 1.5.1 and I have detected some problems:

1.- version tag is not updated appears 1.5 and should be 1.5.1 --> required to modify in main.cpp "const char* version = "1.5";"

2.- in ram inventory is not correct, for example this machines
Not Specified 1024 System Memory DDR3 1333 MHz 0 01BD3629

Not Specified 0 DDR3 Unknown 1

Not Specified 1024 DDR3 1333 MHz 2 CDBC3629

Not Specified 0 DDR3 Unknown 3

Not Specified 4096 Flash Unknown 4 Not Specified

show as it has 6GB RAM, when really has 2GB RAM

3.- in ram appears 1025 mb ram, when really has to be 1024

4.- If you have a machine with one ethernet and then you have to replace with another ethernet (different mac address) then machine is not inventoried with new changes (new ethernet), only if you remove the computer from ocs, then is inventoried with new ethernet.
IT seems that is since this commit 9f81b9f

Thanks

Add glpi inventory support

Add support for glpi json inventory format
GLPI doesn't accept OCS inventory format directly, we'll need to implement generating inventory with its own format

date incorrect and inventory not updated correctly in some situations

in ocs agent appears that inventory date is incorrect and hits generates that inventory is not updated in some cases, always appear 2013-05-10-10-10 as inventory date

It seems that error is in Configuration.cpp and always appear :
ts-2013-05-10-10-10-10
and generating local XML filename is the same ts-2013-05-10-10-10-10.xml

If I import a modified xml with current date/time then it works...

can you solve with current data/time and recompile?

Thanks

Change agent version string

Change the agent version string to be unique. It should identify the specific agent and should contain the agent version.

To be able to use a custom version string, one would then need to modify the ocsinventory server configuration, like this:

`# ===== EXTERNAL USERAGENTS =====

#Path for external useragents reference file
#!! WARNING !! : external agents may not be supported by OCS NG Community !
#PerlSetEnv OCS_OPT_EXT_USERAGENTS_FILE_PATH /tmp/yourfile.txt

Ref: OCSInventory-NG/OCSInventory-Server#69

Memory size incorrect

In the current master branch, memory inventory is broken.
It will show memory speed instead of memory size.

Rewrite GetLSHWData() for XML output

GetLSHWData() currently parses the "default" output of the lshw command (where available).
It should insead parse the XML output of lshw -xml, since it's more structured and should be simpler to parse (with tinyxml2).

Rename the executable

Currently the makefile produce an executable called "ocsinventory-agent". This clashes with the official ocsinventory agent so we should rename it.

Install in thinstation 5.4

Hi,

I can't find any doc about how to install in thinstation 5.4, can you help?

  • I have checked taht dmidecode doesn't exist i nthinstation, how are you obtaining info without dmidecode
  • Can you detail steps to install in thinstaiton, in setup.sh appears THINSTATION_PATH and SET_ENV, but I don't know where are this files

Config
THINSTATION_PATH=cat ../../THINSTATION_PATH

. ../SET_ENV

Thanks

FreeBSD support?

hello!

just curios - have you tried to compile it on freebsd?
i'm thinking to install it on pfsense/opnsense... and before setup clean freebsd - i wanted to ask - are there any problems?

port different from 80 can't be used

if an URL contain a port, it doesn't works.
for exemple : --server http://<ocsserver>:<ocsport>/ocsinventory
it seems the port is hard coded in HTTP/http.h
As workaround I changed the default port in HTTP/http.h

Anyway, Thanks a lot for sharing this "lite" agent, very usefull !

Fail to compile

Hello,
I found your project and this is very useful for my work to inventory 10zig Thinclients into GLPI (or Ocsinventory).
I tryed to complile on linux Ubuntu 22.04.4.LTS but I receive the error below.
Hope you can solve .
Thanks for you work.


----/ocs-agent-2.0.0$
<<>>...<<>>

Building file: http/SocketGetter.cpp
Invoking: GCC C++ Compiler
g++ -DTIXML_USE_STL -fPIE -O2 -Wall -I ./ -c -fmessage-length=0 -MMD -MP -MF"http/SocketGetter.d" -MT"http/SocketGetter.d" -o "http/SocketGetter.o" "http/SocketGetter.cpp"
In file included from http/SocketGetter.cpp:11:
http/SSLSocket.h:13:10: fatal error: openssl/ssl.h: No such file or directory
13 | #include <openssl/ssl.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
make: *** [subdir.mk:41: http/SocketGetter.o] Error 1

version 1.6.4 not showed correctly

It seems that was not released with version numberhttps://github.com/jackburton79/ocs-agent/commit/5b5d887b3bd5619181006d924c2f1274f2cf79bf

Release 1.6.5 or 1.7?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.