Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    interazione php-perl: x very esperti

    Salve a tutti, sto realizzando un sistema di monitoraggio integrato,utilizzando Big Brother come progr di netmonitoring. BB crea dei report "a volo" mediante uno script perl (cgi). Io vorrei innanzitutto far partire questo script dal mio portale mdpro, magari facendo si che in base all'utente che si logga si possano visualizzare solo i report ad esso relativi...
    cioè l’utente che si logga sul mio portale fatto in “ mdpro “, dovrebbe cliccare su un bottone che fa partire tale script il quale visualizza in un frame SOLO i suoi servizi non tutti!!!
    Ora io avevo pensato di fare una pagina in php che mi identifica l'utente (cosa semplice con le api) e poi devo innanzitutto vedere come far partire lo script perl
    poi avevo pensato di cambiare il ciclo for del mio script(ciclo che visualizza tutti insieme gli sla) in un “if”, ma quale variabile di controllo devo usare? Dovrebbe essere la stessa che nel php mi identifica gli utenti,credo

    Forse è una cosa semplice ma sono un po' ignorante in programmaz e nei forum nn ho trovato granchè a riguardo.

    Vi prego datemi una mano, sono giunto a un punto morto della mia tesi!
    Infinitamente grazie
    mcgyver

  2. #2
    Credo che se postassi del codice sarebbe meglio per tutti...

  3. #3

    ok ecco il codice ma è molto lungo

    use strict;
    use Time::Local;
    # C O N F I G U R A B L E V A R I A B L E S
    # Where the BBHOME is
    # ---------------------------------------------------
    my($bbhome) = "/usr/local/bb";

    # Where to find the history logs to analyze
    my($histdir) = "$bbhome/bbvar/hist";

    # Where to get history external to Big Brother

    my($exthistfile) = "$bbhome/bbvar/ext/sla-report/history.txt";

    # The name of your configfile
    # ---------------------------
    my($configfile) = "$bbhome/bb/ext/sla-report/sla-report.cfg";

    # Web-stuff
    # ---------
    my($webdir) = "$bbhome/bb/web";
    my($webheader) = $webdir . "/bb_header";
    my($webfooter) = $webdir . "/bb_footer";

    # Data structures
    # %apps will contain the break down of applications from the config file:
    # $apps{GROUPNAME}->{COMPONENTS}->{COMPONENTNAME}->{HOSTS}->(array of hosts)
    # {TESTS}->(array of tests)
    # {TESTINFO}->{TESTNAMES host.test format}->{STATUS} known test
    # {TOTAL_GREEN} Actual uptime of test
    # {SW}->(array of service windows)
    # {DEPENDS}->(array of dependencies)
    # {TYPE}->[USER|SYSTEM|CORE]
    # {TOTAL_TIME} = Total of expected uptime of component
    # {TOTAL_GREEN}= Total of actual uptime of component
    # {TOTAL_TIME} = Total of expected uptimes of each USER component
    # {TOTAL_GREEN}= Total of actual uptime of each USER component
    my(%apps);

    # %components_by_test will be a reverse lookup of test (hostname.test format)
    # to an array of ($apps{GROUPNAME}->{COMPONENTNAME}, GROUPNAME, COMPONENTNAME)
    my(%components_by_test);

    # %events_by_app will be a hash of arrays. Linking appname to a list of
    # all events (including servicewindow events)
    my(%events_by_app);

    # %ext_events_by_test will be a hash keyed by test of all the events from an external
    # history file
    my(%ext_events_by_test);

    my($debug)=0;

    # cgi is set to 1 if this script was called from a web server
    my($cgi)=0;

    # -------------------------------------------------------------------
    my($query);
    if ( $ENV{'SERVER_SOFTWARE'} ) {
    $cgi = 1;
    use CGI;
    $query = new CGI;
    }
    else {
    $cgi = 0;
    }

    # get date from localtime
    my(@date) = localtime();
    # localtime returns the month as 0-11, Ugh
    $date[4]++;
    my($date) = scalar localtime();

    # Month name to number hash
    my(%months) = ( "Jan" => 1,
    "Feb" => 2,
    "Mar" => 3,
    "Apr" => 4,
    "May" => 5,
    "Jun" => 6,
    "Jul" => 7,
    "Aug" => 8,
    "Sep" => 9,
    "Oct" => 10,
    "Nov" => 11,
    "Dec" => 12);

    # select_app is a regular expression that will allow users to report only on selected
    # applications
    my($select_app)="/.*/";

    #Use the dates given on the command line to find what period to look at
    my ($todate, $fromdate);
    if ( ! $cgi ) {
    if ( $ARGV[0] ) {
    $fromdate = $ARGV[0];
    }
    else {
    $fromdate = "01.01.2002.00.00.00";
    }
    if ( $ARGV[1] ) {
    $todate = $ARGV[1];
    }
    else {
    $todate = sprintf("%02d.%02d.%04d.%02d.%02d.%02d",$date[3],
    $date[4],
    $date[5]+1900,
    $date[2],
    $date[1],
    $date[0]
    );
    }
    # Allow the user to select a specific app to report on
    # This can be a regular expression to select multiple apps
    if ( $ARGV[2] ) {
    $select_app = $ARGV[2];
    }
    if ( $ARGV[3] ) {
    $debug = $ARGV[3];
    }
    }
    else {
    if ( $cgi && $query->param('start-mon') ) {
    $fromdate = $query->param('start-day') . "." .
    $months{$query->param('start-mon')} . "." .
    $query->param('start-yr')
    ;
    }
    else {
    $fromdate = "01.01.2002.00.00.00";
    }
    if ( $cgi && $query->param('end-mon') ) {
    $todate = $query->param('end-day') . "." .
    $months{$query->param('end-mon')} . "." .
    $query->param('end-yr')
    ;
    }
    else {
    $todate = sprintf("%02d.%02d.%04d.%02d.%02d.%02d",$date[3],
    $date[4],
    $date[5]+1900,
    $date[2],
    $date[1],
    $date[0]
    );
    }
    if ( $query->param('select_app') ) {
    $select_app = $query->param('select_app');
    }
    }

    # if the // start and end the select_app string, then assume its a regular expression,
    # otherwise assume an exact match and append the ^ and $ chars to force the regex interpreter
    # to do the right thing
    if ($select_app =~ /^\/(.*)\/$/) {
    $select_app = $1;
    } else {
    $select_app = "^" . $select_app . "\$";
    }

    my($fromts, $tots) = &find_period_ts($fromdate, $todate);
    if ( $tots > time()) { $tots=time(); }

    &read_config;

    &read_ext_history;

    &read_history;

    &analyze_apps;

    if ( $cgi ) {
    &print_web_results;
    }
    else {
    &print_results;
    }

    exit;

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.