summaryrefslogtreecommitdiffstats
path: root/src/libs/zbxsysinfo
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-11-07 08:24:50 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-11-07 08:24:50 +0000
commit865102cfae357d5e95483f2a4060b7bdbce99dc3 (patch)
tree623ab01cf91e5ff523fed300b4f212ae37c3c090 /src/libs/zbxsysinfo
parentef8201709492f258edd729703f2c671303d0508e (diff)
downloadzabbix-865102cfae357d5e95483f2a4060b7bdbce99dc3.tar.gz
zabbix-865102cfae357d5e95483f2a4060b7bdbce99dc3.tar.xz
zabbix-865102cfae357d5e95483f2a4060b7bdbce99dc3.zip
- added support of net.if.collisions[*] for Linux (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2282 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxsysinfo')
-rw-r--r--src/libs/zbxsysinfo/linux/net.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/libs/zbxsysinfo/linux/net.c b/src/libs/zbxsysinfo/linux/net.c
index 3091ec96..74abf75f 100644
--- a/src/libs/zbxsysinfo/linux/net.c
+++ b/src/libs/zbxsysinfo/linux/net.c
@@ -31,6 +31,7 @@ struct net_stat_s {
unsigned long opackets;
unsigned long oerr;
unsigned long odrop;
+ unsigned long colls;
};
static int get_net_stat(const char *interface, struct net_stat_s *result)
@@ -56,7 +57,8 @@ static int get_net_stat(const char *interface, struct net_stat_s *result)
p = strstr(line,":");
if(p) p[0]='\t';
- if(sscanf(line,"%s\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\n",
+ if(sscanf(line,"%s\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t \
+ %lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\n",
name,
&(result->ibytes), /* bytes */
&(result->ipackets), /* packets */
@@ -69,8 +71,12 @@ static int get_net_stat(const char *interface, struct net_stat_s *result)
&(result->obytes), /* bytes */
&(result->opackets), /* packets*/
&(result->oerr), /* errs */
- &(result->odrop) /* drop */
- ) == 13)
+ &(result->odrop), /* drop */
+ &(tmp), /* fifo */
+ &(result->colls), /* icolls */
+ &(tmp), /* carrier */
+ &(tmp) /* compressed */
+ ) == 17)
{
if(strncmp(name, interface, MAX_STRING_LEN) == 0)
{
@@ -234,10 +240,36 @@ int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT
int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
- assert(result);
+ struct net_stat_s ns;
+
+ char interface[MAX_STRING_LEN];
+
+ int ret = SYSINFO_RET_FAIL;
+
+ assert(result);
clean_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;
+ }
- return SYSINFO_RET_FAIL;
+
+ ret = get_net_stat(interface, &ns);
+
+
+ if(ret == SYSINFO_RET_OK)
+ {
+ result->type |= AR_DOUBLE;
+ result->dbl = (double)(ns.colls);
+ }
+
+ return ret;
}