Sending in the data

Now is the time to send in our data, which will be a bit fake. As mentioned, IT services/SLA functionality is more interesting when we have data for a longer period of time, and we could try to send in data for a year. Of course, we won't create it manually—we'll generate it. Create a script like this on the Zabbix server:

#!/bin/bash 
hostname="IT services" 
time_period=$[3600*24*365] # 365 days 
interval=3600 # one hour 
probability=100 
current_time=$(date "+%s") 
for item_key in code_repo warehouse_analytics ticketing; do 
        [[ -f $item_key.txt ]] && { 
                echo "file $item_key.txt already exists" 
                exit 
        } 
        for ((value_timestamp=$current_time-$time_period;             value_timestamp<$current_time;             value_timestamp=value_timestamp+$interval)); do 
                echo ""$hostname" $item_key $value_timestamp                 $([[ $(($RANDOM%$probability)) < 1 ]] && echo 0 ||                 echo 1)" >> $item_key.txt 
        done 
done 

This script will generate values for each of our three item keys every hour, for one year in the past, starting at the current time. For each entry, there's a small chance of getting a value of 0, which is failure. The result will be random, but it should fluctuate around our acceptable SLA level, so hopefully we'll get some services that do meet the SLA level and some that don't. As all of the values are sent in with a one-hour interval and it's quite unlikely that two failures would follow one another, no downtime should be longer than one hour. Assuming the script was saved as generate_values.sh, you just have to run it once:

$ ./generate_values.sh 

Three files should be generated:

  • code_repo.txt
  • ticketing.txt
  • warehouse_analytics.txt
The following could generate quite a lot of alert emails. If you would like to avoid that, disable the actions we added earlier.

Now run zabbix_sender for each of these files:

$ zabbix_sender -z 127.0.0.1 -T -i code_repo.txt
$ zabbix_sender -z 127.0.0.1 -T -i ticketing.txt
$ zabbix_sender -z 127.0.0.1 -T -i warehouse_analytics.txt

The output on each invocation should be similar to this:

info from server: "processed: 250; failed: 0; total: 250; seconds spent: 0.001747"
...
info from server: "processed: 10; failed: 0; total: 10; seconds spent: 0.000063"
sent: 8760; skipped: 0; total: 8760 
Zabbix sender processes up to 250 values per connection—refer to Chapter 10, Advanced Item Monitoring, for more details about this small, but great, utility.

If all of the preceding succeeded, great; we now have a year's worth of data.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.130.24