Sorry small error on my part. It's working now and the reports are excellent. Has anyone been able to tweak the script to show the reports per individual userid and not for all users?
Ad Widget
Collapse
Generating email-based reports with inline charts
Collapse
X
-
Its designed to email each users favorite graphs individually, so you shouldn't see anyone else's favorite graphs. nclemons SQL query fixed an issue I hadn't noticed until one of my colleagues mentioned it wasn't working for simple graphs. So, I would use his fix with the rest of the script.Comment
-
I see your point Danrog, but what I was looking for was the ability for only single users to receive reports. Everytime I run this script, every user with a favourite graph/screen will receive a report. A lot of those users do not want to receive these reports so I'm wondering if there is a way to limit it so it only sends a report to user1. Unfortunately I don't have the perl skills to be able to make this change to the script. Just wondering if anyone else has?Comment
-
@Danrog,
im trying your script.
But i seem to have lot of issues.( im a first time perl user)
First at line
if($ARGV[0] eq "-months")
It gives me error"Use of uninitialized value in string eq a"
For the moment i have commented this place.
And the mysql query provided in the script always returns a empty set
mysql> SELECT p.value_id, IF(s.resourceid IS NULL,p.value_id,s.resourceid) as graphid, p.idx, IF(s.resourceid IS NOT NULL,ss.name,'Graphs') as title, u.name, u.surname, u.userid, m.sendto, p.source FROM profiles p LEFT JOIN screens_items s ON ( p.value_id = s.screenid ) LEFT JOIN screens ss ON ( s.screenid = ss.screenid ) LEFT JOIN users u ON ( p.userid = u.userid ) LEFT JOIN media m ON ( u.userid = m.userid ) WHERE (p.idx like 'web.favorite.screenids' OR p.idx like 'web.favorite.graphids') AND m.mediatypeid = 1;
Empty set (0.00 sec)Comment
-
hi,
i get a mail but there is no picture inside..
This is what i get. After get, there are two small attachments, but no pictures enclosed.
Week of Wed, Feb 13, 2013 through Wed, Feb 20, 2013
Graphs
________________________________________
You can change the graphs sent to you by changing your saved favorite graphs/items from the dashboard.Comment
-
Error running script
Hi, I get the following error.
syntax error at graphreport.pl line 10, near "my "
Execution of graphreport.pl aborted due to compilation errors.
Line 10 is:
my $cookie = "/tmp/cookie.txt";
/tmp of course does exist and I have created a file "cookie.txt" (just in case.)
No joy.
I have all dependencies installed and have entered the correct url and username/password comboComment
-
Newer Version?
Is there a newer version of this script out?
I'm running a dev box of zabbix running 2.0.6 and this script is only partially working. Perhaps I'm missing some perl modules?
I get the email and it seems to send the proper users graphs only the graphs are ALL html files named as .png files.. No images and it looks like the HTML content of ALL the png files is the same:
I've checked to make sure the login API credentials are ok but it's like the script is failing to login to Zabbix to pull the graphs out? Any input would be appreciated.
See attached txt file which is one of the .png generated by the script.Attached FilesComment
-
fixed login issue
n/m I fixed it:
my $cmdLogin = `curl -k -s -c $cookie -d 'form=1&form_refresh=1&name=$login&password=$pass& enter=Sign%20in' $zabbix/index.php`;
Seems the newer version of Zabbix (2+) uses "Sign In" as the value for the login button rather than "Enter" quick change to the script and it works now..Comment
-
MySQL Query Problem
Hi,
I recently stumble upon this script and gave it a try but without success. After some testing I found that the problem relies with the query.
It executes without error but it returns 0 rows.
I have added 5 screens to a user's Favorite screens, the are ok on the webUI but I'm lost, don't know what to verify next.
Zabbix version 2.4.7
mysql Ver 14.14 Distrib 5.6.27, for FreeBSD10.2 (amd64) using EditLine wrapper
I tested the query on phpmyadmin and I got this (the output is on the attachment), if it's of any help.
zabbix_query_return.pdf
I really appreciate any help.Comment
-
I made it work on 3.0.2
Hi All,
I made it work on Zabbix 3.0.2 but some modifications needed. Maybe it will be useful for others.
Dependencies:
Mime and DateTime perl modules and some dependencies were missing in my Zabbix server so be sure perl modules are installed. When you run the script manually it will let you know which ones are missing.
Code related changes.
First, there is a mistype in the file. An ending is missing at line 9.
$pass = 'zabbix'; # zabbix api pass
Needed to change the DSN variable to this (my DB named “zabbix”):
my $dsn = 'DBI:mysql:zabbix';
The login method is changed so we need to modify the “my $cmdLogin” line too:
my $cmdLogin = `curl -k -s -c $cookie -d 'form=1&form_refresh=1&name=$login&password=$pass& enter=Sign%20in' $zabbix/index.php`;
Save the script and run it manually like:
/usr/bin/perl /usr/share/zabbix/scripts/graphreport.pl 2>&1 >/dev/null
Now I get only one error message:
Use of uninitialized value $ARGV[0] in string eq at /usr/share/zabbix/scripts/graphreport.pl line 29.
I do not know what it means but I get the reports so I do not care about this error for now.
Comment
-
Hi All,
I made it work on Zabbix 3.0.2 but some modifications needed. Maybe it will be useful for others.
Dependencies:
Mime and DateTime perl modules and some dependencies were missing in my Zabbix server so be sure perl modules are installed. When you run the script manually it will let you know which ones are missing.
Code related changes.
First, there is a mistype in the file. An ending is missing at line 9.
$pass = 'zabbix'; # zabbix api pass
Needed to change the DSN variable to this (my DB named “zabbix”):
my $dsn = 'DBI:mysql:zabbix';
The login method is changed so we need to modify the “my $cmdLogin” line too:
my $cmdLogin = `curl -k -s -c $cookie -d 'form=1&form_refresh=1&name=$login&password=$pass& enter=Sign%20in' $zabbix/index.php`;
Save the script and run it manually like:
/usr/bin/perl /usr/share/zabbix/scripts/graphreport.pl 2>&1 >/dev/null
Now I get only one error message:
Use of uninitialized value $ARGV[0] in string eq at /usr/share/zabbix/scripts/graphreport.pl line 29.
I do not know what it means but I get the reports so I do not care about this error for now.
Guys you did amazing work! This works great!
Since I am not good with perl, I believe it would be possible to make this script to sort graphs by some filter...
For example, I would like from script to take only largest 20 graphs from screens and send them via email.
Under link: (https://ibb.co/bxdXhv) there is 1 of the graphs in my favourite screen.
I have looked into the script and I was thinking is it possible to do by just changing your SQL query a bit?
SELECT p.value_id, IF(s.resourceid IS NULL,p.value_id,s.resourceid) as graphid, p.idx, IF(s.resourceid IS NOT NULL,ss.name,'Graphs') as title,
u.name, u.surname, u.userid, m.sendto, p.source FROM profiles p
LEFT JOIN screens_items s ON ( p.value_id = s.screenid )
LEFT JOIN screens ss ON ( s.screenid = ss.screenid )
LEFT JOIN users u ON ( p.userid = u.userid )
LEFT JOIN media m ON ( u.userid = m.userid )
WHERE (p.idx like 'web.favorite.screenids' OR p.idx like 'web.favorite.graphids')
AND m.mediatypeid = 1;
Maybe I could add to query to take only TOP 20 by value of graphs Y axis (Which is 300Mpbs in link above)?
Problem is I am not sure where to find that value in zabbix database.
I found under graphs table "yaxismax" column, but value of that column is always 100.
Do you have any ideas?Last edited by Cenzoooo; 12-07-2017, 11:36.Comment
-
Hi guys!
Can someone help me change this code that it will work in Zabbix 4.0? I meanwhen I use this script now and I want graphs from last month I only receive an email which contains graphs from last hour.
If anyone know the solution please answer. Thank you.Comment
-
Just want to let you know guys that I figured it out. If you want to have graphs from previous month (for example for billing reasons) you have to modify 72th line of this script to:
my $cmdImage = `curl -k -s -b $cookie -o "$output" '$zabbix/$chart=$graphid&from=now-1M%2FM&to=now-1M%2FM&isNow=0&profileIdx=web.screens.filter&width =$width&height=$height'`;Comment
-
based on the original script here's a version for Postgres + Zabbix 4 and a -month -week- yesterday switchAttached FilesComment
Comment