]> jfr.im git - irc/SurrealServices/srsv.git/commitdiff
another go at flood warnings. blame tabris and alucard
authortabris <redacted>
Sun, 16 Jun 2013 00:56:52 +0000 (00:56 +0000)
committertabris <redacted>
Sun, 16 Jun 2013 00:56:52 +0000 (00:56 +0000)
git-svn-id: http://svn.tabris.net/repos/srsv@3612 70d4eda1-72e9-0310-a436-91e5bd24443c

branches/0.4.3/SrSv/IRCd/Event.pm

index 8866b8d5949ff021a3a06bd2b08161e27fbb9bb2..56fe7baaf7d37cf93323bfc8d51c41151c7ae567 100644 (file)
@@ -55,6 +55,8 @@ sub addhandler($$$$;$) {
 }
 
 our $last_highqueue = time();
+our $highest_queue_highwater = 0;
+our $highest_queue_lowwater = 0;
 sub callfuncs {
        my ($args, $sync, $wf, $message);
 
@@ -79,16 +81,24 @@ sub callfuncs {
                ARGS => $args,
                ON_FINISH => ($sync ? undef : 'SrSv::IRCd::Queue::finished'), # FIXME
                SYNCED => [synced, initial_synced],
-               QUEUE_DEPTH_HIGHPRIO => SrSv::IRCd::Queue::queue_size(WF_ALL),
-               QUEUE_DEPTH => SrSv::IRCd::Queue::queue_size(WF_MAX), # but not WF_MSG
+               QUEUE_DEPTH_HIGHPRIO => SrSv::IRCd::Queue::queue_size(WF_ALL), # but not WF_MSG
+               QUEUE_DEPTH => SrSv::IRCd::Queue::queue_size(WF_MAX),
        };
        if(initial_synced && ($message->{QUEUE_DEPTH_HIGHPRIO} > main_conf_queue_lowwater) && ($last_highqueue < time()-5)) {
+               my $queue_depth = $message->{QUEUE_DEPTH_HIGHPRIO};
                ircd::privmsg_noloop(main_conf_local, main_conf_operchan, "HIGH TRAFFIC WARNING",
-                       "Queue depth exceeded @{[main_conf_queue_lowwater]}") if defined(main_conf_operchan);
+                       "Queue depth exceeded: $queue_depth > @{[main_conf_queue_lowwater]}") if defined(main_conf_operchan);
                ircd::privmsg_noloop(main_conf_local, main_conf_diag, "HIGH TRAFFIC WARNING",
-                       "Queue depth exceeded @{[main_conf_queue_lowwater]}");
+                       "Queue depth exceeded: $queue_depth > @{[main_conf_queue_lowwater]}");
                $last_highqueue = time();
        }
+       if($message->{QUEUE_DEPTH_HIGHPRIO} > $highest_queue_lowwater) {
+               $highest_queue_lowwater = $message->{QUEUE_DEPTH_HIGHPRIO};
+       }
+       if($message->{QUEUE_DEPTH} > $highest_queue_highwater) {
+               $highest_queue_highwater = $message->{QUEUE_DEPTH};
+       }
+
 
        if($sync) {
                message($message);
@@ -97,6 +107,24 @@ sub callfuncs {
        }
 }
 
+#FIXME: need an Event->timer call here.
+sub check_highqueue() {
+       my @msgs;
+       if($highest_queue_highwater > main_conf_queue_highwater) {
+               push @msgs, "Highest full queue depth: $highest_queue_highwater";
+       }
+       if($highest_queue_lowwater > main_conf_queue_lowwater) {
+               push @msgs, "Highest main queue depth: $highest_queue_lowwater";
+       }
+       if(scalar @msgs) {
+               ircd::privmsg_noloop(main_conf_local, main_conf_diag, @msgs);
+               ircd::privmsg_noloop(main_conf_local, main_conf_operchan, @msgs)
+                       if defined(main_conf_operchan);
+       }
+
+       $highest_queue_highwater = $highest_queue_lowwater = 0;
+}
+
 sub _realcall($$) {
        no strict 'refs';