def createGraphByKeyPattern(self, template, keypattern, name, drawtype='2', width='900', height='200'): """ Creates zabbix template graph for items with key matched pattern. If graph already exists, updates it. Parameters: template - template name keypattern - key pattern which should match items for graphing name - graph name drawtype - Line(0), filled region(1), bold line(2), dot(3), dashed(4), gradient(5) width - width of graph height - height of graph """ try: gitems = [] items = self.zapi.item.get({'sortfield':'itemid', 'templated': True, 'search' : {'key_': keypattern}, 'searchWildcardsEnabled': True} ) from pprint import pprint pprint(items) for item in items: gitem = self._makeGraphItem(item['itemid'], drawtype, getColor(len(items), items.index(item)), items.index(item)) gitems.append(gitem) graph = self._makeGraph(gitems, name, width, height) self._createGraph(graph) except ZabbixAPIException, e: sys.stderr.write(str(e) + '\n')
def createGraphByHostgroup(self, group, key, name, drawtype='2', width='900', height='200'): """ Creates zabbix graph for hostgroup with graphitems determined by key. If graph already exists, updates it. Parameters: group - host group key - item key which will be graphed name - graph name drawtype - Line(0), filled region(1), bold line(2), dot(3), dashed(4), gradient(5) width - width of graph height - height of graph """ try: gitems = [] items = self.zapi.item.get({'group': group, 'sortfield': 'itemid', 'selectHosts': 'extend', 'filter' : {'key_': key}}) # Add sorting as human expect def sort_by_host(items): convert = lambda text: int(text) if text.isdigit() else text alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ] return sorted(items, key=lambda item: alphanum_key(item['hosts'][0]['name'])) sorted_items = sort_by_host(items) for item in sorted_items: gitem = self._makeGraphItem(item['itemid'], drawtype, getColor(len(items), sorted_items.index(item)), sorted_items.index(item)) gitems.append(gitem) graph = self._makeGraph(gitems, name, width, height) self._createGraph(graph) except ZabbixAPIException, e: sys.stderr.write(str(e) + '\n')
def createGraphByKeyPattern(self, template, keypattern, name, drawtype="2", width="900", height="200"): """ Creates zabbix template graph for items with key matched pattern. If graph already exists, updates it. Parameters: template - template name keypattern - key pattern which should match items for graphing name - graph name drawtype - Line(0), filled region(1), bold line(2), dot(3), dashed(4), gradient(5) width - width of graph height - height of graph """ try: gitems = [] items = self.zapi.item.get( { "sortfield": "itemid", "templated": True, "search": {"key_": keypattern}, "searchWildcardsEnabled": True, } ) from pprint import pprint pprint(items) for item in items: gitem = self._makeGraphItem( item["itemid"], drawtype, getColor(len(items), items.index(item)), items.index(item) ) gitems.append(gitem) graph = self._makeGraph(gitems, name, width, height) self._createGraph(graph) except ZabbixAPIException, e: sys.stderr.write(str(e) + "\n")
def createGraphByHostgroup(self, group, key, name, drawtype="2", width="900", height="200"): """ Creates zabbix graph for hostgroup with graphitems determined by key. If graph already exists, updates it. Parameters: group - host group key - item key which will be graphed name - graph name drawtype - Line(0), filled region(1), bold line(2), dot(3), dashed(4), gradient(5) width - width of graph height - height of graph """ try: gitems = [] items = self.zapi.item.get( {"group": group, "sortfield": "itemid", "selectHosts": "extend", "filter": {"key_": key}} ) # Add sorting as human expect def sort_by_host(items): convert = lambda text: int(text) if text.isdigit() else text alphanum_key = lambda key: [convert(c) for c in re.split("([0-9]+)", key)] return sorted(items, key=lambda item: alphanum_key(item["hosts"][0]["name"])) sorted_items = sort_by_host(items) for item in sorted_items: gitem = self._makeGraphItem( item["itemid"], drawtype, getColor(len(items), sorted_items.index(item)), sorted_items.index(item) ) gitems.append(gitem) graph = self._makeGraph(gitems, name, width, height) self._createGraph(graph) except ZabbixAPIException, e: sys.stderr.write(str(e) + "\n")
def renderSprites(self, pixels: pygame.PixelArray) -> None: lcdc = self.emu.read(LCDC_ADDR) if not getBit(lcdc, LCDC_OBJ_EN): return Sprite = SpriteTile16 if getBit(lcdc, LCDC_OBJ_SIZE) else SpriteTile8 for addr in range(0xFE00, 0xFEA0, 4): tile = Sprite(self.emu, addr) for dy in range(tile.ROWS): if not (0 <= tile.y + dy < ROWS): continue for dx in range(tile.COLS): if not (0 <= tile.x + dx < COLS): continue x, y = self.scx + tile.x + dx, self.scy + tile.y + dy if tile.priority or pixels[x * RESIZE, y * RESIZE] == getColor( 0, PPU.NOSTALGIC): if tile.pixels[dy][dx] < 0: continue PPU.fill(x, y, tile.pixels[dy][dx], pixels) del tile
def fill(x: int, y: int, colorCode: int, pixels: pygame.PixelArray) -> None: for dy in range(RESIZE): for dx in range(RESIZE): pixels[x * RESIZE + dx, y * RESIZE + dy] = getColor(colorCode, PPU.NOSTALGIC)