top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Monitoring a List of Process in Linux

+2 votes
466 views

I want a script which -
1. Monitor is list of process in Linux.
2. When it is any process is down it can log the error and restart the process.
3. List of the processes can be supplied as the command line parameters.

posted Sep 20, 2013 by Salil Agrawal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Try MonIt it is good and very powerful also, download from
http://mmonit.com/monit/

answer Sep 20, 2013 by anonymous
Similar Questions
0 votes

I am looking for a tool which let me monitor memory consumption per process on CentOS 5/6. The tool should be able to save its history so I could see what amount of memory was consumed yesterday/week ago/etc by each process.

Can you recommend anything like that ?

+4 votes

Code to write data in to file example.txt.. which is working fine

// basic file operations
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  ofstream myfile;
  myfile.open ("example.txt");
  myfile << "Writing this to a file.\n";
  myfile << "Writing this to a file.\n";
  myfile << "Writing this to a file.\n";
  myfile << "Writing this to a file.\n";
  myfile << "Writing this to a file.\n";
  myfile << "Writing this to a file.\n";
  myfile.close();
  return 0;
}

File : filelimit.c below which takes input as the compiled binary of above code
In this code i am setting the file size limit of process to 10 bytes and the above code is trying to write more than 10 bytes. According to below code if a process is trying to write more than 10 bytes to file it should send the signal SIGXFSZ (see more about this here)

It is not sending here... Why??

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>

void handler(int sig)
{
    if(sig == SIGXFSZ)
        printf("Inside handler with correct signal\n");
    else
        printf("Inside handler with wrong signal\n");
}


int main(int argc, char const *argv[])
{
    pid_t pid;
    pid = fork();

    if(pid == 0)
    {
        signal(SIGXFSZ, handler);

        char command[256];
        scanf("%s", command);

        int ret;

        struct rlimit rl;
        rl.rlim_cur = 10;
        rl.rlim_max = 10;
        setrlimit (RLIMIT_FSIZE, &rl);

        char *envp[] = { NULL };
        char *argv[] = { command , NULL };
        ret = execve(command, argv, envp);

        while(1);
    }
    else
    {
        printf("%d - %d\n", getpid(), pid);
        signal(SIGXFSZ, handler);
        while(1);
    }
    return 0;
}
...