Shell cron script/utility to make screenshots and periodically emailing

you need a font that displays non ascii characters same width as the ascii one
normaly if the font in use do not have all the unicode glyphs they are are brought in from other fonts
i used gnu unifont to fix it

Code:
tmux capturep -p -e -S 0 -E 80 | aha -b -l |sed -e 's/<pre>/<pre style="font-family:unifont">/g' >s.html
1677647440813.png
 
you need a font that displays non ascii characters same width as the ascii one
normaly if the font in use do not have all the unicode glyphs they are are brought in from other fonts
i used gnu unifont to fix it

Code:
tmux capturep -p -e -S 0 -E 80 | aha -b -l |sed -e 's/<pre>/<pre style="font-family:unifont">/g' >s.html
So, as I able to see, You much better in this than I am ;)

May be You able also resolving this (https://forums.freebsd.org/threads/...y-resource-monitoring-tool.85687/#post-573743) my problem?

Thank You A LOT !
 
if you still need images you probably can use some html2pdf kind of software but they need to use the same font
but html should be good enough for viewing
I have a thought all this conversion would be a pressure on resources, this is hi-load server and I need something extremely "light"...
Am I wrong about pressure on resources ?
 
I have a thought all this conversion would be a pressure on resources, this is hi-load server and I need something extremely "light"...
Am I wrong about pressure on resources ?

Can you explain why you want pictures instead of just text or html? They will make the process much heavier. And you can't copy and paste from them, they are not very practical for communicating about them.
 
Can you explain why you want pictures instead of just text or html? They will make the process much heavier. And you can't copy and paste from them, they are not very practical for communicating about them.
Please, take my sorry about some kinde of stupidness (may be I need more clearly taking a question, a little bit tied in a country with a War...;)

As You may see by screenshots above in this thread, the are:
- rack server for hi-loading, w/ or w/o attached locally 17" monitor;
- after booting complete, the btop/bpytop automatically started on ttyv0 for server current state visual control by local tech stuff;

Also, there would be (and this is what I exactly asking for) some sh/zsh shell script to 24/7 periodically making screenshots (I think that would be "get dump of ttyv0 output, format it to bitmap and save as a .jpg/.png file) of btop/bpytop output (ASCII colors control, TUI interface), place this .jpg/.png to certain directory, and sending by schedule mail with this .jpg/.png attached and saving to remote cloud like Amazon S3/private collocation server/VPS).

Tech stuff using this "set of btop/bpytop states" as one of source of collected data for QC/QA (together with Prometheus, Grafana....).

Is this description exactly that You asking for? ;)
Have a nice day!
 
Please, take my sorry about some kinde of stupidness (may be I need more clearly taking a question, a little bit tied in a country with a War...;)

As You may see by screenshots above in this thread, the are:
- rack server for hi-loading, w/ or w/o attached locally 17" monitor;
- after booting complete, the btop/bpytop automatically started on ttyv0 for server current state visual control by local tech stuff;

Also, there would be (and this is what I exactly asking for) some sh/zsh shell script to 24/7 periodically making screenshots (I think that would be "get dump of ttyv0 output, format it to bitmap and save as a .jpg/.png file) of btop/bpytop output (ASCII colors control, TUI interface), place this .jpg/.png to certain directory, and sending by schedule mail with this .jpg/.png attached and saving to remote cloud like Amazon S3/private collocation server/VPS).

Tech stuff using this "set of btop/bpytop states" as one of source of collected data for QC/QA (together with Prometheus, Grafana....).

Is this description exactly that You asking for? ;)
Have a nice day!

I (we?) understand all that. Just not why you want to email bitmaps around instead of text.
 
I (we?) understand all that. Just not why you want to email bitmaps around instead of text.
Thank You for patience..:)
Three reason:

1. Pattern of mind (I even do not know that was possible, because on macOS (Debian) realizing even if really needed that involving a lot of apps and human efforts ;).

2. I still thinking that whole operation "taking scrnshot + converting" eating server resources (let's note this is hi-loading server where each "extra" load is strongly unwanted).
Am I wrong ?

3. Image are VERY USABLE (easy emailing, drop in chats, the same view on different devices/OSs,...) during meetups with managers about servers/appliance upgrade, taking decisions about future structure changing, etc.

P.S.
God Bless, we not need making PDF or paste to Word file this scrnshot;)
 
I see that you have a hammer (= taking a screenshot) but I would recommend to rethink if this is really the right tool for the screw (server stats) you want to drill in.
 
I see that you have a hammer (= taking a screenshot) but I would recommend to rethink if this is really the right tool for the screw (server stats) you want to drill in.
Thank You for make me smiley:)

I understand You point. As any other peoples here in this thread.

We collect statistics by several ways (Including Network Weathermap, Prometheus, Grafana, LibreNMS, Splunk, Smokeping, Cacti, etc, etc...), and exactly this tool we need for certain purposes and certain goals.

I just a little bit shocked, that in 2023 year we all in this thread need spend time on 2-nd page, trying to finding utility for I am just asking - "making scrnshot of a screen" (technically this mean "grab the ttyv0 buffer (TUI interface of app, encode to img form, write to file on local disk or remote storage")...
 
I just a little bit shocked, that in 2023 year we all in this thread need spend time on 2-nd page, trying to finding utility for I am just asking - "making scrnshot of a screen" (technically this mean "grab the ttyv0 buffer (TUI interface of app, encode to img form, write to file on local disk or remote storage")...
People are trying to understand what you are trying to achieve to best help you.

Your requirements seem unusual to most people here - you want to capture a lot of textual data and then make a bitmap graphic of that text.

So everyone trying to understand WHY you want to do things this way - don’t think anyone does understand but at least we know now what you want to do.

I think it was confusing because you asked how to make a bitmap graphic for server health and metrics text. Maybe in this case there was a bit too much information initially.
 
this will create a pdf out of aha's output |reads html from stdin, writes pdf to stdout
requires tcl, tdom, pdf4tcl but the get the latest version from sourceforge, port is buggy

Code:
package require tdom
#lappend auto_path /extra/fs/d/tcl86/Tcl-amd64/lib
package require pdf4tcl
proc mm2p { x } {
 return [expr {$x / 25.4 * 72}]
 }
encoding system utf-8
set FONT_SIZE 18
pdf4tcl::new mypdf  -margin 0 -paper A3  -landscape 1
pdf4tcl::loadBaseTrueTypeFont Baseunifont unifont-15.0.01.ttf
pdf4tcl::createFont Baseunifont TestFont utf-8
mypdf setFont $FONT_SIZE TestFont
mypdf setFillColor 0 0 0
mypdf rectangle 0 0 [mm2p 420] [mm2p 297] -filled 1
set fh [mypdf getFontMetric height]
set fw [mypdf getCharWidth T]
set html [read stdin]
set doc [dom parse -keepEmpties -html $html ]
set rootnode [$doc documentElement]
set x0 [mm2p 5]
set y0 [mm2p 5]
set x $x0
set y $y0
set ppnodes [$rootnode selectNodes "//span/text()"]
foreach node $ppnodes {
 set pnode [$node parent]
 set bold_hack 0
 if { [$pnode hasAttribute style ] } {
  set stl [$pnode getAttribute style]
  set lsl [split $stl ";"]
  foreach s $lsl {
   if { $s == "" } { continue }
   set ss [split $s ":"]
   if { [llength $ss] == 2 } {
    switch [lindex $ss 0 ] {
     color {
      lappend gugu [list setFillColor [lindex $ss 1]]
      }
     background-color {
      lappend gugu [list setBgColor [lindex $ss 1]]
      }
     font-weight {
      if { [lindex $ss 1] == "bold" } {
       set bold_hack 1
       }
      }
     }
    }
   }

  }
 set text [$node nodeValue]
 set ltext [split $text "\n"]
 set had_nl 0
 set zz [string length $text]
 for { set i 0 } { $i < $zz } { incr i } {
  set shit [string range $text $i $i]
  if { ![info exists A($shit) ]} {
    set A($shit) 1
    lappend Z [scan $shit %c]
   }
  }
 foreach str $ltext {
  if { $had_nl } {
   set x $x0
   set y [expr {$y + $fh }]
 # puts ""
   }
   lappend gugu [list $str $x $y]
   if { $bold_hack } {
    lappend gugu [list $str [expr $x+0.3] [expr $y+0.3]]
    }
  set x [expr {$x +[string length $str] * $fw }]
#  puts -nonewline $str
  set had_nl 1
  }
 }
#puts $Z
pdf4tcl::createFontSpecEnc Baseunifont CombinedFont $Z
mypdf setFont $FONT_SIZE CombinedFont
foreach cmd $gugu {
 set n [llength $cmd ]
 if { $n == 3 } {
  mypdf text [lindex $cmd 0] -x [lindex $cmd 1] -y [lindex $cmd 2]
  } else {
  mypdf [lindex $cmd 0] [lindex $cmd 1]
   }
 }
mypdf write
mypdf destroy
 

Attachments

  • out.pdf
    11.4 KB · Views: 62
People are trying to understand what you are trying to achieve to best help you.
Because of this initially friendly mood of this FreeBSD forum, and of coarse, HUGE user experience, I love and thrust this community.
Your requirements seem unusual to most people here - you want to capture a lot of textual data and then make a bitmap graphic of that text.
I not imagin that one screen of app would be "a lot of textual data". ;)

So everyone trying to understand WHY you want to do things this way - don’t think anyone does understand but at least we know now what you want to do.

I think it was confusing because you asked how to make a bitmap graphic for server health and metrics text. Maybe in this case there was a bit too much information initially.
Or may be I need to be shortly. ;)

Anyway THANK YOU ALL for efforts on the way to resolving the case. ;)
 
If you really want the bitmap graphics I would run an xterm inside XPra and then capture with xwd or ImageMagick. Or even a real X11 server.
Thank You for suggestion, but as I say before ANY extra loading on the server are strongly unwanted...
May be some other solution ?
 
Back
Top