コード例 #1
0
ファイル: madwifi.c プロジェクト: fcagsaway/collectd
static int
process_athstats (int sk, const char *dev)
{
	struct ifreq ifr;
	struct ath_stats stats;
	int status;

	sstrncpy (ifr.ifr_name, dev, sizeof (ifr.ifr_name));
	ifr.ifr_data = (void *) &stats;
	status = ioctl (sk, SIOCGATHSTATS, &ifr);
	if (status < 0)
	{
		/* Silent, because not all interfaces support all ioctls. */
		DEBUG ("madwifi plugin: Sending IO-control "
				"SIOCGATHSTATS to device %s "
				"failed with status %i.",
				dev, status);
		return (status);
	}

	/* These stats are handled as a special case, because they are
	   eight values each */

	if (item_watched (STAT_AST_ANT_RX))
		submit_antx (dev, "ast_ant_rx", stats.ast_ant_rx,
				STATIC_ARRAY_SIZE (stats.ast_ant_rx));

	if (item_watched (STAT_AST_ANT_TX))
		submit_antx (dev, "ast_ant_tx", stats.ast_ant_tx,
				STATIC_ARRAY_SIZE (stats.ast_ant_tx));

	/* All other ath statistics */
	process_stat_struct (ATH_STAT, &stats, dev, NULL, "ath_stat", "ast_misc");
	return (0);
}
コード例 #2
0
ファイル: madwifi.c プロジェクト: fcagsaway/collectd
static int
process_station (int sk, const char *dev, struct ieee80211req_sta_info *si)
{
	struct iwreq iwr;
	static char mac[DATA_MAX_NAME_LEN];
	struct ieee80211req_sta_stats stats;
	const struct ieee80211_nodestats *ns = &stats.is_stats;
	int status;

	macaddr_to_str (mac, sizeof (mac), si->isi_macaddr);

	if (item_watched (STAT_NODE_TX_RATE))
		submit_gauge (dev, "node_tx_rate", mac, NULL,
			(si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL) / 2);

	if (item_watched (STAT_NODE_RSSI))
		submit_gauge (dev, "node_rssi", mac, NULL, si->isi_rssi);

	memset (&iwr, 0, sizeof (iwr));
	sstrncpy(iwr.ifr_name, dev, sizeof (iwr.ifr_name));
	iwr.u.data.pointer = (void *) &stats;
	iwr.u.data.length = sizeof (stats);
	memcpy(stats.is_u.macaddr, si->isi_macaddr, IEEE80211_ADDR_LEN);
	status = ioctl(sk, IEEE80211_IOCTL_STA_STATS, &iwr);
	if (status < 0)
	{
		/* Silent, because not all interfaces support all ioctls. */
		DEBUG ("madwifi plugin: Sending IO-control "
				"IEEE80211_IOCTL_STA_STATS to device %s "
				"failed with status %i.",
				dev, status);
		return (status);
	}

	/* These two stats are handled as a special case as they are
	   a pair of 64bit values */
	if (item_watched (STAT_NODE_OCTETS))
		submit_derive2 (dev, "node_octets", mac, NULL,
			ns->ns_rx_bytes, ns->ns_tx_bytes);

	/* This stat is handled as a special case, because it is stored
	   as uin64_t, but we will ignore upper half */
	if (item_watched (STAT_NS_RX_BEACONS))
		submit_derive (dev, "node_stat", "ns_rx_beacons", mac,
			(ns->ns_rx_beacons & 0xFFFFFFFF));

	/* All other node statistics */
	process_stat_struct (NOD_STAT, ns, dev, mac, "node_stat", "ns_misc");
	return (0);
}
コード例 #3
0
ファイル: madwifi.c プロジェクト: fcagsaway/collectd
static void
process_stat_struct (int which, const void *ptr, const char *dev, const char *mac,
			 const char *type_name, const char *misc_name)
{
	uint32_t misc = 0;
	int i;

	assert (which >= 1);
	assert (which < STATIC_ARRAY_SIZE (bounds));

	for (i = bounds[which - 1]; i < bounds[which]; i++)
	{
		uint32_t val = *(uint32_t *)(((char *) ptr) + specs[i].offset) ;

		if (item_watched (i) && (val != 0))
			submit_derive (dev, type_name, specs[i].name, mac, val);

		if (item_summed (i))
			misc += val;
	}
	
	if (misc != 0)
		submit_derive (dev, type_name, misc_name, mac, misc);

}
コード例 #4
0
ファイル: madwifi.c プロジェクト: Mindera/collectd
static int
process_stations (int sk, const char *dev)
{
	uint8_t buf[24*1024];
	struct iwreq iwr;
	uint8_t *cp;
	int nodes;
	size_t len;
	int status;

	memset (&iwr, 0, sizeof (iwr));
	sstrncpy (iwr.ifr_name, dev, sizeof (iwr.ifr_name));
	iwr.u.data.pointer = (void *) buf;
	iwr.u.data.length = sizeof (buf);

	status = ioctl (sk, IEEE80211_IOCTL_STA_INFO, &iwr);
	if (status < 0)
	{
		/* Silent, because not all interfaces support all ioctls. */
		DEBUG ("madwifi plugin: Sending IO-control "
				"IEEE80211_IOCTL_STA_INFO to device %s "
				"failed with status %i.",
				dev, status);
		return (status);
	}

	len = iwr.u.data.length;

	cp = buf;
	nodes = 0;
	while (len >= sizeof (struct ieee80211req_sta_info))
	{
		struct ieee80211req_sta_info *si = (void *) cp;
		process_station(sk, dev, si);
		cp += si->isi_len;
		len -= si->isi_len;
		nodes++;
	}

	if (item_watched (STAT_ATH_NODES))
		submit_gauge (dev, "ath_nodes", NULL, NULL, nodes);
	return (0);
}