← Back to team overview

screenlets-dev team mailing list archive

[Bug 1040713] [NEW] CPUs load values are incorrect on Sysmonitor applet

 

You have been subscribed to a public bug by Gaëtan André (gaetan-andre):

Hello,

The CPUs load values are incorrect.

Morever screenlets.sensors.cpu_get_cpu_load() is not implemented in a
good way.

I corrected the code directly in the applet code : here is the diff.

There is also a hack to reserve space (but only works if the applet is
on the right of the screen).

34d33
< import commands
45,48d43
< 
< last_total_time = [0,0,0,0]
< last_idle_time = [0,0,0,0]
< 
238,245d232
< 		#reserve space
< 		print "reserve space"
< 		#self.window.window.property_change('_NET_WM_STRUT_PARTIAL', 'CARDINAL', 32, gtk.gdk.PROP_MODE_REPLACE, [ int((self.width *self.scale)), 0, 0, 0, 0, int((self.width *self.scale)), 0, 0, 0, 0, 0, 0])
< 		self.window.window.property_change("_NET_WM_STRUT", "CARDINAL", 32, 
< 		gtk.gdk.PROP_MODE_REPLACE, [0, int((self.width *self.scale)), 0, 0]) 
< 		
< 		
< 
261,285d247
< 	def get_cpu_loads(self):
< 		#print "truc"
< 		for i in range (0,self.cpu_nb):
< 			line = commands.getoutput("cat /proc/stat|grep cpu"+str(i))
< 			ss = line.split();
< 						
< 			user_time = int(ss[1])
< 			#print str(user_time) + " " + ss[1]
< 			nice_time = int(ss[2])
< 			system_time = int(ss[3])
< 			idle_time = int(ss[4])
< 
< 			idle_time = idle_time + nice_time
< 			total_time = idle_time + user_time + system_time
< 
< 			total_elapsed=total_time - last_total_time[i]
<  			last_total_time[i]=total_time
<  			idle_elapsed=idle_time - last_idle_time[i]
<  			last_idle_time[i]=idle_time
< 
< 			self.cpu_load[i] = 100 - 100 * idle_elapsed / total_elapsed
< 			#if i==0 :			
< 			#	print self.cpu_load[i]
< 			
< 
304,314c266,275
< 			self.get_cpu_loads();
< #			for i in range (0,self.cpu_nb):  #Sets CPU info#
< #				self.new_cpu[i]=sensors.cpu_get_load(i#)
< #
< #				self.cpu_load[i] = self.update_interval #(self.new_cpu[i]-self.old_cpu[i]) #*1.0/(1.0*self._update_interval)
< #				
< #				self.old_cpu[i] = self.new_cpu[i]
< #				try:
< #					if self.cpu_load[i] > 99: self.cpu_load[i] = 99
< #					elif self.cpu_load[i] < 0: self.cpu_load[i]=0
< #				except : pass
---
> 			for i in range (0,self.cpu_nb):  #Sets CPU info
> 				self.new_cpu[i]=sensors.cpu_get_load(i)
> 
> 				self.cpu_load[i] = (self.new_cpu[i]-self.old_cpu[i])/self.update_interval
> 				
> 				self.old_cpu[i] = self.new_cpu[i]
> 				try:
> 					if self.cpu_load[i] > 99: self.cpu_load[i] = 99
> 					elif self.cpu_load[i] < 0: self.cpu_load[i]=0
> 				except : pass
343c304
< 		#self.get_variables()
---
> 		self.get_variables()

** Affects: screenlets
     Importance: Undecided
         Status: New

-- 
CPUs load values are incorrect on Sysmonitor applet
https://bugs.launchpad.net/bugs/1040713
You received this bug notification because you are a member of Screenlets Dev Team, which is subscribed to the bug report.


References