mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
Zabbix: import 2.2.2 from packages
Signed-off-by: Etienne CHAMPETIER <etienne.champetier@free.fr>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#see http://wiki.openwrt.org/doc/howto/zabbix for ready to use templates
|
||||
|
||||
# If you want to know the exact meaning of an UserParameter, you can search in the ieee80211 standard:
|
||||
# http://standards.ieee.org/getieee802/download/802.11-2012.pdf
|
||||
# exemple: for mac80211.ACKFailureCount search for dot11ACKFailureCount (page 2145)
|
||||
|
||||
# mac80211 phy discovery (like 'phy0')
|
||||
# exemple: {"data":[{"{#PHY}":"phy0"}]}
|
||||
#
|
||||
UserParameter=mac80211.phydiscovery,zabbix_helper_mac80211 discovery
|
||||
|
||||
#phy statistics (you need {#PHY} as parameter)
|
||||
#
|
||||
UserParameter=mac80211.ACKFailureCount[*],zabbix_helper_mac80211 $1 dot11ACKFailureCount
|
||||
UserParameter=mac80211.FCSErrorCount[*],zabbix_helper_mac80211 $1 dot11FCSErrorCount
|
||||
UserParameter=mac80211.RTSFailureCount[*],zabbix_helper_mac80211 $1 dot11RTSFailureCount
|
||||
UserParameter=mac80211.RTSSuccessCount[*],zabbix_helper_mac80211 $1 dot11RTSSuccessCount
|
||||
UserParameter=mac80211.FailedCount[*],zabbix_helper_mac80211 $1 failed_count
|
||||
UserParameter=mac80211.FrameDuplicateCount[*],zabbix_helper_mac80211 $1 frame_duplicate_count
|
||||
UserParameter=mac80211.MulticastReceivedFrameCount[*],zabbix_helper_mac80211 $1 multicast_received_frame_count
|
||||
UserParameter=mac80211.MulticastTransmittedFrameCount[*],zabbix_helper_mac80211 $1 multicast_transmitted_frame_count
|
||||
UserParameter=mac80211.MultipleRetryCount[*],zabbix_helper_mac80211 $1 multiple_retry_count
|
||||
UserParameter=mac80211.ReceivedFragmentCount[*],zabbix_helper_mac80211 $1 received_fragment_count
|
||||
UserParameter=mac80211.RetryCount[*],zabbix_helper_mac80211 $1 retry_count
|
||||
UserParameter=mac80211.TransmittedFragmentCount[*],zabbix_helper_mac80211 $1 transmitted_fragment_count
|
||||
UserParameter=mac80211.TransmittedFrameCount[*],zabbix_helper_mac80211 $1 transmitted_frame_count
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#see http://wiki.openwrt.org/doc/howto/zabbix for ready to use templates
|
||||
|
||||
# network interface discovery
|
||||
# exemple: {"data":[{"{#IF}":"lo", "{#NET}":"loopback"},{"{#IF}":"br-lan", "{#NET}":"lan"},{"{#IF}":"eth0.1", "{#NET}":"wan"}]}
|
||||
#
|
||||
UserParameter=netowrt.discovery,lua -l uci -e 'x = uci.cursor(nil, "/var/state");list = "{\"data\":[";x:foreach("network", "interface", function(s) list=list.."{\"{#IF}\":\""..s.ifname.."\", \"{#NET}\":\""..s[".name"].."\"}," end); list=string.gsub(list,",$",""); print(list.."]}")'
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#see http://wiki.openwrt.org/doc/howto/zabbix for ready to use templates
|
||||
|
||||
# wifi interface discovery
|
||||
# exemple: {"data":[{"{#IF}":"wlan0", "{#MODE}":"ap", "{#SSID}":"Openwrt", "{#NET}":"lan", "{#DEV}":"radio0", "{#ENC}":"psk2+ccmp", "{#TYPE}":"mac80211", "{#HWMODE}":"11ng", "{#CHANNEL}":"11", "{#BSSID}":"xx:xx:xx:xx:xx:xx"}]}
|
||||
#
|
||||
UserParameter=wifi.ifdiscovery,lua -l uci -l iwinfo -e 'x = uci.cursor(nil, "/var/state");list = "{\"data\":[";x:foreach("wireless", "wifi-iface", function(s) list=list.."{\"{#IF}\":\""..s.ifname.."\", \"{#MODE}\":\""..s.mode.."\", \"{#SSID}\":\""..s.ssid.."\", \"{#NET}\":\""..s.network.."\", \"{#DEV}\":\""..s.device.."\", \"{#ENC}\":\""..(s.encryption or "?").."\", \"{#TYPE}\":\""..x:get("wireless",s.device,"type").."\", \"{#HWMODE}\":\""..(x:get("wireless",s.device,"hwmode") or "?").."\", \"{#CHANNEL}\":\""..x:get("wireless",s.device,"channel").."\", \"{#BSSID}\":\""..iwinfo[iwinfo.type(s.ifname)].bssid(s.ifname).."\"}," end); list=string.gsub(list,",$",""); print(list.."]}")'
|
||||
|
||||
|
||||
#iwinfo info (you need {#IF} as parameter, like 'wlan0')
|
||||
UserParameter=wifi.iwinfo.channel[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].channel('$1'))"
|
||||
UserParameter=wifi.iwinfo.frequency[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].frequency('$1'))"
|
||||
UserParameter=wifi.iwinfo.txpower[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].txpower('$1'))"
|
||||
UserParameter=wifi.iwinfo.bitrate[*],lua -l iwinfo -e "b = iwinfo[iwinfo.type('$1')].bitrate('$1'); print(b or '0')"
|
||||
UserParameter=wifi.iwinfo.signal[*],lua -l iwinfo -e "s = iwinfo[iwinfo.type('$1')].signal('$1'); print(s or '-255')"
|
||||
UserParameter=wifi.iwinfo.noise[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].noise('$1'))"
|
||||
UserParameter=wifi.iwinfo.quality[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].quality('$1'))"
|
||||
UserParameter=wifi.iwinfo.quality_max[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].quality_max('$1'))"
|
||||
UserParameter=wifi.iwinfo.mode[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].mode('$1'))"
|
||||
UserParameter=wifi.iwinfo.ssid[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].ssid('$1'))"
|
||||
UserParameter=wifi.iwinfo.bssid[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].bssid('$1'))"
|
||||
UserParameter=wifi.iwinfo.country[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].country('$1'))"
|
||||
UserParameter=wifi.iwinfo.nbusers[*],lua -l iwinfo -e "n = 0; for _,_ in pairs(iwinfo[iwinfo.type('$1')].assoclist('$1')) do n = n + 1 end; print(n)"
|
||||
UserParameter=wifi.iwinfo.encryption[*],lua -l iwinfo -e "e = iwinfo[iwinfo.type('$1')].encryption('$1'); print(e and e.description or 'None')"
|
||||
UserParameter=wifi.iwinfo.hwmode[*],lua -l iwinfo -e "x=iwinfo[iwinfo.type('$1')].hwmodelist('$1'); print((x.a and 'a' or '')..(x.b and 'b' or '')..(x.g and 'g' or '')..(x.n and 'n' or ''))"
|
||||
|
||||
#uci info (you need {#DEV} as parameter, like 'radio0')
|
||||
UserParameter=wifi.uci.hwmode[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','hwmode'))"
|
||||
UserParameter=wifi.uci.channel[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','channel'))"
|
||||
UserParameter=wifi.uci.txpower[*],lua -l uci -e "x = uci.cursor(nil, '/var/state'); print(x:get('wireless','$1','txpower'))"
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2008-2011 OpenWrt.org
|
||||
|
||||
START=60
|
||||
|
||||
PROG=/usr/sbin/zabbix_agentd
|
||||
CONFIG=/etc/zabbix_agentd.conf
|
||||
SERVICE_PID_FILE=/var/run/zabbix_agentd.pid
|
||||
|
||||
start() {
|
||||
# Sometimes the agentd config was installed in /etc/zabbix/zabbix_agentd.conf
|
||||
[ -f /etc/zabbix/zabbix_agentd.conf ] && mv /etc/zabbix/zabbix_agentd.conf ${CONFIG}
|
||||
|
||||
[ -f ${CONFIG} ] || return 1
|
||||
|
||||
grep -q "^PidFile=${SERVICE_PID_FILE}" ${CONFIG} || {
|
||||
logger -s -t ${CONFIG} -p daemon.error "Only \"PidFile=${SERVICE_PID_FILE}\" supported"
|
||||
return 1
|
||||
}
|
||||
|
||||
grep -q "^AllowRoot=1" ${CONFIG} || {
|
||||
user_exists zabbix 53 || user_add zabbix 53
|
||||
group_exists zabbix 53 || group_add zabbix 53
|
||||
touch ${SERVICE_PID_FILE}
|
||||
chown zabbix:zabbix ${SERVICE_PID_FILE}
|
||||
}
|
||||
|
||||
service_start ${PROG} -c ${CONFIG}
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop ${PROG}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int discovery()
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
bool comma = false;
|
||||
if ((dir = opendir ("/sys/kernel/debug/ieee80211/")) != NULL) {
|
||||
printf("{\"data\":[");
|
||||
while ((ent = readdir (dir)) != NULL) {
|
||||
if (strcmp(".", ent->d_name) && strcmp("..", ent->d_name)) {
|
||||
if (comma)
|
||||
printf(",");
|
||||
printf("{\"{#PHY}\":\"%s\"}", ent->d_name);
|
||||
comma = true;
|
||||
}
|
||||
}
|
||||
printf("]}\n");
|
||||
closedir(dir);
|
||||
} else {
|
||||
perror("");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int get_param(char *phy, char *stat)
|
||||
{
|
||||
char *filename = NULL;
|
||||
FILE *f = NULL;
|
||||
phy = basename(phy);
|
||||
stat = basename(stat);
|
||||
if (asprintf(&filename, "/sys/kernel/debug/ieee80211/%s/statistics/%s", phy, stat) > 0)
|
||||
f = fopen(filename, "r");
|
||||
|
||||
if (f != NULL) {
|
||||
char temp[256];
|
||||
while (fgets(temp, 256, f) != NULL)
|
||||
printf("%s",temp);
|
||||
|
||||
fclose(f);
|
||||
} else {
|
||||
perror("");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
free(filename);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int usage(char *name)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " %s discovery\n", name);
|
||||
fprintf(stderr, " => print mac80211.phydiscovery discovery rule\n");
|
||||
fprintf(stderr, " %s PHY STAT\n", name);
|
||||
fprintf(stderr, " => cat /sys/kernel/debug/ieee80211/PHY/statistics/STAT as root\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
switch (argc) {
|
||||
case 2:
|
||||
return discovery();
|
||||
case 3:
|
||||
return get_param(argv[1], argv[2]);
|
||||
default:
|
||||
return usage(argv[0]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user