5.0
2020-11-15T10:42:19Z
Templates/Modules
Filesystem biggest files by Zabbix agent
Filesystem biggest files by Zabbix agent
# working in bash in alpine image, zabbix-agent2
find / -type f -exec du {} + 2>/dev/null | sort -n -r | grep -v ^0 | head -20 | base64 -w0
# biggest directories
du -a / | sort -n -r | head -n 5
# together with sender
zabbix_sender -c /etc/zabbix/zabbix_agent2.conf -s $(hostname -s).gnt.ros.do -k big.in -o "find / -type f -exec du {} + 2>/dev/null | sort -n -r | grep -v ^0 | head -20 | base64 -w0"
Templates/Modules
Alive
Biggest directories delta
Biggest directories size
Biggest files delta
Biggest files size
Zabbix raw items
Zabbix sender
-
Receive biggest files
TRAP
biggest.files
0
0
TEXT
3145728 /myswap
767012 /root/zabbix-source/.git/objects/pack/pack-6f2063f3b8802ba65e63a46440c618ad9239ead0.pack
161452 /var/lib/rpm/Packages
123984 /usr/lib/oracle/18.5/client64/lib/libociei.so
103656 /usr/lib/locale/locale-archive
102792 /root/zabbix-source.tar
102596 /usr/bin/dockerd
87168 /var/cache/yum/x86_64/7/centos-sclo-rh/gen/filelists_db.sqlite
87128 /usr/bin/docker
76368 /usr/lib/oracle/18.5/client64/lib/libclntsh.so.18.1
SOFTWARE_FULL
Zabbix raw items
JAVASCRIPT
return "SIZE,FILE\n"+value.replace(/\s+\//gm,",\/");
CSV_TO_JSON
,
"
1
JAVASCRIPT
var jsonData = JSON.parse(value);
return JSON.stringify(jsonData.slice(0,{$Z_BIGGEST_FILES_CNT}));
-
detect.if.content.file
DEPENDENT
detect.if.content.file
0
0
Alive
JAVASCRIPT
return value.length;
biggest.files
{nodata({$DATA_NOT_COMMING})}=1
No data {$DATA_NOT_COMMING} for file receiver
HIGH
YES
-
Find biggest files
system.run["{$Z_SNDR_CNF} -s \"{HOST.HOST}\" -k biggest.files -o \"$({$Z_BIGGEST_FILES})\"",nowait]
55m
0
Zabbix sender
big.file.discovery
DEPENDENT
big.file.discovery
0
0
file.on.fs.change[{#FILE}]
DEPENDENT
file.on.fs.change[{#FILE}]
0
B
Biggest files delta
JSONPATH
$..[?(@.FILE == "{#FILE}")].SIZE.first()
MULTIPLIER
1024
SIMPLE_CHANGE
biggest.files
file.on.fs[{#FILE}]
DEPENDENT
file.on.fs[{#FILE}]
0
B
Biggest files size
JSONPATH
$..[?(@.FILE == "{#FILE}")].SIZE.first()
MULTIPLIER
1024
biggest.files
biggest.files
{#FILE}
$.FILE
{$DATA_NOT_COMMING}
26h
{$Z_BIGGEST_FILES}
find / -type f -exec du {} + 2>/dev/null | sort -n -r | grep -v ^0 | head -30
{$Z_BIGGEST_FILES_CNT}
16
Filesystem biggest folders by Zabbix agent
Filesystem biggest folders by Zabbix agent
# working in bash in alpine image, zabbix-agent2
find / -type f -exec du {} + 2>/dev/null | sort -n -r | grep -v ^0 | head -20 | base64 -w0
# biggest directories
du -a / | sort -n -r | head -n 5
# together with sender
zabbix_sender -c /etc/zabbix/zabbix_agent2.conf -s $(hostname -s).gnt.ros.do -k big.in -o "find / -type f -exec du {} + 2>/dev/null | sort -n -r | grep -v ^0 | head -20 | base64 -w0"
Templates/Modules
Alive
Biggest directories delta
Biggest directories size
Biggest files delta
Biggest files size
Zabbix raw items
Zabbix sender
-
Receive biggest directories
TRAP
biggest.directories
0
0
TEXT
var jsonData = JSON.parse(value);
// sort json data by size property and DIR property
// first it sorts the data by SIZE property ( Descending)
// and then if the SIZE is same, it checks the DIR property. longer string will be front of shoter string.
jsonData.sort(function(a, b){
return a.SIZE > b.SIZE || (a.SIZE == b.SIZE && a.DIR.toLowerCase().localeCompare(b.DIR) > 0);
})
// check each row and remove the data
for(var row = 0; row < jsonData.length - 1; row++){
// this will check the first condition.
if(jsonData[row].SIZE == jsonData[row+1].SIZE && jsonData[row].DIR.startsWith(jsonData[row+1].DIR)){
// remove the row.
jsonData.splice(row + 1, 1);
}
else{
// this will check the second condition.
// for the second condition, it needs extra loop while the difference of size is smaller than 20480.
var pointer = 1;
while(row + pointer < jsonData.length && jsonData[row].SIZE - jsonData[row + pointer].SIZE < 20480){
if (jsonData[row + pointer].DIR.startsWith(jsonData[row].DIR)) {
// remove the current row and then reduce row because array items after row will be shifted
jsonData.splice(row, 1);
row--;
break;
}
pointer ++;
}
}
}
return JSON.stringify(jsonData);
HARDWARE_FULL
Zabbix raw items
JAVASCRIPT
return "SIZE,DIR\n"+value.replace(/\t/gm,",");
CSV_TO_JSON
,
1
JAVASCRIPT
var jsonData = JSON.parse(value);
// check each row and remove the data
for(var row = 0; row < jsonData.length - 1; row++){
// this will check the first condition.
var pointer = 1;
while(row + pointer < jsonData.length && jsonData[row].SIZE == jsonData[row + pointer].SIZE){
if( jsonData[row].DIR.startsWith(jsonData[row+1].DIR) ){
jsonData.splice(row + pointer, 1);
}
else {
pointer++;
}
}
// this will check the second condition.
// for the second condition, it needs extra loop while the difference of size is smaller than 20480.
pointer = 1;
while(row + pointer < jsonData.length && jsonData[row].SIZE - jsonData[row + pointer].SIZE < {$Z_BIGGEST_DIRS_SIZE_DIFF}){
if (jsonData[row + pointer].DIR.startsWith(jsonData[row].DIR)) {
// remove the current row and then reduce row because array items after row will be shifted
jsonData.splice(row, 1);
row--;
break;
}
pointer ++;
}
}
return JSON.stringify(jsonData.slice(0,{$Z_BIGGEST_DIRS_CNT}));
-
detect.if.content.dir
DEPENDENT
detect.if.content.dir
0
0
Alive
JAVASCRIPT
return value.length;
biggest.directories
{nodata({$DATA_NOT_COMMING})}=1
No data {$DATA_NOT_COMMING} for directory receiver
HIGH
YES
-
Find biggest directories
system.run["{$Z_SNDR_CNF} -s \"{HOST.HOST}\" -k biggest.directories -o \"$({$Z_BIGGEST_DIRS})\"",nowait]
55m
0
Zabbix sender
big.dir.discovery
DEPENDENT
big.dir.discovery
0
0
dir.on.fs.change[{#DIR}]
DEPENDENT
dir.on.fs.change[{#DIR}]
0
B
Biggest directories delta
JSONPATH
$..[?(@.DIR == "{#DIR}")].SIZE.first()
MULTIPLIER
1024
SIMPLE_CHANGE
biggest.directories
dir.on.fs[{#DIR}]
DEPENDENT
dir.on.fs[{#DIR}]
0
B
Biggest directories size
JSONPATH
$..[?(@.DIR == "{#DIR}")].SIZE.first()
MULTIPLIER
1024
biggest.directories
biggest.directories
{#DIR}
$.DIR
{$DATA_NOT_COMMING}
26h
{$Z_BIGGEST_DIRS}
du / 2>/dev/null | sort -n -r | head -n 50
{$Z_BIGGEST_DIRS_CNT}
16
{$Z_BIGGEST_DIRS_SIZE_DIFF}
204800