Page 1 of 1

How to automatically generate scheduled reports entries?

Posted: Wed Jun 13, 2018 9:09 am
by lvaillant
Hello,

Still working on my "scheduled reports" topic, I'm looking at a solution to create around 100 scheduled reports without using the web GUI.

In a previous topic, I found a SQL request to display existing reports:

Code: Select all

echo "select * from xi_usermeta where keyname = 'scheduled_reports';;" | mysql -uroot -pnagiosxi nagiosxi
Is there some documentation available that describes the format of each report?
I would like to automate the creation of the expected reports.

The format is quite understandable, but I'd appreciate to have a more official way of managing this than reverse engineering.

Thank you

Re: How to automatically generate scheduled reports entries?

Posted: Wed Jun 13, 2018 9:44 am
by scottwilkerson
lvaillant wrote: Is there some documentation available that describes the format of each report?
We do not have any documentation on individual reports as we don't manyally construct the serialized array you are looking at

The changes for different reports basically all get injected in the url field you have likely seen.

The only other think that I know of worth explaining is that a few reports have csv available as attachments, but the rest just have pdf or jpg

Re: How to automatically generate scheduled reports entries?

Posted: Wed Jun 13, 2018 10:09 am
by lvaillant
scottwilkerson wrote:We do not have any documentation on individual reports as we don't manyally construct the serialized array you are looking at

The changes for different reports basically all get injected in the url field you have likely seen.
The difficult part is to identify the potential algorithm to generate the report ID (randow 6-car string?) and to determine the int value associated to the 'a' attribute (item/tuple count?).
  • The 's' attribute identifies a string, followed by the length of the related string : s:4:"1234"
  • The 'i' attribute is an integer: s:11:"dontdisplay";i:0;
scottwilkerson wrote:The only other think that I know of worth explaining is that a few reports have csv available as attachments, but the rest just have pdf or jpg
I need CVS attachements :)
But it's easy to add

Code: Select all

	s:11:"attachments";a:1:{
		s:7:"csvhost";s:2:"on";
	}

Re: How to automatically generate scheduled reports entries?

Posted: Wed Jun 13, 2018 1:42 pm
by scottwilkerson
lvaillant wrote:The difficult part is to identify the potential algorithm to generate the report ID (randow 6-car string?)
Yes, but must be unique.
lvaillant wrote:and to determine the int value associated to the 'a' attribute (item/tuple count?).
Yes, this is the count of attachments.

Not sure if you develop in php at all but this whole item can be grabbed from the database and passed to unserialize() and it will become an array.

Then after you modify the array, pass to serialize() and it will be converted to this string to put in the DB again.

This eliminates counting string lengths etc, this all happens automatically

Re: How to automatically generate scheduled reports entries?

Posted: Thu Jun 14, 2018 6:43 am
by lvaillant
Hello.

Thank you.
You can close this thread.

Re: How to automatically generate scheduled reports entries?

Posted: Thu Jun 14, 2018 8:41 am
by scottwilkerson
Glad to hear it is resolved.

Locking