Jump to content

WhiteCrow

Active Members
  • Posts

    58
  • Joined

  • Last visited

WhiteCrow's Achievements

Wayfarer

Wayfarer (2/7)

0

Reputation

  1. Thank you for this nice example, i had trouble figuring out the total download speed. Now i know how
  2. Excellent example script, i'll check it out.
  3. I'm using this program right now, smart idea
  4. /edit: Fixed it, and it wasn't weird at all. Ignore my post
  5. What a nice piece of code, you really did good
  6. This is faster, with my computer this code gives me about the same interval as the task manager does. Global $wbemFlagReturnImmediately = 0x10 Global $wbemFlagForwardOnly = 0x20 Global $wbemFlags = $wbemFlagReturnImmediately + $wbemFlagForwardOnly Global $strComputer = @ComputerName Global $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Func CPU_utilize() Global $colItems = $objWMIService.ExecQuery("SELECT LoadPercentage FROM Win32_Processor", "WQL", $wbemFlags) For $objItem In $colItems $sMsg = INT($objItem.LoadPercentage) Next Return $sMsg EndFunc ProgressOn ( "CPU Utilisation", "" , "") While 1 $returned=CPU_utilize() ProgressSet($returned, $returned & " %") WEnd
  7. Found the solution: Global $wbemFlagReturnImmediately = 0x10 Global $wbemFlagForwardOnly = 0x20 Global $wbemFlags = $wbemFlagReturnImmediately + $wbemFlagForwardOnly Global $strComputer = @ComputerName Global $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Global $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlags) $n = 0 $sMsg = "" For $objItem In $colItems $sMsg &= $n & ": LoadPercentage: " & $objItem.LoadPercentage & @CRLF $n += 1 Next MsgBox(64, "CPU Load", $sMsg)
  8. A good reply, thank you, but there has to be another way I'll see if i can find it Here another version made by Jos (but its still not what i'm looking for ) Func _Busy( $WINDOW ) Do Do Sleep( 100 ) $PC = StatusbarGetText("Windows Task Manager","",2) $PC = StringTrimRight( $PC, 1) ; remove the % $PC = StringRight( $PC, 3 ) ; get the possible 3 digits $PC = Int(StringReplace($PC,":","")); remove colon and convert to int. Until $PC < 10 Do Sleep( 100 ) Until MouseGetCursor( ) <> 15 Until WinActive($WINDOW) EndFunc ;==>_Busy
  9. Sorry to bump this so soon, but i'm really curious how to read the cpu usage. And i have no idea where to look
  10. I made a simple restarter program, made for a WoW emulator known as MangOS. It might be of some use for someone Restarter application: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.1.4 (beta) Author: R.Westerhof (www.drakkaa.nl) Script Function: Restarts a MangOs server With logging and a inifile #ce ---------------------------------------------------------------------------- $x=0 $y=0 $crashnumber_m=-1 $crashnumber_r=-1 $backupmade=1 $time=IniRead ( "restart.ini", "Config", "Time", "320" ) $mangos_ini=IniRead ( "restart.ini", "Config", "MangOS", "mangosd.exe" ) $realmd_ini=IniRead ( "restart.ini", "Config", "Realmd", "realmd.exe" ) $mangos_path=IniRead ( "restart.ini", "Config", "Path", "c:\mangos\" ) $logging_enabled=IniRead ( "restart.ini", "Logging", "LogEnabled", "1" ) $log_filename=IniRead ( "restart.ini", "Logging", "LogName", "restartlog.txt" ) $save_number=IniRead ( "restart.ini", "AccountSave", "save_number", "1" ) $starttime=IniRead ( "restart.ini", "Config", "StartTime", "320" ) Sleep($starttime*1000) $time=$time*1000 If $logging_enabled=1 Then FileWriteLine ( $log_filename, @CRLF ) FileWriteLine ( $log_filename, TimeStamp() & " - MangOs restarter Started" ) endif ;MainLoop While 1 Sleep($time) ;wich errors window to check, and enter away. IF WinExists ( "Microsoft Windows") Then Send ("{Enter}") Sleep(3000) EndIf IF WinExists ( "mangosd.exe - Toepassingsfout") Then Send ("{Enter}") Sleep(3000) EndIf IF WinExists ( "mangosd.exe - Application Error") Then Send ("{Enter}") Sleep(3000) EndIf IF WinExists ( "Microsoft Visual C++ Runtime Library") Then Send ("{Enter}") Sleep(3000) EndIf IF WinExists ( "mysqld-nt.exe - Application Error") Then Send ("{Enter}") Sleep(3000) EndIf ;check if its time for backup If @HOUR = 13 or @HOUR=1 Then $backupmade=0 EndIf If $backupmade = 0 Then If @HOUR = 14 or @HOUR=2 Then BackupDB() $backupmade=1 EndIf EndIf ;check if the server process1 exists If ProcessExists($mangos_ini) = 0 then If $logging_enabled=1 Then $crashnumber_m+=1 If $crashnumber_m > 0 then FileWriteLine ( $log_filename, TimeStamp() & " - " & $mangos_ini & " - process missing from memory. " & "Restart (" & $crashnumber_m & ")" ) EndIf endif Run($mangos_path & $mangos_ini) Endif ;check if the server process2 exists If ProcessExists($realmd_ini) = 0 then If $logging_enabled=1 Then $crashnumber_r+=1 If $crashnumber_r > 0 Then FileWriteLine ( $log_filename, TimeStamp() & " - " & $realmd_ini & " - process missing from memory. " & "Restart (" & $crashnumber_r & ")" ) EndIf EndIf Run($mangos_path & $realmd_ini) endif Wend ;Timestamp for logging Func TimeStamp() $far=@MON & "-" & @MDAY & "-" & @YEAR & " / " & @HOUR & ":" & @MIN & ":" & @SEC Return $far Endfunc ;backup the database and copy the files to the backup directory Func BackupDB() If $backupmade=1 Then return 0 Else run("backup.bat") Sleep(300000) ;copy the freshly made MySQL backup files to @scriptdir \ backup dir Filecopy( @ScriptDir & "\" & "realmd_backup.sql", @ScriptDir & "\backup\" & "realmd_backup" & @YEAR & @MON & @MDAY & ".sql", 9) Filecopy( @ScriptDir & "\" & "characters_backup.sql", @ScriptDir & "\backup\" & "characters_backup" & @YEAR & @MON & @MDAY & ".sql", 9) EndIf EndFunc The restart.ini file: [Config] ;howmany seconds much restarter wait to begin opening the server processes. StartTime=60 ;every how many seconds does restarter check server memory for server processes, or errors. Time=10 ;MangOS .exe name (case sensitive.) MangOS=mangosd.exe ;RealmD .exe name (case sensitive.) Realmd=realmd.exe ;The path of mangos, include the last \ e.g. : c:\mangos\ (case sencitive.) Path=c:\mangos\ [Logging] ;are crashlogs enabled 1 for yes and 0 for no. LogEnabled=1 ;the filename of the crashlog. LogName=restartlog.txt ;========== server restarter and config by www.drakkaa.nl========== The MySql commandline backup.bat (makes a complete backup of the MangOS mysql database.) @ECHO OFF SET DBUSER=root SET DBPASS=1234 SET MDBNAME=mangos SET RDBNAME=realmd SET CHRDBNM=characters SET SCRIPTDEV=scriptdev2 SET MYPATH="C:\Program Files\MySQL\MySQL Server 6.0\bin\mysqldump.exe" ECHO EXPORTING FULL BACKUP... ECHO. ECHO EXPORTING REALMD DB... %MYPATH% --user=%DBUSER% --password=%DBPASS% --opt %RDBNAME% > realmd_backup.sql ECHO EXPORTING MANGOS DB... %MYPATH% --user=%DBUSER% --password=%DBPASS% --opt %MDBNAME% > mangos_backup.sql ECHO EXPORTING SCRIPTDEV2 DB... %MYPATH% --user=%DBUSER% --password=%DBPASS% --opt %SCRIPTDEV% > scriptdev2_backup.sql ECHO EXPORTING CHARACTERS DB... %MYPATH% --user=%DBUSER% --password=%DBPASS% --opt %CHRDBNM% > characters_backup.sql ECHO. ECHO COMPLETED ECHO. Edit: Forgot to add some checks for when the MySQL backups should be made.
  11. I can't find a clear way to see at what cpu % usage my machine is, anyone know how to ? Becouse i have made this server restart program, wich works fine exept when the server application it monitors "freezes", and the monitored application just sits there using 100% cpu utilisation. So if the monitored application hits 100% cpu usage it should be closed, and restarted. Here is what i have, and works fine: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.1.4 (beta) Author: R.Westerhof (www.drakkaa.nl) Script Function: Restarts a MangOs server With logging and a inifile #ce ---------------------------------------------------------------------------- $x=0 $y=0 $crashnumber_m=-1 $crashnumber_r=-1 $time=IniRead ( "restart.ini", "Config", "Time", "320" ) $mangos_ini=IniRead ( "restart.ini", "Config", "MangOS", "mangosd.exe" ) $realmd_ini=IniRead ( "restart.ini", "Config", "Realmd", "realmd.exe" ) $mangos_path=IniRead ( "restart.ini", "Config", "Path", "c:\mangos\" ) $logging_enabled=IniRead ( "restart.ini", "Logging", "LogEnabled", "1" ) $log_filename=IniRead ( "restart.ini", "Logging", "LogName", "restartlog.txt" ) $save_number=IniRead ( "restart.ini", "AccountSave", "save_number", "1" ) $starttime=IniRead ( "restart.ini", "Config", "StartTime", "320" ) Sleep($starttime*1000) $time=$time*1000 If $logging_enabled=1 Then FileWriteLine ( $log_filename, @CRLF ) FileWriteLine ( $log_filename, TimeStamp() & " - MangOs restarter Started" ) endif ;MainLoop While 1 Sleep($time) ;wich errors window to check, and enter away. IF WinExists ( "Microsoft Windows") Then Send ("{Enter}") Sleep(3000) EndIf IF WinExists ( "mangosd.exe - Toepassingsfout") Then Send ("{Enter}") Sleep(3000) EndIf IF WinExists ( "mangosd.exe - Application Error") Then Send ("{Enter}") Sleep(3000) EndIf IF WinExists ( "Microsoft Visual C++ Runtime Library") Then Send ("{Enter}") Sleep(3000) EndIf IF WinExists ( "mysqld-nt.exe - Application Error") Then Send ("{Enter}") Sleep(3000) EndIf ;check if its time for backup If @HOUR = 13 or @HOUR=1 Then BackupDB() EndIf ;check if the server process1 exists If ProcessExists($mangos_ini) = 0 then If $logging_enabled=1 Then $crashnumber_m+=1 If $crashnumber_m > 0 then FileWriteLine ( $log_filename, TimeStamp() & " - " & $mangos_ini & " - process missing from memory. " & "Restart (" & $crashnumber_m & ")" ) EndIf endif Run($mangos_path & $mangos_ini) Endif ;check if the server process2 exists If ProcessExists($realmd_ini) = 0 then If $logging_enabled=1 Then $crashnumber_r+=1 If $crashnumber_r > 0 Then FileWriteLine ( $log_filename, TimeStamp() & " - " & $realmd_ini & " - process missing from memory. " & "Restart (" & $crashnumber_r & ")" ) EndIf EndIf Run($mangos_path & $realmd_ini) endif Wend ;Timestamp for logging Func TimeStamp() $far=@MON & "-" & @MDAY & "-" & @YEAR & " / " & @HOUR & ":" & @MIN & ":" & @SEC Return $far Endfunc ;backup the database and copy the files to the backup directory Func BackupDB() If $backuprun=1 Then return 0 Else run("backup.bat") Sleep(300000) ;copy the freshly made MySQL backup files to @scriptdir \ backup dir Filecopy( @ScriptDir & "\" & "realmd_backup.sql", @ScriptDir & "\backup\" & "realmd_backup" & @YEAR & @MON & @MDAY & ".sql", 9) Filecopy( @ScriptDir & "\" & "characters_backup.sql", @ScriptDir & "\backup\" & "characters_backup" & @YEAR & @MON & @MDAY & ".sql", 9) EndIf EndFunc The ini file: [Config] ;howmany seconds much restarter wait to begin opening the server processes. StartTime=60 ;every how many seconds does restarter check server memory for server processes, or errors. Time=10 ;MangOS .exe name (case sensitive.) MangOS=mangosd.exe ;RealmD .exe name (case sensitive.) Realmd=realmd.exe ;The path of mangos, include the last \ e.g. : c:\mangos\ (case sencitive.) Path=c:\mangos\ [Logging] ;are crashlogs enabled 1 for yes and 0 for no. LogEnabled=1 ;the filename of the crashlog. LogName=restartlog.txt ;========== server restarter and config by www.drakkaa.nl==========
  12. How can you make a webcamshot, when the webcam is in use ? Tried many things but it always seems to give a popup with the required source, and yield a 0 bytes file in return. Thanks in advance.
  13. Thanks for sharing (je Nederlandse) script
  14. Aaah, i was looking for something like this.. Made some programs for my server, and i dont want any overactive user, peeking into a readable source. Thank you for making this possible!
  15. oh, sorry, didnt see you changed the code my bad, i'll check right away. /edit: thats not the embedded video
×
×
  • Create New...