mikaku / Monitorix

Monitorix is a free, open source, lightweight system monitoring tool.
https://www.monitorix.org
GNU General Public License v2.0
1.12k stars 167 forks source link

Option to change imgformat for graphs #132

Closed mariotaku closed 8 years ago

mariotaku commented 8 years ago

First of all, thank you for such an amazing tool!

I wonder if there could be an option to change imgformat for graphs, like jpg, or svg. Thanks a lot!

mikaku commented 8 years ago

According to the RRDtool documentation http://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html, the option --imgformat accepts the following graphical formats:

[-a|--imgformat PNG|SVG|EPS|PDF]

Problem here is that Monitorix has the graphical format PNG hard-coded in every single module. I'll try to find enough time to remedy this situation with a new option from the configuration file where will let you specify the final image format.

Stay tuned, please. Thanks.

mariotaku commented 8 years ago

Thanks. here's a working patch for current version on APT repo:

#!/bin/sh

cd /usr/lib/monitorix

if [ $(which apt-get) ]; then
    apt-get install -y patchutils
elif [ $(which yum) ]; then
    yum -y install patch
fi

patch <<EOF
--- HTTPServer.pm   2015-11-13 12:51:36.000000000 +0000
+++ HTTPServer.pm.patched   2016-01-12 16:06:22.298993411 +0000
@@ -129,6 +129,8 @@
        print "Content-Type: text/html; charset=UTF-8\r\n";
    } elsif(\$mimetype eq "css") {
        print "Content-Type: text/css; charset=UTF-8\r\n";
+   } elsif(\$mimetype eq "svg") {
+       print "Content-Type: image/svg+xml\r\n";
    } else {
        print "Content-Type: image/\$mimetype;\r\n";
    }
EOF

# Replaces all png to svg
grep -rl png . | xargs sed -i "s/png/svg/g"
grep -rl PNG . | xargs sed -i "s/PNG/SVG/g"

service monitorix restart
mikaku commented 8 years ago

After applying the modifications to create SVG images, I've seen that zoomed images are not correctly fit in the pop-up window. This is due because RRDs::graphv function does not return correctly the size of the zoomed image with SVG format.

Are you experiencing the same behavior for the zoomed images?

I'm using RRDtool version 1.3.8, perhaps newer versions are returning correct values. Please, let me know.

mariotaku commented 8 years ago

Yes, I also encountered this problem. Other images are OK.

Jordi Sanfeliu notifications@github.com于2016年1月25日周一 下午7:56写道:

After applying the modifications to create SGV images, I've seen that zoomed images are not correctly fit in the pop-up window. This is due because RRDs::graphv function does not return correctly the size of the zoomed image with SGV format.

Are you experiencing the same behavior for the zoomed images?

I'm using RRDtool version 1.3.8, perhaps newer versions are returning correct values. Please, let me know.

— Reply to this email directly or view it on GitHub https://github.com/mikaku/Monitorix/issues/132#issuecomment-174484173.

mikaku commented 8 years ago

I have also tested it under RRDtool version 1.4.8 and I got the same bad results. :(

mikaku commented 8 years ago

I've added the new option image_format which has by default the value PNG. Such option accepts only the values PNG and SVG. It should work as expected except the problem with the zoomed graphs.

Please, download all the .pm files, the monitorix.cgi file and update your monitorix.conf to reflect such new option. And let me know how it works.

Thanks.

mariotaku commented 8 years ago

image

works on Debian 8. (though zoomed image is a little buggy)

mikaku commented 8 years ago

Yeah, zoomed image won't fit in the pop-up window because it's using the <iframe> tag. I think we can close this.