web-dev-qa-db-fra.com

PS n'imprime que 4096 caractères de la ligne de commande de n'importe quel processus

Lorsque je grep pour un Java processus, je reçois en dessous de la sortie, mais il est limité à 4096 caractères qui permet un nom de processus réel (qui est kafka.kafka) non affiché dans grep Sortie.

Est-ce une limitation de grep? Y a-t-il un moyen d'imprimer des caractères au-delà de la limite de 4096?

ps -ef | grep Java

Java -XMX6G -XMS6G -SERVER -XX: + UtilisationG1GC -XX: Maxgcpausemillis = 20 -xx: initiationHeapecpupbanypercenter = 35 -xx: + désactiverExplicitgc -djava.awt.adjava.awt.adless = true -xloggc:/x/kafka/data01/kafka-application -Logs/KAFKASERVER-GC.LOG -VERBOSE: GC -XX: + PrintGCDétails -xx: + printgcdatestams -xx: + printgctMestamps -dcom.sun.management.jmxremote -dcom.sun.management.jmxremote.authenticiat = false -dcom. Sun.management.jmxremote.ssl = false -dkafka.logs.dir =/x/kafka/data01/kafka-app-journaux -dlog4j.configuration = fichier :./../ config/log4j.properties -cp:/x /Home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin/../libs/aopalliance-repackaged-2.4.0-B34.jar:/x/home/bmcuser/kafka-paypal/kafka_2.10 -0,10.1.1/bin /../ libs/argparse4j-0.5.0.jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/Connect-Api- 0.10.1.1.jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/connect-file-0.10.1.1.jar:/x/home/bmcuser/kafka/kafka -Paypal/kafka_2.10-0.10.1.1/bin /../ libs/connect-json-0.10.1.1.jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.1 0.1.1/Bin /../ libs/Connect-Runtime-0.10.1.1.jar: /x/Home/bmcuser/KAFKA-PAYPAL/KAFKA_2.10-0.10.1.1/bin /../ Libs/Guava-18.0 .jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/hk2-api-2.4.0-b34.jar:/x/home/bmcuser/kafka- PayPal/kafka_2.10-0.10.1.1/bin /../ libs/hk2-locator-2.4.0-b34.jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin/ ../libs/hk2-utils-2.4.0-b34.jar:/x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.10/bin/../libs/jackson-notations-2.6.0 .jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/jackson-core-2.6.3jar:/x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/jackson-databind-2.6.3jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs /jackson-jaxrs-base-2.6.3jar:/x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin/../libs/jackson-jaxrs-json-provider-2.6.3 .jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/jackson-module-jaxb-annotations-2.6.3jar:/x/home/bmcuser/Kafka-PayPal/kafka_2.10-0.10.1.1/bin /../ libs/javass IST-3.18.2-GA.JAR: /x/Home/bmcuser/KAFKA-PAYPAL/KAFKA_2.10-0.10.1.1/bin /../ libs/javax.notation-API-1.2.jar:/x/home /bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin/../libs/javax.inject--.jar:/x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../libs/javax.inject-2.4.0-b34.jar:/x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin/../libs/javax.servlet-api- 3.1.0.jar: /x/Home/bmcuser/KAFKA-PAYPAL/KAFKA_2.10-0.10.1.1/bin /../ libs/javax.ws.rs-API-2.0.1.jar:/x/home /bmCuser/KAFKA-PAYPAL/KAFKA_2.10-0.10.1.1/BIN/../LIBS/JERSEY-CLIENT-2.22.2.JARRAG/X/HOME/BMCUSER/KAFKA-PAYPAL/KAFKA_2.10-0.10.1.1 /bin/../libs/jersey-commmon-2.2.2.jar:/x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin/../libs/jersey-container-Servlet- 2.22.2.jar: /x/Home/bmcuser/KAFKA-PAYPAL/KAFKA_2.10-0.10.1.1/bin /../ libs/jersey-conteneur-servlet-core-2.22.2.jar:/x/home /bmCuser/kafka-paypal/kafka_2.10-0.10.1.1/bin/../libs/jersey-guava-2.22.2.jar :/x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1 /bin/../libs/jersey-media-jaxb-2.22.2.jar :/x /Home/bmcuser/KAFKA-PAYPAL/KAFKA_2.10-0.10.1.1/BIN/../LIBS/JERSEY-SERVER-2.22.2.jAR:/x/Home/BMCUSER/KAFKA-PAYPAL/KAFKA_2.10-0.10 .1.1/bin /../ libs/jetty-continuation-9.2.15.v20160210.jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/jetée- http-9.2.15.v20160210.jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/jetty-io-9.2.15.v20160210.jar:/x /Home/bmcuser/KAFKA-PAYPAL/KAFKA_2.10-0.10.1.1/bin/../libs/Jetty-Security-9.2.15.v20160210.jar :/x/Home/bmcuser/KAFKA-PAYPAL/KAFKA_2.10 -0,10.1.1/bin /../ libs/jetty-serveur-9.2.15.v20160210.jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/Jetty-servlet-9.2.15.v20160210.jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/jetty-servlets-9.2.15.v20160210.jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin/../libs/Jetty-util-9.2.15.v20160210.jar :/x/Home/bmcuser/kafka-paypal/kafka_2 .10-0.10.1.1/bin /../ libs/jopt-simple-4.9.jar: /x/home/bmcuser/kafka-paypal/kafka_2.10-0.10.1.1/bin /../ libs/kafka_2. dix- 0.10.1.1.jar: /x/home/bmcuser/KAFKA-PAYPAL/KAFKA_2.10-0.10.1.1/bin /../ libs/kafka_2.10-0.10.1.1-Ainsi

19
zer0Id0l

Ce n'est pas une limitation de grep, mais de /proc/PID/cmdline (techniquement, une décision de conception, pas une limitation). /proc/PID/cmdline contient la ligne de commande complète du processus, avec la commande principale et les arguments séparés par ASCII nul, et le fichier se termine également à Nul. Ainsi, grep imprimera le tout Contenu de fichier s'il y a un match. (ps -ef Obtient le contenu de ce fichier comme CMD).

La longueur maximale est codée en dur dans le noyau (Linux) au PAGE_SIZE :

static int proc_pid_cmdline(struct task_struct *task, char * buffer)
{
        int res = 0;
        unsigned int len;
        struct mm_struct *mm = get_task_mm(task);
        if (!mm)
                goto out;
        if (!mm->arg_end)
                goto out_mm;    /* Shh! No looking before we're done */

        len = mm->arg_end - mm->arg_start;

        if (len > PAGE_SIZE)
                len = PAGE_SIZE;

par conséquent, 4096 octets pour un tel système:

% getconf PAGE_SIZE
4096

De plus, si vous avez des caractères multibytes, le nombre de caractères serait inférieur à 4096, comme vous pouvez l'imaginer.

35
heemayl