KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

VHDX Dateien auslesen

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
EasyFone



Joined: 09 Aug 2023
Posts: 3

PostPosted: Fri Aug 11, 2023 12:42 am    Post subject: VHDX Dateien auslesen Reply with quote

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
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Fri Aug 11, 2023 1:49 am    Post subject: Reply with quote

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/mframe.htm#tests.htm#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
Back to top
View user's profile Send private message Visit poster's website
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Fri Aug 11, 2023 1:53 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
EasyFone



Joined: 09 Aug 2023
Posts: 3

PostPosted: Fri Aug 11, 2023 4:17 am    Post subject: Reply with quote

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,
Back to top
View user's profile Send private message
EasyFone



Joined: 09 Aug 2023
Posts: 3

PostPosted: Fri Aug 11, 2023 4:20 am    Post subject: Reply with quote

[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/mframe.htm#tests.htm#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]
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Fri Aug 11, 2023 6:20 am    Post subject: Reply with quote

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/mframe.htm#tests.htm#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?


Quote:
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:
...
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
Back to top
View user's profile Send private message Visit poster's website
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Fri Aug 11, 2023 6:24 am    Post subject: Reply with quote

Code:
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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index