Giter Site home page Giter Site logo

python-varnishapi's People

Contributors

ema avatar ianmccown avatar szymi- avatar xcir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-varnishapi's Issues

Crash if log abandoned

./vsldump.py[32535]: Traceback (most recent call last):
File "./vsldump.py", line 46, in main
smp.execute(vap)
File "./vsldump.py", line 12, in execute
ret = self.vap.Dispatch(self.vapCallBack)
File "/home/xcir/ex/libvmod-dump/tools/varnishapi.py", line 544, in Dispatch
i = self.__cbMain(cb,priv)
File "/home/xcir/ex/libvmod-dump/tools/varnishapi.py", line 537, in __cbMain
self.vslq = self.lva.VSLQ_New(self.vsl, POINTER(c), self.__g_arg, self.__q_arg);
TypeError: must be a ctypes type

Reading from dump file leads to assert in vsm.c (varnishlog -r)

Issue: When attempting to use python-varnishapi to read varnishlog dumped to binary file on disk, opening it with Varnishapi.VarnishLog() triggers assert in vsm.c.

Assert error in VSM_Get(), vsm.c line 1019:
  Condition((vd->attached) != 0) not true.

python-varnishapi from pypi, version 60.24.
debian testing with Varnish 6.0.7 from packagecloud varnish60lts.

Using this snippet based on the examples:

#!/usr/bin/env python3
import varnishapi
from time import sleep

def cbline(vap, cbd, priv):
    print(cbd)

def cbvxid(vap, priv):
    print("VXID")

def cbgroup(vap, priv):
    print("GROUP")

def main():
#    vsl = varnishapi.VarnishLog(["-g", "request"])
    vsl = varnishapi.VarnishLog(["-r", "foo.dump", "-g", "request"])
    arg = {
        "cb": cbline,
        "vxidcb": cbvxid,
        "groupcb": cbgroup,
        "maxread": 0,
    }

    while 1:
        ret = vsl.Dispatch(**arg)
        if 0 == ret:
            sleep(0.5)
        print(".", end="")
    vsl.Fini()

if __name__ == "__main__":
    main()

How can specify an instance name?

I'm using multiple Varnish named instances.

Here is the crash test with the latest version of the API, using Debian Jessie and its python 2.7.9

>>> import varnishapi
>>> vsc = varnishapi.VarnishStat(opt='-n translation')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "varnishapi.py", line 372, in __init__
    self.__setArg(opt)
  File "varnishapi.py", line 383, in __setArg
    if self.__r_arg and self.vsm:
AttributeError: VarnishStat instance has no attribute '_VarnishStat__r_arg'

empty stats when specifyin -n

With CLI, I can use:

varnishstat -n translation -1

It returns lots of stuff.

I want to do the same with python :

import varnishapi

vsc = varnishapi.VarnishStat(opt=["-n translation"])
r = vsc.getStats()
for k, v in r.iteritems():
        print k, v
vsc.Fini()

Notice that opt is a list of string.

It print nothing.

When I debug, in __gestat, bool(pt) is False and pt is a varnishapi.LP_VSC_point. VSM_n_Arg return 1. Everything seems OK, but it returns nothing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.