Hello,

Until there is a fix for the NTOP segmentation fault problem,
I though others might need this work around that I am using.
It is a simple little 'C' program I coded to re-start NTOP if the 
"ntop caught signal" serror message is found.


/*
   Earl Terwilliger
   [EMAIL PROTECTED]
*/

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define BUFSIZE 80

/*
   Change the next three lines to match
   your start/stop process and the error message
   which will re-start the process
*/

#define PROCESS_START "ntop -i \"eth0,eth1,eth2\"  -u ntop -P /temp"
#define PROCESS_ERROR_MSG "ntop caught signal"
#define PROCESS_KILL "ps -ef | grep \"ntop \" | grep -v grep | awk '{ print $2 }' | 
xargs kill -9"

int main() {
        
    FILE *read_fp;
    char buffer[BUFSIZE + 1];
    int chars_read;

   while (1) {
    system(PROCESS_KILL);
    memset(buffer, '\0', sizeof(buffer));    
    printf("\n%s\n\n",PROCESS_START);
    read_fp = popen(PROCESS_START, "r");
    if (read_fp != NULL) {
        chars_read = fread(buffer, sizeof(char), BUFSIZE, read_fp);
        while (chars_read > 0) {
            buffer[chars_read] = (char)'\0';
            printf("%s", buffer);
            if (strstr(buffer,PROCESS_ERROR_MSG) != NULL) break;
            chars_read = fread(buffer, sizeof(char), BUFSIZE, read_fp);
        }
/* normally we would need the pclose but we ignore it here to avoid hang-up
   since we will kill the process anyway
*/
//        pclose(read_fp);
    }
   }  

   exit(EXIT_SUCCESS);
}

_______________________________________________
Ntop-dev mailing list
[EMAIL PROTECTED]
http://lists.ntop.org/mailman/listinfo/ntop-dev

Reply via email to