@@ -8,13 +8,15 @@ import (
88 "fmt"
99 "os"
1010 "os/exec"
11+ "strconv"
1112 "strings"
1213 "time"
1314
1415 "github.com/go-ini/ini"
1516 _ "github.com/go-sql-driver/mysql" // Keep anonymous import for side effects
1617 _mysql "github.com/go-sql-driver/mysql" // Import with alias
1718 "github.com/monobilisim/monokit/common"
19+ issues "github.com/monobilisim/monokit/common/redmine/issues"
1820 "github.com/rs/zerolog/log"
1921)
2022
@@ -554,6 +556,87 @@ func CheckCertificationWaiting() {
554556 }
555557}
556558
559+ func CheckReceiveQueue () {
560+ limit := 10
561+ if DbHealthConfig .Mysql .Cluster .Receive_queue_limit != 0 {
562+ limit = DbHealthConfig .Mysql .Cluster .Receive_queue_limit
563+ }
564+
565+ query := "SHOW GLOBAL STATUS WHERE Variable_name = 'wsrep_local_recv_queue'"
566+ rows , err := Connection .Query (query )
567+ if err != nil {
568+ log .Error ().Err (err ).Msg ("CheckReceiveQueue query failed" )
569+ return
570+ }
571+ defer rows .Close ()
572+
573+ var name string
574+ var value string
575+ if rows .Next () {
576+ if err := rows .Scan (& name , & value ); err != nil {
577+ log .Error ().Err (err ).Msg ("Error scanning Receive Queue count" )
578+ return
579+ }
580+ }
581+
582+ count , _ := strconv .Atoi (value )
583+
584+ // Update health data
585+ healthData .ClusterInfo .ReceiveQueue .Count = count
586+ healthData .ClusterInfo .ReceiveQueue .Limit = limit
587+ healthData .ClusterInfo .ReceiveQueue .Exceeded = count > limit
588+
589+ if count > limit {
590+ msg := fmt .Sprintf ("Galera Receive Queue değeri %d (Limit: %d)" , count , limit )
591+ // Only send alarm (webhook), no Redmine issue for Receive Queue as requested
592+ common .AlarmCheckDown ("receive queue" , msg , false , "" , "" )
593+ } else {
594+ common .AlarmCheckUp ("receive queue" , fmt .Sprintf ("Receive Queue OK: %d/%d" , count , limit ), false )
595+ }
596+ }
597+
598+ func CheckFlowControl () {
599+ threshold := 0.2
600+ if DbHealthConfig .Mysql .Cluster .Flow_control_limit != 0 {
601+ threshold = DbHealthConfig .Mysql .Cluster .Flow_control_limit
602+ }
603+
604+ query := "SHOW GLOBAL STATUS WHERE Variable_name = 'wsrep_flow_control_paused'"
605+ rows , err := Connection .Query (query )
606+ if err != nil {
607+ log .Error ().Err (err ).Msg ("CheckFlowControl query failed" )
608+ return
609+ }
610+ defer rows .Close ()
611+
612+ var name string
613+ var value string
614+ if rows .Next () {
615+ if err := rows .Scan (& name , & value ); err != nil {
616+ log .Error ().Err (err ).Msg ("Error scanning Flow Control Paused value" )
617+ return
618+ }
619+ }
620+
621+ paused , _ := strconv .ParseFloat (value , 64 )
622+
623+ // Update health data
624+ healthData .ClusterInfo .FlowControlPaused = paused
625+ healthData .ClusterInfo .FlowControlLimit = threshold
626+
627+ if paused > threshold {
628+ msg := fmt .Sprintf ("Galera Flow Control duraklama oranı %.4f (Limit: %.2f)" , paused , threshold )
629+ subject := fmt .Sprintf ("%s için Galera Flow Control duraklama oranı %.2f üstüne çıktı" , common .Config .Identifier , threshold )
630+
631+ common .AlarmCheckDown ("flow control" , msg , false , "" , "" )
632+ issues .CheckDown ("flow-control" , subject , msg , false , 0 )
633+ } else {
634+ msg := fmt .Sprintf ("%s için Galera Flow Control duraklama oranı %.2f altına düştü" , common .Config .Identifier , threshold )
635+ common .AlarmCheckUp ("flow control" , "Flow Control OK" , false )
636+ issues .CheckUp ("flow-control" , msg )
637+ }
638+ }
639+
557640func checkPMM () {
558641 // Check if PMM monitoring is enabled in config (default: enabled)
559642 if DbHealthConfig .Mysql .Pmm_enabled != nil && ! * DbHealthConfig .Mysql .Pmm_enabled {
0 commit comments