This file is indexed.

/usr/share/perl5/NagiosGrapher/Hooks/Generic.pm is in nagiosgrapher 1.7.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/perl -w

# Generic.pm - the default hook library.
# Copyright (C) 2004, NETWAYS GmbH, Gerd Mueller, Marius Hein
# $Id: Generic.pm 1279 2006-06-19 15:02:15Z mhein $

#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

# $Id: Generic.pm 1279 2006-06-19 15:02:15Z mhein $

package NagiosGrapher::Hooks::Generic;
use NagiosGrapher;

use vars qw (
	%TYPES
	@ISA
);

# The different hookup types,
# set in the init sub in the child class.
%TYPES = (
	'before_serviceext' => 1,
	'before_rrdupdate' => 1,
	'before_imagegraph' => 1,
	'before_imagemultigraph' => 1,
);

# constructor
sub new {
  my $package = shift;

  $ng = NagiosGrapher::getInstance();

  my $self = bless {
	    NagiosGrapher => $ng,

	    Values => undef,
	    Service => undef,
	    Host => undef,

	    Types => [],
  }, $package;

  return $self;
}

# Set the types, multiple values allowed
sub SetTypes {
	my $self = shift;
	foreach my $Type (@_) {
		push @{ $self->{Types} }, $Type
			if (exists $NagiosGrapher::Hooks::Generic::TYPES{$Type});
	}
}

# Check if the right type is set.
# called from NagiosGrapher.pm
sub CheckType {
	my $self = shift;
	my ($type) = @_;

	foreach (@{$self->{Types}}) {
		return 1 if ($_ eq $type);
	}

	return;
}

# The init sub.
sub init {
	my $self = shift;
	my %args = (
		Values => undef,
		Service => undef,
		Host => undef,

		@_
	);

	$self->{Values} = $args{'Values'};
	$self->{Service} = $args{'Service'};
	$self->{Host} = $args{'Host'};

	return 1;
}

# Customized log function
sub print_log {
	my $self = shift;
	my ($msg) = @_;

	$self->NG->print_log(sprintf("HOOKMSG: %s", $msg))
		if ($self->NG->get_log_level & $NagiosGrapher::LOG_HOOK);

	return 1;
}

# Accessor methods

sub NG {
	my $self = shift;
	return $self->{NagiosGrapher};
}

sub Values {
	my $self = shift;
	return $self->{Values};
}

sub Types {
	my $self = shift;
	return $self->{Types};
}

sub Service {
	my $self = shift;
	return $self->{Service};
}

sub Host {
	my $self = shift;
	return $self->{Host};
}

# Methods to inherit ...
sub prepare {
	return 1;
}

sub commit {
	return 1;
}

sub cleanup {
	return 1;
}

1;