IOMonitor Plugin does not use optimal /proc parameter to find process PID

Bug #735452 reported by heckheck on 2011-03-15
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
powernap
Undecided
Andres Rodriguez
powernap (Ubuntu)
High
Andres Rodriguez

Bug Description

Binary package hint: powernap

I have been looking at the forthcoming changes to powernap in natty and noticed something I think can be a significant enhancement for the IOMonitor Plugin.

The IOManager Plugin currently uses a regex search of '/proc/%s/cmdline' to find the process name pattern for a process it will be monitoring. Many processes that may be of interest to monitor with the IOManager do not have a command line. For example, NFS daemons processes, which would be very useful to monitor don't have a cmdline with the process name.

I suggest that instead the IOManager perform its regex search to find PIDs on the Name: field that is at the start of the /proc/PID/status record to search for process names. This would allow many more "interesting" processes to be monitored.

This would require a relatively simple modification to the Python script. Normally I'd code and test this myself before submitting the bug report, but I thought I'd report quickly in case there is any chance such a change can make it into Natty.

root@twilightzone:/etc# ps -ef |grep nfsd
root 1638 2 0 Mar10 ? 00:00:00 [nfsd4]
root 1639 2 0 Mar10 ? 00:00:01 [nfsd]
root 1640 2 0 Mar10 ? 00:00:00 [nfsd]
root 1641 2 0 Mar10 ? 00:00:21 [nfsd]
root 1642 2 0 Mar10 ? 00:00:13 [nfsd]
root 1643 2 0 Mar10 ? 00:00:00 [nfsd]
root 1644 2 0 Mar10 ? 00:00:08 [nfsd]
root 1645 2 0 Mar10 ? 00:00:17 [nfsd]
root 1646 2 0 Mar10 ? 00:00:18 [nfsd]
root 3340 3129 0 08:46 pts/3 00:00:00 grep nfsd
root@twilightzone:/etc# cat /proc/1639/cmdline
root@twilightzone:/etc# cat /proc/1639/status
Name: nfsd
State: S (sleeping)
Tgid: 1639
Pid: 1639
PPid: 2
TracerPid: 0
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 64
Groups:
Threads: 1
SigQ: 1/31638
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: fffffffffffffef8
SigCgt: 0000000000000107
CapInh: 0000000000000000
CapPrm: ffffffffffffffff
CapEff: fffffffffffffeff
CapBnd: ffffffffffffffff
Cpus_allowed: 3
Cpus_allowed_list: 0-1
Mems_allowed: 00000000,00000001
Mems_allowed_list: 0
voluntary_ctxt_switches: 20175
nonvoluntary_ctxt_switches: 48

heckheck (jinfo) wrote :

One more piece of useful information. Processes without a /proc/PID/cmdline can be easily identified in the ps list, in that they have their process names placed inside square brackets. From the ps man page:

       args COMMANDcommand with all its arguments as a string. Modifications to the arguments may be shown. The output in this column may contain spaces. A process marked <defunct> is partly dead, waiting to be fully destroyed by its parent. Sometimes the process args will be unavailable; when this happens, ps will instead print the executable name in brackets.

heckheck (jinfo) wrote :

It occurred to me just after writing this bug report, that some people may be using the current functionality of the regex search of the cmdline to find a particular instance of a process based on its args.

So a better enhancement idea may be to keep the current functionality of scanning the /proc/PID/cmdline with the regex expression while adding a second regex search of the Name: field in the /proc/PID/status file using the same expression. Then monitor the PID if either of the two searches successfully finds a match using the regex search (a logical OR of the two searches, with only one match required to declare the PID monitored)

This would preserve existing functionality of allowing a more specific search of the cmdline (with arguments), should the use specify a more complex regex that will match specifically a given cmdline for a particular process. It would also now enable the monitoring of a set of processes that lack a cmdline (such as NFSD) if the user specifies just the process name for the regex search, which will be found by the search of the Name: field in the status file.

Andres Rodriguez (andreserl) wrote :

Hi there,

Thank you for reporting bugs and trying to make Ubuntu better.

I'll take a look at this later this week however, after a quick look /proc/<PID>/status I found that under the field name, some processes names that are long might not show the complete name, i.e.:

$ cat status
Name: chromium-browse

Note that the complete name of the process is not shown when it should. This might affect regex's for daemons which name's too long. In turn, cmdline shows:

$ cat cmdline
/usr/lib/chromium-browser/chromium-browser --type=extension --lang=en-US --force-fieldtest=ConnCountImpact/conn_count_8/ConnnectBackupJobs/ConnectBackupJobsEnabled/DnsImpact/max_2s_queue_prefetch/DnsParallelism/parallel_14/GlobalSdch/global_enable_sdch/IdleSktToImpact/idle_timeout_60/Prefetch/ContentPrefetchDisabled/ProxyConnectionImpact/proxy_connections_32/SpdyCwnd/cwnd16/SpdyImpact/npn_with_spdy/ --channel=4516.0x7f839042d000.717038638

Cheers,

Changed in powernap (Ubuntu):
status: New → Triaged
importance: Undecided → Low
Andres Rodriguez (andreserl) wrote :

Indeed,

That's what I was thinking about too. Since this would be considered as a bug it would make it to natty in case it's decided to go thru with this.

Cheers!

Changed in powernap (Ubuntu):
assignee: nobody → Andres Rodriguez (andreserl)
status: Triaged → In Progress
Changed in powernap (Ubuntu):
status: In Progress → Invalid
Changed in powernap:
status: New → In Progress
Changed in powernap (Ubuntu):
assignee: Andres Rodriguez (andreserl) → nobody
Changed in powernap:
assignee: nobody → Andres Rodriguez (andreserl)
Changed in powernap (Ubuntu):
status: Invalid → In Progress
assignee: nobody → Andres Rodriguez (andreserl)
Changed in powernap (Ubuntu):
status: In Progress → Fix Committed
Changed in powernap:
status: In Progress → Fix Committed
Changed in powernap (Ubuntu):
status: Fix Committed → Confirmed
importance: Low → Wishlist
Changed in powernap (Ubuntu):
importance: Wishlist → High
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package powernap - 2.6-0ubuntu1

---------------
powernap (2.6-0ubuntu1) natty; urgency=low

  * debian/copyright: Update upstream authors and license years.
  * powernap/monitors/IOMonitor.py: If processes do not have a command line,
    search regex in the 'Name:' field of /proc/<PID>/status (LP: #735452)
  * actions/cpu_frequency: Fix saving/restoring of wrong governor (LP: #743682)
    Thanks to Mathieu Berard for the patch.
    - Additionally, save 'ondemand' as default when acpi-support and ondemand
      are run on boot to handle special case when running on battery.
  * debian/powernap.{preinst,postinst}: Add logic to handle the upgrade of
    the config file as format has changed. (LP: #744588)
    - install copy of config file in /usr/share/powernap to help with this.
 -- Andres Rodriguez <email address hidden> Mon, 28 Mar 2011 17:38:34 -0400

Changed in powernap (Ubuntu):
status: Confirmed → Fix Released
Changed in powernap:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers