lightning talk – zabbix-cli · lightning talk – zabbix-cli rafael martinez guerrero center for...
TRANSCRIPT
![Page 1: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/1.jpg)
Lightning Talk – ZABBIX-CLIRafael Martinez GuerreroCenter for Information Technology ServicesUniversity of Oslo
Zabbix conference 20169-10 Sep. Riga, Latvia
![Page 2: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/2.jpg)
![Page 3: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/3.jpg)
![Page 4: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/4.jpg)
![Page 5: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/5.jpg)
/usr/bin/zabbixcli/usr/bin/zabbixcliinit
![Page 6: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/6.jpg)
zabbixcliinit https://zabbix.example.org/
![Page 7: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/7.jpg)
Configuration file: $HOME/.zabbixcli/zabbixcli.conf
[.....]system_id=PRODlogging=ON[.....]
Logfile:$HOME/.zabbixcli/zabbixcli.log
![Page 8: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/8.jpg)
Interactive shell mode:
[user@host]# zabbixcli#############################################################Welcome to the Zabbix commandline interface (v.1.5.4)#############################################################Type help or \? to list commands.
[zabbixcli joshua@WOPR]$
Commandline mode:[user@host]# zabbixcli <param> C <command>[user@host]# zabbixcli help
![Page 9: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/9.jpg)
![Page 10: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/10.jpg)
help <command_name>
![Page 11: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/11.jpg)
[zabbixcli joshua@WOPR]$ show_host# Host: zabbixsrv01.uio.no# Filter: [....]
[zabbixcli joshua@WOPR]$ show_host zabbixsrv01.uio.no “”[....]
![Page 12: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/12.jpg)
[zabbixcli joshua@WOPR]$ show_host zabbix*proxy* “”[....]
[zabbixcli joshua@WOPR]$ show_alarms *ICMP* “” “” “”
[zabbixcli joshua@WOPR]$ show_alarms *ICMP* “” Rolerhel5servers,Rolerhel6servers “”
![Page 13: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/13.jpg)
[user@host]$ zabbixcli o json C “show_host zabbixsrv01.uio.no ''”{ "0": { "groups": [ { "groupid": "13", "name": "Allhosts" }, { "groupid": "94", "name": "Siteadminitdriftgdgid" },[...................] { "groupid": "108", "name": "Rolerhel7servers" } ], "host": "zabbixsrv01.uio.no", "hostid": "10001", "maintenance_status": "No maintenance (0)", [.....................]
![Page 14: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/14.jpg)
for HOST in
`zabbix-cli -o json -C "show_host *zabbix*proxy*" | jq -a '.[].host'`;
do
echo $HOST;
zabbix-cli -C "update_host_inventory $HOST type 'Zabbix proxy'";
done
![Page 15: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/15.jpg)
[user@host]$ cat zabbixbulk.txt
# HOSTGROUPScreate_hostgroup Zabbixconftest
#HOSTScreate_host zabbixconf01.example.org Zabbixconftest .* 0create_host zabbixconf02.example.org Zabbixconftest .* 0create_host zabbixconf03.example.org Zabbixconftest .* 0
# TRIGGERSlink_template_to_host Templateicmpping zabbixconf01.example.org
# DELETESremove_host zabbixconf01.example.orgremove_host zabbixconf02.example.orgremove_host zabbixconf03.example.org
[user@host]$ zabbixcli file zabbixbulk.txt
![Page 16: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/16.jpg)
Authfile: $HOME/.zabbixcli_auth
Format:USERNAME::PASSWORD
Tokenfile:$HOME/.zabbixcli_auth_tokenFormat:USERNAME::SESSION_TOKEN
● OBS: .zabbixcli_auth saves the password in plain text.● Zabbixcli saves the APIauthtoken of a session in $HOME/.zabbixcli_auth_token only if use_auth_token_file=ON is defined in the configuration file.
![Page 17: Lightning Talk – ZABBIX-CLI · Lightning Talk – ZABBIX-CLI Rafael Martinez Guerrero Center for Information Technology Services University of Oslo Zabbix conference 2016 9-10 Sep](https://reader030.vdocuments.net/reader030/viewer/2022041014/5ec5581113b08355f20aa0df/html5/thumbnails/17.jpg)
https://github.com/usitgd/zabbixcli