summaryrefslogtreecommitdiffstats
path: root/src/libs/zbxsysinfo/openbsd
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-12 14:23:12 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-12 14:23:12 +0000
commit4182bc6afb20b00fa27a54c67056bb98a58a49bb (patch)
tree5cab17d23e387cc3b6e8c92e4c928ac5e1111b76 /src/libs/zbxsysinfo/openbsd
parent6a6ac0772b8215bffc5fe8b02fc1033dbf273f41 (diff)
downloadzabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.tar.gz
zabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.tar.xz
zabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.zip
- speed improvement for Overview screens (Eugene)
- developed 'net.if.total[*]' parameter (Eugene) - fixed new map link adding (Eugene) - fixed host group adding (Eugene) - fixed map displaying (Eugene) - fixed 'No permissions' for 'Latest data','Triggers','Alarms' screens (Eugene) - fixed permision deletion (Eugene) - fixed 'get_map_by_sysmapid' function calls(Eugene) - improved php code execution speed (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2825 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxsysinfo/openbsd')
-rw-r--r--src/libs/zbxsysinfo/openbsd/net.c149
-rw-r--r--src/libs/zbxsysinfo/openbsd/openbsd.c1
2 files changed, 150 insertions, 0 deletions
diff --git a/src/libs/zbxsysinfo/openbsd/net.c b/src/libs/zbxsysinfo/openbsd/net.c
index 2adb526b..467cf1bb 100644
--- a/src/libs/zbxsysinfo/openbsd/net.c
+++ b/src/libs/zbxsysinfo/openbsd/net.c
@@ -383,6 +383,155 @@ NET_FNCLIST
return SYSINFO_RET_FAIL;
}
+static int NET_IF_TOTAL_BYTES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ struct ifnet value;
+ char interface[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ init_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ ret = get_ifdata(interface, &value);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ SET_UI64_RESULT(result, value.if_obytes + value.if_ibytes);
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
+}
+
+static int NET_IF_TOTAL_PACKETS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ struct ifnet value;
+ char interface[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ init_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ ret = get_ifdata(interface, &value);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ SET_UI64_RESULT(result, value.if_opackets + value.if_ipackets);
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
+}
+
+static int NET_IF_TOTAL_ERRORS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+ struct ifnet value;
+ char interface[MAX_STRING_LEN];
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
+
+ init_result(result);
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ ret = get_ifdata(interface, &value);
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ SET_UI64_RESULT(result, value.if_oerrors + value.if_ierrors);
+ ret = SYSINFO_RET_OK;
+ }
+
+ return ret;
+}
+
+int NET_IF_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
+{
+#define NET_FNCLIST struct net_fnclist_s
+NET_FNCLIST
+{
+ char *mode;
+ int (*function)();
+};
+
+ NET_FNCLIST fl[] =
+ {
+ {"bytes", NET_IF_TOTAL_BYTES},
+ {"packets", NET_IF_TOTAL_PACKETS},
+ {"errors", NET_IF_TOTAL_ERRORS},
+ {0, 0}
+ };
+
+ char interface[MAX_STRING_LEN];
+ char mode[MAX_STRING_LEN];
+ int i;
+
+ assert(result);
+
+ init_result(result);
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, interface, MAX_STRING_LEN) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, MAX_STRING_LEN) != 0)
+ {
+ mode[0] = '\0';
+ }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "bytes");
+ }
+
+ for(i=0; fl[i].mode!=0; i++)
+ {
+ if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0)
+ {
+ return (fl[i].function)(cmd, interface, flags, result);
+ }
+ }
+
+ return SYSINFO_RET_FAIL;
+}
+
int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
assert(result);
diff --git a/src/libs/zbxsysinfo/openbsd/openbsd.c b/src/libs/zbxsysinfo/openbsd/openbsd.c
index cf2db472..3d57642c 100644
--- a/src/libs/zbxsysinfo/openbsd/openbsd.c
+++ b/src/libs/zbxsysinfo/openbsd/openbsd.c
@@ -237,6 +237,7 @@ ZBX_METRIC parameters_specific[]=
{"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes"},
{"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes"},
+ {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo,bytes"},
{"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo"},
{"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"},