in reply to Re^14: show a message only during the sleep time
in thread show a message only during the sleep time

So, that lives if "ntop.sh" says something, and dies otherwise. I can't tell if that's what you want, since you haven't yet given me any information.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on Re^15: show a message only during the sleep time

Replies are listed 'Best First'.
Re^16: show a message only during the sleep time
by cc (Beadle) on Jul 25, 2005 at 22:51 UTC
    this script should stop the ntop and start it again after 8 seconds.

    I did some tests and ntop will be stopped with:
    my $stop = `/usr/local/bin/sudo /usr/local/www/cgi-bin/ntop/ntop.sh st +op` or die "cannot stop ntop: $!";
    and started again with:
    <br> my $start = `/usr/local/bin/sudo /usr/local/www/cgi-bin/ntop/ntop.sh s +tart` or die "cannot start ntop: $!";
    I cannot see errors on the ntop output.

    I have only one problem if the ntop is already running,
    an I start the script, I don't get any errors,
    but if it was stopped before,
    then I get an error:
    Software error: cannot stop ntop: at /usr/local/www/cgi-bin/ntop/ntop.cgi line 41.

    it needs to check first if the ntop is already running and then stop it.
Re^16: show a message only during the sleep time
by cc (Beadle) on Jul 25, 2005 at 23:41 UTC
    or has someone any other idea ?
      You still haven't completely specified what you want to do, and what ntop.sh is doing.
      • What does ntop.sh exit with on success or failure, for both starting and stopping?
      • What does ntop.sh say on success and failure, for both starting and stopping?
      • How do you want to wire that in to your program?
      Do you now understand system() and backquotes? Do you know what "and die" vs "or die" does?

      It seems so far you're just randomly throwing stuff in (we call that "cargo culting") without understanding. Are you understanding this yet?

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        hi

        Sorry for misunderstanding
        I'll be happy for any help
        Did you see my my penultimate posting ?
        I would like to stop the ntop monitoring tool, if it's running and start it again.
        I don't want to start it, if it's already already running.

        after stop with the script ntop says:
        Jul 27 01:06:48 bsd ntop[9723]: STATS: 0 packets dropped (by ntop) Jul 27 01:06:48 bsd kernel: vr0: promiscuous mode disabled Jul 27 01:06:48 bsd ntop[9723]: TERM: Removed pid file (/var/db/ntop +/ntop.pid) Jul 27 01:06:48 bsd ntop[9723]: =================================== Jul 27 01:06:48 bsd ntop[9723]: ntop is shutdown... Jul 27 01:06:48 bsd ntop[9723]: ===================================

        and after start with the script, ntop says:
        Jul 27 01:03:14 bsd sudo: www : TTY=unknown ; PWD=/usr/local/www/ +cgi-bin-dist/ntop ; USER=root ; COMMAND=/usr/local/www/cgi-bin/ntop/n +top.sh start Jul 27 01:03:14 bsd ntop[9650]: ntop v.3.1 MT (SSL) Jul 27 01:03:14 bsd ntop[9650]: Configured on Apr 4 2005 7:36:12, +built on Apr 4 2005 07:40:20. Jul 27 01:03:14 bsd ntop[9650]: Copyright 1998-2004 by Luca Deri <de +ri@ntop.org> Jul 27 01:03:14 bsd ntop[9650]: Get the freshest ntop from http://ww +w.ntop.org/ Jul 27 01:03:14 bsd ntop[9650]: Initializing ntop Jul 27 01:03:14 bsd kernel: vr0: promiscuous mode enabled Jul 27 01:03:14 bsd ntop[9650]: NONBLOCK: pcap_setnonblock(), device + 0, succeeded Jul 27 01:03:14 bsd ntop[9650]: **WARNING** NONBLOCK: cpu usage may +be high - see man page and FAQ Jul 27 01:03:14 bsd ntop[9650]: **WARNING** Truncated network size ( +device vr0) to 1024 hosts (real netmask 255.255.252.0) Jul 27 01:03:14 bsd ntop[9650]: Checking vr0 for additional devices Jul 27 01:03:14 bsd ntop[9650]: Resetting traffic statistics for dev +ice vr0 Jul 27 01:03:14 bsd ntop[9650]: DLT: Device 0 [vr0] is 1, mtu 1514, +header 14 Jul 27 01:03:14 bsd ntop[9650]: Initializing gdbm databases Jul 27 01:03:14 bsd ntop[9650]: VENDOR: Loading MAC address table. Jul 27 01:03:14 bsd ntop[9650]: VENDOR: Checking for MAC address tab +le file Jul 27 01:03:14 bsd ntop[9650]: VENDOR: File '/usr/local/etc/ntop/sp +ecialMAC.txt.gz' does not need to be reloaded Jul 27 01:03:14 bsd ntop[9650]: VENDOR: ntop continues ok Jul 27 01:03:14 bsd ntop[9650]: VENDOR: Checking for MAC address tab +le file Jul 27 01:03:14 bsd ntop[9650]: VENDOR: File '/usr/local/etc/ntop/ou +i.txt.gz' does not need to be reloaded Jul 27 01:03:14 bsd ntop[9650]: VENDOR: ntop continues ok Jul 27 01:03:14 bsd ntop[9650]: Fingeprint: Loading signature file. Jul 27 01:03:15 bsd ntop[9650]: Fingeprint: ...loaded 1697 records Jul 27 01:03:15 bsd ntop[9651]: INIT: Bye bye: I'm becoming a daemon +... Jul 27 01:03:15 bsd ntop[9650]: INIT: Parent process is exiting (thi +s is normal) Jul 27 01:03:15 bsd ntop[9651]: Now running as a daemon Jul 27 01:03:15 bsd ntop[9651]: ASN: Checking for Autonomous System +Number table file Jul 27 01:03:15 bsd ntop[9651]: **WARNING** ASN: Unable to open file + 'AS-list.txt' Jul 27 01:03:15 bsd ntop[9651]: I18N: This instance of ntop does not + support multiple languages Jul 27 01:03:15 bsd ntop[9651]: IP2CC: Checking for IP address <-> C +ountry Code mapping file Jul 27 01:03:15 bsd ntop[9651]: IP2CC: Loading file '/usr/local/etc/ +ntop/p2c.opt.table.gz' Jul 27 01:03:17 bsd ntop[9651]: IP2CC: ...found 52395 lines Jul 27 01:03:17 bsd ntop[9651]: GDVERCHK: Guessing at libgd version Jul 27 01:03:17 bsd ntop[9651]: GDVERCHK: ... as 2.0.21+ Jul 27 01:03:17 bsd ntop[9651]: Initializing external applications Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: Started thread (13461299 +2) for network packet analyser Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: Started thread (13461350 +4) for fingerprinting Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: Started thread (13461401 +6) for idle hosts detection Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: Started thread (13461452 +8) for DNS address resolution Jul 27 01:03:17 bsd ntop[9651]: Calling plugin start functions (if a +ny) Jul 27 01:03:17 bsd ntop[9651]: SSL: Initializing... Jul 27 01:03:17 bsd ntop[9651]: SSL_PRNG: Automatically initialized! Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: Packet processor thread +running... Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: Fingerprint scan thread +running... Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: Idle host scan thread ru +nning... Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: Address resolution threa +d running... Jul 27 01:03:17 bsd ntop[9651]: SSL initialized successfully Jul 27 01:03:17 bsd ntop[9651]: INITWEB: Initializing web server Jul 27 01:03:17 bsd ntop[9651]: INITWEB: Initializing tcp/ip socket +connections for web server Jul 27 01:03:17 bsd ntop[9651]: INITWEB: Converted address '10.41.3. +77' - binding to the specific interface Jul 27 01:03:17 bsd ntop[9651]: INITWEB: Initialized ssl socket, por +t 3001, address 10.41.3.77 Jul 27 01:03:17 bsd ntop[9651]: INITWEB: Waiting for HTTPS (SSL) con +nections on 10.41.3.77 port 3001 Jul 27 01:03:17 bsd ntop[9651]: INITWEB: Starting web server Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: Started thread (14567116 +8) for web server Jul 27 01:03:17 bsd ntop[9651]: Listening on [vr0] Jul 27 01:03:17 bsd ntop[9651]: Loading Plugins Jul 27 01:03:17 bsd ntop[9651]: Searching for plugins in /usr/local/ +lib/ntop/plugins Jul 27 01:03:17 bsd ntop[9651]: ICMP: Welcome to icmpWatchPlugin. (C +) 1999-2004 by Luca Deri Jul 27 01:03:17 bsd ntop[9651]: LASTSEEN: Welcome to LastSeenWatchPl +ugin. (C) 1999 by Andrea Marangoni Jul 27 01:03:17 bsd ntop[9651]: NETFLOW: Welcome to NetFlow.(C) 2002 +-04 by Luca Deri Jul 27 01:03:17 bsd ntop[9651]: PDA: Welcome to PDAPlugin. (C) 2001- +2004 by L.Deri and W.Brock Jul 27 01:03:17 bsd ntop[9651]: RRD: Welcome to rrdPlugin. (C) 2002- +04 by Luca Deri. Jul 27 01:03:17 bsd ntop[9651]: SFLOW: Welcome to sFlow.(C) 2002-04 +by Luca Deri Jul 27 01:03:17 bsd ntop[9651]: SNMP: Welcome to snmpPlugin. (C) 200 +4 by F.Fusco and G.Giardina Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: web connections thread ( +9651) started... Jul 27 01:03:17 bsd ntop[9651]: XML: Welcome to xmldump plugin. (C) +2003-2004 by Burton Strauss Jul 27 01:03:17 bsd ntop[9651]: Note: SIGPIPE handler set (ignore) Jul 27 01:03:17 bsd ntop[9651]: Calling plugin start functions (if a +ny) Jul 27 01:03:17 bsd ntop[9651]: WEB: ntop's web server is now proces +sing requests Jul 27 01:03:17 bsd ntop[9651]: SFLOW: no devices to initialize Jul 27 01:03:17 bsd ntop[9651]: RRD: Welcome to the RRD plugin Jul 27 01:03:17 bsd ntop[9651]: RRD: Mask for new directories is 070 +0 Jul 27 01:03:17 bsd ntop[9651]: RRD: Mask for new files is 0066 Jul 27 01:03:17 bsd ntop[9651]: RRD: Started thread (145672192) for +data collection. Jul 27 01:03:17 bsd ntop[9651]: NETFLOW: no devices to initialize Jul 27 01:03:17 bsd ntop[9651]: Now running as requested user 'nobod +y' (65534:65534) Jul 27 01:03:17 bsd ntop[9651]: INIT: Created pid file (/var/db/ntop +/ntop.pid) Jul 27 01:03:17 bsd ntop[9651]: Note: Reporting device initally set +to 0 [vr0] Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: Started thread (14567270 +4) for network packet sniffing on vr0 Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: rrd thread (145672192) s +tarted Jul 27 01:03:17 bsd ntop[9651]: THREADMGMT: pcapDispatch(vr0) thread + running...
        can somene tell me pls, if is it correct now ?