Skip to content

Instantly share code, notes, and snippets.

@v-zhuravlev
v-zhuravlev / active-triggers-count.sql
Last active June 12, 2023 12:46
Zabbix SQL queries collection
select count(*) FROM (select distinct h.hostid, h.host, t.description from triggers t
join functions f on f.triggerid = t.triggerid
join items i on i.itemid = f.itemid
join hosts h on h.hostid = i.hostid
join hosts_groups hg on h.hostid = hg.hostid
join hstgrp hg2 on hg2.groupid = hg.groupid
where
-- value=1 - trigger is in problem state
t.value = 1 and
@v-zhuravlev
v-zhuravlev / to_lld.js
Last active October 3, 2019 08:40
JSON array to Zabbix LLD sample
// run wmi.getall[root\cimv2,"select * from win32_networkadapter where PhysicalAdapter=True"]
// this filters other performance metric counters, so Discard can be applied.
output = JSON.parse(value).map(function(net){
return {
"{#IFNAME}": net.Name,
"{#IFDESCR}": net.Description,
"{#IFPHYSICALADAPTER}": net.PhysicalAdapter,
"{#IFALIAS}": net.NetConnectionID,
"{#IFNETENABLED}": net.NetEnabled
}})
#!/bin/bash
## Performs rDNS check using 'host' command
if [[ $# -eq 0 ]] ; then
echo 'You must provide DNS record as the first argument'
exit 0
fi
function lookup(){
@v-zhuravlev
v-zhuravlev / fillBoxes.js
Created June 1, 2018 12:23
color boxes in InDesign with js
if (parseFloat(app.version) > 6)
main();
else
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Color Textboxes Based on Word");
function main() {
var red = app.activeDocument.colors.itemByName("RGB Red");
var blue = app.activeDocument.colors.itemByName("RGB Blue");
var sel = app.selection;
for(s=0;s<sel.length;s++){
@v-zhuravlev
v-zhuravlev / zabbix agent ping
Last active November 8, 2023 17:14
Various example of using ping from Zabbix agent
UserParameter=u.ping[*],/bin/ping -c 1 -W 1 -q -n $1 &> /dev/null && echo 1 || echo 0
UserParameter=u.ping.avg[*],/bin/ping -c $2 -s $3 -W 1 -q -n $1 | tail -1 | awk -F '/' '{print $$5}'
UserParameter=u.ping.loss[*],/bin/ping -c $2 -s $3 -W 1 -q -n $1 | grep -oP '[0-9]+% packet loss' | cut -d'%' -f1
#sample key:
#u.ping.loss[10.77.248.165,5,100]
#Last octet only
#example keys:
@v-zhuravlev
v-zhuravlev / uDiffPrograms
Created February 18, 2017 12:04
uDiffPrograms.vbs (zabbix)
'KNOWN ISSUE: If Application name conatins '-' symbol then e-mail alert containing software list will be sent all on one line instead of each packet on a single line
variable=InstalledApplications(".")
'WScript.Echo strConvert(variable,"Windows-1251","cp866")
Const ForReading = 1
zabbix_dir="C:\zabbix\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Create old file if does not exist
If objFSO.FileExists(zabbix_dir&"uDiffPrograms_old.txt")=0 Then
Set objFile4 = objFSO.CreateTextFile(zabbix_dir&"uDiffPrograms_old.txt")
objFile4.WriteLine variable
@v-zhuravlev
v-zhuravlev / riemann.clj
Last active April 22, 2024 06:42
Send metrics to influx(and zabbix_sender) from riemann only if value changed(or when heartbeat interval of 300seconds) or if state changed (for service client-test)
;; InfluxDB database details where Riemann will store the data. Setup :username and :password
;; if you added security step behind riemann database access.
(def influxdb-creds {
:version :0.9
:host "localhost"
:port 8086
:db "riemann"
; :username "riemann"
; :password "riemann"
})