-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
all: main.c getdata.c | ||
gcc -v -O2 main.c getdata.c -o zabbix_data | ||
install: zabbix_data | ||
cp zabbix_data /usr/local/bin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Это минимальный пакет для мониторинга extFilter через файл /var/run/extFilter_stat в zabbix. | ||
Установка: | ||
make && make install | ||
Необходимо также установить zabbix-agent. | ||
|
||
Затем добавить в файл /etc/zabbix/zabbix_agent.conf строку | ||
UserParameter=extfilter.stat[*],zabbix_data $1 | ||
и перезапустить сервис агента. | ||
|
||
Затем импорти ровать шаблон через WEB-интерфейс. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <string.h> | ||
#include <ctype.h> | ||
char* trimall(char* s){ | ||
char *temp=malloc(255); | ||
memset(temp,0,sizeof(temp)); | ||
int i=0,j=0; | ||
char c; | ||
while( (c=*(s+i))!= 0){ | ||
if(!isspace(c)){ | ||
*(temp+j)=c; | ||
j++; | ||
} | ||
i++; | ||
} | ||
return temp; | ||
} | ||
char* getparam(char *s){ | ||
char *temp=malloc(255),*c; | ||
memset(temp,0,sizeof(temp)); | ||
if((c=strchr(s,'='))!=NULL){ | ||
strncpy(temp,s,c-s); | ||
} | ||
return temp; | ||
} | ||
char* getvalue(char *s){ | ||
char *temp=malloc(255),*c; | ||
memset(temp,0,sizeof(temp)); | ||
if((c=strchr(s,'='))!=NULL){ | ||
strcpy(temp,(c+1)); | ||
} | ||
return temp; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
char* trimall(char* s); | ||
char* getparam(char* s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "getdata.h" | ||
#include <stdio.h> | ||
#define statfile "/var/run/extFilter_stat" | ||
void main(char argc, char **argv){ | ||
if(argc!=2){ | ||
fprintf(stderr, "Usage example:\n \tzabbix_data extfilter.discovery\n\t or \n\tzabbix_data allports.received_packets\n",statfile); | ||
exit(1); | ||
} | ||
if((argc==2) && !strcmp(argv[1],"extfilter.discovery")){ | ||
char temp[255]; | ||
memset(temp,0,sizeof(temp)); | ||
FILE *sf=fopen(statfile,"r"); | ||
if(sf==NULL){ | ||
fprintf(stderr, "File %s not found!\n",statfile); | ||
exit(1); | ||
} | ||
puts("{\n\"data\":["); | ||
int commafirst=1; | ||
while(fgets(temp,255,sf)!=NULL){ | ||
if(commafirst){ | ||
printf("{\"{#STATPARAM}\":\"%s\"}",getparam(trimall(temp))); | ||
}else{ | ||
printf(",\n{\"{#STATPARAM}\":\"%s\"}",getparam(trimall(temp))); | ||
} | ||
commafirst=0; | ||
} | ||
puts("\n]\n}"); | ||
fclose(sf); | ||
} | ||
if(argc==2 && | ||
(strstr(argv[1],"worker.")!=NULL) || (strstr(argv[1],"allworkers.")!=NULL) || (strstr(argv[1],"allports.")!=NULL) ){ | ||
char temp[255]; | ||
memset(temp,0,sizeof(temp)); | ||
FILE *sf=fopen(statfile,"r"); | ||
if(sf==NULL){ | ||
fprintf(stderr, "File %s not found!\n",statfile); | ||
exit(1); | ||
} | ||
while(fgets(temp,255,sf)!=NULL){ | ||
if( !strcmp(getparam(trimall(temp)),trimall(argv[1])) ){ | ||
puts(getvalue(trimall(temp))); | ||
} | ||
} | ||
fclose(sf); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<zabbix_export> | ||
<version>2.0</version> | ||
<date>2017-09-04T00:56:44Z</date> | ||
<groups> | ||
<group> | ||
<name>extfilter</name> | ||
</group> | ||
</groups> | ||
<templates> | ||
<template> | ||
<template>extfilter</template> | ||
<name>extfilter</name> | ||
<groups> | ||
<group> | ||
<name>extfilter</name> | ||
</group> | ||
</groups> | ||
<applications/> | ||
<items/> | ||
<discovery_rules> | ||
<discovery_rule> | ||
<name>extfilter</name> | ||
<type>0</type> | ||
<snmp_community/> | ||
<snmp_oid/> | ||
<key>extfilter.stat["extfilter.discovery"]</key> | ||
<delay>300</delay> | ||
<status>0</status> | ||
<allowed_hosts/> | ||
<snmpv3_contextname/> | ||
<snmpv3_securityname/> | ||
<snmpv3_securitylevel>0</snmpv3_securitylevel> | ||
<snmpv3_authprotocol>0</snmpv3_authprotocol> | ||
<snmpv3_authpassphrase/> | ||
<snmpv3_privprotocol>0</snmpv3_privprotocol> | ||
<snmpv3_privpassphrase/> | ||
<delay_flex/> | ||
<params/> | ||
<ipmi_sensor/> | ||
<authtype>0</authtype> | ||
<username/> | ||
<password/> | ||
<publickey/> | ||
<privatekey/> | ||
<port/> | ||
<filter>{#STATPARAM}:</filter> | ||
<lifetime>30</lifetime> | ||
<description/> | ||
<item_prototypes> | ||
<item_prototype> | ||
<name>extfilter.stat.$1</name> | ||
<type>0</type> | ||
<snmp_community/> | ||
<multiplier>0</multiplier> | ||
<snmp_oid/> | ||
<key>extfilter.stat[{#STATPARAM}]</key> | ||
<delay>300</delay> | ||
<history>90</history> | ||
<trends>365</trends> | ||
<status>0</status> | ||
<value_type>3</value_type> | ||
<allowed_hosts/> | ||
<units/> | ||
<delta>0</delta> | ||
<snmpv3_contextname/> | ||
<snmpv3_securityname/> | ||
<snmpv3_securitylevel>0</snmpv3_securitylevel> | ||
<snmpv3_authprotocol>0</snmpv3_authprotocol> | ||
<snmpv3_authpassphrase/> | ||
<snmpv3_privprotocol>0</snmpv3_privprotocol> | ||
<snmpv3_privpassphrase/> | ||
<formula>1</formula> | ||
<delay_flex/> | ||
<params/> | ||
<ipmi_sensor/> | ||
<data_type>0</data_type> | ||
<authtype>0</authtype> | ||
<username/> | ||
<password/> | ||
<publickey/> | ||
<privatekey/> | ||
<port/> | ||
<description/> | ||
<inventory_link>0</inventory_link> | ||
<applications/> | ||
<valuemap/> | ||
<logtimefmt/> | ||
</item_prototype> | ||
</item_prototypes> | ||
<trigger_prototypes/> | ||
<graph_prototypes/> | ||
<host_prototypes/> | ||
</discovery_rule> | ||
</discovery_rules> | ||
<macros/> | ||
<templates/> | ||
<screens/> | ||
</template> | ||
</templates> | ||
</zabbix_export> |