Ein praktischer Leitfaden zur Begrenzung der Bandbreite in QRadar-Netzdiagramm
Der Bandbreitenmanager in IBM® QRadar ® nutzt die Warteschlangendisziplin "Hierarchical Token Bucket" (HTB), die im Linux -Kernel angeboten wird. Für spezielle oder erweiterte Nutzung gibt es viele Seiten im Internet, die beschreiben, was es ist und wie es funktioniert, einschließlich:
Bevor Sie beginnen, müssen Sie zuerst die Datei bandwidthManagerCLI.sh optimieren, um die Position von buildcpath zu ändern. Geben Sie edit /opt/qradar/bin/bandwidthManagerCLI.shein, um die Datei bandwidthManagerCLI.sh zu bearbeiten. Ändern Sie die dritte Zeile in der Datei in /opt/qradar/systemd/bin/buildcpath. Speichern und schließen Sie die Datei.
Bandbreitenmanager-Hilfe und Nutzung
Der folgende Codeausschnitt listet die Nutzung des Bandbreitenmanagers auf:
[root@m5arch06 ~]# /opt/qradar/bin/bandwidthManagerCLI.sh
usage: BandwidthManagerCLI -a <ACTION>
-a,--action The desired action. Recognized Actions: help, add_class, add_egress_filter,
delete_class, delete_egress_filter
usage: add_class <OPTIONS>
-i,--hostID The managed host ID which uniquely identifies the host. You can optionally
use '-1' to indicate you wish this to be applied to all hosts in the deployment
-n,--name A user-friendly name for the new configuration
-c,--classID The desired class ID of the class to be added
-d,--device The device name (e.g. eth0) which this configuration will apply to. You can
optionally use '*' to indicate you wish to be applied to all devices
-h,--hostname The managed host host name. Can be used when you don't provide the host ID
-k,--kbpsLimit The rate limit to be applied against the class in kilobytes/sec
-p,--parentID The parent ID for this class
-q,--qdiscID The desired queuing discipline ID of the egress filter to be added
usage: add_egress_filter <OPTIONS>
-i,--hostID The managed host ID which uniquely identifies the host. You can
optionally use '-1' to indicate you wish this to be applied to all hosts in the deployment
-n,--name A user-friendly name for the new configuration
-P,--protocol The protocol for the new configuration
-d,--device The device name (e.g. eth0) which this configuration will apply to.
You can optionally use '*' to indicate you wish to be applied to all devices
-dc,--dstCIDR [Optional] The destination CIDR for the egress filter
-dport,--dstPort [Optional] The destination port for the egress filter
-dportm,--dstPortMask [Optional] The destination port mask for the egress filter. If not
provided, 0xffff will be used (meaning match only that port)
-f,--filterID The desired filter ID to be assigned to the new egress filter
-fl,--flowID The filter's target flow ID (which represents the minor ID of a
class or qdisc). Traffic matched by this filter with go to that location
-fp,--filterPriority The fitler's priority relative to others attached to the same parent
(lower number is higher priority)
-h,--hostname The managed host host name. Can be used when you don't provide the
host ID
-ma,--matchAll [Optional] If "true", the filter that is created will match *all*
incoming packets at its priority level.
-p,--parentID The parent ID for this egress filter
-q,--qdiscID The desired queuing discipline ID of the egress filter to be added
-sc,--sourceCIDR [Optional] The source CIDR for the egress filter
-sport,--srcPort [Optional] The source port for the egress filter
-sportm,--srcPortMask [Optional] The source port mask for the egress filter. If not
provided, 0xffff will be used (meaning match only that port)
usage: delete_class <OPTIONS>
-i,--hostID The managed host ID which uniquely identifies the host. You can optionally
use '-1' to indicate you wish this to be applied to all hosts in the deployment
-c,--classID The class ID to class to delete
-d,--device The device name (e.g. eth0) of the configuration to be deleted
-h,--hostname The managed host host name. Can be used when you don't provide the host ID
-q,--qdiscID The queuing discipline ID of the class you wish to delete
usage: delete_egress_filter <OPTIONS>
-i,--hostID The managed host ID which uniquely identifies the host. You can optionally
use '-1' to indicate you wish this to be applied to all hosts in the deployment
-d,--device The device name (e.g. eth0) of the configuration to be deleted
-f,--filterID The filter ID of the filter to delete
-h,--hostname The managed host host name. Can be used when you don't provide the host ID
[root@m5arch06 ~]#
Terminologie
- Klassen
Definieren Sie Blöcke mit Bandbreitenmindestwerten und Maximalwerten. Sie sind in einer Baumstruktur angeordnet. Sie haben beispielsweise einen 10-Mbit-Link, der von QRadar-Netzdiagramm und anderen Anwendungen gemeinsam genutzt wird. Sie möchten sicherstellen, dass QRadar-Netzdiagramm nie mehr als 5 Mbit/s verwendet, damit die Verbindung nicht gesättigt wird. Sie definieren eine Klasse für den gesamten Datenverkehr, der auf 5 Mbit/s begrenzt ist, und können diese dann weiter unterteilen, damit Ihre PostgreSQL -Replikation die Suchleistung nicht beeinträchtigt.
- Filter
Wählen Sie den Netzverkehr aus, der in jedem dieser Klassenplatziert wird. In der Regel von IP/Protokoll/Port-Kombinationen durchgeführt, sind die Filter bemerkenswert flexibel und erlauben eine sehr feine Granularität-für unsere Zwecke werden wir mit den einfachen IP/Protokoll/Port-Kombinationen bleiben.
Cookbook-Beispiele
Alle Befehle werden auf der Konsole ausgeführt-keine Ausführung auf einem verwalteten Host erforderlich. Sie geben in der bandwidthManagerCLI.sh -Befehlszeile an, auf welchen Host die Änderung angewendet werden soll.
Beispiel: Verlangsamung der Replikation auf einen Host (gesamter Datenverkehr an Port 443-vorausgesetzt, nicht verschlüsselt)
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_class -h m5arch06 -n SlowReplication -c 1 -q 30 -p 0 -k 10 -d eno1
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch06 -n MatchHttps -d eno1 -dc 192.0.2.0/32 -f 2 -fl 1 -fp 1 -p 0 -q 30 -sport 443 -P tcp
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch06 -n MatchHttps -d eno1 -dc 192.0.2.0/32 -f 3 -fl 3 -fp 1 -p 0 -q 1 -sport 443 -P tcp
….
2750K .......... .......... .......... .......... .......... 4% 9.02K 1h45m
2800K .......... .......... .......... .......... .......... 4% 9.68K 1h45m
2850K .......... .......... .......... .......... .......... 4% 9.51K 1h45m
2900K .......... .......... .......... .......... .......... 4% 8.14K 1h45m
2950K .......... .......... .......... .......... .......... 5% 9.00K 1h45m
3000K .......... .......... .......... .......... .......... 5% 9.00K 1h45m
3050K .......... .......... .......... .......... .......... 5% 9.99K 1h44m
…..
Raten sind ungefähr (und nicht mehr als) 10 Kbyte/Sekunde.
Um zu testen, ob die Regulierung in der Konsole stattfindet, sehen Sie sich die Ausgabe der von Ihnen eingerichteten Klasse an:
[root@m5arch06 ~]# tc -s class ls dev eno1 classid 30:1
class htb 30:1 root prio 1 rate 80000bit ceil 80000bit burst 1600b cburst 1600b
Sent 8579563 bytes 7315 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 3p requeues 0
lended: 4682 borrowed: 0 giants: 0
tokens: -4730822 ctokens: -4730822
[root@m5arch06 ~]#
Geben Sie die folgenden Befehle ein, um die Bandbreitenregeln zu entfernen:
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch06 -d eno1 -f 2
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch06 -d eno1 -f 3
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_class -h m5arch06 -c 1 -q 30 -d eno1
Beispiel: Die gesamte Bandbreite zwischen der Konsole und einem verwalteten Host begrenzen
Die Bandbreite wird auf der Konsole und in der folgenden Konfiguration überwacht:
- m5arch06 (198.51.100.0) ist die Konsole.
- m5arch07 (192.0.2.0) ist der verwaltete Host.
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_class -h m5arch06 -n SlowCommunicationToHost -c 1 -q 30 -p 0 -k 10 -d eno1
Fügen Sie Filter hinzu, die der Klasse und der Warteschlangendisziplin entsprechen, indem Sie den folgenden Befehl eingeben:
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch06 -n MatchToIP -d eno1 -dc 192.0.2.0/32 -f 2 -fl 1 -fp 1 -p 0 -q 30 -P tcp
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch06 -n MatchToIP -d eno1 -dc 192.0.2.0/32 -f 3 -fl 3 -fp 1 -p 0 -q 1 -P tcp
Geben Sie den folgenden Befehl ein, wenn Sie die Bandbreite auf dem verwalteten Host drosseln möchten (beachten Sie die Änderung an hostname , für die diese gelten, und an der Ziel-CIDR):
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_class -h m5arch07 -n SlowCommunicationToHost -c 1 -q 30 -p 0 -k 10 -d eno1
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch07 -n MatchToIP -d eno1 -dc 198.51.100.0/32 -f 2 -fl 1 -fp 1 -p 0 -q 30 -P tcp
/opt/qradar/bin/bandwidthManagerCLI.sh -a add_egress_filter -h m5arch07 -n MatchToIP -d eno1 -dc 198.51.100.0/32 -f 3 -fl 3 -fp 1 -p 0 -q 1 -P tcp
Geben Sie zum Löschen von der Konsole und vom verwalteten Host den folgenden Befehl ein:
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch06 -d eno1 -f 2
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch06 -d eno1 -f 3
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_class -h m5arch06 -c 1 -q 30 -d eno1
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch07 -d eno1 -f 2
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_egress_filter -h m5arch07 -d eno1 -f 3
/opt/qradar/bin/bandwidthManagerCLI.sh -a delete_class -h m5arch07 -c 1 -q 30 -d eno1
Beispiel: Änderungen über SQL und Poking-MBeans hinzufügen, damit die Änderungen wirksam werden (etwas schneller und scriptfähiger)
In diesem Beispiel wird dieselbe Konfiguration wie im ersten Beispielverwendet, aber es wird in PostgreSQL eingefügt, anstatt darauf zu warten, dass der Bandbreitenmanager Frameworks initialisiert und alle erforderlichen Schritte für uns ausgeführt werden.
- Die Tabelle bandwidth_configuration enthält alle Klassen-/Bandbreiteninformationen:
qradar=# \d bandwidth_configurationTable "public.bandwidth_configuration" Column | Type | Modifiers ----------------+------------------------+------------------------------------------------------------ sequenceid | bigint | not null default nextval('bandwidth_configuration_seq'::regclass) appname | character varying(100) | not null mh_id | bigint | not null device | character varying(100) | not null qdisc_id | integer | not null class_id | integer | not null parent_id | integer | not null bandwidth_kbps | bigint | not null created_by | character varying(100) | - Der Filter bandwidth_egress_filter enthält alle Filter:
qradar=# \d bandwidth_egress_filterTable "public.bandwidth_egress_filter" Column | Type | Modifiers -----------------+------------------------+----------------------------------------------------------- sequenceid | bigint | not null default nextval('bandwidth_egress_filter_seq'::regclass) appname | character varying(100) | not null mh_id | bigint | not null device | character varying(100) | not null qdisc_id | integer | not null parent_id | integer | not null filter_id | integer | not null flow_id | integer | not null filter_priority | integer | not null src_port | integer | src_port_mask | integer | src_cidr | character varying(45) | dst_port | integer | dst_port_mask | integer | dst_cidr | character varying(45) | match_all | boolean | not null default false created_by | character varying(100) | protocol | character varying(4) |
Bei Verwendung der Konfiguration aus Beispiel 1wird eine SQL angezeigt, die wie das folgende Snippet aussieht:
INSERT INTO bandwidth_configuration (appname, mh_id, device, qdisc_id, class_id, parent_id, bandwidth_kbps, created_by) VALUES ('SlowReplication', 53, 'eno1', 30, 1, 0, 10, 'SQL_Insert');
INSERT INTO bandwidth_egress_filter (appname, mh_id, device, qdisc_id, parent_id, filter_id, flow_id, filter_priority, src_port, src_port_mask, dst_cidr, created_by, protocol) VALUES ('MatchHttps', 53, 'eno1', 30, 0, 2, 1, 1, 443, 65535, '192.0.2.0/32', 'SQL_Insert', 'ip');
INSERT INTO bandwidth_egress_filter (appname, mh_id, device, qdisc_id, parent_id, filter_id, flow_id, filter_priority, src_port, src_port_mask, dst_cidr, created_by, protocol) VALUES ('MatchHttps', 53, 'eno1', 1, 0, 3, 3, 1, 443, 65535, '192.0.2.0/32', 'SQL_Insert', 'ip');
Jetzt wird die MBean gepoke und ihre Konfiguration aktualisiert:
[root@m5arch06 ~]# /opt/qradar/support/jmx.sh 7778 'com.q1labs.hostcontext.bm:application=hostcontext.hostcontext,type=BandwidthManager' reloadConfig
Invoking operation: reloadConfig ( )
Result: true
[root@m5arch06 ~]#
Und voilà! Die Klasse ist zurück:
[root@m5arch06 ~]# tc class ls dev eno1
class prio 1:1 parent 1: leaf 10:
class prio 1:2 parent 1: leaf 20:
class prio 1:3 parent 1: leaf 30:
class prio 1:4 parent 1: leaf 40:
class prio 1:5 parent 1: leaf 50:
class prio 1:6 parent 1: leaf 60:
class prio 1:7 parent 1: leaf 70:
class htb 30:1 root prio 1 rate 80000bit ceil 80000bit burst 1600b cburst 1600b
[root@m5arch06 ~]#
Dann löschen wir die Einträge in der Datenbank und laden erneut:
[root@m5arch06 ~]# psql -U qradar -c "DELETE from bandwidth_configuration"
DELETE 1
[root@m5arch06 ~]# psql -U qradar -c "DELETE from bandwidth_egress_filter"
DELETE 2
[root@m5arch06 ~]# /opt/qradar/support/jmx.sh 7778 'com.q1labs.hostcontext.bm:application=hostcontext.hostcontext,type=BandwidthManager' reloadConfig
Invoking operation: reloadConfig ( )
Result: true
[root@m5arch06 ~]#
Und voilà! Die Klasse wird wieder ausgeblendet:
[root@m5arch06 ~]# tc class ls dev eno1
class prio 1:1 parent 1: leaf 10:
class prio 1:2 parent 1: leaf 20:
class prio 1:3 parent 1: leaf 30:
class prio 1:4 parent 1: leaf 40:
class prio 1:5 parent 1: leaf 50:
class prio 1:6 parent 1: leaf 60:
class prio 1:7 parent 1: leaf 70:
[root@m5arch06 ~]#