[SOLVED] Cacti 0.8.7g+RRDTool 1.4.3+ru_RU.UTF8 => Cyrillic

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
cepxuo
Posts: 9
Joined: Tue Sep 22, 2009 3:01 am

[SOLVED] Cacti 0.8.7g+RRDTool 1.4.3+ru_RU.UTF8 => Cyrillic

Post by cepxuo »

Could anyone help me with drawing graphs, using Cyrillic letters? I have Cacti 0.8.7g, running on Ubuntu 10.04.2 LTE server, with RRDTool 1.4.3 and locale ru_RU.UTF-8. Cacti Database uses UTF-8 charset.

When I name graphs with Cyrillic characters it does not store any characters. Only Latin characters are stored. Therefore there are no Cyrillic characters in Cacti management console, nor in the graphs. I found one topic here with similar problem while upgrading from RRDTool 1.2.x to 1.3.x, but there were boxes instead of letters. I do not get neither boxes, nor any other letters, and I did not use older version of RRDTool before.

Is there any solution?

PS: I am sorry for 2 duplicate posts before this one :(
Last edited by cepxuo on Mon Mar 07, 2011 10:37 am, edited 1 time in total.
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Cacti 0.8.7g + RRDTool 1.4.3 + ru_RU.UTF8 => Cyrillic gr

Post by noname »

Can you use Cyrillic characters for graph title when using rrdtool only?
To verify, try this code and look title of 'test.png':

Code: Select all

#!/bin/sh

rrdtool graph test.png \
--imgformat=PNG \
--title='((Title with Cyrillic characters))' \
--font TITLE:12: \
DEF:a="cacti/rra/localhost_cpu_system_XXX.rrd":cpu_system:AVERAGE \
AREA:a#FF0000FF:"System"
(Fit "cacti/rra/localhost_cpu_system_XXX.rrd' to your environment)

If you have your own Cyrillic font, check whether your font exists or not in output of 'fc-list' command:
(see font-config manual)

Code: Select all

% fc-list :lang=ru
FreeSans:style=Bold,polkrepko
FreeMono:style=Bold,Negreta,tun,fed,Fett,ντονα,Negrita,Lihavoitu,Gras,Flkvr,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kaln,polkrepko,m,Lodia
...
then modify

Code: Select all

--font TITLE:12: \
to

Code: Select all

--font TITLE:12:FreeMono(or your font) \
If rrdtool worked fine, then try modifications mentioned the topic [ Cacti russian charset description to host ].
(Maybe it need to change 'include/top_header.php' and 'include/top_graph_header.php' only?)

Note: 'Content-Type' in <meta> tag settings seems to be implemented in 0.8.8...
cepxuo
Posts: 9
Joined: Tue Sep 22, 2009 3:01 am

Re: Cacti 0.8.7g + RRDTool 1.4.3 + ru_RU.UTF8 => Cyrillic gr

Post by cepxuo »

noname wrote:If rrdtool worked fine, then try modifications mentioned the topic [ Cacti russian charset description to host ].
(Maybe it need to change 'include/top_header.php' and 'include/top_graph_header.php' only?)
The magic worked!!! Thank you very much!!!!
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: [SOLVED] Cacti 0.8.7g+RRDTool 1.4.3+ru_RU.UTF8 => Cyrill

Post by noname »

I'm glad to hear that.

I'm also using this way to show Japanese characters. :wink:
cepxuo
Posts: 9
Joined: Tue Sep 22, 2009 3:01 am

Re: [SOLVED] Cacti 0.8.7g+RRDTool 1.4.3+ru_RU.UTF8 => Cyrill

Post by cepxuo »

noname wrote:I'm glad to hear that.

I'm also using this way to show Japanese characters. :wink:
Unfortunately it worked in a half. Now I see Cyrillic in Cacti console. But There are still empty spaces in graphs :(
Your script worked OK. I mean RRDTool shows Cyrillic when it is called directly. What else should I modify?
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: [SOLVED] Cacti 0.8.7g+RRDTool 1.4.3+ru_RU.UTF8 => Cyrill

Post by noname »

Oh, sadly.

Did you specify the default font in 'Console -> Settings-> Visual' tab?
cepxuo
Posts: 9
Joined: Tue Sep 22, 2009 3:01 am

Re: [SOLVED] Cacti 0.8.7g+RRDTool 1.4.3+ru_RU.UTF8 => Cyrill

Post by cepxuo »

noname wrote:Oh, sadly.

Did you specify the default font in 'Console -> Settings-> Visual' tab?
Yes I did, and also in Console->Paths->RRDTool Default Font
It looks like the values are passed to RRDTool with wrong encoding, while drawing graphs:

Code: Select all

03/07/2011 10:59:08 PM - WEBLOG: Poller[0] CACTI2RRD: /usr/bin/rrdtool graph - --imgformat=PNG --start=-86400 --end=-300 --title=' - /' --rigid --base=1024 --height=120 --width=600 --alt-autoscale-max --lower-limit=0 --vertical-label='' --slope-mode --font TITLE:10: --font AXIS:8: --font LEGEND:9: --font UNIT:8: DEF:a="/var/lib/cacti/rra/1/137.rrd":hdd_total:AVERAGE DEF:b="/var/lib/cacti/rra/1/137.rrd": GPRINT:a:LAST:"" GPRINT:a:AVERAGE:"" GPRINT:a:MAX:"" AREA:b#F51D30FF:"" GPRINT:b:LAST:"" GPRINT:b:AVERAGE:"" GPRINT:b:MAX:"" VRULE:1299438000#FF0000FF:""
Look at --title=' - /' and for example hdd_used:AVERAGE AREA:a#002A97FF:""
The values are empty

Also I tried to change manually (via phpmyadmin) values in cacti database (table graph_template_item) and now I see Cyrillic in legend of the graph. But still nothing in the title.
So I guess Cacti still does not "understand" cyrillic and does not pass it to RRDTool nor MySQL,
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: [SOLVED] Cacti 0.8.7g+RRDTool 1.4.3+ru_RU.UTF8 => Cyrill

Post by noname »

Okay..

Then, try this.

(1) Test behavior of escapeshellarg()

At function cacti_escapeshellarg() within 'lib/functions.php':
change

Code: Select all

$string = escapeshellarg($string);
to

Code: Select all

# $string = escapeshellarg($string);
If graph title shows Cyrillic characters, it seems be problem of locale settings,
like as this. (but that's not bug)

Then, proceed to (2).
(Please don't forget to revert the above change)

(2) Set default locale in your PHP or Apache or Server

Try one (or all) of the below:

[A] PHP settings
In php.ini:

Code: Select all

default_charset               = UTF-8
mbstring.language             = Windows-1251 (or else)
mbstring.encoding_translation = On
mbstring.internal_encoding    = UTF-8
* old version of PHP had problems for russian encoding


Apache start-up script
In '/etc/init.d/httpd' (or else):
change

Code: Select all

HTTPD_LANG=${HTTPD_LANG-"C"}
to (or add)

Code: Select all

HTTPD_LANG=${HTTPD_LANG-"ru_RU.UTF8"}
[C] Server settings
In '/etc/sysconfig/i18n' (or other system-wide settings):
change or add

Code: Select all

LANG=ru_RU.UTF8
Good luck.
If all failed, I can't imagine any more.. sorry.
cepxuo
Posts: 9
Joined: Tue Sep 22, 2009 3:01 am

Re: [SOLVED] Cacti 0.8.7g+RRDTool 1.4.3+ru_RU.UTF8 => Cyrill

Post by cepxuo »

Thank you once again. Now everything works fine. I did what you said, and some more:
1) I have 2 php.ini files: one in /etc/php5/apache2 and another is in /etc/php5/cli. I added changes to both files.
2) I made changes to /etc/init.d/apache2 file as you said
3) I did not find i18n file in /etc but I chenged the following in /etc/apache2/envvars:

Code: Select all

export LANG=C
to

Code: Select all

export LANG=ru_RU.UTF8
4) I uncommented the line in /etc/apache2/conf.d/charset

Code: Select all

AddDefaultCharset UTF-8
And now everything works fine!
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: [SOLVED] Cacti 0.8.7g+RRDTool 1.4.3+ru_RU.UTF8 => Cyrill

Post by noname »

Cheers! (^o^/
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests