aca839ff12
also includes a few new features, such as a grapher and support for tcp transport.
105 lines
3.4 KiB
Text
105 lines
3.4 KiB
Text
$NetBSD: patch-ab,v 1.2 2004/02/24 23:34:11 cube Exp $
|
|
|
|
--- gkrellm_snmp.c.orig 2003-09-21 14:49:36.000000000 +0200
|
|
+++ gkrellm_snmp.c
|
|
@@ -59,7 +59,7 @@
|
|
|
|
#include <gkrellm2/gkrellm.h>
|
|
|
|
-/* #define STREAM /* test for Lou Cephyr */
|
|
+/* #define STREAM -- test for Lou Cephyr */
|
|
|
|
|
|
#define SNMP_PLUGIN_MAJOR_VERSION 0
|
|
@@ -67,6 +67,7 @@
|
|
|
|
#define PLUGIN_CONFIG_NAME "SNMP"
|
|
#define PLUGIN_CONFIG_KEYWORD "snmp_monitor"
|
|
+#define PLUGIN_MONITOR_KEYWORD "monitor"
|
|
|
|
|
|
typedef struct Reader Reader;
|
|
@@ -967,13 +968,16 @@ save_plugin_config(FILE *f)
|
|
unit = g_strdelimit(g_strdup(reader->unit), STR_DELIMITERS, '_');
|
|
if (label[0] == '\0') label = strdup("_");
|
|
if (unit[0] == '\0') unit = strdup("_");
|
|
- fprintf(f, "%s %s snmp://%s@%s:%d/%s %s %d %d %d %d\n",
|
|
+ fprintf(f, "%s %s %s snmp://%s@%s:%d/%s %s %d %d %d %d\n",
|
|
PLUGIN_CONFIG_KEYWORD,
|
|
+ PLUGIN_MONITOR_KEYWORD,
|
|
label, reader->community,
|
|
reader->peer, reader->port,
|
|
reader->oid_str, unit,
|
|
reader->delay, reader->delta,
|
|
reader->divisor, reader->scale);
|
|
+ gkrellm_save_chartconfig(f, reader->chart_config, PLUGIN_CONFIG_KEYWORD,
|
|
+ label);
|
|
g_free(label);
|
|
g_free(unit);
|
|
}
|
|
@@ -984,19 +988,43 @@ load_plugin_config(gchar *arg)
|
|
{
|
|
Reader *reader, *nreader;
|
|
|
|
+ gchar config[32], item[CFG_BUFSIZE];
|
|
gchar proto[CFG_BUFSIZE], bufl[CFG_BUFSIZE];
|
|
gchar bufc[CFG_BUFSIZE], bufp[CFG_BUFSIZE];
|
|
gchar bufo[CFG_BUFSIZE], bufu[CFG_BUFSIZE];
|
|
+ gchar bufpr[CFG_BUFSIZE], bufpeer[CFG_BUFSIZE];
|
|
gint n;
|
|
|
|
+ n = sscanf(arg, "%31s %s %[^\n]", config, bufl, item);
|
|
+ if (n != 3)
|
|
+ return;
|
|
+
|
|
+ if (!strcmp(config, GKRELLM_CHARTCONFIG_KEYWORD))
|
|
+ {
|
|
+ for (nreader = readers; nreader; nreader = nreader->next)
|
|
+ {
|
|
+ if (!strcmp(bufl, nreader->label))
|
|
+ {
|
|
+ gkrellm_load_chartconfig(&nreader->chart_config, item, 1);
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (strcmp(config, PLUGIN_MONITOR_KEYWORD))
|
|
+ return;
|
|
+
|
|
reader = g_new0(Reader, 1);
|
|
|
|
- n = sscanf(arg, "%s %[^:]://%[^@]@%[^:]:%d/%s %s %d %d %d %d",
|
|
- bufl, proto, bufc, bufp, &reader->port, bufo, bufu,
|
|
+ n = sscanf(item, "%[^:]://%[^@]@%[^:]:%[^:]:%d/%s %s %d %d %d %d",
|
|
+ proto, bufc, bufpr, bufpeer, &reader->port, bufo, bufu,
|
|
&reader->delay, &reader->delta,
|
|
&reader->divisor, &reader->scale);
|
|
if (n >= 6)
|
|
{
|
|
+ g_snprintf(bufp, CFG_BUFSIZE, "%s:%s", bufpr, bufpeer);
|
|
+ bufp[CFG_BUFSIZE-1] = '\0';
|
|
if (g_strcasecmp(proto, "snmp") == 0) {
|
|
gkrellm_dup_string(&reader->label, bufl);
|
|
gkrellm_dup_string(&reader->community, bufc);
|
|
@@ -1055,6 +1083,7 @@ apply_plugin_config()
|
|
for (row = 0; row < GTK_CLIST(reader_clist)->rows; ++row)
|
|
{
|
|
gint i;
|
|
+ gchar peername[MAXHOSTNAMELEN+1];
|
|
i = 0;
|
|
reader = g_new0(Reader, 1);
|
|
|
|
@@ -1062,6 +1091,11 @@ apply_plugin_config()
|
|
gkrellm_dup_string(&reader->label, name);
|
|
|
|
gtk_clist_get_text(GTK_CLIST(reader_clist), row, i++, &name);
|
|
+ if (strncasecmp(name, "tcp:", 4) && strncasecmp(name, "udp:", 4))
|
|
+ {
|
|
+ g_snprintf(peername, MAXHOSTNAMELEN, "udp:%s", name);
|
|
+ name = peername;
|
|
+ }
|
|
gkrellm_dup_string(&reader->peer, name);
|
|
|
|
gtk_clist_get_text(GTK_CLIST(reader_clist), row, i++, &name);
|