how to use if condition in uipath? I want to check the CPU usage and physical memory using if condition for multiple servers…how to automate this? i have used the screen scraping to extract the value of CPU usage and physical memory from task bar… SO i have created the variable for this. how to use this variable in if condition to get satisfied the condition?
You really don’t need to use screen scraping for this. There are plenty of system commands to get you this information.
What are you trying to achieve? If you are trying to check if CPU Usage is over a certain percentage then put cpuUsage >= .7 where cpuUsage is our variable in which you have stored the value
Thanks for the help.Actually i want to send an email if cpu usage and physical memory goes above 90%. So how to use that in if command?
Well it all depends on the number that you have in the variable. Once you have it in a percentage format it really is as simple as If cpuUsage >-.9 or physMemory > .9 then do (left hand panel) else (right hand panel)
Have you done the RPA Basic Academy? I feel you would benefit from this.
About getting the value you can use this
Counter = new PerformanceCounter(“Processor”,"% Processor Time","_Total")
Assign a variable of type System.Diagnotics.PerformenceCounter then use it inside a loop.
You should add some delay inside the loop in order to save some processor time.
Usage is variable of Type System.Single that you need to assign with “Counter.NextValue()”
the loop will exit only if the processor usage exceed the value, so you can make your email sending after.
You will would need to improve a bit, maybe have maximum iteration to exit loop too.
While I really like new usages for robots, and @Florent_Salendres example is a really good one if you need to monitor the machine it’s running on, I would be hesitant if using a robot for server load monitoring is the right solution when things like Nagios (and many other) exist.
A robot would be good to react to an alert, effectively acting like a service desk person, but the monitoring itself is I’d say better with tools specifically designed for that (especially scaling - I don’t see a single robot efficiently monitoring a couple dozens, or even hundreds of servers).
Totally agreed, this is how you could do it, but i would not recommand anyoneto monitor a server using UIPath.
To be fair it would need to be more advanced, like check if the usage exceeded a specific threshold for a longer duration (ex:5 secs) for example.
for the current case, only resizing the windows for few seconds would trigger the 80 percents.
I need to check this for multiple servers. So how to automate logging off from the server and instantly next server should get logged in and repeat the task of checking cpu usage and physical memory. i am trying this by using the foreach loop but no scuccess.