atop

atop -r y -b 18:00 -e 18:00

-r: read

-b: begin time

-e: end time

atop -r -b 18:00 // no need to specify time for today’s data

atop -r 20150624 -b 18:00 -e 08:00 // specify date for the file to look up

atop => show cpu, memory at a time in the past

Advertisements

double/int/string to bool in c++

Q:

int main(void) {
  using namespace std;
  vector<bool> a;
  a.push_back("asdf");
  a.push_back("");  
  a.push_back(12);  
  a.push_back(0.0);  
  copy(a.begin(), a.end(), ostream_iterator<bool>(cout, "\n"));
  return 0;
}

Pointers and integers, and also booleans, are integral types. The first three are all either pointers or integers, and since they are all non-zero, they convert to the boolean value true. The fourth value of type double converts to a zero integral value and hence false.

Conversion of doubles that are not representable as integral values (like infinity and NaN) is undefined.

2>/dev/null

> file redirects stdout to file
1> file redirects stdout to file
2> file redirects stderr to file
&> file redirects stdout and stderr to file

You can redirect stdout to stderr by doing 1>&2

echo test 1>&2 

1 is stdout. 2 is stderr.

Here is one way to remember this construct (altough it is not entirely accurate): at first, 2>1 may look like a good way to redirect stderr to stdout. However, it will actually be interpreted as “redirect stderr to a file named 1“. & indicates that what follows is a file descriptor and not a filename. So the construct becomes: 2>&1.