Jump to content

Recommended Posts

Posted (edited)

A demonstration how to use pseudo multi processing to speed up collection of information of remote systems:

Normally a script works sequentially, e.g. it checks one system by one. If a systems hangs then whole script hangs, too.

How about to speed up script by using multiple processes?

Let's see my solution for that!

This command line tool S(ystem)I(nformation)C(ollector)2 aka SIC2 is helpful for system admins which need to collect data from their systems in an easy and fast way.

SIC2 is a tool which can do that, particularly with ability of pseudo parallel multiple processes (multi threading).

It connects e.g. via WMI to local and/or remote systems to collect data (see options below).

Here the command line (use it in a CMD box):

Usage: SIC2.exe [-i "<system filename="" list="">"]

[-master -slaves <n>] for multiprocessing mode

[-ver] for version number

[-prio <0-3>] for process prio - standard is 0 (idle)

[<options>]

[-? | /? | -help | /help]] for this page

Options can be:

-os get only information about operating system

-rl get only information about role of system

-sv get only information about running services

If argument [-master -slaves <n>] is not given then sequential

mode will be used automatically!

Output will be written to folder Output where SIC2.exe was started.

Output format is a semicolon separated text file (*.csv).

On each run output files will be overwritten!

<system filename="" list=""> is a text file with the names of the systems in each line.

An example of the command line could be: SIC2.exe -i serverlist.txt -master -slaves 15 -os -rl -sv -prio 1

This will run SIC2.exe which will create 15 sub processes (slaves) which are connecting to the systems given in serverlist.txt.

Of course it makes no sense to select 15 slaves when the list contains less systems!

Currently only 3 modules are implemented. Feel free to upgrade it with more options. See below for a version with more modules!

Benchmark on a terminal server with only 4 users, with gigabit network and SIC2.exe in idle priority:

152 systems, only LAN connection, no WAN.

post-29844-1223671890_thumb.png

WAN benchmark will follow hopefully.

I hope this is tool is helpful for you! But have in mind that this project is still in beta phase and thus maybe buggy!

Some parts also adjusted to my needs and will give no results probably on your systems.

Here the code (early stage with 3 modules only):

  Reveal hidden contents


New Version Below:

You can download source + compiled exes (22 modules) here: SIC2.exe + SIC2.au3 + SIC2GUI.exe

Source code of full version (22 modules) here (build 2012-02-24 beta): SIC2_Src.7z (149 downloads of previous versions)

Use e.g. 7-Zip to extract archive.

SIC2.txt Commandline Parameters:

  Reveal hidden contents

If I have more time I will code a GUI for SIC2 because without a GUI many people will not use it!

-> Done! SIC2 GUI download here: SIC2_GUI.7z (10 downloads of previous versions)

Please post any criticism, if you like it or not!

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • 1 month later...
Posted

I discovered coincidentally that also TrendMicro has a tool with the name SIC. :)

Should I rename my tools, in order to avoid legal problems? :)

Did someone already make such experiences?

Thanks,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • 2 years later...
Posted (edited)

Wow, after nearly 3 years a reply! :D

How did you run it? In the CMD line or via the GUI? Is there a Errors.csv file in the output folder? If yes, what is the content?

I need more information otherwise I cannot say what might be wrong!

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

Yes, because i'm looking for a script to give me the serial number of the HDD, and there is nothing in the forum...

I execute by the GUi, and with the command line, I have the same problem :

I execute this : SIC2.exe -i list.txt -all

And in the prompt I have : File list.txt is empty!

No csv file.

Posted (edited)

What is the content of list.txt? list.txt must contain ip addresses or host names (one per line)!

Further, as far as I can remember there is no option to read the s/n of the HDD but maybe I can add it...

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

Try this:

Global $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler")

MsgBox(0, "Test", WMI_GetHDDSN("."))

Func WMI_GetHDDSN($host, $usr = "", $pass = "") ;coded by UEZ 2011
    If $host = "." Then $host = "localhost"
    Local $HDD_SN
    Local $ping = Ping($host, 1000)
    If @error Then Return SetError(1, 0, -1)
    Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator")
    Local $objWMIService = $objWMILocator.ConnectServer($host, "rootcimv2", $usr, $pass, "", "", 128)
    If @error Then Return SetError(2, 0, -1)
    Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive WHERE MediaType LIKE '%Fixed%'", "WQL", 0x30)
    If IsObj($colItems) Then
        For $objItem In $colItems
            $HDD_SN &= "Model: " & $objItem.Model & ", S/N: " & WMI_GetHDDSN2(StringMid($objItem.Name, 5), $host, $usr, $pass) & @LF
        Next
    Else
        Return SetError(3, 0, -1)
    EndIf
    Return $HDD_SN
EndFunc

Func WMI_GetHDDSN2($Tag, $host, $usr = "", $pass = "") ;coded by UEZ 2011
    Local $HDD_SN
    Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator")
    Local $objWMIService = $objWMILocator.ConnectServer($host, "rootcimv2", $usr, $pass, "", "", 128)
    Local $colItems = $objWMIService.ExecQuery("SELECT SerialNumber,Tag FROM Win32_PhysicalMedia WHERE Tag  LIKE '%" & $Tag & "%'", "WQL", 0x30)
    If IsObj($colItems) Then
        For $objItem In $colItems
            ConsoleWrite($objItem.Tag & @LF)
            $HDD_SN = $objItem.SerialNumber
        Next
    Else
        Return SetError(3, 0, -1)
    EndIf
    Return $HDD_SN
EndFunc

Func ObjErrorHandler()
     ConsoleWrite(  "A COM Error has occured!" & @CRLF  & @CRLF & _
                                "err.description is: "    & @TAB & $oErrorHandler.description    & @CRLF & _
                                "err.windescription:"     & @TAB & $oErrorHandler & @CRLF & _
                                "err.number is: "         & @TAB & Hex($oErrorHandler.number, 8)  & @CRLF & _
                                "err.lastdllerror is: "   & @TAB & $oErrorHandler.lastdllerror   & @CRLF & _
                                "err.scriptline is: "     & @TAB & $oErrorHandler.scriptline     & @CRLF & _
                                "err.source is: "         & @TAB & $oErrorHandler.source         & @CRLF & _
                                "err.helpfile is: "       & @TAB & $oErrorHandler.helpfile       & @CRLF & _
                                "err.helpcontext is: "    & @TAB & $oErrorHandler.helpcontext & @CRLF _
                            )
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

I try it on 3 different computers (XP-SP3), the same result, nothing in the msgbox,

  Quote

A COM Error has occured!

err.description is:

err.windescription:

err.number is: 80041017

err.lastdllerror is: 0

err.scriptline is: 15

err.source is:

err.helpfile is:

err.helpcontext is:

Edited by ricky03
Posted

Local $objWMIService = $objWMILocator.ConnectServer($host, "rootcimv2", $usr, $pass, "", "", "&H80")

This might need to be:

Local $objWMIService = $objWMILocator.ConnectServer($host, "rootcimv2", $usr, $pass, Default, Default, 128)

&H80 is the way VBScript does Hex Numbers, so for AutoIt, it would be 0x80, which is the same number as 128. I've used it with success along with ConnectServer.

Posted

@SkinnyWhiteGuy :

I try with your line and I try also with "" at the place of Default and the problem is the same with the same error.

Posted

Better, No COM error, but not correct :

Model: WDC WD2500SD-01KCC0, S/N: 4457572d4143374c323635373738 036 0 0 0 0

Model: WDC WD5002ABYS-01B1B0, S/N:

Posted

This is what WMI returns!

And what about this?:

Global $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler")

MsgBox(0, "Test", WMI_GetHDDSN("."))

Func WMI_GetHDDSN($host, $usr = "", $pass = "") ;coded by UEZ 2011
    If $host = "." Then $host = "localhost"
    Local $HDD_SN
    Local $ping = Ping($host, 1000)
    If @error Then Return SetError(1, 0, -1)
    Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator")
    Local $objWMIService = $objWMILocator.ConnectServer($host, "rootcimv2", $usr, $pass, "", "", 128)
    If @error Then Return SetError(2, 0, -1)
    Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive WHERE MediaType LIKE '%Fixed%'", "WQL", 0x30)
    If IsObj($colItems) Then
        For $objItem In $colItems
            $HDD_SN &= "Model: " & $objItem.Model & ", S/N: " & $objItem.SerialNumber & @LF
        Next
    Else
        Return SetError(3, 0, -1)
    EndIf
    Return $HDD_SN
EndFunc

Func ObjErrorHandler()
     ConsoleWrite(  "A COM Error has occured!" & @CRLF  & @CRLF & _
                                "err.description is: "    & @TAB & $oErrorHandler.description    & @CRLF & _
                                "err.windescription:"     & @TAB & $oErrorHandler & @CRLF & _
                                "err.number is: "         & @TAB & Hex($oErrorHandler.number, 8)  & @CRLF & _
                                "err.lastdllerror is: "   & @TAB & $oErrorHandler.lastdllerror   & @CRLF & _
                                "err.scriptline is: "     & @TAB & $oErrorHandler.scriptline     & @CRLF & _
                                "err.source is: "         & @TAB & $oErrorHandler.source         & @CRLF & _
                                "err.helpfile is: "       & @TAB & $oErrorHandler.helpfile       & @CRLF & _
                                "err.helpcontext is: "    & @TAB & $oErrorHandler.helpcontext & @CRLF _
                            )
EndFunc

On my notebook this function return not the correct value but value is correct from post#10.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

Here are :

  Quote

Model: WDC WD2500SD-01KCC0, S/N:

Model: WDC WD5002ABYS-01B1B0, S/N:

  Quote

A COM Error has occured!

err.description is:

err.windescription:

err.number is: 80020006

err.lastdllerror is: 0

err.scriptline is: 18

err.source is:

err.helpfile is:

err.helpcontext is:

Posted (edited)

I can speak German, Turkish and English but not C/C++ :D

But I can try!

I asume if you want to enumerate only on local PC, not remotely, then the s/n can be read out of a build-in DLL (e.g. kernel32.dll)!

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...