Sponsored Content
Top Forums Shell Programming and Scripting Script to convert csv file to html with good visibility Post 302710399 by rdrtx1 on Thursday 4th of October 2012 11:43:35 AM
Old 10-04-2012
if the % column is # 2 (otherwise change $pct_col):

Code:
 
#!/bin/ksh
perl -F',' -lane 'BEGIN{
$pct_col=2;
@bgc=("lightgreen","lightsteelblue");
open O, ">output_db.html"; print O "<html><body><table border=1><tbody>"
};
chomp;
print O "<tr>";
for $i (0..@F-1) {
   $cbgc=@bgc[$i % 2];
   if (${i} == ($pct_col - 1)) {
      $pct=@F[$i];
      $pct=~s/ *[%].*$//;
      $pct=~s/^ *//;
      $cbgc="red" if ($pct <= 20);
   }
   print O "<td bgcolor=" . $cbgc . " >@F[$i]<\/td>"
}
print O "<\/tr>";
END {print O "</tbody><\/table><\/body><\/html>"; close O}' DBA_CHECKS.csv


Last edited by rdrtx1; 10-04-2012 at 01:10 PM..
This User Gave Thanks to rdrtx1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sample Unix script file to convert .xml to .csv

Dear all, Can you send me a script file the changes .xml to .csv file. Thanks, Srinivasa (4 Replies)
Discussion started by: srinivasaphani
4 Replies

2. UNIX for Dummies Questions & Answers

Unix script to convert .csv file to.xls format

I have a .csv file in Unix box i need a UNIX script to convert the.csv files to.xls format. Its very urgent please help me. (1 Reply)
Discussion started by: moon_friend
1 Replies

3. UNIX for Dummies Questions & Answers

convert csv to html file

Hi All, I am new to this forum,not sure where to post this query...so posted here Kindly need any of your help on the below ------------ I am using shell scripting and trying to convert a csv file to html file... example.csv --------------- Name Country Age Sex Andy India 25 ... (4 Replies)
Discussion started by: sumithra
4 Replies

4. Shell Programming and Scripting

Is there any script which convert binary file to CSV format

Dear guys; I have a binary file and I need to convert its data to csv format ...appreciating your help. Best Regards (14 Replies)
Discussion started by: ahmad.diab
14 Replies

5. Shell Programming and Scripting

Awk script to convert csv to html

Hi Written some script to convert csv to html but could not add table headers.Below are the errors iam getting ./csv2html | more + awk -v border=1 -v width=10 -v bgcolor=black -v fgcolor=white BEGIN { printf("<table border=\"%d\" bordercolor=\"%s\" width=\"%d\"... (2 Replies)
Discussion started by: zeebala1981
2 Replies

6. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

7. Shell Programming and Scripting

Script to convert CSV file to HTML

Hi, I have made a a script which creates a csv file as daily database report However i want to covert that csv file to html because csv file does not have a good visibilty. So it is possible to have such csv to html coversion script. Your prompt help much appreciated. Thanks in advance (4 Replies)
Discussion started by: sv0081493
4 Replies

8. Shell Programming and Scripting

Need script to convert TXT file into CSV

Hi Team, i have some script which give output in TXT format , need script to convert TXT file into CSV. Output.TXT 413. U-UU-LVDT-NOD-6002 macro_outcome_dist-8.0.0(v1_0_2) KK:1.2.494 (1234:333:aaa:2333:3:2:333:a) 414. U-UU-LVDT-NOD-6004 ... (10 Replies)
Discussion started by: Ganesh Mankar
10 Replies

9. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies

10. Shell Programming and Scripting

Convert csv data to html format

I am new to html and need to convert the attached csv file data to html format ; running into issues. please assist. #!/bin/ksh echo "<html>" ; echo "<head><style> table {border-collapse: collapse;} table, td, th {border: 1px solid black;} </style></head>" echo "<title> REPORT </title>" echo... (0 Replies)
Discussion started by: archana25
0 Replies
PMIECONF(5)							File Formats Manual						       PMIECONF(5)

PMIECONF(5)							File Formats Manual						       PMIECONF(5)

NAME
pmieconf - generalized pmie rules and customizations DESCRIPTION
The pmieconf file formats are used by the pmieconf(1) tool as a way to generalize pmie(1) rule sets such that they can be easily configured for different systems and different environments. There are two completely different (although closely related) file formats discussed here, namely ``pmieconf-rules'' and ``pmieconf-pmie''. The directory $PCP_VAR_DIR/config/pmieconf contains information about all the default system pmie generalized rules and variables, includ- ing default values for all variables. These files are in the pmieconf-rules format. Although new pmieconf-rules files can be added, the files in this directory should never be changed. Instead, use the pmieconf utility to change variable values in the pmie configuration file. The pmieconf-pmie format allows site specific customizations of the rules contained in pmieconf-rules files and their associated variables. The pmieconf-pmie format is generated by pmieconf and should not be edited by hand. This generated file is in the pmie format, with some additional information held at the head of the file - thus, the pmieconf-pmie format is a superset of the pmie file format (extended to hold customizations to the generalized rules, but also containing the actual performance rules for pmie to evaluate) which can also be parsed by pmie (all extensions are hidden within comments, and are thus meaningless to pmie itself). The file $PCP_VAR_DIR/config/pmieconf/config.pmie contains local system settings for pmieconf configurable variables. The variable set- tings in this file replace the default values specified in $PCP_VAR_DIR/config/pmieconf/*/*. PMIECONF-PMIE SYNTAX All rule customization lines in a valid pmieconf-pmie specification are prefixed by ``//'' and are located at the head of the file - this allows files containing a pmieconf-pmie specification to be successfully parsed by pmie. A pmieconf-pmie must always have the first line in the form: // pmieconf-pmie version pmieconf_path The version specifies which version of the pmieconf-pmie syntax should be used to parse this file. Currently the only supported version is 1. The pmieconf_path specifies the path to the pmieconf-rules files which were used, by pmieconf, to generate this file. This is dis- cussed in the pmieconf(1) man page (see the -r option). The remainder of the specification consists of one line entries for each of the modified variables. The syntax for each line is: // rule_version rule_name rule_variable = value The rule_version and rule_name are used to identify the rule with which to associate the customization. These are followed by the rule_variable name (i.e. the variable of rule rule_name which has been changed) for which the new value is to be used. A pmieconf-pmie specification must be terminated with the ``end'' keyword. This is used by pmieconf to distinguish where the customiza- tions ends, and the actual pmie rule component begins. PMIECONF-PMIE EXAMPLE The following example is a valid pmieconf-pmie format file, as generated by pmieconf. In order to make changes by hand which are preserved by pmieconf, see the comments contained in the generated file (below) as to where such changes should be made. // pmieconf-pmie 1 $PCP_VAR_DIR/config/pmieconf // 1 memory.exhausted delta = "4 minutes" // 1 memory.exhausted enabled = yes // 1 memory.exhausted pcplog_action = yes // end // // --- START GENERATED SECTION (do not change this section) --- // generated by pmieconf on: [DATESTAMP] // // 1 memory.exhausted delta = 4 minutes; some_host ( ( avg_sample (swap.pagesout @0..9 ) ) > 0 && 30 %_sample swap.pagesout >= 5 ) -> shell 10 min "$PCP_BINADM_DIR/pmpost Severe demand for real memory" " %vpgsout/s@%h"; // --- END GENERATED SECTION (changes below will be preserved) --- To see how this all works, you can generate this file as follows: # cat - | pmieconf -f /tmp/pmieconf.out -r $PCP_VAR_DIR/config/pmieconf/memory:$PCP_VAR_DIR/config/pmieconf/global modify memory.exhausted delta "4 minutes" modify memory.exhausted enabled yes modify memory.exhausted pcplog_action yes ^D # Then verify that the generated file is a valid pmie configuration file using: # pmie -C /tmp/pmieconf.out This parses the file, and then exits after reporting any syntax errors. Now replace -C with -v (above), and watch pmie do its work! PMIECONF-RULES SYNTAX A pmieconf-rules specification consists of a number of separate data objects which together form a complete rule specification (note that a specification may span multiple files and even multiple subdirectories). Each object must have an identifier string and a data type, fol- lowed by an (optional) list of attributes. The generic specification of a pmieconf-rules object is thus: type identifier [ attribute = value ]* ; The set of valid types is: "rule" (rule definition), "string" (arbitrary, double-quote enclosed string), "double", "integer", "unsigned", "percent" (real number between 0 and 100), "hostlist" (space separated list of host names), "instlist" (space separated list of metric instance names), and the four pmie action types, namely "print", "shell", "alarm", and "syslog". Rule names use the ``.'' character to introduce the concept of a rule group, e.g. "memory.exhausted" associates this rule with the "memory" group. pmieconf can operate at either the level of rule groups or individual rules. The group name "global" is reserved and may not be used with any rule. Usually when an object is created it is associated with the current rule. However, if an object's name is preceded by the reserved group name "global", then that object is visible to all rules. The set of valid attributes is: "help" (descriptive text about this object), "modify" (value is yes/no, flags whether pmieconf should allow changes), "enabled" (value is yes/no, flags whether this is on or off - only meaningful for rules and actions), "display" (yes/no - flags whether pmieconf should show this object), "default" (value determined by type, and is the default value for this object), and specific to objects of rule type are the "version", "predicate", and "enumerate" attributes. "version" and "predicate" are fairly self explanatory ("predicate" must equate to a valid pmie rule when expanded), but "enumerate" requires further discussion. The "enumerate" clause is useful when you wish to generate multiple, similar pmie rules from a single predicate. This is most useful for rule definitions wishing to use the "some_inst" clause in the pmie language across multiple hosts. For a rule to use these together, it must be certain that the instance list is the same on all of the monitored hosts. This is rarely true, so the "enumerate" attribute allows us to generate multiple rules, expanded over variables of either type "instlist" or "hostlist". These variables make up the value for the "enumerate" attribute - which is a space-separated list of "instlist" or "hostlist" variable names. Objects can be incorporated into other object definitions using the $identifier$ syntax. See the example later for more insight into how this is useful. When pmieconf is generating the pmie configuration file, it looks at each enabled rule with N enabled actions (where N > 0) and expands the string: // "version" identifier delta = $delta$; "predicate" -> $threshold$ $action1$ & ... & $actionN$ ; The delta, threshold, and action variables are defined globally (using the "global" keyword) for all rules, but can, of course, be changed at the level of an individual rule or rule group. PMIECONF-RULES EXAMPLE The following is an example of a single pmieconf-rules specification, showing a number of different aspects of the language discussed above. The example defines a rule ("memory.exhausted") and a string ("rule"). rule memory.exhausted default = "$rule$" predicate = "some_host ( ( avg_sample (swap.pagesout $hosts$ @0..9 ) ) > 0 && $pct$ %_sample swap.pagesout $hosts$ @0..9 >= $threshold$ )" enabled = yes version = 1 help = "The system is swapping modified pages out of main memory to the swap partitions, and has been doing this on at least pct of the last 10 evaluations of this rule. There appears to be insufficient main memory to meet the resident demands of the current workload."; string rule default = "Severe demand for real memory" modify = no display = no; Note that for the above rule to be complete, "threshold" and "pct" would also need to be defined - for the full expression of this rule, refer to $PCP_VAR_DIR/config/pmieconf/memory/exhausted. FILES
$PCP_VAR_DIR/config/pmieconf/*/* generalized system resource monitoring rules $PCP_VAR_DIR/config/pmieconf/config.pmie default super-user settings for system resource monitoring rules $HOME/.pcp/pmie/config.pmie default user settings for system resource monitoring rules SEE ALSO
pmie(1) and pmieconf(1). Performance Co-Pilot PCP PMIECONF(5)
All times are GMT -4. The time now is 10:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy