Quantcast
Channel: Ocsinventory Q&A - Recent questions and answers
Viewing all articles
Browse latest Browse all 11994

Answered: How to customize the unix agent or send data to the OCS server

$
0
0

Hi,

To add softwares, you should only write a plugin that prints :

<SOFTWARES>
<PUBLISHER>MyPublisher</PUBLISHER>
<NAME>MySoftware</NAME>
<VERSION>15</VERSION>
<COMMENTS>Some comments</COMMENTS>
</SOFTWARES>

For example, this plugin lists thr ODBC drivers on Windows :

const HKEY_LOCAL_MACHINE = &H80000002

'
'
'
Sub ListDrivers(archbits, regtype)
    Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
        oCtx.Add "__ProviderArchitecture", regtype

    strComputer = "."
    set objFSO = CreateObject("Scripting.FileSystemObject")
    
    'set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
        set oLocator = CreateObject("Wbemscripting.SWbemLocator")
        set objReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")

    'WScript.Echo "Architecture : "& regtype & " sur "& archbits
    strKeyPath = "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"
    objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
    
    objReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames
    for i=0 to UBound(arrValueNames)
        driver = arrValueNames(i)        
        key = "SOFTWARE\ODBC\ODBCINST.INI\"& driver
        objReg.GetStringValue HKEY_LOCAL_MACHINE, key, "Driver", dll
        if dll<>"" then
            if archbits=64 and regtype=32 then
                dll = Replace(dll, "system32", "SysWOW64")
            end if
            dllname = objFSO.GetFileName(dll)
            if dllname<>"odbcjt32.dll" and dllname<>"msorcl32.dll" and dllname<>"vfpodbc.dll" and objFSO.FileExists(dll) then
                dllVer =  objFSO.GetFileVersion(dll)
                wscript.echo "<SOFTWARES>"
                wscript.echo "<PUBLISHER>Driver ODBC "& regtype & " bits</PUBLISHER>"
                wscript.echo "<NAME>"& driver & "</NAME>"
                wscript.echo "<VERSION>"& dllver & "</VERSION>"
                wscript.echo "<COMMENTS>"& dll & "</COMMENTS>"
                wscript.echo "</SOFTWARES>"
            end if
        end if
    next
End Sub

'
' Windows 32 ou 64 bits ?
'
Set wshShell = CreateObject( "WScript.Shell" )
arch6432 = wshShell.ExpandEnvironmentStrings( "%PROCESSOR_ARCHITEW6432%" )
arch = wshShell.ExpandEnvironmentStrings( "%PROCESSOR_ARCHITECTURE%" )
if arch="AMD64" or arch6432="AMD64" then
    'archbits = 64
    ListDrivers 64, 32
    ListDrivers 64, 64
else
    'archbits = 32
    ListDrivers 32, 32
end if
Set wshShell = Nothing

Regards


Viewing all articles
Browse latest Browse all 11994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>