varnish / libvmod-rtstatus

Varnish realtime status page.
Other
37 stars 16 forks source link

rtstatus.vcl file giving error not able to see UI #34

Closed thatsk closed 5 years ago

thatsk commented 5 years ago
vcl 4.1;
import rtstatus;
import std;

sub vcl_recv {
        if (req.url ~ "/rtstatus.json") {
                return(synth(700, "OK"));
        }
        if (req.url ~ "/rtstatus") {
                return(synth(800, "OK"));
        }
}
sub vcl_synth {
        if (resp.status == 700){
                set resp.status = 200;
                set resp.http.Content-Type = "text/plain; charset=utf-8";
                synthetic(rtstatus.rtstatus(5));
                return (deliver);
        }
        if (resp.status == 800) {
                set resp.status = 200;
                set resp.http.Content-Type = "text/html; charset=utf-8";
                synthetic(std.fileread("/var/www/html/rtstatus.html"));
                return (deliver);
                }
}
thatsk commented 5 years ago
varnishd -C -f /etc/varnish/default.vcl
Running VCC-compiler failed, exited with 2
VCL compilation failed
thatsk commented 5 years ago

any instruction to install and configure UI ?

gquintard commented 5 years ago

please check the README, your VCL is trying to access an html page that doesn't exist (I guess)

thatsk commented 5 years ago

nope its there @gquintard

root@testserver: ~# ls -la /var/www/html/rtstatus.html
-rwxrwxrwx 1 apache apache 5498 Oct 23 11:03 /var/www/html/rtstatus.html
root@testserver: ~# varnishd -C -f /etc/varnish/default.vcl
Running VCC-compiler failed, exited with 2
VCL compilation failed
thatsk commented 5 years ago
root@testserver: ~# cat /var/www/html/rtstatus.html
<title>Varnish Status</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js">
  location.href = "http://localhost/rtstaus";
</script>
<style type="text/css">
  .p { white-space: pre;}
  .backend { white-space: pre;}
  .col-xs-12 {padding-top: 20%;}
</style>
</head>
<body>
  <h1><b>VARNISH STATUS</b></h1>
  <div class="container" style="float:left;text-align:left;padding-top:2%;">
    <div class="info" >
      <script type="text/javascript">
        var myVar = setInterval(function(){info()}, 1000);
        function info(){
        $.getJSON( "/rtstatus.json", function( data ) {
        var items = [];
        var index = 0;
        items.push("<p>"+  data.req_request + " " + data.obj_status + "</p>");
        items.push("<p>" + data.timestamp + "</p>");
        items.push("<p>"+ "<b>Varnish version:</b> " + data.varnish_version + "," + "</p>");
        items.push("<p>"+ "<b>Varnish port:</b> " + data.varnish_port + "," + "</p>");
        items.push("<p>"+ "<b>Server identity:</b> " + data.server_id + "," + "</p>");
        items.push("<p>" + "<b>Director name:</b>" + " " + data.director.name + "," +  "</p>" );
        items.push("<p>"+ "<b>VCL name:</b>"+ " " + data.director.vcl_name + "," + "</p>");
        items.push("<p>"+ "<b>Hitrate:</b>"+ " " + data.hitrate + "%"+ "</p>");
               items.push("<p>"+ "<b>Load:</b>"+ " " + data.load + "req/s"+ "</p>");
        $("div.info").html("");
        $( "<p/>", {
        "class": "my-new-list",
        html: items.join( "" )
        }).appendTo( "div.info" );
        })();
        };
        info();

      </script>
    </div>
    <h1>Backends</h1>
    <div class="backend">

      <script type="text/javascript">
        var myVar = setInterval(function(){backend()}, 1000);
        function backend(){
        $.getJSON( "/rtstatus.json", function( data ) {
        var items = [];
        var i;
        $.each( data, function( key, val ) {
        if(key === "backend"){
        var tmp = data.backend;
        for(i = 0; i < tmp.length;i++){
        items.push( "<p>" + "<b>Name:</b>      " + tmp[i].name + " : " + tmp[i].value + "," + "</p>" );
        }
        }
        });
        $("div.backend").html("")
        $( "<p/>", {
        "class": "my-new-list",
        html: items.join( "" )
        }).appendTo( "div.backend" );
        })();
        };
        backend();

      </script>
    </div>
    <script>
      function openSpoiler(id){
      var a = document.getElementById(id).style;
      a.display = a.display=='block'?'none':'block'}
    </script>
    <a href="javascript:openSpoiler('spoil')">
      <b>Show detailed counters</b></a>
    <div id="spoil" class="row" style="display: none;">
      <div class="col-xs-4">
        <h2>Description:</h2>
        <p1>qui ci meto i nomi</p1>
        <script type="text/javascript">
          $.getJSON( "/rtstatus.json", function( data ) {
          var items = [];
          var cont = 0;
          $.each( data, function( key, val ) {
          if(cont>9){
          if(!val.type){
          items.push( "<li>" + val.descr + "</li>" );
          }
          }
          cont++;
          });
          $("p1").html("")
          $( "<ul/>", {
          "class": "my-new-list",
          html: items.join( "" )
          }).appendTo( "p1" );
          })();
      </script>
    </div>
    <div class="col-xs-3">
      <h2>Name:</h2>
      <p2>name</p2>
      <script type="text/javascript" style="float:left">
        $.getJSON( "/rtstatus.json", function( data ) {
        var items = [];
        var cont = 0;
        var i = 1;
        $.each( data, function( key, val ) {
        if(cont>9){
        if(!val.type){
        items.push( "<span>" + "<sub>"+ i + ". " + "</sub>" + "[" + key + "]" + "</span><BR>" );
        i++;
        }
        }
        cont++;
        });
        $("p2").html("")
        $( "<ul/>", {
        "class": "my-new-list",
        html: items.join( "" )
        }).appendTo( "p2" );
        })();
      </script>
    </div>
    <div class="col-xs-2">
      <h2>Value:</h2>
      <p3>value</p3>
      <script type="text/javascript">
        var myVar = setInterval(function(){value()}, 1000);
        function value(){
        $.getJSON( "/rtstatus.json", function( data ) {
        var items = [];
        var cont = 0;
        var i = 1;
        $.each( data, function( key, val ) {
        if(cont>9){
        if(!val.type){
        items.push( "<span>" + "<sub>"+ i + ". " + "</sub>" + val.value + "</span><BR>");
        i++;
        }
        }
        cont++;
        });
        $("p3").html("")
        $( "<ul/>", {
        "class": "my-new-list",
        html: items.join( "" )
        }).appendTo( "p3" );
        })();
        };
        value();
      </script>
    </div>
  </div>
</div>
<hr>
  <div class="row">
    <div class="col-xs-12">
      <footer>
        <a href="/rtstatus.json" target="_blank">Complete JSON file</a><br />
        <a href="https://github.com/arianna-aondio/libvmod-rtstatus" target="_blank">Github repository</a><br /><br /><br />
        <p>&copy;Copyright 2014 Varnish Software AS</p>
      </footer>
    </div>
  </div>
  </div>
</body>
</html>
gquintard commented 5 years ago

Is there anything other than "compilation failed" when you run the "varnishd -C" command? It's unlike varnish to just exit silently.

What varnish version are you running?

On Thu, Oct 24, 2019, 00:21 Thatsk notifications@github.com wrote:

root@testserver: ~# cat /var/www/html/rtstatus.htmlVarnish Status

VARNISH STATUS

Backends

Show detailed counters

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or unsubscribe .
thatsk commented 5 years ago

6.3.1

thatsk commented 5 years ago

even i am not getting rtstatus.json file which shows output.

thatsk commented 5 years ago
root@test: /etc/varnish# rpm -qa | grep varnish
varnish_exporter-1.0.12-1.noarch
varnish-6.3.1-1.el7.x86_64
varnish-devel-6.3.1-1.el7.x86_64
thatsk commented 5 years ago
default.vcl
#############################
# GENERATED FILE. DONT EDIT #
#############################
vcl 4.1;

import directors;

backend default {
  .host = "127.0.0.1";
  .port = "80";
  .connect_timeout = 0.7s;
  .first_byte_timeout = 60s;
  .between_bytes_timeout = 60s;
}

############
# INCLUDES #
############

include "/etc/varnish/conf.d/varnish-health.vcl";
include "/etc/varnish/conf.d/rtstatus.vcl";
thatsk commented 5 years ago

this is default.vcl

thatsk commented 5 years ago

@gquintard is there anyinformation you want?

gquintard commented 5 years ago

rtstatus.rtstatus() isn't a valid call, it appears that it's what's tripping the VCL compiler. Your code is wrong, but VCC should be more explicit. I'll open the relevant varnish bug.

thatsk commented 5 years ago

@gquintard i just made changs to syntetic compilation error gone. but not able to see any output.

vcl 4.1;
import rtstatus;
import std;
#######################
# vcl_recv SUBROUTINE #
#######################

/*
 * Called at the beginning of a request, after the complete request has been received and parsed.
 * Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,
 * which backend to use. Also used to modify the request.
 */
sub vcl_recv {
  if (req.url ~ "/rtstatus.json") {
    return (synth(700, "OK"));
  }
  if (req.url ~ "/rtstatus") {
    return (synth(800, "OK"));
  }
}

########################
# vcl_synth SUBROUTINE #
########################

/*
 * Called to deliver a synthetic object generated in VCL, not fetched from the backend.
 * Its body may be constructed using the synthetic() function.
 */
sub vcl_synth {
  if (resp.status == 700) {
    set resp.status = 200;
    set resp.http.Content-Type = "text/plain; charset=utf-8";
    rtstatus.synthetic_json();
    return (deliver);
  }
  if (resp.status == 800) {
    set resp.status = 200;
    set resp.http.Content-Type = "text/html; charset=utf-8";
    rtstatus.synthetic_html();
    return (deliver);
  }
}
thatsk commented 5 years ago

why its not showing any output on browser?

thatsk commented 5 years ago

as per vcl file described in web page:- https://docs.varnish-software.com/varnish-cache-plus/vmods/rtstatus/

thatsk commented 5 years ago

@gquintard

gquintard commented 5 years ago

please don't send multiple messages in rapid succession, it doesn't help.

This bug tracker is reserved for bugs, please move the discussion to one of the user help channels: https://varnish-cache.org/support/