comparison dash.py @ 25:05e5441c5160

charts will now be displayed as they should!
author sean
date Fri, 14 Aug 2015 00:31:48 +0200
parents 7d431b779512
children af280057d5fa
comparison
equal deleted inserted replaced
24:7d431b779512 25:05e5441c5160
77 except KeyError: 77 except KeyError:
78 settings = default_settings["settings"] 78 settings = default_settings["settings"]
79 79
80 ###write the default condfig file if there is none 80 ###write the default condfig file if there is none
81 def write_default_config(): 81 def write_default_config():
82 print("there is no Config file! Creating one...") 82 logger.info("No config-file found. create new config file")
83 file = open(CONFIG_PATH, "w") 83 file = open(CONFIG_PATH, "w")
84 file.write(""" 84 file.write("""
85 ### bottledash default configuration 85 ### bottledash default configuration
86 ### created by sean engelhardt >sean.engelhardt@intevation.de 86 ### created by sean engelhardt >sean.engelhardt@intevation.de
87 ### license: GNU GPL >= v2. See LICENSE for details 87 ### license: GNU GPL >= v2. See LICENSE for details
102 # default: True 102 # default: True
103 # hint: the top-bar has got a height of 5%! 103 # hint: the top-bar has got a height of 5%!
104 104
105 [settings] 105 [settings]
106 show_top_bar=False 106 show_top_bar=False
107 rows=2
107 108
108 # Tiles: 109 # Tiles:
109 # example: 110 # example:
110 # -------------------- 111 # --------------------
111 # [tile1] 112 # [tile1]
121 # default: - 122 # default: -
122 # 123 #
123 # source (<IP> or <FQDN>) [required for mon-types] 124 # source (<IP> or <FQDN>) [required for mon-types]
124 # ONLY FOR MON-Type tiles! 125 # ONLY FOR MON-Type tiles!
125 # tells the tile which resource to watch 126 # tells the tile which resource to watch
126 # default: none
127 #
128 # status: (up / down) [required]
129 # ONLY FOR DEBUGGING PURPOSE - WILL BE REMOVED LATER 127 # ONLY FOR DEBUGGING PURPOSE - WILL BE REMOVED LATER
130 # simulates up and down events for mon-type-tiles 128 # simulates up and down events for mon-type-tiles
131 # 129 #
132 # div_name: (identifier) [required for d3js-types] 130 # div_name: (identifier) [required for d3js-types]
133 # 131 #
134 # script: (name of a script without extension) [required for d3js-types0] 132 # script: (name of a script without extension) [required for d3js-types0]
135 # 133 #
136 [tile1] 134 [tile1]
137 type=mon 135 type=mon
138 source=192.168.0.2 136 source=red2.rgb.intevation.de
139 status=down 137 status="dynamic"
140 138
141 [tile2] 139 [tile2]
142 type=mon 140 type=mon
143 source=192.168.2.3 141 source=192.168.2.3
144 status=up 142 status="dynamic"
145 143
146 [tile3] 144 [tile3]
147 type=mon 145 type=mon
148 source=192.168.4.3 146 source=192.168.4.3
149 status=up 147 status="dynamic"
150 148
151 [tile4] 149 [tile4]
152 type=d3js 150 type=web_view
153 div_name=techintern 151 div_name=techintern
154 script=display_issues_techintern 152 script=display_issues_techintern
155 """) 153 """)
156 file.close() 154 file.close()
157 155
179 logger.info('------- new alert --------') 177 logger.info('------- new alert --------')
180 logger.info('Service : ' + str(service)) 178 logger.info('Service : ' + str(service))
181 logger.info('Status : ' + str(status)) 179 logger.info('Status : ' + str(status))
182 # log_tile_status() 180 # log_tile_status()
183 181
184 return "thanks for informing bottledash! :: " + str(service) + " is " + str(status) + " !" 182 return ":: " + str(service) + " is " + str(status) + " !"
185 183
186 184
187 @post('/ask-systemstate') 185 @post('/ask-systemstate')
188 def get_systemstate(): 186 def get_systemstate():
189 global tiles 187 global tiles
190 service = request.forms.get('service') 188 service = request.forms.get('service')
191 189
192 print("service: " + service) 190 # print("service: " + service)
193 191
194 try: 192 try:
195 for tile in tiles: 193 for tile in tiles:
196 if tile["source"] == str(service): 194 if tile["source"] == str(service):
197 # return "service : " + str(service) + " is " + str(tile["status"]) 195 # return "service : " + str(service) + " is " + str(tile["status"])
210 def error404(error): 208 def error404(error):
211 return 'Nothing here, sorry <br /> 404' 209 return 'Nothing here, sorry <br /> 404'
212 210
213 read_config() 211 read_config()
214 # print(tiles) 212 # print(tiles)
215 run(host='localhost', port=8080, debug=True) 213 run(host='localhost', port=8080, debug=False, quiet=True)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)