linux

How to install Zabbix 6.0 on Debian 12

1.apt-get install mariadb-server
2.Setup rights for user root or zabbix or similar
3.mysql
4.create DB zabbix with collate utf8_bin
5.create user zabbix with correct rights on zabbix DB
6.apt-get install zabbix-server-mysql zabbix-frontend-php php-mysql
7./etc/init.d/mysql restart
8.a2enconf zabbix-frontend-php
9.nano /etc/php/7.3/apache2/php.ini
10.setup date.timezone in php.ini (Europe/Rome)
11.systemctl reload apache2
12.systemctl restart apache2
13.nano /etc/mysql/mariadb.conf.d/50-server.cnf
14.innodb_log_file_size = 500M
15.innodb_log_buffer_size = 800M
16.innodb_strict_mode = 0
17.cd /usr/share/zabbix-server-mysql/
18.gunzip *.gz
19.mysql -uzabbix -p zabbix < schema.sql
20.mysql -uzabbix -p zabbix < images.sql
21.mysql -uzabbix -p zabbix < double.sql
22.mysql -uzabbix -p zabbix < data.sql
23.systemctl reload apache2
24.systemctl restart apache2 25.http://zabbix
26.apt-get install zabbix-agent
27.nano /etc/zabbix/zabbix_server.conf (DBPassword)
28.systemctl enable zabbix-server
29.reboot

    HwGroup SMS-GW3

    Links:
    https://www.hw-group.com/support/how-to-send-sms-via-hwg-sms-gw3
    https://www.hw-group.com/accessory/sms-gw3

    smspreshwg-sms-gw3

    Methods of sending text messages:

    Using netGSM (SOAP – HTTP POST)
    Uploading a XML file using cURL
    Uploading a XML file using PHP
    Sending a SMS from Nagios
    Using HTTP GET
    Sending a SMS from Nagios
    Sending a SMS using Wget
    Sending a SMS using cURL
    Sending a SMS from PRTG
    Using the SNMP Write function

    Sending text messages using the netGSM protocol

    The netGSM protocol is based on SOAP; that is, sending a XML file using HTTP POST. For a description of the netGSM protocol, see: http://hw-group.us/product-version/netgsm

    In a nutshell, HTTP POST is used to send a XML file (service.xml) with the following structure:

    GsmOut

    SMS
    123456789
    Hello World!

    For a description of individual parameters, see the above-mentioned protocol description.
    Uploading a XML file using cURL

    cURL is a command-line tool to transfer data using protocols such as HTTP, FTP and more. cURL consists of two parts – the curl.exe console application, and the libcurl.dll library that implements all the curl functions.

    The library can be used for writing your own scripts (bindings are available for many languages).

    cURL is available free of charge at https://curl.haxx.se/ (https://curl.haxx.se/download.html) however, attention must be paid to choose the correct version to download.

    The 32-bit version will not work in a 64-bit Windows environment, even though it starts OK!

    cURL is started from the command line with the following command:

    curl -X POST -T service.xml 192.168.100.169

    where

    -X defines the transfer method, in this case POST
    -T specifies that a file is uploaded and what is its name (the file must be in the same folder as the curl.exe utility; otherwise, the path must be given)
    IP address is the address of HWg-SMS-GW3

    If the HWg-SMS-GW3 is secured with a username and a password, the credentials must be specified with the -u parameter:

    curl -X POST -T service.xml -u user:pass 192.168.100.169

    The response is:

    C:\Users\volmr\Desktop\curl>curl -X POST -T service.xml -u user:pass 192.168.100.169
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 375 0 0 0 0 0 0 –:–:– 0:00:01 –:–:– 0

    1
    169

    100 667 100 292 100 375 292 375 0:00:01 0:00:01 –:–:– 657

    C:\Users\volmr\Desktop\curl>

    Uploading a XML file using PHP

    PHP is one of the most popular open source web scripting language. Sending a SMS from your own website is very simple; an example script follows:

    GsmOut

    “.$type.”
    “.$nmr.”
    “.$text.”

    “;

    $fp = @fsockopen($host, $port, $errno, $errstr, 30);
    if (!$fp) {
    echo “$host:$port: $errstr ($errno)\r\n”;
    }
    else {
    fwrite($fp, “POST /service.xml HTTP/1.0\r\n”);
    fwrite($fp, “User-Agent: MyPHPTest\r\n”);
    fwrite($fp, sprintf(“Host: %s\r\n”, $host));
    fwrite($fp, sprintf(“Authorization: Basic %s\r\n”, base64_encode($user . “:” . $pass)));
    fwrite($fp, sprintf(“Content-Length: %d\r\n\r\n”, strlen($xml)));

    fwrite($fp, $xml);
    while (!feof($fp)) {
    echo fgets($fp, 128);
    }
    fclose($fp);
    }

    ?>

    Simply fill out the address, username and password for your HWg-SMS-GW3 and everything works right away. The $type, $nmr and $text variables can be of course passed from other scripts.
    Sending a SMS from Nagios

    Nagios uses scripts written in Perl. The Netways company from Germany has provided the notify-poseidon-sms.pl script that can send up to 160 characters with this command:

    ./notify-poseidon-sms.pl -H 192.0.2.10 -M “Test message” -D 123456789

    where:
    -H – (Host) IP address of HWg-SMS-GW3
    -M – (Message) message text
    -D – (Destination) recipient’s telephone number

    A limitation is that the script can only send SMS and cannot ring the recipient’s phone number; however, this can be easily changed, see e.g. notify-poseidon-call.pl (see the attachments). Also, it does not support http authentication.

    Example of use in Windows:

    C:\Users\volmr\Desktop\curl>perl notify-poseidon-sms.pl -H 192.168.100.169 -M “Hello World!” -D 777232759
    OK, message sent with ID 1 to ‘777232759’

    C:\Users\volmr\Desktop\curl>

    Sending text messages using HTTP GET

    HTTP GET is a method where all parameters are passed directly in the URL. This method is often used for simple applications because it allows for simple debugging and is easy to code. One simply invokes the address with the necessary parameters:

    values.xml?Cmd=SMS&Nmr=00420123456789&Text=Hello World!

    where:
    Values.xml – file in the GW that the command should process. It is either values.xml or service.xml
    Cmd – command that instructs what the GW should do: SMS – send a text message, CALL – ring the number
    Nmr – phone number in national or international format. It is recommended to use 00 instead of the “+” sign so that there is no need to replace the “+” with an entity
    Text – message text encoded in UTF-8

    A disadvantage is that the HTTP GET method, natively used to display WWW pages, is difficult to secure against misuse (one would need to set WWW Security, which then prevents unrestricted browsing of the HWg-SMS-GW3 web interface).

    And even then, the login credentials are sent in the URL in the open:

    http://user:pass@192.168.1.1/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello 20World!

    For these reasons, the sending of messages via HTTP GET is disabled by default, and must be manually enabled at the GSM Modem tab if it is needed:

    Sending a SMS from a web browser

    Enter the URL of HWg-SMS-GW3 including the requested commands into the address field of the web browser:

    http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello World!

    After sending, a XML confirmation appears:

    1
    2

    Sending SMS using Wget

    GNU Wget is a command-line utility that serves as a simple but powerful http client. It implements file transfer over HTTP, HTTPS and FTP protocols. It is available at https://www.gnu.org/software/wget/ and Windows versions are available at http://gnuwin32.sourceforge.net/packages/wget.htm

    Wget is very simple to use – simply enter the same command that would be entered in the browser address field. However, the entire URL must be enclosed in double quotes:

    wget “http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello World!”

    The result looks like this:

    C:\Users\volmr\Desktop\wget>wget “http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello World!”
    –2017-12-28 15:56:35– http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello%20World!
    Connecting to 192.168.100.169:80… connected.
    HTTP request sent, awaiting response… 200 Ok
    Length: unspecified [text/xml]
    Saving to: ‘values.xml@Cmd=SMS&Nmr=777232759&Text=Hello%20World!.1’

    values.xml@Cmd=SMS&Nmr=777232 [ <=> ] 118 –.-KB/s in 0s

    2017-12-28 15:56:35 (5.48 MB/s) – ‘values.xml@Cmd=SMS&Nmr=777232759&Text=Hello%20World!.1’ saved [118]

    C:\Users\volmr\Desktop\wget>

    Sending SMS using cURL

    The cURL utility is used in the same way as the wget utility. This is the command:

    curl “http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello World!”

    And this is the application’s response:

    C:\Users\volmr\Desktop\curl>curl “http://192.168.100.169/values.xml?Cmd=SMS&Nmr=777232759&Text=Hello World!”

    1
    4

    C:\Users\volmr\Desktop\curl>

    Of course, the main result is that the message is sent.
    Sending a SMS from PRTG

    PRTG Network Monitor is a complex network monitoring solution that combines Paessler’s expertise with a complete set of monitoring functions, intuitive and easy-to-use UI and the most advanced monitoring tool suitable for all types of networks.

    PRTG Network Monitor can send text messages using the HTTP GET method. The setting up only involves specifying a URL for sending the messages.

    This is done with the Enterprise Console (application or WWW interface) in Setup > System Administration > Notification Delivery. The Custom URL field should contain:

    http://IP_adresa/values.xml?Cmd=SMS&Nmr=%SMSNUMBER&Text=%SMSTEXT

    This ensures that the SMSNUMBER and SMSTEXT system variables are inserted at the correct places in the URL.

    PRTG currently does not support security using username and password!

    Sending a SMS using the SNMP Write function (snmpset)

    Starting from firmware version 1.1.3, HWg-SMS-GW3 supports the sending of SMS and dialing of numbers using SNMP. SNMP write, or more exactly SNMP SET function, is used for that purpose.

    However, it is necessary to write all the 3 required OIDs for the recipient’s number, message text and function (SMS/ring/SMS+ring). The OIDs are the following:

    msgQueueNmr (OID .1.3.6.1.4.1.21796.4.10.2.2.0) – (mandatory) Recipient’s phone number in national or international format. The international format can use either “+” or “00”.
    msgQueueCmd (OID .1.3.6.1.4.1.21796.4.10.2.3.0) – (mandatory) Action: 1=sms, 2=ring, 3=sms+ring
    msgQueueText (OID .1.3.6.1.4.1.21796.4.10.2.1.0) – (mandatory) Message text. Can be omitted if the requested action is ring only.

    In a concrete example, the individual commands could look like this:

    snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.2.0 i: 777232759
    snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.1.0 s “Hello World!”
    snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.3.0 i: 1

    When the commands are entered in the command line, the following appears:

    C:\usr\bin>snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.2.0 i: 777232759
    SNMPv2-SMI::enterprises.21796.4.10.2.2.0 = INTEGER: 777232759

    C:\usr\bin>snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.1.0 s “Hello World!”
    SNMPv2-SMI::enterprises.21796.4.10.2.1.0 = STRING: “Hello World!”

    C:\usr\bin>snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.3.0 i: 1
    SNMPv2-SMI::enterprises.21796.4.10.2.3.0 = INTEGER: 1

    C:\usr\bin>

    The command to ring the number then looks like this:

    snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.2.0 i: 777232759
    snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.3.0 i: 2

    and the response:

    C:\usr\bin>snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.2.0 i: 777232759
    SNMPv2-SMI::enterprises.21796.4.10.2.2.0 = INTEGER: 777232759

    C:\usr\bin>snmpset -v 1 -c private 192.168.100.169 1.3.6.1.4.1.21796.4.10.2.3.0 i: 2
    SNMPv2-SMI::enterprises.21796.4.10.2.3.0 = INTEGER: 2

    C:\usr\bin>

    How to install Zabbix on Debian 9

    1. apt-get install mysql-server
    2. mysql
    a. Setup rights for user root or zabbix or similar
    b. create DB zabbix with collate utf8_bin
    c. create user zabbix with correct rights on zabbix DB
    3. apt-get install zabbix-server-mysql zabbix-frontend-php php-mysql
    4. nano /etc/mysql/mysql.conf.d/mysqld.cnf
    a. setup bind setting to allow or not remote connections to DB
    5. /etc/init.d/mysql restart
    6. a2enconf zabbix-frontend-php
    7. nano /etc/php/7.2/apache2/php.ini
    a. setup date.timezone in php.ini (Europe/Rome)
    8. systemctl reload apache2
    9. cd /usr/share/zabbix-server-mysql/
    10. gunzip data.sql.gz
    11. gunzip images.sql.gz
    12. gunzip schema.sql.gz
    13. mysql -uzabbix -p zabbix < schema.sql
    14. mysql -uzabbix -p zabbix < images.sql
    15. mysql -uzabbix -p zabbix < data.sql
    16. open browser to http:///zabbix -> and follow setup instructions, download zabbix.conf.php file and copy it in the following path:
    17. mv zabbix.conf.php /etc/zabbix/
    19. chown root:root zabbix.conf.php
    20. apt-get install zabbix-agent
    21. nano /etc/zabbix/zabbix_server.conf
    a. verify DBPassword correctly reported into zabbix_server.conf file
    22. systemctl enable zabbix-server