ZABBIX Forums  
  #1  
Old 19-03-2009, 12:59
blokje blokje is offline
Junior Member
 
Join Date: Apr 2008
Posts: 7
Default IT Services per Month

As I need to get IT services states per month I've created a patch file with some adjustments to create an report with IT SLA overview's per month.

I've build this on Zabbix 1.6.2 frontend. For me it is working if it is working for you I don't know. It creates a few files and alters the include/page_header.php file.

As Zabbix is OSS I'm publishing my patch under the same license agreement.


Please let me know what you think about it.

Zabbix is a great product but is lacking some minor functions sometimes, like IT services overview per month. Maybe something for the developers to include in a next release. It was not that much of a work and I saw requests for this functionality a few times on the boards.
Attached Images
 
Attached Files
File Type: patch zabbix-1.6.2-itsla-month.patch (20.9 KB, 216 views)
Reply With Quote
  #2  
Old 19-03-2009, 15:26
welkin welkin is offline
Senior Member
 
Join Date: Mar 2007
Posts: 119
Default

sounds great but what a about per year? many contracts are signed with a sla period of one year so zabbix should honor this fact.

regards
welkin
Reply With Quote
  #3  
Old 19-03-2009, 15:28
blokje blokje is offline
Junior Member
 
Join Date: Apr 2008
Posts: 7
Default

Quote:
Originally Posted by welkin View Post
sounds great but what a about per year? many contracts are signed with a sla period of one year so zabbix should honor this fact.

regards
welkin
A friend of mine also suggested this. I did this in just a day or a half of it when I count my coffee breaks out of it. So it should be easily do-able. I'll take a look at it later on today.


Update
Another patch set which you can apply to the other patch. This will add the feature for year views.
Code:
diff -ruN zabbix.bck/chart_sla2.php zabbix/chart_sla2.php
--- zabbix.bck/chart_sla2.php	2009-03-18 11:30:44.000000000 +0100
+++ zabbix/chart_sla2.php	2009-03-19 15:41:05.000000000 +0100
@@ -80,13 +80,20 @@
 	ImageFilledRectangle($im,0,0,$sizeX,$sizeY,ImageColorAllocate($im,120,200,120));
 
 	$now=time(NULL);
-	// Start is: first day of the month
-	$period_start=mktime(0,0,0,$month,1,$year);
-	// Stop is last day of the month
-	$period_end=mktime(0,0,0,$month+1,1,$year);
+	if($month==0)
+	{
+		$period_start=mktime(0,0,0,1,1,$year);
+		$period_end  =mktime(0,0,0,1,1,$year+1);
+	}
+	else
+	{
+		// Start is: first day of the month
+		$period_start=mktime(0,0,0,$month,1,$year);
+		// Stop is last day of the month
+		$period_end=mktime(0,0,0,$month+1,1,$year);
+	}
 	if($period_end>time())
 	     	$period_end=time();
-
 	$stat=calculate_service_availability($_REQUEST["serviceid"],$period_start,$period_end);
 
 	$problem=$stat["problem"];
diff -ruN zabbix.bck/srv_status2.php zabbix/srv_status2.php
--- zabbix.bck/srv_status2.php	2009-03-19 12:40:23.000000000 +0100
+++ zabbix/srv_status2.php	2009-03-19 15:39:03.000000000 +0100
@@ -84,6 +84,7 @@
         }
 
         $cmbMonth = new CComboBox("month",$month,"submit()");
+	$cmbMonth->AddItem(0,S_ALL_SMALL);
 	if($year<date('Y'))
 	{
 		$maxmonth=12;
@@ -104,6 +105,10 @@
 	$from='1/'.$month.'/'.$year;
 	$to  =date('t',mktime(1,1,1,$month,1,$year)).'/'.$month.'/'.$year;
 	$HeaderTitle=S_TIME_PERIOD . " (" . $from . " - " . $to . ")";
+	if($month==0)
+	{
+		$HeaderTitle=S_TIME_PERIOD . " (Year: " . $year . ")";
+	}
         $menu = get_table_header($HeaderTitle,$form);
 
 //--------
@@ -208,19 +213,27 @@
 			
 			if($row["showsla"]==1){
 				# SLA Bar
+				$period=(($month==0)?'yearly':'monthly');
 				$row['sla'] = new CLink(new CImg("chart_sla2.php?serviceid=".$row["serviceid"]."&year=" . $year . "&month=" . $month),
-						"report3.php?serviceid=".$row["serviceid"]."&period=monthly&year=".$year);
+						"report3.php?serviceid=".$row["serviceid"]."&period=" . $period . "&year=".$year);
 				
 				#$now		= time(NULL);
 				#$period_start	= $now-7*24*3600;
 				#$period_end	= $now;
 			        #$period_start=$now-7*86400;
 			        #$period_end=$now;
-			        // Start is: first day of the month
-        			$period_start=mktime(0,0,0,$month,1,$year);
-        			// Stop is last day of the month
-        			$period_end=mktime(0,0,0,$month+1,1,$year);
-					
+				if($month==0)
+				{
+					$period_start=mktime(0,0,0,1,1,$year);
+					$period_end=mktime(0,0,0,1,1,$year+1);
+				}
+				else
+				{
+			        	// Start is: first day of the month
+        				$period_start=mktime(0,0,0,$month,1,$year);
+        				// Stop is last day of the month
+        				$period_end=mktime(0,0,0,$month+1,1,$year);
+				}
 				if($period_end>time())
 					$period_end=time();
 				$stat = calculate_service_availability($row["serviceid"],$period_start,$period_end);
@@ -263,7 +276,7 @@
 						'status' => bold(S_STATUS), 
 						'reason' => bold(S_REASON),
 						'sla' => bold(S_SLA_LAST_7_DAYS),
-						'sla' => bold('SLA (this month)'),
+						'sla' => bold('SLA'),
 						'sla2' => bold(nbsp(S_SLA)),
 						'graph' => bold(S_GRAPH)));
__________________
Zabbix IT services per month patch : http://zabbix.com/forum/showthread.p...3593#post43593

Last edited by blokje; 19-03-2009 at 15:43.
Reply With Quote
  #4  
Old 20-03-2009, 11:02
flexguy flexguy is offline
Junior Member
 
Join Date: Sep 2008
Posts: 17
Default should be integrated in the next version, Alexei?

have a look at this:

http://www.zabbix.com/forum/showthread.php?t=11798
Reply With Quote
  #5  
Old 20-03-2009, 14:12
dotneft dotneft is offline
Senior Member
 
Join Date: Nov 2008
Location: Russia
Posts: 374
Send a message via ICQ to dotneft
Default

not show more than three addictions
__________________
I apologize for my English
Reply With Quote
  #6  
Old 14-04-2010, 08:39
aigars aigars is offline
Junior Member
 
Join Date: Apr 2010
Posts: 27
Default

Sorry for stupid question I'm not familiar with linux and Zabbix, yet. But I'm trying... How can I applied this patch to my existing Zabbix installation?
Thanks.
Reply With Quote
  #7  
Old 14-04-2010, 09:21
blokje blokje is offline
Junior Member
 
Join Date: Apr 2008
Posts: 7
Default

Quote:
Originally Posted by aigars View Post
Sorry for stupid question I'm not familiar with linux and Zabbix, yet. But I'm trying... How can I applied this patch to my existing Zabbix installation?
Thanks.
You can apply this with patch

Code:
patch < input.patch.file.patch
As this patch has been based for zabbix 1.6.2 I will not guarantee that it will work with your installation.
__________________
Zabbix IT services per month patch : http://zabbix.com/forum/showthread.p...3593#post43593
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:32.