diff options
-rw-r--r-- | FS/FS/part_pkg/torrus_Common.pm | 4 | ||||
-rw-r--r-- | FS/FS/part_pkg/torrus_bw_percentile.pm | 32 | ||||
-rw-r--r-- | FS/FS/part_pkg/torrus_bw_usage.pm | 32 | ||||
-rw-r--r-- | FS/FS/svc_port.pm | 212 | ||||
-rw-r--r-- | FS/MANIFEST | 4 | ||||
-rw-r--r-- | FS/t/h_svc_port.t | 5 | ||||
-rw-r--r-- | FS/t/svc_port.t | 5 | ||||
-rwxr-xr-x | httemplate/edit/part_svc.cgi | 90 | ||||
-rw-r--r-- | torrus/FREESIDE_INSTALL | 30 | ||||
-rw-r--r-- | torrus/FREESIDE_MODIFIED | 12 |
10 files changed, 400 insertions, 26 deletions
diff --git a/FS/FS/part_pkg/torrus_Common.pm b/FS/FS/part_pkg/torrus_Common.pm index 229a0c3..d34f724 100644 --- a/FS/FS/part_pkg/torrus_Common.pm +++ b/FS/FS/part_pkg/torrus_Common.pm @@ -28,13 +28,13 @@ sub calc_usage { my $self = shift; my($cust_pkg, $sdate, $details, $param ) = @_; - my $serviceid = 'TESTING_1'; #XXX from svc_port (loop?) - my $rep_id = 2; #XXX find the one matching the timeframe #SELECT id FROM WHERE reportname = 'MonthlyUsage' AND rep_date = '' #XXX abort if ! iscomplete? + my $serviceid = 'TESTING_1'; #XXX from svc_port (loop?) + my $sql = " SELECT value FROM reportfields WHERE rep_id = $rep_id diff --git a/FS/FS/part_pkg/torrus_bw_percentile.pm b/FS/FS/part_pkg/torrus_bw_percentile.pm new file mode 100644 index 0000000..7cf254a --- /dev/null +++ b/FS/FS/part_pkg/torrus_bw_percentile.pm @@ -0,0 +1,32 @@ +package FS::part_pkg::torrus_bw_percentile; + +use strict; +use base qw( FS::part_pkg::torrus_Common ); +use List::Util qw(max); + +our %info = ( + 'name' => '95th percentile billing based on the integrated Torrus NMS', + 'shortname' => 'Bandwidth (95th percentile)', + 'weight' => 54.5, #:/ + 'inherit_fields' => [ 'flat', 'global_Mixin' ], + 'fields' => { + #'recur_temporality' => { 'hidden' => 1, 'value' => 'preceding' }, #XXX do + 'recur_temporality' => { 'disabled' => 1 }, + 'sync_bill_date' => { 'disabled' => 1 }, + 'cutoff_day' => { 'disabled' => 1 }, + 'base_mbps' => { 'name' => 'Included megabytes/sec (95th percentile)', + 'default' => 0, + }, + 'mbps_rate' => { 'name' => 'Charge per megabyte/sec (95th percentile)', + 'default' => 0, + }, + }, + 'fieldorder' => [ qw( base_mbps mbps_rate ) ], + 'freq' => 'm', +); + +sub _torrus_name { '95TH_PERCENTILE'; } +sub _torrus_base { 'base_mbps'; } +sub _torrus_rate { 'mbps_rate'; } + +1; diff --git a/FS/FS/part_pkg/torrus_bw_usage.pm b/FS/FS/part_pkg/torrus_bw_usage.pm new file mode 100644 index 0000000..5ce2005 --- /dev/null +++ b/FS/FS/part_pkg/torrus_bw_usage.pm @@ -0,0 +1,32 @@ +package FS::part_pkg::torrus_bw_usage; + +use strict; +use base qw( FS::part_pkg::torrus_Common ); +use List::Util qw(max); + +our %info = ( + 'name' => 'Volume billing based on the integrated Torrus NMS', + 'shortname' => 'Bandwidth (volume)', + 'weight' => 54.7, #:/ + 'inherit_fields' => [ 'flat', 'global_Mixin' ], + 'fields' => { + #'recur_temporality' => { 'hidden' => 1, 'value' => 'preceding' }, #XXX do + 'recur_temporality' => { 'disabled' => 1 }, + 'sync_bill_date' => { 'disabled' => 1 }, + 'cutoff_day' => { 'disabled' => 1 }, + 'base_gb' => { 'name' => 'Included gigabytes', + 'default' => 0, + }, + 'gb_rate' => { 'name' => 'Charge per gigabyte', + 'default' => 0, + }, + }, + 'fieldorder' => [ qw( base_gb gb_rate ) ], + 'freq' => 'm', +); + +sub _torrus_name { 'VOLUME'; } +sub _torrus_base { 'base_gb'; } +sub _torrus_rate { 'gb_rate'; } + +1; diff --git a/FS/FS/svc_port.pm b/FS/FS/svc_port.pm new file mode 100644 index 0000000..931880e --- /dev/null +++ b/FS/FS/svc_port.pm @@ -0,0 +1,212 @@ +package FS::svc_port; + +use strict; +use base qw( FS::svc_Common ); +#use FS::Record qw( qsearch qsearchs ); +use FS::cust_svc; + +=head1 NAME + +FS::svc_port - Object methods for svc_port records + +=head1 SYNOPSIS + + use FS::svc_port; + + $record = new FS::svc_port \%hash; + $record = new FS::svc_port { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + + $error = $record->suspend; + + $error = $record->unsuspend; + + $error = $record->cancel; + +=head1 DESCRIPTION + +An FS::svc_port object represents a router port. FS::table_name inherits from +FS::svc_Common. The following fields are currently supported: + +=over 4 + +=item svcnum - + +=item serviceid - Torrus serviceid (in srvexport and reportfields tables) + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Creates a new port. To add the port to the database, see L<"insert">. + +Note that this stores the hash reference, not a distinct copy of the hash it +points to. You can ask the object for a copy with the I<hash> method. + +=cut + +sub table { 'svc_port'; } + +sub table_info { + { + 'name' => 'Port', + #'name_plural' => 'Ports', #optional, + #'longname_plural' => 'Ports', #optional + 'sorts' => [ 'svcnum', 'serviceid' ], # optional sort field (or arrayref of sort fields, main first) + 'display_weight' => 75, + 'cancel_weight' => 10, + 'fields' => { + 'serviceid' => 'Torrus serviceid', + }, + }; +} + +=item search_sql STRING + +Class method which returns an SQL fragment to search for the given string. + +=cut + +#or something more complicated if necessary +sub search_sql { + my($class, $string) = @_; + $class->search_sql_field('serviceid', $string); +} + +=item label + +Returns a meaningful identifier for this port + +=cut + +sub label { + my $self = shift; + $self->serviceid; #or something more complicated if necessary +} + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +The additional fields pkgnum and svcpart (see L<FS::cust_svc>) should be +defined. An FS::cust_svc record will be created and inserted. + +=cut + +sub insert { + my $self = shift; + my $error; + + $error = $self->SUPER::insert; + return $error if $error; + + ''; +} + +=item delete + +Delete this record from the database. + +=cut + +sub delete { + my $self = shift; + my $error; + + $error = $self->SUPER::delete; + return $error if $error; + + ''; +} + + +=item replace OLD_RECORD + +Replaces the OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=cut + +sub replace { + my ( $new, $old ) = ( shift, shift ); + my $error; + + $error = $new->SUPER::replace($old); + return $error if $error; + + ''; +} + +=item suspend + +Called by the suspend method of FS::cust_pkg (see L<FS::cust_pkg>). + +=item unsuspend + +Called by the unsuspend method of FS::cust_pkg (see L<FS::cust_pkg>). + +=item cancel + +Called by the cancel method of FS::cust_pkg (see L<FS::cust_pkg>). + +=item check + +Checks all fields to make sure this is a valid port. If there is +an error, returns the error, otherwise returns false. Called by the insert +and repalce methods. + +=cut + +sub check { + my $self = shift; + + my $x = $self->setfixed; + return $x unless ref($x); + my $part_svc = $x; + + my $error = $self->ut_textn('serviceid'); #too lenient? + return $error if $error; + + $self->SUPER::check; +} + +=item + +Returns a PNG graph for this port. + +XXX Options + +=cut + +sub graph_png { + my $self = shift; + my $serviceid = $self->serviceid; + + +} + +=back + +=head1 BUGS + +=head1 SEE ALSO + +L<FS::svc_Common>, L<FS::Record>, L<FS::cust_svc>, L<FS::part_svc>, +L<FS::cust_pkg>, schema.html from the base documentation. + +=cut + +1; + diff --git a/FS/MANIFEST b/FS/MANIFEST index f6d6602..cdb2851 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -552,3 +552,7 @@ FS/part_pkg_vendor.pm t/part_pkg_vendor.t FS/cust_note_class.pm t/cust_note_class.t +FS/svc_port.pm +t/svc_port.t +FS/h_svc_port.pm +t/h_svc_port.t diff --git a/FS/t/h_svc_port.t b/FS/t/h_svc_port.t new file mode 100644 index 0000000..c75d203 --- /dev/null +++ b/FS/t/h_svc_port.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::h_svc_port; +$loaded=1; +print "ok 1\n"; diff --git a/FS/t/svc_port.t b/FS/t/svc_port.t new file mode 100644 index 0000000..d6f2691 --- /dev/null +++ b/FS/t/svc_port.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::svc_port; +$loaded=1; +print "ok 1\n"; diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 437f7e8..d608657 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -11,27 +11,9 @@ Service <INPUT TYPE="text" NAME="svc" VALUE="<% $hashref->{svc} %>"><BR> Disable new orders <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>><BR> <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $hashref->{svcpart} %>"> + <BR> -Service definitions are the templates for items you offer to your customers. -<UL><LI>svc_acct - Accounts - anything with a username (Mailboxes, PPP accounts, shell accounts, RADIUS entries for broadband, etc.) - <LI>svc_domain - Domains - <LI>svc_cert - Certificates - <LI>svc_dsl - DSL - <LI>svc_forward - Mail forwarding - <LI>svc_mailinglist - Mailing list - <LI>svc_www - Virtual domain website - <LI>svc_broadband - Broadband/High-speed Internet service (always-on) - <LI>svc_phone - Customer phone numbers - <LI>svc_pbx - Customer PBXs - <LI>svc_external - Externally-tracked service -<!-- <LI>svc_charge - One-time charges (Partially unimplemented) - <LI>svc_wo - Work orders (Partially unimplemented) ---> -</UL> -For the selected table, you can give fields default or fixed (unchangable) -values, or select an inventory class to manually or automatically fill in -that field. -<BR><BR> + % #YUCK. false laziness w/part_svc.pm. go away virtual fields, please % my %vfields; @@ -100,6 +82,8 @@ that field. % % my $html = qq!<INPUT TYPE="hidden" NAME="svcdb" VALUE="$layer">!; % +% $html .= $svcdb_info; +% % my $columns = 3; % my $count = 0; % my $communigate = 0; @@ -126,7 +110,7 @@ that field. % $count++; % $html .= '</TR><TR>' unless $count % $columns; % } -% $html .= '</TR></TABLE><BR><BR>'; +% $html .= '</TR></TABLE><BR><BR>'. $mod_info; % % $html .= include('/elements/table-grid.html', 'cellpadding' => 4 ). % '<TR>'. @@ -454,6 +438,70 @@ my %communigate_fields = ( #'svc_cert' => { map { $_=>1 } qw( ) }, ); +my $svcdb_info = ' +<TABLE> + <TR> + <TH ALIGN="left">Generic</TH> + <TH ALIGN="left">Access</TH> + <TH ALIGN="left">Telephony</TH> +<!-- <TH>Hosting</TH> + <TH>Colocation</TH> +--> + </TR> + <TR> + <TD VALIGN="top"> + <UL STYLE="margin:0"> + <LI><B>svc_acct</B>: Accounts - anything with a username (mailbox, shell, RADIUS, etc.) + <LI><B>svc_external</B>: Externally-tracked service + </UL> + </TD> + <TD VALIGN="top"> + <UL STYLE="margin:0"> + <LI><B>svc_dsl</B>: DSL + <LI><B>svc_broadband</B>: Wireless broadband + </UL> + </TD> + <TD VALIGN="top"> + <UL STYLE="margin:0"> + <LI><B>svc_phone</B>: Customer phone number + <LI><B>svc_pbx</B>: Customer PBX + </UL> + </TD> + </TR> +</TABLE> +<BR> +<TABLE> + <TR> + <TH ALIGN="left">Hosting</TH> + <TH ALIGN="left">Colocation</TH> + </TR> + <TD VALIGN="top"> + <UL STYLE="margin:0"> + <LI><B>svc_domain</B>: Domain + <LI><B>svc_cert</B>: Certificate + <LI><B>svc_forward</B>: Mail forwarding + <LI><B>svc_mailinglist</B>: Mailing list + <LI><B>svc_www</B>: Virtual domain website + </UL> + </TD> + <TD VALIGN="top"> + <UL STYLE="margin:0"> + <LI><B>svc_port</B>: Customer router/switch port + </UL> + </TD> + </TR> +<TABLE> +<!-- <LI>svc_charge - One-time charges (Partially unimplemented) + <LI>svc_wo - Work orders (Partially unimplemented) +--> +'; + +my $mod_info = ' +For the selected table, you can give fields default or fixed (unchangable) +values, or select an inventory class to manually or automatically fill in +that field. +'; + </%init> diff --git a/torrus/FREESIDE_INSTALL b/torrus/FREESIDE_INSTALL index 7432c00..130168b 100644 --- a/torrus/FREESIDE_INSTALL +++ b/torrus/FREESIDE_INSTALL @@ -1,11 +1,13 @@ i should move to the wiki once this is further along -aptitude install rrdtool librrds-perl libxml-libxml-perl libberkeleydb-perl libtemplate-perl libproc-daemon-perl libnet-snmp-perl libapache-session-perl libjson-perl +aptitude install rrdtool librrds-perl libxml-libxml-perl libberkeleydb-perl libtemplate-perl libproc-daemon-perl libnet-snmp-perl libapache-session-perl libjson-perl libdbix-abstract-perl libdbix-sequence-perl # in Makefile, set TORRUS_ENABLED = 1 make configure-torrus make deploy +set network_monitoring_system config setting to Torrus_Internal + #a little more one-offy from here so far http://torrus.org/install.pod.html#configuring_torrus : @@ -44,5 +46,27 @@ but do go from http://torrus.org/install.pod.html#cron_job on #--- -this seems to be required on restarts during dev (upgrades?) -rm /var/torrus/cache/* /var/torrus/db/render_cache.db +http://torrus.org/reporting_setup.pod.html + +cd /usr/local/etc/torrus/discovery +vi routers.ddx + + <!-- host-specfic parameter --> + <param name="RFC2863_IF_MIB::external-serviceid"> + TESTING_1:TenGigabitEthernet2_1:Both:main, + TESTING_2:TenGigabitEthernet2_2:Both:main, + </param> + +torrus devdiscover --in=routers.ddx +torrus compile --tree=main --verbose + +#kill collector, then restart +torrus collector --tree=main + +#--- + +add serviceids + +in freeside, setup svc_port service defs, packages with torrus billing types +order the package, provision an svc_port with a valid serviceid + diff --git a/torrus/FREESIDE_MODIFIED b/torrus/FREESIDE_MODIFIED new file mode 100644 index 0000000..34c361a --- /dev/null +++ b/torrus/FREESIDE_MODIFIED @@ -0,0 +1,12 @@ +configs/torrus-siteconfig.pl #turn of torrus auth, set URLs +perllib/Torrus/CGI.pm # header/footer +perllib/Torrus/Freeside.pm # header/footer +perllib/Torrus/Renderer.pm # header/footer + perllib/Torrus/Renderer/Freeside.pm # header/footer +perllib/Torrus/Renderer/Frontpage.pm # header/footer +perllib/Torrus/Renderer/HTML.pm # header/footer + perllib/Torrus/ReportOutput/Freeside.pm # header/footer +perllib/Torrus/ReportOutput/HTML.pm # header/footer +templates/html-incblocks.txt # header/footer +tempaltes/default-rrd.html # title beautification +sup/webplain/torrus.css #skinning |