Giter Club home page Giter Club logo

Comments (11)

mnpenner avatar mnpenner commented on July 19, 2024 1

@szepeviktor You can rebundle as a new phar I guess. Unless you can require 'cachetool.phar'?

from cachetool.

szepeviktor avatar szepeviktor commented on July 19, 2024

And without human-readable M/kbytes.

from cachetool.

szepeviktor avatar szepeviktor commented on July 19, 2024

When using as a library the server will have a lot of unpackaged/uncontrolled files.

from cachetool.

szepeviktor avatar szepeviktor commented on July 19, 2024

The current work-around is

#!/bin/bash

declare -r -i OPCACHE_MIN_MB="5"
declare -r -i OPCACHE_STRING_MIN_MB="1"

# opcache.memory_consumption
Opcache_free() {
    local -i OPCACHE_MB
    local -i MIN="$1"

    OPCACHE_FREE="$(cachetool opcache:status | sed -n -e 's/^| Memory free\s\+| \(\S\+ \S\+\)\s*|$/\1/p')"

    # Test human-readable bytes
    grep -q -F "MiB" <<< "$OPCACHE_FREE"

    # Integer only size
    OPCACHE_MB="$(cut -d " " -f 1 <<< "$OPCACHE_FREE" | cut -d "." -f 1)"

    test "$OPCACHE_MB" -ge "$MIN"
}

# opcache.interned_strings_buffer
Opcache_string_free() {
    local -i OPCACHE_MB
    local -i MIN="$1"

    OPCACHE_FREE="$(cachetool opcache:status | sed -n -e 's/^| Strings memory free\s\+| \(\S\+ \S\+\)\s*|$/\1/p')"

    # Test human-readable bytes
    grep -q -F "MiB" <<< "$OPCACHE_FREE"

    # Integer only size
    OPCACHE_MB="$(cut -d " " -f 1 <<< "$OPCACHE_FREE" | cut -d "." -f 1)"

    test "$OPCACHE_MB" -ge "$MIN"
}

# opcache.max_accelerated_files
Opcache_max_keys() {
    local -i OPCACHE_CACHED_KEYS
    local -i OPCACHE_MAX_KEYS

    OPCACHE_CACHED_KEYS="$(cachetool opcache:status | sed -n -e 's/^| Cached keys\s\+| \(\S\+\)\s*|$/\1/p')"
    OPCACHE_MAX_KEYS="$(cachetool opcache:status | sed -n -e 's/^| Max cached keys\s\+| \(\S\+\)\s*|$/\1/p')"

    test "$OPCACHE_MAX_KEYS" -gt "$OPCACHE_CACHED_KEYS"
}

set -e

Opcache_free "$OPCACHE_MIN_MB"
Opcache_string_free "$OPCACHE_STRING_MIN_MB"
Opcache_max_keys

from cachetool.

mnpenner avatar mnpenner commented on July 19, 2024

@szepeviktor Might be easier for you to go through the PHP API

from cachetool.

szepeviktor avatar szepeviktor commented on July 19, 2024

So you're suggesting me a rewrite in PHP.

from cachetool.

szepeviktor avatar szepeviktor commented on July 19, 2024

When using as a library the server will have a lot of unpackaged/uncontrolled files.

Is there a way to use one phar file? This shell script is one part of a monitoring solution so all cachetool source files have nowhere to go.

from cachetool.

mnpenner avatar mnpenner commented on July 19, 2024

I dunno man. I just found this tool, I know almost nothing about it. The maintainer didn't respond to you, so I was just offering an alternative if you don't want to wait. Yes -- my suggestion is to rewrite in PHP. It should be like 5 lines of code. Use the API to grab the $info, then you can json_encode it just like you wanted.

from cachetool.

szepeviktor avatar szepeviktor commented on July 19, 2024
$ composer require gordalina/cachetool
$ find -type f | wc -l
1264

So my monitoring solution would grow by 1264 files :-)

from cachetool.

gordalina avatar gordalina commented on July 19, 2024

There are a couple of solutions to this problem:

  1. require the phar as @mnpenner suggested:
include 'phar://cachetool.phar/path/to/file.php';

// use cachetool as a library
// see README.md
  1. Add support for multi-format output (instead of just tables). You'd have to send in a PR to address this.

from cachetool.

gordalina avatar gordalina commented on July 19, 2024

Closing in favor of #81

from cachetool.

Related Issues (20)

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.