CPUs load values are incorrect on Sysmonitor applet

Bug #1040713 reported by Gaëtan André
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Screenlets
Undecided
Unassigned

Bug Description

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()

Revision history for this message
Gaëtan André (gaetan-andre) wrote :
Revision history for this message
Märt Põder (boamaod) wrote :

Are you familiar with Bazaar on Launchpad? Maybe you can submit your fix yourself?

Revision history for this message
Gaëtan André (gaetan-andre) wrote :

No I am not very familiar with it, but I may become familiar with it if necessary.

I wrote a function to replace screenlets.sensors.cpu_get_cpu_load(int i) directly in the SysMonitor screenlet code, it would be better to fix this function in the API. But it may change the results returned by this function and other screenlets may then have unexpected behaviors.

Who is in charge of screenlets.sensors ?

Revision history for this message
Märt Põder (boamaod) wrote :

Screenlets has been on autopilot already for some years. I have been fixing this and that and couple of other people too.

If the changes you are planning to the API are backward compatible (format of returned values basically), you can try. To change screenlets core framework or API you have to join https://launchpad.net/~screenlets-dev. To change Sysmonitor screenlet you have to join https://launchpad.net/~indiv-screenlets-dev.

Basic documentation can be found at http://screenlets.org/index.php/Documentation#Help_to_develop_Screenlets

Revision history for this message
Gaëtan André (gaetan-andre) wrote : Re: [Bug 1040713] Re: CPUs load values are incorrect on Sysmonitor applet

Sorry for the very late response but I had troubles with my Internet
connection.

If I understand, anybody can change anything without review ?

Gaëtan

2012/8/29 Märt Põder <email address hidden>

> Screenlets has been on autopilot already for some years. I have been
> fixing this and that and couple of other people too.
>
> If the changes you are planning to the API are backward compatible
> (format of returned values basically), you can try. To change screenlets
> core framework or API you have to join https://launchpad.net
> /~screenlets-dev. To change Sysmonitor screenlet you have to join
> https://launchpad.net/~indiv-screenlets-dev.
>
> Basic documentation can be found at
> http://screenlets.org/index.php/Documentation#Help_to_develop_Screenlets
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1040713
>
> Title:
> CPUs load values are incorrect on Sysmonitor applet
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/screenlets/+bug/1040713/+subscriptions
>

Revision history for this message
Rastko Karadzic (rastkokaradzic) wrote : Re: [Screenlets-dev] [Bug 1040713] Re: CPUs load values are incorrect on Sysmonitor applet

Also, there is another bug. More than 2 cores are not supported in
Sysmonitor screenlet.

On Sat, Oct 13, 2012 at 7:13 PM, Gaëtan André <email address hidden>wrote:

> Sorry for the very late response but I had troubles with my Internet
> connection.
>
> If I understand, anybody can change anything without review ?
>
> Gaëtan
>
> 2012/8/29 Märt Põder <email address hidden>
>
> > Screenlets has been on autopilot already for some years. I have been
> > fixing this and that and couple of other people too.
> >
> > If the changes you are planning to the API are backward compatible
> > (format of returned values basically), you can try. To change screenlets
> > core framework or API you have to join https://launchpad.net
> > /~screenlets-dev. To change Sysmonitor screenlet you have to join
> > https://launchpad.net/~indiv-screenlets-dev.
> >
> > Basic documentation can be found at
> > http://screenlets.org/index.php/Documentation#Help_to_develop_Screenlets
> >
> > --
> > You received this bug notification because you are subscribed to the bug
> > report.
> > https://bugs.launchpad.net/bugs/1040713
> >
> > Title:
> > CPUs load values are incorrect on Sysmonitor applet
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/screenlets/+bug/1040713/+subscriptions
> >
>
> --
> You received this bug notification because you are a member of
> Screenlets Dev Team, which is subscribed to the bug report.
> https://bugs.launchpad.net/bugs/1040713
>
> Title:
> CPUs load values are incorrect on Sysmonitor applet
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/screenlets/+bug/1040713/+subscriptions
>
> _______________________________________________
> Mailing list: https://launchpad.net/~screenlets-dev
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~screenlets-dev
> More help : https://help.launchpad.net/ListHelp
>

--
Regards,
Rastko Karadzic

Revision history for this message
Gaëtan André (gaetan-andre) wrote :

I don't have/had this problem ...

2012/10/14 Rastko Karadzic <email address hidden>

> Also, there is another bug. More than 2 cores are not supported in
> Sysmonitor screenlet.
>
> On Sat, Oct 13, 2012 at 7:13 PM, Gaëtan André
> <email address hidden>wrote:
>
> > Sorry for the very late response but I had troubles with my Internet
> > connection.
> >
> > If I understand, anybody can change anything without review ?
> >
> > Gaëtan
> >
> > 2012/8/29 Märt Põder <email address hidden>
> >
> > > Screenlets has been on autopilot already for some years. I have been
> > > fixing this and that and couple of other people too.
> > >
> > > If the changes you are planning to the API are backward compatible
> > > (format of returned values basically), you can try. To change
> screenlets
> > > core framework or API you have to join https://launchpad.net
> > > /~screenlets-dev. To change Sysmonitor screenlet you have to join
> > > https://launchpad.net/~indiv-screenlets-dev.
> > >
> > > Basic documentation can be found at
> > >
> http://screenlets.org/index.php/Documentation#Help_to_develop_Screenlets
> > >
> > > --
> > > You received this bug notification because you are subscribed to the
> bug
> > > report.
> > > https://bugs.launchpad.net/bugs/1040713
> > >
> > > Title:
> > > CPUs load values are incorrect on Sysmonitor applet
> > >
> > > To manage notifications about this bug go to:
> > > https://bugs.launchpad.net/screenlets/+bug/1040713/+subscriptions
> > >
> >
> > --
> > You received this bug notification because you are a member of
> > Screenlets Dev Team, which is subscribed to the bug report.
> > https://bugs.launchpad.net/bugs/1040713
> >
> > Title:
> > CPUs load values are incorrect on Sysmonitor applet
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/screenlets/+bug/1040713/+subscriptions
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~screenlets-dev
> > Post to : <email address hidden>
> > Unsubscribe : https://launchpad.net/~screenlets-dev
> > More help : https://help.launchpad.net/ListHelp
> >
>
>
> --
> Regards,
> Rastko Karadzic
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1040713
>
> Title:
> CPUs load values are incorrect on Sysmonitor applet
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/screenlets/+bug/1040713/+subscriptions
>

Revision history for this message
Märt Põder (boamaod) wrote : Re: [Screenlets-dev] [Bug 1040713] Re: CPUs load values are incorrect on Sysmonitor applet

In indiv-screenlets, you can change anything without review, if it more
or less follows the guidelines at:
https://launchpad.net/~indiv-screenlets-dev

In screenlets you can change most of the stuff, if it doesn't break
compatibility with previous versions. It would be nice though if you
introduced your plans for changes before starting to submit code. Just
to get some feedback and make sure you are moving in the right direction.

Märt

13.10.2012 20:13, Gaëtan André kirjutas:
> Sorry for the very late response but I had troubles with my Internet
> connection.
>
> If I understand, anybody can change anything without review ?
>
> Gaëtan
>
> 2012/8/29 Märt Põder <email address hidden>
>
>> Screenlets has been on autopilot already for some years. I have been
>> fixing this and that and couple of other people too.
>>
>> If the changes you are planning to the API are backward compatible
>> (format of returned values basically), you can try. To change screenlets
>> core framework or API you have to join https://launchpad.net
>> /~screenlets-dev. To change Sysmonitor screenlet you have to join
>> https://launchpad.net/~indiv-screenlets-dev.
>>
>> Basic documentation can be found at
>> http://screenlets.org/index.php/Documentation#Help_to_develop_Screenlets
>>
>> --
>> You received this bug notification because you are subscribed to the bug
>> report.
>> https://bugs.launchpad.net/bugs/1040713
>>
>> Title:
>> CPUs load values are incorrect on Sysmonitor applet
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/screenlets/+bug/1040713/+subscriptions
>>

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Patches