2 pièce(s) jointe(s)
CGI bash/ apache / Gnuplot
Bonjour,
Tout d'abord, le problème que je vais vous exposer étant lié à Apache et travaillant sous RedHat, je ne sais pas si je suis dans la bonne section ! Du coup, à lecture de mon post, si un modo/admin décide de déplacer mon post au bon endroit, il n'y a pas de problème ! :mouarf:
Le problème :
J'essaie de mettre en place une CGI qui va me permettre, grâce à Gnuplot de générer des graphiques sur la consommation RAM/CPU de clusters. Comme je n'ai jamais fait ça, je test en local sur ma machine :
- J'ai installé Apache
- Dans mon dossier cgi-bin j'ai : mes deux " pages web " pour ma CGI, j'ai un .txt contenant des informations sur un cluster ( qui permet de générer le graph ) et un autre .txt contenant les commandes gnuplot que je souhaite exécuter.
Voici à quoi ressemble le code de ma page principale de ma CGI pour le moment :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #!/bin/bash
echo "Content-type: text/html"
echo ""
echo '
<html>
<head>
<meta http-equiv="Content-Type" content="test/html"; charset=UTF-8">
<title> CLUSTER GRAPH </title>
<h1> Cluster Graph </h1>
<hr size="4" color="blue">
</head>
<body>
<p> Press the button to generate the graph ! </p>
<form action="GNUGRAPH.sh" target="_blank">
<button name="buton">Generate</button>
</form>
</body>
</head>
</html> ' |
Donc sur cette page se trouve un bouton " Générer " qui, une fois que l'on clique dessus, va ouvrir dans un nouvel onglet ma deuxième page dont voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #!/bin/bash
echo "Content-type: text/html"
echo ""
echo "
<html>
<head>
<title> Cluster Graph </title>
<h1> Cluster Graph </h1>
<hr size="4" color="blue" >
</head>
<body>
<PRE>"
gnuplot gnuplot_test.txt
echo "
</PRE>
</body>
</html>
" |
Cette page doit exécuter la commande " gnuplot gnuplot_test.txt " afin de générer mon graphique. Voici le contenu de mon " gnuplot_test.txt " :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| f(w) = (strlen(w) > 10 ? word(w, 1) . "\n" . word(w, 2) : w)
set title "CLUSTER 1"
set terminal png truecolor size 960, 720
set output 'cluster2.png'
set bmargin at screen 0.1
set key top center
set grid
set style data histograms
set style fill solid 1.00 border -1
set boxwidth 0.7 relative
set yrange [0:]
set format y "%g%%"
set datafile separator ","
plot "/var/www/cgi-bin/CLUSTER_1.txt" using 2:xtic(f(stringcolumn(1))) title " CPU consumption (%) ", \
'' using 3 title " RAM consumption (%)", \
'' using 0:($2+1):(sprintf("%g%%",$2)) with labels notitle, \
'' using 0:($3+1):(sprintf(" %g%%",$3)) with labels notitle |
Le graphique qui doit être généré doit ressembler à cela ( le but final c'est qu'il s'affiche sur ma page directement, mais pour le moment je veux juste le générer ) :
Pièce jointe 465383
Sauf que... ça ne fonctionne pas ! La commande " gnuplot gnuplot_test.txt " s'execute parfaitement manuellement si je suis dans le dossier /cgi-bin/, mais elle ne fonctionne pas via mon interface et je ne comprends pas pourquoi !
Du coup j'ai été jeter un petit coup d'oeil dans mon /etc/httpd/logs/error_log et voici le contenu :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
[Wed Apr 10 10:21:00.467978 2019] [cgi:error] [pid 11948] [client ::1:46340] AH01215: , referer: http://localhost/cgi-bin/Index.sh
[Wed Apr 10 10:21:00.468099 2019] [cgi:error] [pid 11948] [client ::1:46340] AH01215: "gnuplot_test.txt", line 5: , referer: http://localhost/cgi-bin/Index.sh
[Wed Apr 10 10:21:00.468289 2019] [cgi:error] [pid 11948] [client ::1:46340] AH01215: util.c: Permission denied, referer: http://localhost/cgi-bin/Index.sh
[Wed Apr 10 10:21:00.468333 2019] [cgi:error] [pid 11948] [client ::1:46340] AH01215: , referer: http://localhost/cgi-bin/Index.sh
[Wed Apr 10 10:50:14.995409 2019] [cgi:error] [pid 11969] [client ::1:48676] AH01215: , referer: http://localhost/cgi-bin/Index.sh
[Wed Apr 10 10:50:14.995503 2019] [cgi:error] [pid 11969] [client ::1:48676] AH01215: set output 'cluster2.png', referer: http://localhost/cgi-bin/Index.sh
[Wed Apr 10 10:50:14.995562 2019] [cgi:error] [pid 11969] [client ::1:48676] AH01215: ^, referer: http://localhost/cgi-bin/Index.sh
[Wed Apr 10 10:50:14.995653 2019] [cgi:error] [pid 11969] [client ::1:48676] AH01215: cannot open file; output not changed, referer: http://localhost/cgi-bin/Index.sh
[Wed Apr 10 10:50:14.995772 2019] [cgi:error] [pid 11969] [client ::1:48676] AH01215: "gnuplot_test.txt", line 5: util.c: Permission denied, referer: http://localhost/cgi-bin/Index.sh
[Wed Apr 10 10:50:14.995785 2019] [cgi:error] [pid 11969] [client ::1:48676] AH01215: , referer: http://localhost/cgi-bin/Index.sh |
Je ne comprends pas ces erreurs... Pourriez-vous m'expliquer ?
Aussi, au cas où, j'ai même testé un chmod 777 sur mes fichiers pour voir si c'était un problème de droit, mais rien n'y fait :
Pièce jointe 465389
Auriez-vous une idée ?
Merci d'avance !