Ad Widget

Collapse

Set default graph timeframe to all users

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andrecamargo_07
    Junior Member
    • Dec 2013
    • 4

    #1

    Set default graph timeframe to all users

    Hello,
    currently, zabbix remembers the last selection of time period on per graph level.
    I want to remove it... I want that everytime someone login, the graphs are set to the last day, independently of the last selection.
    Is there a way to do that?

    I have found this thread, but it didn't help me. The zabbix version is diferent.




    I am using zabbix 2.2, on RHEL 5.4 with oracle database.
  • andrecamargo_07
    Junior Member
    • Dec 2013
    • 4

    #2
    no one knows?

    Comment

    • jan.garaj
      Senior Member
      Zabbix Certified Specialist
      • Jan 2010
      • 506

      #3
      You have to make a dirty hack in Zabbix PHP frontend.

      Proof of concept (changed/added code is bolded):
      deleting "saved" values related to graphs from user profiles, so Zabbix has to use default values

      include/defines.inc.php:
      Code:
      define('ZBX_PERIOD_DEFAULT',	[B]86400[/B]); // set your default period in seconds; 86400sec=1day
      include/classes/class.cwebuser.php:
      Code:
      public static function logout() {
      	self::$data['sessionid'] = get_cookie('zbx_sessionid');
      	self::$data = API::User()->logout();    
      	zbx_unsetcookie('zbx_sessionid');
      }
      change to:
      Code:
      public static function logout() {
              [B]DBexecute('DELETE FROM profiles WHERE idx=\'web.screens.period\'');[/B]
              [B]DBexecute('DELETE FROM profiles WHERE idx=\'web.screens.stime\'');[/B]
      	self::$data['sessionid'] = get_cookie('zbx_sessionid');
      	self::$data = API::User()->logout();    
      	zbx_unsetcookie('zbx_sessionid');
      }
      Better way will be if you delete profiles data after login of user (function login in class.cwebuser.php). Try it and improve it - it's only concept.

      Or you can hack it in another place e.g. include/classes/CSreenBase.php (calculateTime function), ...

      Anyway you will need some PHP devel skills for this action.
      Devops Monitoring Expert advice: Dockerize/automate/monitor all the things.
      My DevOps stack: Docker / Kubernetes / Mesos / ECS / Terraform / Elasticsearch / Zabbix / Grafana / Puppet / Ansible / Vagrant

      Comment

      • andrecamargo_07
        Junior Member
        • Dec 2013
        • 4

        #4
        Originally posted by jan.garaj
        You have to make a dirty hack in Zabbix PHP frontend.

        Proof of concept (changed/added code is bolded):
        deleting "saved" values related to graphs from user profiles, so Zabbix has to use default values

        include/defines.inc.php:
        Code:
        define('ZBX_PERIOD_DEFAULT',	[B]86400[/B]); // set your default period in seconds; 86400sec=1day
        include/classes/class.cwebuser.php:
        Code:
        public static function logout() {
        	self::$data['sessionid'] = get_cookie('zbx_sessionid');
        	self::$data = API::User()->logout();    
        	zbx_unsetcookie('zbx_sessionid');
        }
        change to:
        Code:
        public static function logout() {
                [B]DBexecute('DELETE FROM profiles WHERE idx=\'web.screens.period\'');[/B]
                [B]DBexecute('DELETE FROM profiles WHERE idx=\'web.screens.stime\'');[/B]
        	self::$data['sessionid'] = get_cookie('zbx_sessionid');
        	self::$data = API::User()->logout();    
        	zbx_unsetcookie('zbx_sessionid');
        }
        Better way will be if you delete profiles data after login of user (function login in class.cwebuser.php). Try it and improve it - it's only concept.

        Or you can hack it in another place e.g. include/classes/CSreenBase.php (calculateTime function), ...

        Anyway you will need some PHP devel skills for this action.
        That worked

        Thanks a lot.

        Cheers

        Comment

        Working...