prevent apps.plugin errors when files are not found
Costa Tsaousis committed
Aug 1, 2016 at 18:54 UTC
ec313f2fb9f0d348fa25f5575d223a7b5892bafb
1 file changed
+24
-7
src/apps_plugin.c
+24
-7
@@ -1654,7 +1654,10 @@ void collect_data_for_pid(pid_t pid) {
1654
// /proc/<pid>/stat
1655
1656
if(unlikely(read_proc_pid_stat(p))) {
1657
- error("Cannot process %s/proc/%d/stat (command '%s')", host_prefix, pid, p->comm);
1657
+ if(errno != ENOENT || debug)
1658
+ error("Cannot process %s/proc/%d/stat (command '%s')", host_prefix, pid, p->comm);
1659
+ else
1660
+ errno = 0;
1661
// there is no reason to proceed if we cannot get its status
1662
return;
1663
}
@@ -1670,14 +1673,21 @@ void collect_data_for_pid(pid_t pid) {
1673
// --------------------------------------------------------------------
1674
// /proc/<pid>/io
1675
1673
- if(unlikely(read_proc_pid_io(p)))
1674
- error("Cannot process %s/proc/%d/io (command '%s')", host_prefix, pid, p->comm);
1676
+ if(unlikely(read_proc_pid_io(p))) {
1677
+ if(errno != ENOENT || debug)
1678
+ error("Cannot process %s/proc/%d/io (command '%s')", host_prefix, pid, p->comm);
1679
+ else
1680
+ errno = 0;
1681
+ }
1682
1683
// --------------------------------------------------------------------
1684
// /proc/<pid>/statm
1685
1686
if(unlikely(read_proc_pid_statm(p))) {
1680
- error("Cannot process %s/proc/%d/statm (command '%s')", host_prefix, pid, p->comm);
1687
+ if(errno != ENOENT || debug)
1688
+ error("Cannot process %s/proc/%d/statm (command '%s')", host_prefix, pid, p->comm);
1689
+ else
1690
+ errno = 0;
1691
// there is no reason to proceed if we cannot get its memory status
1692
return;
1693
}
@@ -1690,8 +1700,12 @@ void collect_data_for_pid(pid_t pid) {
1700
if(unlikely(p->new_entry)) {
1701
// /proc/<pid>/cmdline
1702
if(likely(proc_pid_cmdline_is_needed)) {
1693
- if(unlikely(read_proc_pid_cmdline(p)))
1694
- error("Cannot process %s/proc/%d/cmdline (command '%s')", host_prefix, pid, p->comm);
1703
+ if(unlikely(read_proc_pid_cmdline(p))) {
1704
+ if(errno != ENOENT || debug)
1705
+ error("Cannot process %s/proc/%d/cmdline (command '%s')", host_prefix, pid, p->comm);
1706
+ else
1707
+ errno = 0;
1708
+ }
1709
}
1710
1711
if(unlikely(debug))
@@ -1729,7 +1743,10 @@ void collect_data_for_pid(pid_t pid) {
1743
// /proc/<pid>/fd
1744
1745
if(unlikely(read_pid_file_descriptors(p))) {
1732
- error("Cannot process entries in %s/proc/%d/fd (command '%s')", host_prefix, pid, p->comm);
1746
+ if(errno != ENOENT || debug)
1747
+ error("Cannot process entries in %s/proc/%d/fd (command '%s')", host_prefix, pid, p->comm);
1748
+ else
1749
+ errno = 0;
1750
}
1751
1752
// --------------------------------------------------------------------