aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xcollectors/snmpfetchng.pl9
-rw-r--r--web/js/nms-info-box.js2
-rw-r--r--web/templates/HOWTO.txt126
-rw-r--r--web/templates/switch.txt19
-rw-r--r--web/templates/switches.txt4
-rw-r--r--web/templates/test.conf17
7 files changed, 9 insertions, 169 deletions
diff --git a/.gitignore b/.gitignore
index 292e2fa..129e70e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
.*.swp
data/
+web/templates
web/templates/
web/files/
diff --git a/collectors/snmpfetchng.pl b/collectors/snmpfetchng.pl
index cfa0d77..3a5ecce 100755
--- a/collectors/snmpfetchng.pl
+++ b/collectors/snmpfetchng.pl
@@ -99,6 +99,7 @@ sub inner_loop
my $s = SNMP::Session->new(DestHost => $switch{'mgtip'},
Community => $switch{'community'},
UseEnums => 1,
+ Timeout => 5000000,
Version => '2');
my $ret = $s->bulkwalk(0, 10, @nms::config::snmp_objects, sub{ callback(\%switch, @_); });
if (!defined($ret)) {
@@ -106,7 +107,7 @@ sub inner_loop
}
}
mylog( "Polling " . @switches . " switches: $poll_todo");
- SNMP::MainLoop(5);
+ SNMP::MainLoop(10);
}
sub callback{
@@ -197,11 +198,15 @@ sub callback{
$tmp_field = '"'.$tree{$iid}{$key}.'"';
}
+ if ($iid eq "") {
+ $iid = "0";
+ }
push (@influx_tree,
{
measurement => 'snmp',
tags => {
switch => $switch{'sysname'},
+ idd => $iid
},
fields => { $key => $tmp_field },
});
@@ -237,7 +242,7 @@ sub callback{
warn "caught error: $_";
};
- if ((time - $switch{'start'}) > 10) {
+ if ((time - $switch{'start'}) > 5) {
mylog( "Polled $switch{'sysname'} in " . (time - $switch{'start'}) . "s.");
}
} else {
diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js
index 2e3eb06..4de8f3e 100644
--- a/web/js/nms-info-box.js
+++ b/web/js/nms-info-box.js
@@ -954,7 +954,7 @@ var switchLinks = function() {
var topp = document.createElement("div")
var urls = [ "http://gondul.tg23.gathering.org/api/templates/magic.conf/switch=" + sw,
- "http://185.110.149.4/api/templates/magic.conf/switch=" + sw ];
+ "http://185.110.148.105/api/templates/magic.conf/switch=" + sw ];
if (testTree(nmsData,['smanagement','switches',sw])) {
var mg = nmsData["smanagement"]["switches"][sw];
urls.push("ssh://[" + mg.mgmt_v6_addr + "]");
diff --git a/web/templates/HOWTO.txt b/web/templates/HOWTO.txt
deleted file mode 100644
index 641878e..0000000
--- a/web/templates/HOWTO.txt
+++ /dev/null
@@ -1,126 +0,0 @@
-How to use Gondul templating
-============================
-
-We utilize Jinja2 templates.
-
-{#
- This is a jinja2 comment!
--#}
-
-{% set url = "localhost" -%}
-{% set example_switch = "r1.tele" -%}
-
-See http://jinja.pocoo.org/ for the full documentation of the templating
-language.
-
-The rest of this document is about templating as it relates to Gondul
-
-Neat: This document is an actual template, so the examples are working
-examples. The best place to view this HOWTO is in the Gondul GUI, where you
-get a side-by-side comparison of the template and the rendered result.
-
-URLs
-====
-
-To read raw (unprocessed) templates, see http://{{ url }}/templates
-
-To see the rendered final result, see http://{{ url }}/api/templates
-
-Otherwise, use the Template-tab at http://{{ url }}/
-
-Basics
-======
-
-Gondul provides templating through two different, but similar mechanisms.
-
-First, there are permanent templates, or server-side templates. These are
-templates stored on the server and accessible by all Tech crew/equipment.
-
-These are fetched typically through a HTTP GET request. E.g.:
-
-http://{{ url }}/api/templates/switches.txt
-
-Secondly, you can write templates yourself and POST them to Gondul. This is
-highly useful for one-off templates or template development. The syntax is
-the same.
-
-Simply write a template-file and POST it with your favorite command-line
-tool to:
-
-http://{{ url }}/api/templates/WHATEVER
-
-Example:
-
-POST http://{{ url }}nms/api/templates/foobar < my-local-template
-
-Available objects
-=================
-
-Gondul templates have two dictionaries available for general use. The first
-is "options". This is a simple list of GET parameters. If you access
-http://{{ url }}/api/templates/HOWTO.txt?foo=bar, options[foo] will evaluate to
-"bar" in that template. This can be accessed in the template as:
-
-Foo: {{ options["foo"] }}
-
-The second object is the "objects" ... dictionary. This is a list of all
-the HTTP API end-points, in all their glory. The key is the URL.
-
-To use this, you need to review the relevant endpoint. This is best done by
-reading the API documentation (or skimming through other templates). If you
-want to acces e13-2's latency, for example, you can access
-objects["public/ping"].switches["{{ example_switch }}"].latency4
-
-As such: {{ objects["public/ping"].switches[example_switch].latency4 }}
-
-The logic is that "public/ping" is the url: http://{{ url }}/api/public/ping, it
-contains JSON that begins with "switches", a list of all switches, each
-switch as a "latency4" object (among other things)
-
-Other worth-while api-endpoints:
-
-- read/switch-management - Management information
-- public/switches - All switches
-- read/snmp - All SNMP data
-
-Filters
-=======
-
-Jinja2 uses a number of filters to transform variables. They can be used to
-do anything from upper-case all text to pretty-print JSON objects. They are
-used by piping a variable. For example: options|pprint . This will "pretty
-print" the options-object:
-
-{{ options|pprint }}
-
-See http://jinja.pocoo.org/docs/dev/templates/#builtin-filters for a list
-of available filters.
-
-Loops
-=====
-
-You can easily loop over objects, such as switches, using a for-loop.
-Combine this with the "dictsort" filter to get a sorted list.
-
-{% for switch in objects["public/switches"].switches|dictsort %}
- Switch {{ loop.index }} is {{ switch[0] }} or {{ switch[1] }} or full version: {{ switch }}
-{% endfor %}
-
-To avoid having to worry about indices of tuples (e.g.: switch[0]), you can
-also use a simpler style:
-
-{% for key, value in objects["public/ping"].switches|dictsort %}
- Switch {{ loop.index }} is {{ key}} with latency4 of {{ value.latency4 }}ms
-{% endfor %}
-
-Work flow
-=========
-
-Recommended:
-
-1. Read some other template with relevant data.
-2. Open the API endpoints in your browser to review the data structure
-3. Use query-parameters to provide user-selection (e.g.: ?switch=foobar)
-4. Write your template on your local machine, test frequently by POST'ing it
-5. When done: Ask us and we'll upload it server-side
-
diff --git a/web/templates/switch.txt b/web/templates/switch.txt
deleted file mode 100644
index 0fd9754..0000000
--- a/web/templates/switch.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-{#
- This can be used through GET /templating/switch.txt?switch=e41-2
-
- It is provided as a simple demo of how to combine "GET parameters" with
- templating.
-
- #}
-{% set sw = options["switch"] %}
-{% set s = objects["public/switches"].switches[sw] %}
-{% if s %}
-{% set mg = objects["read/switches-management"].switches[sw] %}
-
-Switch {{ sw }} has management ip {{ mg.mgmt_v4_addr }}
-
-It is assoicated with distro {{ s.distro_name }}
-{% else %}
-Switch not found
-{% endif %}
-
diff --git a/web/templates/switches.txt b/web/templates/switches.txt
deleted file mode 100644
index b710066..0000000
--- a/web/templates/switches.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-{% for (switch, s) in objects["public/switches"].switches|dictsort %}
- {% set mg = objects["read/switches-management"].switches[switch] -%}
- {{ switch }} {{mg.subnet4 }} {{ mg.subnet6 }} {{ mg.mgmt_v4_addr }} {{ mg.mgmt_v6_addr }} {{ mg.traffic_vlan }} {{ s.distro_name }}
-{% endfor %}
diff --git a/web/templates/test.conf b/web/templates/test.conf
deleted file mode 100644
index ce2fe0d..0000000
--- a/web/templates/test.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-{# Fetches something simple from gondul #}
-{# Query parameters: ?switch=e1-1 #}
-
-{# Check if ?switch option is given#}
-{% if not options["switch"] %}
- {# pretty print public/switches endpoint#}
- {{ objects["public/switches"] | pprint }}
-{% else %}
- {# sets sw variable using the query parameter #}
- {% set sw = options["switch"] %}
-{% endif %}
-{% if sw %}
- {# find the correct switch from public/switches api endpoint using query paramter#}
- {% set switch = objects["public/switches"].switches[sw] %}
- {# pretty print info in api #}
- {{ switch | tojson }}
-{% endif %}