+  HandyCache форум
|-+  Главная категория» English forum» Monitor action to my text
Имя пользователя:
Пароль:
Страниц: [1]   Вниз
  Отправить эту тему    Печать  
Автор Тема: Monitor action to my text  (Прочитано 3033 раз)
0 Пользователей и 1 Гость смотрят эту тему.
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« : 07 июня 2017, 00:43:19 »

Hi. I have question for script... i can RULES in monitor show as my definition text convert to Response?

Example:

Response: 200 OK, Rules: U.1, S.2
convert to show as red color text:
Response: Save to Cache, Rules:U.1, S.2

and for

Response: 200 OK From Cache (HC), Rules: U.20, D.2
convert to show as green color text:
Response: Load From Cache, Rules: U.20, D.2
 

Do you can help me to create? I know param "hc.monitor_string" but no idea for include how build to script.
Сообщить модератору   Записан
mai62
Автор HC
*****

Репутация: +226/-4
Offline Offline

Сообщений: 6383


« Ответ #1 : 10 июня 2017, 17:30:33 »

Цитировать
Response: 200 OK From Cache (HC), Rules: U.20, D.2
convert to show as green color text:
Response: Load From Cache, Rules: U.20, D.2
Код:
--[[ <HCExtension>
@name          Test_color
@event      RequestHeaderReceived
</HCExtension> ]]

function RequestHeaderReceived()
  if re.find(hc.answer_header, [[200 OK From Cache (HC)]]) then
    hc.monitor_string = hc.monitor_string..'Load From Cache'
    hc.monitor_text_color = 0 + 90*256 + 0*256*256  -- Green (R+G+B)
  end
end
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #2 : 15 июня 2017, 11:28:17 »

No show text from this.

And second question. How add combine with apply one file type?

My script based on filetype is:
No show text in monitor
Код:
function Test()
if re.match (hc.url, [[\.(jpe?g|bmp|png|webp|gif)(\?|$)]]) then
              hc.answer_header = [[200 OK From Cache (HC)]]
              hc.monitor_string = hc.monitor_string..'Images - Cache'
            else
      hc.monitor_string = hc.monitor_string..'Images - WAN '
            end
end


This show text monitor
Код:
function Test()
  if re.match (hc.url, [[\.(jpe?g|bmp|png|webp|gif)(\?|$)]]) then
    hc.monitor_string = hc.monitor_string..'Images - From WAN '
hc.monitor_text_color = 0 + 90*256 + 0*256*256  -- Green (R+G+B)
    end
end
----------------------
And bug:
If add this:

Код:
  if re.match(hc.answer_header, [[^HTTP/1\.1\s304[^\r\n]+]]) then
    hc.monitor_string = hc.monitor_string..'Client Cache'
    hc.monitor_text_color = 4557568
  end

then show line "304 Not modified" only as green (no 304 Not modified (HC)), and "200 OK From Cache (HC)" show as green.


----------
Complette test script:

Код:
--[[ <HCExtension>
@name          Test
@description   For testing
@event         AnswerHeaderReceived
</HCExtension> ]]

function AnswerHeaderReceived()
  if re.match (hc.url, [[\.(jpe?g|bmp|png|webp|gif)(\?|$)]]) then
    hc.monitor_string = hc.monitor_string..'Images - From WAN'
hc.monitor_text_color = 0 + 90*256 + 0*256*256  -- Green (R+G+B)
  end
  if re.find(hc.answer_header, [[200 OK From Cache (HC)]]) then
    hc.monitor_string = hc.monitor_string..'Images - Cache'
    hc.monitor_text_color = 0 + 90*256 + 0*256*256  -- Green (R+G+B)
  end
  if re.match(hc.answer_header, [[^HTTP/1\.1\s304[^\r\n]+]]) then
    hc.monitor_string = hc.monitor_string..'Client Cache'
    hc.monitor_text_color = 0 + 90*256 + 0*256*256  -- Green (R+G+B)
  end
end

function Test()
if re.match (hc.url, [[\.(jpe?g|bmp|png|webp|gif)(\?|$)]]) then
              hc.answer_header = [[200 OK From Cache (HC)]]
              hc.monitor_string = hc.monitor_string..'Images - Cache'
            else
          hc.monitor_string = hc.monitor_string..'Images - WAN'
            end
end
« Последнее редактирование: 15 июня 2017, 11:38:02 от truefriend-cz » Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #3 : 15 июня 2017, 14:19:27 »

Mai62 where is problem?

I run two testing script, but no solutions. How worked RequestHeaderReceived?

Код:
--[[ <HCExtension>
@name          Test
@event       RequestHeaderReceived
</HCExtension> ]]

function RequestHeaderReceived()
    if not re.find(hc.request_header, [[Cache]]) then
    hc.monitor_string = hc.monitor_string..'Test RequestHeaderReceived OK'
end

Код:
--[[ <HCExtension>
@name          Test
@event       RequestHeaderReceived
</HCExtension> ]]

function RequestHeaderReceived()
    if re.find(hc.request_header, [[Cache]]) then
    hc.monitor_string = hc.monitor_string..'Test RequestHeaderReceived OK'
end
Сообщить модератору   Записан
mai62
Автор HC
*****

Репутация: +226/-4
Offline Offline

Сообщений: 6383


« Ответ #4 : 17 июня 2017, 13:06:31 »

I made a mistake. You do not need to use RequestHeaderReceived, but AnswerHeaderReceived and hc.answer_header.
Код:
--[[ <HCExtension>
@name          Test
@event       AnswerHeaderReceived
</HCExtension> ]]

function AnswerHeaderReceived ()
    if not re.find(hc.answer_header, [[Cache]]) then
    hc.monitor_string = hc.monitor_string..'Test AnswerHeaderReceived OK'
end
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #5 : 19 июня 2017, 13:45:14 »

Thanks. Version HC 1.0.0.671 maybe have bug. Version 1.0.0.571 and etc..

I tested on original Rev5 script Extension... on clean HC (all other Extensions disabled). Only on 1.0.0.671 no show colors and "my texts" in monitor.
« Последнее редактирование: 19 июня 2017, 13:52:54 от truefriend-cz » Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #6 : 21 июня 2017, 14:53:15 »

Thank you very much Улыбка
Сообщить модератору   Записан
Страниц: [1]   Вверх
  Отправить эту тему    Печать  

 
Перейти в: