How to create a bash script that runs periodically through a cronjob to gather readings of a running processes on the current machine (1 sample per process on each run ) from the system the readings are: 1 CPU load percentage. 2 Memory Usage. 3 Open files count. 4 Open ports count.
Asked
Active
Viewed 65 times
0
-
you can use `sar` utility for this. – Siddharth sharma Jan 08 '16 at 07:31
-
@Siddharthsharma, I think **`sar`** reports for the whole system, not for individual processes -- Perhaps I misunderstood the question because of "a running process**es**". – Jdamian Jan 08 '16 at 08:10
1 Answers
0
I gues you could iterate through /proc
filesystem analysing files uid
and stat*
. Then the uid needs to be mapped to /etc/passwd
to get real user names. In my opinion a perl script would be more convenient for this need.

dmi
- 1,424
- 1
- 9
- 9