VHDX Dateien auslesen

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
EasyFone
Posts: 3
Joined: Wed Aug 09, 2023 1:24 am

VHDX Dateien auslesen

Post by EasyFone »

Hallo KS-Soft Forum,

ich habe ein Problem, weshalb ich um Rat frage.

Wir haben einen Pfad => W:
Typ: Netzlaufwerk
Dateisystem: NTFS
Dort werden .VHDX Dateien gespeichert.

Jetzt möchte ich per Batch, die Dateien größer als 10 GB auslesen.
Sollte keine Datei >= 10GB sein, soll ein good zurückkommen, falls aber eine oder mehrere Dateien >= 10GB sind bad zurückkommen.
Das Ganze möchte ich in unseren Hostmonitor eintragen, der das per Batch prüfen soll, sollte dann eine Datei >= 10GB sein, soll uns nur mitgeteilt werden, das wir in dem Pfad nach den Dateien schauen müssen.

Das habe ich so weit hinbekommen:
@echo off
wmic datafile where "drive='w:' AND extension='vhdx' AND filesize>='10741612540'" get filesize 1>%TMP%\zzz.tmp 2>nul
Call :File_Size %TMP%\zzz.tmp

if %FileSize% GEQ 10 (
echo ScriptRes:Bad:0
) else if %FileSize% LSS 9 (
echo ScriptRes:Ok:1
)

:ende
exit /b

::====================================================
:File_Size
Set FileSize=%~z1
Exit /B 0

Wenn ich das Ganze in der CMD ausführe, bekomme ich bei groeßer oder gleich 10741612540 ein bad uns sonst eine good Nachricht, genau so soll es sein.

Mein Problem ist aber nun, im Hostmonitor bekomme ich nur Good oder nur Bad, egal was ich an der Größe ändere...
Ich habe auch schon geschaut, ob ich das mit WMI test überprüfen könnte, wäre auch in Ordnung, bekomme es aber nicht hin.


Ich hoffe, ihr könnt mir helfen, bin über jede Hilfe dankbar:)

VG
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

1) Sorry, we do not speak German. As you may see language of this forum is English

2) Why you don't use Count Files test method? It may check file size as well.
https://www.ks-soft.net/hostmon.eng/mfr ... countfiles

3) Mein Problem ist aber nun, im Hostmonitor bekomme ich nur Good oder nur Bad, egal was ich an der Größe ändere...Ich habe auch schon geschaut
Yes, your script sets Bad or Ok status. What exactly you don't like?

Regards
Alex
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

4) We cannot find your license. Could you please contact support or sales by e-mail and provide your registration name and/or order number?

Regards
Alex
EasyFone
Posts: 3
Joined: Wed Aug 09, 2023 1:24 am

Post by EasyFone »

Hello KS-Soft Forum,

I have an issue for which I'm seeking advice.

We have a path => W:
Type: Network Drive
File System: NTFS
.VHDX files are stored there.

Now, I want to retrieve files larger than 10 GB using a batch script.
If no file is >= 10GB, it should return "good." However, if one or more files are >= 10GB, it should return "bad."
I want to integrate this into our Hostmonitor, which should perform this batch check. If a file >= 10GB is found, we should be notified to check the path for the files.

Here's what I've achieved so far:
```batch
@echo off
wmic datafile where "drive='w:' AND extension='vhdx' AND filesize>='10741612540'" get filesize 1>%TMP%\zzz.tmp 2>nul
Call :File_Size %TMP%\zzz.tmp

if %FileSize% GEQ 10 (
echo ScriptRes:Bad:0
) else if %FileSize% LSS 10 (
echo ScriptRes:Ok:1
)

:ende
exit /b

::====================================================
:File_Size
Set FileSize=%~z1
Exit /B 0
```

When I execute this in CMD, I get a "bad" message for sizes greater than or equal to 10741612540, and a "good" message for other cases, just as it should be.

However, my problem is that in Hostmonitor, I only get either "Good" or "Bad," regardless of the size I change it to...
I've also tried to see if I could use WMI testing to check, which would be fine, but I can't get it to work.

I hope you can help me out. I appreciate any assistance:)

Best regards,
EasyFone
Posts: 3
Joined: Wed Aug 09, 2023 1:24 am

Post by EasyFone »

[quote="KS-Soft"]1) Sorry, we do not speak German. As you may see language of this forum is English

2) Why you don't use Count Files test method? It may check file size as well.
https://www.ks-soft.net/hostmon.eng/mfr ... countfiles

3) Mein Problem ist aber nun, im Hostmonitor bekomme ich nur Good oder nur Bad, egal was ich an der Größe ändere...Ich habe auch schon geschaut
Yes, your script sets Bad or Ok status. What exactly you don't like?

- Yeah thats the Problem, it only says its bad or good
Example:
3 Files are bigger than 10 GB --> Its bad
No Files are bigger than 10 GB --> Its bad
And if I change things in the script
3 Files are bigger than 10 GB --> Its good
No Files are bigger than 10 GB --> Its good

But it should be
3 Files are bigger than 10 GB --> Its bad
No Files are bigger than 10 GB --> Its good


Regards
Alex[/quote]
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You missed question #2
Why you do not use built-in test method Count Files?
It may check file size as well.
https://www.ks-soft.net/hostmon.eng/mfr ... countfiles


Also you ignored question #4
We cannot find your license. Could you please contact support or sales by e-mail and provide your registration name and/or order number?

Yeah thats the Problem, it only says its bad or good
Yes, its returns Bad or Ok status. I do not see any problem here.
But I do not understand what exactly condition you are trying to check

Code: Select all

...
Call :File_Size %TMP%\zzz.tmp
if %FileSize% GEQ 10
...
Set FileSize=%~z1
Exit /B 0 
You get size of output file zzz.tmp (there is list of files that fit disk+extension+size) filter and set FileSize variable. So, if output file size (list of files zzz.tmp) is over 10 bytes, you set Bad status
So, if "big files list" contains "FileSize"+CRLF+some items then you will get Bad test status.

Regards
Alex
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Code: Select all

3 Files are bigger than 10 GB --> Its bad
No Files are bigger than 10 GB --> Its bad
And if I change things in the script
3 Files are bigger than 10 GB --> Its good
No Files are bigger than 10 GB --> Its good

But it should be
3 Files are bigger than 10 GB --> Its bad
No Files are bigger than 10 GB --> Its good 
We do not have access to your system so we cannot tell you what exactly is going on. Its your system and your script.
I would suggest to execute single command and check result
wmic datafile where "drive='w:' AND extension='vhdx' AND filesize>='10741612540'" get filesize

Also, check %TMP%\zzz.tmp file, you may see result of above command there

Regards
Alex
Post Reply