~ubuntu-branches/ubuntu/oneiric/munin/oneiric-updates

« back to all changes in this revision

Viewing changes to debian/patches/160-node.d-postgres-plugins.patch

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-08-04 20:05:11 UTC
  • mfrom: (8.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090804200511-9p1s1pgev129e4rh
Tags: 1.2.6-13ubuntu1
* Merge from debian unstable, remaining changes:
  - Suggest libdate-manip-perl (LP: #306274)
  - Recommend "cron". (LP: #225061)
  - Update maintainer accord to spec.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Backported plugins from upstream tags/1.3.4. postgres_block_read_,
 
2
 postgres_commits_, postgres_connections, postgres_locks, postgres_queries_,
 
3
 postgres_space_
 
4
Origin: http://munin.projects.linpro.no/browser/tags/1.3.4/node/node.d/
 
5
 
1
6
Index: munin-1.2.6/node/node.d/postgres_block_read_.in
2
7
===================================================================
3
8
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
4
 
+++ munin-1.2.6/node/node.d/postgres_block_read_.in     2008-10-26 13:55:37.000000000 +0100
 
9
+++ munin-1.2.6/node/node.d/postgres_block_read_.in     2009-07-27 00:50:56.000000000 +0200
5
10
@@ -0,0 +1,167 @@
6
11
+#!@@PERL@@ -w
7
12
+# -*- perl -*-
173
178
Index: munin-1.2.6/node/node.d/postgres_commits_.in
174
179
===================================================================
175
180
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
176
 
+++ munin-1.2.6/node/node.d/postgres_commits_.in        2008-10-26 13:55:56.000000000 +0100
 
181
+++ munin-1.2.6/node/node.d/postgres_commits_.in        2009-07-27 00:50:56.000000000 +0200
177
182
@@ -0,0 +1,225 @@
178
183
+#!@@PERL@@
179
184
+# -*- perl -*-
403
408
Index: munin-1.2.6/node/node.d/postgres_connections.in
404
409
===================================================================
405
410
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
406
 
+++ munin-1.2.6/node/node.d/postgres_connections.in     2008-10-26 13:55:00.000000000 +0100
 
411
+++ munin-1.2.6/node/node.d/postgres_connections.in     2009-07-27 00:50:56.000000000 +0200
407
412
@@ -0,0 +1,73 @@
408
413
+#!@@PERL@@
409
414
+# -*- perl -*-
481
486
Index: munin-1.2.6/node/node.d/postgres_locks.in
482
487
===================================================================
483
488
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
484
 
+++ munin-1.2.6/node/node.d/postgres_locks.in   2008-10-26 13:55:00.000000000 +0100
 
489
+++ munin-1.2.6/node/node.d/postgres_locks.in   2009-07-27 00:50:56.000000000 +0200
485
490
@@ -0,0 +1,83 @@
486
491
+#!@@PERL@@
487
492
+# -*- perl -*-
569
574
Index: munin-1.2.6/node/node.d/postgres_queries_.in
570
575
===================================================================
571
576
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
572
 
+++ munin-1.2.6/node/node.d/postgres_queries_.in        2008-10-26 13:56:15.000000000 +0100
 
577
+++ munin-1.2.6/node/node.d/postgres_queries_.in        2009-07-27 00:50:56.000000000 +0200
573
578
@@ -0,0 +1,194 @@
574
579
+#!@@PERL@@
575
580
+# -*- perl -*-
768
773
Index: munin-1.2.6/node/node.d/postgres_space_.in
769
774
===================================================================
770
775
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
771
 
+++ munin-1.2.6/node/node.d/postgres_space_.in  2008-10-26 13:56:35.000000000 +0100
772
 
@@ -0,0 +1,193 @@
 
776
+++ munin-1.2.6/node/node.d/postgres_space_.in  2009-07-27 00:53:09.000000000 +0200
 
777
@@ -0,0 +1,219 @@
773
778
+#!@@PERL@@ -w
774
779
+# -*- perl -*-
775
780
+#
776
 
+# Plugin to monitor PostgreSQL disk usage.
777
 
+#
778
 
+# Written by Bjrn Ruberg (bjorn@linpro.no) 2006
779
 
+# Rewritten by Moses Moore 2006-04-08  moc.iazom@sesom
780
 
+# Licenced under GPL
781
 
+#
782
 
+# Parameters:
783
 
+#      
784
 
+#      config
785
 
+#      autoconf
786
 
+#
787
 
+# Configuration variables:
788
 
+#
789
 
+#      PGHOST          - Database server to use. Defaults to using ident
790
 
+#                        authentication with the local server.
791
 
+#      PGPORT          - Port to connect to. Defaults to '5432'.
792
 
+#      PGDATABASE      - Database to connect to. Defaults to 'template1'.
793
 
+#                        Note that this can be different from the database to
794
 
+#                        monitor, which is defined via the symlink.
795
 
+#      PGUSER          - User to connect as, if necessary.
796
 
+#      PGPASSWORD      - Corresponding password to use, if necessary.
797
 
+#
798
 
+#      (See libpq documentation for more.)
799
 
+#      Note that PGDATABASE will default to 'template1' in this plugin, and
800
 
+#      without PGHOST it will try ident authentication with the local server,
801
 
+#      as the user that the plugin is running as.
802
 
+#
803
 
+# Configuration example:
804
 
+#
805
 
+#      # Use local server, ident authentication with the 'postgres' user.
806
 
+#      [postgres_*]
807
 
+#      user postgres
808
 
+#
809
 
+#      # Use local server, TCP authentication with a username and password.
810
 
+#      [postgres_*]
811
 
+#      env.PGHOST localhost
812
 
+#      env.PGUSER someuser
813
 
+#      env.PGPASSWORD somepassword
814
 
+#
815
 
+# Magic markers
816
 
+#%# family=auto
817
 
+#%# capabilities=suggest
 
781
+=head1 NAME
 
782
+
 
783
+postgresql_space_ - Plugin to monitor PostgreSQL disk usage.
 
784
+
 
785
+=head1 INSTALLATION
 
786
+
 
787
+Link the plugin to @@CONFDIR@@/plugins/ :
 
788
+  ln -s @@LIBDIR@@/plugins/postgres_space_ @@CONFDIR@@/plugins/postgres_space_dbname
 
789
+
 
790
+The database name from the link is only used in the graph title. You have to
 
791
+configure the name of the database to connect in the configuration file. 
 
792
+
 
793
+=head1 CONFIGURATION
 
794
+
 
795
+The plugin supports the following parameters:
 
796
+       
 
797
+ config        (required)
 
798
+ autoconf      (optional - used by munin-node-configure)
 
799
+
 
800
+
 
801
+To configure the plugin set configuration variables in
 
802
+@@CONFDIR@@/plugin-conf.d/postgres :
 
803
+
 
804
+ PGHOST                - Database server to use. Defaults to using ident
 
805
+                 authentication with the local server.
 
806
+ PGPORT                - Port to connect to. Defaults to '5432'.
 
807
+ PGDATABASE    - Database to connect to. Defaults to 'template1'.
 
808
+                 Note that this can be different from the database to
 
809
+                 monitor, which is defined via the symlink.
 
810
+ PGUSER                - User to connect as, if necessary.
 
811
+ PGPASSWORD    - Corresponding password to use, if necessary.
 
812
+
 
813
+(See libpq documentation for more.)
 
814
+
 
815
+Note that PGDATABASE will default to 'template1' in this plugin, and
 
816
+without PGHOST it will try ident authentication with the local server,
 
817
+as the user that the plugin is running as.
 
818
+
 
819
+Configuration example:
 
820
+
 
821
+# Use local server, ident authentication with the 'postgres' user.
 
822
+ [postgres_*]
 
823
+ user postgres
 
824
+ env.PGDATABASE myappdb
 
825
+
 
826
+# Use local server, TCP authentication with a username and password.
 
827
+ [postgres_*]
 
828
+ env.PGHOST localhost
 
829
+ env.PGDATABASE myappdb
 
830
+ env.PGUSER someuser
 
831
+ env.PGPASSWORD somepassword
 
832
+
 
833
+=head1 AUTHOR
 
834
+
 
835
+ Written by Bjrn Ruberg (bjorn@linpro.no) 2006
 
836
+ Rewritten by Moses Moore 2006-04-08  moc.iazom@sesom
 
837
+
 
838
+=head1 LICENSE
 
839
+
 
840
+Licenced under GPL
 
841
+
 
842
+
 
843
+=head1 MAGIC MARKERS
 
844
+
 
845
+ #%# family=auto
 
846
+ #%# capabilities=autoconf suggest
 
847
+
 
848
+=cut
818
849
+
819
850
+use strict;
820
851
+use DBI;
828
859
+        # Check for DBD::Pg
829
860
+        if (! eval "require DBD::Pg;") {
830
861
+            print "no (DBD::Pg not found)";
831
 
+            exit 1;
 
862
+            exit 0;
832
863
+        }
833
864
+        # Then we try to detect PostgreSQL presence.
834
 
+        my $tempdbh = DBI->connect ('dbi:Pg:', '', '');
 
865
+        my $tempdbh = DBI->connect ('dbi:Pg:', '', '', { PrintError => 0 });
835
866
+        if ($tempdbh) {
836
867
+            print "yes\n";
837
868
+            exit 0;
838
869
+        } else {
839
870
+            print "no (Can't connect to given host, please check environment settings)\n";
840
 
+            exit 1;
 
871
+            exit 0;
841
872
+        }
842
873
+    } elsif ($ARGV[0] and $ARGV[0] eq 'debug') {
843
874
+        # Set config flag
943
974
+                            "pg_toast_${relfilenode}_index");
944
975
+            my $relpages = $sth2->fetchrow_array;
945
976
+            if ($relkind eq 'r') {
946
 
+                $table_pages     += $relpages if $meta == 0;
947
 
+                $metatable_pages += $relpages if $meta == 1;
 
977
+                $table_pages     += $relpages if defined($relpages) and $meta == 0;
 
978
+                $metatable_pages += $relpages if defined($relpages) and $meta == 1;
948
979
+            } elsif ($relkind eq 'i') {
949
 
+                $table_indexes     += $relpages if $meta == 0;
950
 
+                $metatable_indexes += $relpages if $meta == 1;
 
980
+                $table_indexes     += $relpages if defined($relpages) and $meta == 0;
 
981
+                $metatable_indexes += $relpages if defined($relpages) and $meta == 1;
951
982
+            }
952
983
+            print "#\tR:$relfilenode\tP:$table_pages\tI:$table_indexes\n" if $debug;
953
984
+        }