myaaaaa-chan/zabbix-couchbase-template — pull request #2 by Rockes (2014-08-14 15:08:55+00:00)
Title: Lack of free bucket quota warning

For this item configuration

UserParameter=cb.bucket.quotapercent[*],/usr/bin/curl -s -u $1:$2 http://localhost:8091/pools/$3/buckets | /usr/bin/jq ".[0].basicStats.quotaPercentUsed"

The "quotaPercentUsed" field is calculated with the following couchbase code:

QuotaBytes = ns_bucket:ram_quota(BucketConfig),
Stats = last_bucket_stats(ns_bucket:bucket_type(BucketConfig), BucketName, Nodes),
MemUsed = proplists:get_value(memUsed, Stats),
QuotaPercent = try (MemUsed * 100.0 / QuotaBytes) of
X -> X
catch
error:badarith -> 0
end,
[{quotaPercentUsed, lists:min([QuotaPercent, 100])}
For example, the default bucket:

QuotaBytes = 200 mb = 200000 kb = 200000000 bytes
MemUsed = 61.3 mb = 61300 kb = 61300000 bytes

QuotaPercent = MemUsed * 100.0 / QuotaBytes
= 61300000 * 100 / 200000000
= 6130000000 / 200000000
= 30.65 %

[Item]
[default] Bucket used(percent)
= cb.bucket.quotapercent[{$CBUSERNAME},{$CBPASSWORD},default
= 30.65 %

[Trigger]
[default] Lack of free bucket quota warning on server {HOST.NAME}
= {LVCPFMTCCMWP04:cb.bucket.quotapercent[{$CBUSERNAME},{$CBPASSWORD},default].last()}<70

The problem is with the trigger definition

= {LVCPFMTCCMWP04:cb.bucket.quotapercent[{$CBUSERNAME},{$CBPASSWORD},default].last()}<70

The relational operator < should be >

The "quotapercent" returns the amount which is currently used, however, the trigger is measuring the amount which is free.