emotta Posted April 13, 2020 Report Share Posted April 13, 2020 Alguem sabe como obter o percentual de desempenho da CPU via código xHarbour? gostaria de monitorar o consumo de CPU da máquina e se ultrapassar (por exemplo) 90% eu gero um LOG com o horário que isso aconteceu. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted April 13, 2020 Report Share Posted April 13, 2020 Veja se sua versão tem o PCINFO.PRG é por ai... Abs. https://forums.fivetechsupport.com/viewtopic.php?f=3&t=36473&p=217687&hilit=PCINFO#p217687 Quote Link to comment Share on other sites More sharing options...
emotta Posted April 14, 2020 Author Report Share Posted April 14, 2020 pelo que eu vi é pra listar porta serial, preciso do percentual de uso da cpu Quote Link to comment Share on other sites More sharing options...
kapiaba Posted April 14, 2020 Report Share Posted April 14, 2020 Não tenho certeza, mas se não me falha a memória, vi no fonte do PCINFO.PRG, os comandos? GETCPU() y CPUSPEED(). Não consigo achar o link no forum, mas quem tem as novas versões de 2019/2020, deve ter no \samples. Pida a alguém. Abs. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted April 14, 2020 Report Share Posted April 14, 2020 É por aqui.. Ou não... kkkkkkkkkkkkkk https://forums.fivetechsupport.com/viewtopic.php?f=6&t=24849&p=135106&hilit=GETCPU#p135106 Quote Link to comment Share on other sites More sharing options...
emotta Posted April 15, 2020 Author Report Share Posted April 15, 2020 vlw pela tentativa mas não é isso "Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz" e quero isso "90%" Vlw pela tentativa no chute mas não é isso amigo... Quote Link to comment Share on other sites More sharing options...
gilmer Posted April 15, 2020 Report Share Posted April 15, 2020 Bom Dia Emotta, Verifique rotinas em VB Script, achando será fácil de converter para [x]harbour ou usar em VBS mesmo. Quote Link to comment Share on other sites More sharing options...
emotta Posted April 15, 2020 Author Report Share Posted April 15, 2020 Seguindo o norte dado pelo Gilmer consegui desenvolver a funcao a partir de um exemplo vbscript. Segue o codigo pra quem precisar: Function u_Teste() MsgStop(GetCPUUsage()) Return Static FUNCTION GetCPUUsage() local oList, oProc Local nCpu := 0 Local oWmi oWmi := WmiService() oList := oWmi:ExecQuery( "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor" ) for each oProc in oList If "TOTAL" in Upper(oProc:Name) nCpu += Val(oProc:PercentProcessorTime) EndIf next return nCpu Quote Link to comment Share on other sites More sharing options...
kapiaba Posted April 15, 2020 Report Share Posted April 15, 2020 Mais exemplos: https://sourceforge.net/p/hmgs-minigui/svncode/515/tree//trunk/MiniGUI/SAMPLES/Advanced/WMI_Service/demo2.prg?diff=575787f20910d4739e1c9f3b:514 Quote Link to comment Share on other sites More sharing options...
Marca Posted April 15, 2020 Report Share Posted April 15, 2020 Seguindo o norte dado pelo Gilmer consegui desenvolver a funcao a partir de um exemplo vbscript. Segue o codigo pra quem precisar: Function u_Teste() MsgStop(GetCPUUsage()) Return Static FUNCTION GetCPUUsage() local oList, oProc Local nCpu := 0 Local oWmi oWmi := WmiService() oList := oWmi:ExecQuery( "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor" ) for each oProc in oList If "TOTAL" in Upper(oProc:Name) nCpu += Val(oProc:PercentProcessorTime) EndIf next return nCpu Emotta boa tarde O que a função WmiService() faz ? ela não foi colocada ai Quote Link to comment Share on other sites More sharing options...
Valdir Posted April 15, 2020 Report Share Posted April 15, 2020 Marcelo... A wmiservice é uma função que está dentro da pcinfo.prg da pasta samples. Abraços. Quote Link to comment Share on other sites More sharing options...
Marca Posted April 15, 2020 Report Share Posted April 15, 2020 Marcelo... A wmiservice é uma função que está dentro da pcinfo.prg da pasta samples. Abraços. Jóia. Obrigado Valdir Valdir 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.