Make sure that the files have the zabbix user/group and are executable.
# chown zabbix:zabbix /usr/lib/zabbix/externalscripts/*# chmod +x /usr/lib/zabbix/externalscripts/*.shThe Zabbix user cannot login to the bash by default. We need to enable it as follows (if not already done in RZA6).
usermod --shell /bin/bash zabbixIf not already created, create the HOME directory for the Zabbix user.
usermod -m -d /var/lib/zabbix zabbixchown zabbix:zabbix /var/lib/zabbixchmod 755 /var/lib/zabbixCreate the directories for the saved configuration and firmware files and change the access rights.
mkdir /var/lib/zabbix/configuration-backupmkdir /var/lib/zabbix/configuration-backup/raymkdir /var/lib/zabbix/firmwaremkdir /var/lib/zabbix/firmware/ray3chown -R zabbix:zabbix /var/lib/zabbix/The directory for the SSH key should now be located in /var/lib/zabbix/.ssh directory. Change the current directory to this one and login as zabbix.
su zabbixA new prompt appears. We need to upload the SSH keys into every unit we want to control. You can either have you own RSA/DSA key or you can create a new one following this example. Run
ssh-keygen -t rsaFollow the guide of the ssh-keygen application and leave the passphrase empty. To copy our RSA key into RAy3 units, copy the public part of the key and run the following command:
ssh admin@192.168.132.200Just replace 192.168.132.200 with the correct RAy3 IP address. The prompt will ask for the admin password, fill it in and click Enter. Now, you should be logged in RAy3 CLI. Run the following command:
vi .ssh/authorized_keys | Note |
Browse the Internet for how to use ‘vi’ text editor if you are in trouble. |
" N/ n6 ~% k# Z+ v) _5 LInsert (paste) your public part of the key to a new line. Save the changes and close the file. Logout and check, if you can access the unit without a password.
ssh -i rsa admin@192.168.132.200We completed all Linux tasks, but we still need to edit Zabbix web interface.
Scripts must be manually created in the Zabbix Administration – Scripts menu. See the example below and create Zabbix scripts for RAy3 units.
0 J4 {4 Y7 ]& l5 x9 {0 p* [/ a3 x6 C" u, l, I, j# z6 [ {6 _: @+ [
Fig. 3.22: RAy3 scripts in Zabbix
; C3 G' ?: w6 R2 ]1 @5 S( m4 v- b/ W5 E g$ [# f
If you open one of them, you can modify them as required. If you do not have any, you need to create them from scratch.
Configuration backup – the script creates a configuration backup file in /var/lib/zabbix/configuration-backup/ray/ directory. The name is taken from RAy3 S/N and Ethernet IP.
I5 G/ H- @% Z, I) b5 u# C- L- N8 t% X; T- m: b* ~
Fig. 3.23: RSS sample script details
% V9 S. b# S4 W- t3 V
3 p+ p+ G* c+ v, _& v+ BName: RAy3 Configuration backup
Scope: Manual host action
Menu path: RAy3
Type: Script
Execute on: Zabbix server
Commands:
/usr/lib/zabbix/externalscripts/ray_cli_cnf_backup_get.sh {HOST.CONN} {$HOST_SSHKEY} {$HOST_SSHPORT} 2>>/usr/lib/zabbix/externalscripts/script-log.txt
) u8 G/ ?( I; b
0 u+ X. a5 V2 J, `" d5 R& j
Set other parameters to suit your needs.
Displaying firmware version – the script reads a current FW version installed in RAy3 unit.
All is the same, except the “Commands” parameter:
/usr/lib/zabbix/externalscripts/ray_cli_fw_show.sh {HOST.CONN} {$HOST_SSHKEY} {$HOST_SSHPORT} 2>>/usr/lib/zabbix/externalscripts/script-log.txt
Upgrading firmware version – the script uploads a firmware file and a special CLI script into local RAy3 unit which is then executed and FW of both units within the link are upgraded. The script command is:
/usr/lib/zabbix/externalscripts/ray_cli_fw_upgrade.sh {HOST.CONN} {$HOST_SSHKEY} {$HOST_SSHPORT} “/var/lib/zabbix/firmware/ray3/ray3-fw-2.0.3.0.cpio” “2.0.3.0” 2>>/usr/lib/zabbix/externalscripts/script-log.txt
The parameters are MACROs which should be enabled by default due to our Template. Each RAy3 unit uses the SSH port 22 and the SSH key saved in /var/lib/zabbix/.ssh/rsa file by default. If you need to modify any of these parameters, go to the Configuration – Hosts menu and edit the particular Host’s MACROs.
/ d# `; S0 y- W( Y! t1 W% ?
/ [7 Q7 ?* [& S' B+ f; t0 {- y
Fig. 3.24: Host MACROs
1 p2 b& I$ ?: B* u0 h
7 E; ^( _ \+ t+ J$ o$ _6 \+ q
- F7 x' ]4 c$ }( d
/ u7 p d z. o# ?1 g/ d& a, MFig. 3.25: RAy3 scripts – map
' o$ l" x9 v: N8 n/ C! b- c0 Q! G3 F" ~
The easiest script displays the FW version.
# W& F+ h# i; Z9 i- k- ?5 \: r& i
( x S( y1 z) z3 n6 v0 s$ Z5 _3 Z0 fFig. 3.26: Displaying FW version script output
5 J" K/ N( h4 k2 O n& x! M% k3 u& ~
/ b( m) u% f$ S; O9 f8 M& RAnother script is the Configuration backup. The expected output should display a full path to the stored file.
8 E$ p; d0 Z7 O |4 Q' |9 F
, ]' w3 E- Q2 F! E8 M7 { ]Fig. 3.27: RAy3 Configuration backup script output
' I1 X7 Y7 _% C: i& P) U, d; L# [8 S0 u5 Y9 [$ l
The last script should be first tested and verified in RAy3 units/links which are e.g., on your desk so that you double-check a correct behaviour.