Table des matières

1) ZABBIX_Server

- Commandes_Utiles

Reload configuration cache on demand

 # zabbix_server -R config_cache_reload

Execute housekeeper

 # zabbix_server -R housekeeper_execute

Reload SNMP cache

 # zabbix_server -R snmp_cache_reload

Reload Vault secrets

 # zabbix_server -R secrets_reload

For all processes

 # zabbix_server -R diaginfo

For a single process or cache

 # zabbix_server -R diaginfo=historycache

2) Zabbix_Sender

- To send information to Zabbix server, it is required to specify:

 Zabbix server address  -z 	IP or DNS
 Host name  -s  	case-sensitive, visible name is not used
 Item key  -k 	case-sensitive, item name is not used
 Value  -o	 must match the type of information

# zabbix_sender -z zabbix.example.com -s “Production server” -k cron.status -o 1

- A few additional zabbix_sender parameters:

 Use "-" to read from the standard input.

# echo DB01 db.tps 10 | zabbix_sender -z 127.0.0.1 -i -

 Use "-r" to send values one by one as soon as they are received

# echo DB01 db.tps 10 | zabbix_sender -z 127.0.0.1 -r -i -

 Specify custom port using -p option

# zabbix_sender -z zabbix.example.com -h “Production server” -k cron.status -o 1 -p 20051

3) Zabbix-Agent

- Installer Agent-Zabbix-Linux

- Zabbix 6,0 LTS agent 2

 apt remove zabbix-agent
 wget https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-1%2Bdebian11_all.deb
 dpkg -i zabbix-release_6.0-1+debian11_all.deb
 apt update
 apt install zabbix-agent2
 nano /etc/zabbix/zabbix_agent2.conf
 systemctl restart zabbix-agent2

- Zabbix 5.0 LTS version (supported until May 31, 2025)

 sudo wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1+$(lsb_release -sc)_all.deb
 sudo dpkg -i zabbix-release_5.0-1+$(lsb_release -sc)_all.deb                      

- Zabbix 4.0 LTS version (supported until October 31, 2023)

 sudo wget https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-3+$(lsb_release -sc)_all.deb
 sudo dpkg -i zabbix-release_4.0-3+$(lsb_release -sc)_all.deb
 sudo apt update
 sudo apt -y install zabbix-agent

- Sur freeBSD

 Install Zabbix Agent on FreeBSD 12
 pkg update
 pkg upgrade
 pkg search zabbix | grep agent
 pkg install zabbixXX

- Configure Zabbix Agent
- Copy the sample configuration and rename it in place as;

 cp /usr/local/etc/zabbixXX/zabbix_agentd.conf{.sample,}

- Next, edit the configuration file and set the Zabbix server IP for both the passive and active checks and Zabbix agent hostname.

 vi /usr/local/etc/zabbix42/zabbix_agentd.conf
...
Server=192.168.43.62             ## IP for Zabbix Server
...
ServerActive=192.168.43.62        
...
Hostname=freebsd12.example.com
After the configuration, enable and start Zabbix agent to run on system boot.
echo 'zabbix_agentd_enable="yes"' >> /etc/rc.conf
service zabbix_agentd start
To check the status;
service zabbix_agentd status
- Paramètres
Server=192.168.5.43
ServerActive=192.168.5.43
Hostname=host.domaine.com
HostMetadata=Linux
HostnameItem=system.hostname
Tmeout=10
- Commandes
Use Zabbix agent runtime command userparameter_reload:
# zabbix_agentd -R userparameter_reload

4) Zabbix_Macro

System macros {MACRO} User defined macros {$MACRO} Low-level discovery macros {#MACRO} Expression macros {?MACRO}

5) Zabbix_API

- Get_Token

 Curl -s -k -X POST -H 'Content-Type: application/json-rpc' -d '{ "params": { "user": "svc_zabbixapi", "password": "PASS" }, "jsonrpc": "2.0", "method": "user.login", "id": 0 }' 'https://10.1.1.71/zabbix/api_jsonrpc.php'| grep "result" | cut -d '"' -f 8

- Extract_Host-+-Services

 curl -s  -H "Content-Type: application/json-rpc" -X POST http://10.0.66.1/zabbix/api_jsonrpc.php -d '{"jsonrpc":"2.0","method":"host.get","id":1,"auth":"8066c5a8a558dc576e73b3064c1a2b5b","params" : {"selectGroups": "extend","selectInterfaces": "extend","selectItems": "extend","output": ["dns","name"]}}' | jq '.' | grep -Eo '"name": .*|"ip": .*' > /tmp/full-gie.txt
 

6) Autres commandes

Count_Hosts-and-Items_Zabbix

Liste NB hosts et items Orsay

SELECT COUNT(DISTINCT  hosts.name) FROM hosts JOIN hosts_groups ON hosts.hostid = hosts_groups.hostid JOIN hstgrp ON hosts_groups.groupid = hstgrp.groupid JOIN items ON items.hostid = hosts.hostid WHERE hstgrp.name IN ('G_APWIFI','G_GTC','G_BAIE_DISQUES','G_CERTIFICATS','G_ECRANS','G_PROD-LINUX','G_PROD-WINDOWS','G_RESEAU','G_SWITCHS','G_VLANS','G_VSPHERE','G_WEBSERVICES','ILO');
SELECT COUNT (DISTINCT items.name) from hosts JOIN hosts_groups ON hosts.hostid = hosts_groups.hostid JOIN hstgrp ON hosts_groups.groupid = hstgrp.groupid JOIN items ON items.hostid = hosts.hostid WHERE hstgrp.name IN ('G_APWIFI','G_GTC','G_BAIE_DISQUES','G_CERTIFICATS','G_ECRANS','G_PROD-LINUX','G_PROD-WINDOWS','G_RESEAU','G_SWITCHS','G_VLANS','G_VSPHERE','G_WEBSERVICES','ILO');

Avaya-OID

Avaya OID

OID	Name	Sub children	Sub Nodes Total	Description
1.3.6.1.4.1.45.1.6.3.8.1.1.1	s5ChasUtilGrpIndx	0	0	The index of the chassis level group which
contains this component, corresponds to
s5ChasComGrpIndx.
1.3.6.1.4.1.45.1.6.3.8.1.1.2	s5ChasUtilIndx	0	0	The index of the component in the group.
Corresponds to s5ChasComIndx.
1.3.6.1.4.1.45.1.6.3.8.1.1.3	s5ChasUtilSubIndx	0	0	Sub-component index. Corresponds to
s5ChasComSubIndx.
1.3.6.1.4.1.45.1.6.3.8.1.1.4	s5ChasUtilTotalCPUUsage	0	0	This object returns the percentage of time the CPU has been
busy since system initialization.
1.3.6.1.4.1.45.1.6.3.8.1.1.5	s5ChasUtilCPUUsageLast1Minute	0	0	This object returns the percentage of time the CPU has been
busy over the last 1 minute.
1.3.6.1.4.1.45.1.6.3.8.1.1.6	s5ChasUtilCPUUsageLast10Minutes	0	0	This object returns the percentage of time the CPU has been
busy over the last 10 minutes.
1.3.6.1.4.1.45.1.6.3.8.1.1.7	s5ChasUtilCPUUsageLast1Hour	0	0	This object returns the percentage of time the CPU has been
busy over the last 1 hour.
1.3.6.1.4.1.45.1.6.3.8.1.1.8	s5ChasUtilCPUUsageLast24Hours	0	0	This object returns the percentage of time the CPU has been
busy over the last 24 hours.
1.3.6.1.4.1.45.1.6.3.8.1.1.9	s5ChasUtilMemoryAvailable	0	0	This object returns the percentage of dynamic memory that
is currently free. This is measured as a percentage of
the memory the …
1.3.6.1.4.1.45.1.6.3.8.1.1.10	s5ChasUtilMemoryMinAvailable	0	0	This object returns the lowest percentage of dynamic
memory that has been free since system initialization.
This is a 'low-water …
1.3.6.1.4.1.45.1.6.3.8.1.1.11	s5ChasUtilCPUUsageLast10Seconds	0	0	This object returns the percentage of time the CPU has been
busy over the last 10 seconds.
1.3.6.1.4.1.45.1.6.3.8.1.1.12	s5ChasUtilMemoryTotalMB	0	0	This object returns the total RAM of unit.
1.3.6.1.4.1.45.1.6.3.8.1.1.13	s5ChasUtilMemoryAvailableMB	0	0	This object returns the available RAM of unit.

echo $(snmpwalk -Os -c public -v 2c 10.10.1.86 1.3.6.1.4.1.45.1.6.3.7.1.1.5) | awk '{print $4/2}'

Config-alertes-disk-windows

{T_PROD-WINDOWS:vfs.fs.size[{#FSNAME},pfree].last(0)}<5 and {T_PROD-WINDOWS:vfs.fs.size[{#FSNAME},free].last(0)} < 128000000

{T_PROD-WINDOWS:vfs.fs.size[{#FSNAME},pfree].last(0)}<10 and {T_PROD-WINDOWS:vfs.fs.size[{#FSNAME},free].last(0)} < 2560000000 and {T_PROD-WINDOWS:vfs.fs.size[{#FSNAME},pfree].last()}>=5

{T_PROD-WINDOWS:vfs.fs.size[{#FSNAME},pfree].last(0)}<20 and {T_PROD-WINDOWS:vfs.fs.size[{#FSNAME},free].last(0)} < 5120000000 and {T_PROD-WINDOWS:vfs.fs.size[{#FSNAME},pfree].last()}>=10