groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Søren Berg Glasius <soe...@glasius.dk>
Subject Re: Using jacob on Windows to get BIOS info (like server serial number)
Date Tue, 11 Aug 2015 14:05:33 GMT
@Merlin

you can use blogspot.com or tumblr.com to start a blog. Very easy. Then
when you have it running, register it at groovyblogs.org and it will be
aggregated with other Groovy & Grails related blogs.

Not that difficult.


Best regards / Med venlig hilsen,
Søren Berg Glasius

Hedevej 1, Gl. Rye, 8680 Ry, Denmark
Mobile: +45 40 44 91 88, Skype: sbglasius
--- Press ESC once to quit - twice to save the changes.

On 11 August 2015 at 11:32, Merlin Beedell <MBeedell@cryoserver.com> wrote:

> If only I knew how to contribute to a blog of some sort.  Where should I
> start without having to learn too much, and where the feedback comments are
> monitored to remove the ..um.. irrelevant responses?  E.g. register, login,
> type, publish, done!  Preferably a site that is focussed on Groovy related
> entries.
>
>
>
> Merlin Beedell
>
> *From:* Paco Zarate [mailto:contacto@nazcasistemas.com]
> *Sent:* 22 May 2015 6:49 PM
> *To:* users <users@groovy.incubator.apache.org>
> *Subject:* Re: Using jacob on Windows to get BIOS info (like server
> serial number)
>
>
>
> Hey Merlin,
>
> Thanks for sharing this code! It will be helpful for a monitoring script i
> need for doing some sysadmin tasks!
>
> It would be great if you publish it on a blog!
>
> Thanks!
>
> Paco.
>
>
>
> On Fri, May 15, 2015 at 5:44 AM, Merlin Beedell <MBeedell@cryoserver.com>
> wrote:
>
> Just thought one or two of you may be interested on how to get some BIOS
> and O/S level details on a Windows platform.  To do this you will need to
> use the JACOB interface to COM, that allows Java to interact with com/dcom
> components.  In this case, to access the WMI Scripting feature set.
>
> Note: JACOB is installed with Groovy when using the Windows distribution
> (not the zip or scripted installer versions). This is cribbed from the
> excellent example already in the Groovy distribution.
>
>
>
> Now to figure how to do similar for Linux (dmidecode + ?) and on VM
> platforms!
>
> Why? To find some sort of meaningful but ‘unique’ attribute(s) of the
> server on which the service is running.
>
>
>
> Merlin Beedell
>
>
>
> import org.codehaus.groovy.scriptom.*;
>
> import static
> org.codehaus.groovy.scriptom.tlb.wbemscripting.WbemFlagEnum.*;
>
> import static
> org.codehaus.groovy.scriptom.util.wbemscripting.WbemDateTime.*
>
>
>
>     org.codehaus.groovy.scriptom.Scriptom.inApartment {
>
>         def locator = new
> org.codehaus.groovy.scriptom.ActiveXObject('WbemScripting.SWbemLocator')
>
>         def services = locator.ConnectServer('.')
>
>         def returnState
>
>         def Kb2Mb = 1024
>
>         def nf = java.text.NumberFormat.getIntegerInstance()
>
>       def proc_query
>
>        // Lets get some Windows O/S details (
> https://msdn.microsoft.com/en-us/library/dn792258(v=vs.85).aspx )
>
>        // you can specify which details to return, the * for all details..
>
>       proc_query = "SELECT Caption, Version, CSDVersion, OSArchitecture,
> FreePhysicalMemory, TotalVisibleMemorySize FROM Win32_OperatingSystem"
>
>       //proc_query = "SELECT * FROM Win32_OperatingSystem"
>
>       for (process in services.ExecQuery(proc_query, 'WQL',
> wbemFlagForwardOnly) )
>
>       {
>
>         def mem_free = process.FreePhysicalMemory as Integer
>
>         def mem_Total = process.TotalVisibleMemorySize as Integer
>
>         //def mem_swap = (process.TotalSwapSpaceSize+""?:"0") as Integer
>
>         println ("Free Mem = ${nf.format(mem_free / Kb2Mb)}Mb   Total Mem
> = ${nf.format(mem_Total/Kb2Mb)}Mb ")
>
>         println "O/S = $process.Caption [Ver $process.Version]
> $process.CSDVersion [$process.OSArchitecture]\n\n"
>
>         //println "Locale = $process.Locale"
>
>       }
>
>       //  Now to get some BIOS info
>
>       proc_query = "SELECT * FROM Win32_BIOS"
>
>       for (process in services.ExecQuery(proc_query, 'WQL',
> wbemFlagForwardOnly) )
>
>       {
>
>         println process.SerialNumber
>
>         //println process.dump()
>
>         println process.CurrentLanguage
>
>         println process.Description
>
>         println toJavaDate(process.ReleaseDate)
>
>         println process.Manufacturer
>
>       //see
> https://msdn.microsoft.com/en-us/library/aa394077(v=vs.85).aspx for all
> fields
>
>       }
>
> }
>
>
>
>
>

Mime
View raw message