Index: tools/gformat.py
===================================================================
--- tools/gformat.py	(revision 11262)
+++ tools/gformat.py	(revision 11326)
@@ -139,5 +139,6 @@
         'service_proxy_ileiden' : False, 
         'service_accesspoint' : True, 
-        'service_incoming_rdr' : False 
+        'service_incoming_rdr' : False, 
+        'monitoring_group' : 'wleiden',
       }
       for (key,value) in defaults.iteritems():
@@ -1366,4 +1367,5 @@
 \tstandalone [port]            =  Run configurator webserver [8000]
 \tdns [outputdir]              =  Generate BIND compliant zone files in dns [./dns]
+\tnagios-export [--heavy-load] =  Generate basic nagios configuration file.
 \tfull-export                  =  Generate yaml export script for heatmap.
 \tstatic [outputdir]           =  Generate all config files and store on disk
@@ -1534,4 +1536,170 @@
               VALUES ((SELECT id FROM nodes WHERE name = '%(nodename)s'), 'ap',
               '%(ssid)s', 'IEEE 802.11b', %(channel)s, 'active');""" % ifacedump
+    elif sys.argv[1] == "nagios-export":
+      try:
+        heavy_load = (sys.argv[2] == "--heavy-load")
+      except IndexError:
+        heavy_load = False
+
+      hostgroup_details = {
+         'wleiden' : 'Stichting Wireless Leiden - FreeBSD Nodes',
+         'wzoeterwoude' : 'Stichting Wireless Leiden - Afdeling Zoeterwoude - Free-WiFi Project',
+         'walphen' : 'Stichting Wireless Alphen',
+         'westeinder' : 'WestEinder Plassen',
+      }
+
+      params = {
+        'check_interval' : 5 if heavy_load else 60,
+        'retry_interval' : 1  if heavy_load else 5,
+        'max_check_attempts' : 10 if heavy_load else 3,
+      }  
+
+      print '''\
+define host {
+        name                  wleiden-node           ; Default Node Template
+        use                   generic-host           ; Use the standard template as initial starting point
+        check_period          24x7                   ; By default, FreeBSD hosts are checked round the clock
+        check_interval        %(check_interval)s     ; Actively check the host every 5 minutes
+        retry_interval        %(retry_interval)s     ; Schedule host check retries at 1 minute intervals
+        max_check_attempts    %(max_check_attempts)s ; Check each FreeBSD host 10 times (max)
+        register              0                      ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
+}
+
+define service {
+        name                  wleiden-service        ; Default Service Template
+        use                   generic-service        ; Use the standard template as initial starting point
+        check_period          24x7                   ; By default, FreeBSD hosts are checked round the clock
+        check_interval        %(check_interval)s     ; Actively check the host every 5 minutes
+        retry_interval        %(retry_interval)s     ; Schedule host check retries at 1 minute intervals
+        max_check_attempts    %(max_check_attempts)s ; Check each FreeBSD host 10 times (max)
+        register              0                      ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
+}
+
+# Please make sure to install:
+# make -C /usr/ports/net-mgmt/nagios-check_netsnmp install clean
+#
+define command{
+        command_name          check_netsnmp_disk
+        command_line          $USER1$/check_netsnmp -H $HOSTADDRESS$ -o disk
+}
+
+define command{
+        command_name          check_netsnmp_load
+        command_line          $USER1$/check_netsnmp -H $HOSTADDRESS$ -o load
+}
+
+define command{
+        command_name          check_netsnmp_proc
+        command_line          $USER1$/check_netsnmp -H $HOSTADDRESS$ -o proc
+}
+
+# TDB: dhcp leases
+# /usr/local/libexec/nagios/check_netsnmp -H 192.168.178.47 --oid 1 exec
+
+# TDB: internet status
+# /usr/local/libexec/nagios/check_netsnmp -H 192.168.178.47 --oid 1 file
+
+# TDB: Advanced local passive checks
+# /usr/local/libexec/nagios/check_by_ssh
+''' % params
+
+      print '''\
+# Service Group, not displayed by default        
+define hostgroup {
+       hostgroup_name         srv_hybrid
+       alias                  All Hybrid Nodes
+       register 0
+}
+
+define service {
+        use                   wleiden-service
+        hostgroup_name        srv_hybrid
+        service_description   SSH
+        check_command         check_ssh
+}
+
+define service {
+        use                   wleiden-service
+        hostgroup_name        srv_hybrid
+        service_description   HTTP
+        check_command         check_http
+}
+
+define service {
+        use                   wleiden-service
+        hostgroup_name        srv_hybrid
+        service_description   DNS
+        check_command         check_dns
+}
+
+# TDB: Can only test this if we have the proxy listening to all addresses. 
+# define service {
+#         use                   wleiden-service
+#         hostgroup_name        srv_hybrid
+#         service_description   PROXY
+#         check_command         check_tcp!3128
+# }
+'''
+
+      if heavy_load:
+        print '''\
+define service {
+        use                   wleiden-service
+        hostgroup_name        srv_hybrid
+        service_description   SNMP
+        check_command         check_snmp
+}
+
+define service {
+        use                   wleiden-service
+        hostgroup_name        srv_hybrid
+        service_description   NTP
+        check_command         check_ntp_peer
+}
+
+define service {
+        use                   wleiden-service
+        hostgroup_name        srv_hybrid
+        service_description   LOAD
+        check_command         check_netsnmp_load
+}
+
+define service {
+        use                   wleiden-service
+        hostgroup_name        srv_hybrid
+        service_description   PROC
+        check_command         check_netsnmp_proc
+}
+
+define service {
+        use                   wleiden-service
+        hostgroup_name        srv_hybrid
+        service_description   DISK
+        check_command         check_netsnmp_disk
+}
+'''
+      for node in get_hostlist():
+        datadump = get_yaml(node)
+        if not datadump['status'] == 'up':
+          continue
+        if not hostgroup_details.has_key(datadump['monitoring_group']):
+           hostgroup_details[datadump['monitoring_group']] = datadump['monitoring_group']
+        print '''\
+define host {
+        use                   wleiden-node
+        host_name             %(autogen_fqdn)s
+        address               %(masterip)s
+        hostgroups            srv_hybrid,%(monitoring_group)s
+}
+''' % datadump
+
+      for name,alias in hostgroup_details.iteritems(): 
+        print '''\
+define hostgroup {
+       hostgroup_name         %s
+       alias                  %s
+} ''' % (name, alias)      
+
+
     elif sys.argv[1] == "full-export":
       hosts = {}
