<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Cli on falkp.no/blog</title>
    <link>/blog/tags/cli/</link>
    <description>falkp.no/blog (Cli)</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    
      

      
    

    
    <lastBuildDate>Sat, 24 Oct 2020 00:00:00 +0000</lastBuildDate>
    
    <atom:link href="/blog/tags/cli/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Check Commander - Curses interface for Checkmk</title>
      <link>/blog/posts/check_commander_curses_interface_for_checkmk/</link>
      <pubDate>Sat, 24 Oct 2020 00:00:00 +0000</pubDate>
      
      <guid>/blog/posts/check_commander_curses_interface_for_checkmk/</guid>
      <description>&lt;p&gt;A curses interface for &lt;a href=&#34;https://checkmk.com/&#34;&gt;checkmk&lt;/a&gt;. I named it Checkmk Commander, but Check Commander is easier to say.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;chkcomlogo.png&#34; alt=&#34;logo&#34;&gt;&lt;/p&gt;
&lt;p&gt;I use Checkmk daily. A few common tasks are acknowledging, downtiming and reinventorizing hosts and services. In the web UI this takes lots of clicks and time. So I wrote this client to optimize my workflow.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;chkcom.png&#34; alt=&#34;check commander screenshot&#34;&gt;&lt;/p&gt;
&lt;p&gt;Example workflow in web UI:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A new service has been detected on host1, thus I have to reinventorize it.&lt;/li&gt;
&lt;li&gt;Click on host name.&lt;/li&gt;
&lt;li&gt;Click WATO&lt;/li&gt;
&lt;li&gt;Click services&lt;/li&gt;
&lt;li&gt;Click &amp;ldquo;fix all missing/vanished&amp;rdquo;, wait.&lt;/li&gt;
&lt;li&gt;Click &amp;ldquo;1 change&amp;rdquo;&lt;/li&gt;
&lt;li&gt;Click &amp;ldquo;Activate affected&amp;rdquo;, wait.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The same in Check Commander:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A new service has been detected on host1, thus I have to reinventorize it.&lt;/li&gt;
&lt;li&gt;Navigate up/down to target the host&lt;/li&gt;
&lt;li&gt;Hit &amp;ldquo;r&amp;rdquo; and enter to confirm. Reinventorize happens in background, and one does not have to wait for it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are hotkeys for opening web pages (or run other commands) linked with the selected host. I use &amp;ldquo;w&amp;rdquo; to open the host&amp;rsquo;s wiki page, &amp;ldquo;b&amp;rdquo; to open the checkmk web UI in browser and &amp;ldquo;t&amp;rdquo; for opening a new terminal with ssh to the host.&lt;/p&gt;
&lt;p&gt;Since this is in curses, one can also run it in tmux or on a terminal server. Browser commands can then open in elinks, w3c, or other suitable CLI software.&lt;/p&gt;
&lt;p&gt;Easy install from pip. See screenshots and read more at &lt;a href=&#34;https://gitlab.com/larsfp/checkmk-commander&#34;&gt;gitlab&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>graph.no - Weather forecast via finger</title>
      <link>/blog/posts/graph_no___weather_forecast_via_finger/</link>
      <pubDate>Sat, 13 Dec 2014 00:00:00 +0000</pubDate>
      
      <guid>/blog/posts/graph_no___weather_forecast_via_finger/</guid>
      <description>&lt;h2 id=&#34;the-idea&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#the-idea&#34;&gt;
        #
    &lt;/a&gt;
    The idea
&lt;/div&gt;
&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;http://yr.no&#34;&gt;Yr.no&lt;/a&gt; has a brilliant &lt;a href=&#34;http://www.yr.no/place/Norway/Oslo/Oslo/Oslo/hour_by_hour.html&#34;&gt;hour by hour&lt;/a&gt; view. A simple picture where you get all info you need for planning your next 48 hours.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;meteogram.png&#34; alt=&#34;Yr.no&#34;&gt;&lt;/p&gt;
&lt;p&gt;They also give out all their &lt;a href=&#34;http://om.yr.no/verdata/free-weather-data/&#34;&gt;weather data for free&lt;/a&gt;! Having a special fascination for the command line, I wondered if I could represent the same information in a basic, ASCII, 80x22 terminal.&lt;/p&gt;
&lt;h2 id=&#34;development&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#development&#34;&gt;
        #
    &lt;/a&gt;
    Development
&lt;/div&gt;
&lt;/h2&gt;
&lt;p&gt;Earlier I&amp;rsquo;d made my first telnet service for keeping an eye on the status of the office coffee pot (&lt;a href=&#34;http://coffee.graph.no&#34;&gt;coffee.graph.no&lt;/a&gt; / telnet graph.no). After that, I pondered for a while on how to allow for choosing location via such a limited protocol. I did not want to make a service that had to be used by hand, like &lt;a href=&#34;http://www.thelinuxblog.com/quickly-checking-the-weather-with-telnet/&#34;&gt;wunderground&lt;/a&gt;, which I discovered later, but one that could be used in an automated sense.&lt;/p&gt;
&lt;p&gt;I considered running one instance at each port for a subset of the Norwegian postal codes, like 1000, 2000, 3000, etc. Or even for each hundred. I was stopped in pursuing this by two limitations in xinitd: no support for responding to several ports with one config file, and trouble of passing on which port was used to the daemon.&lt;/p&gt;
&lt;p&gt;I also tried to allow for passing an input so that one could run echo &amp;ldquo;oslo&amp;rdquo; | nc graph.no telnet. Can&amp;rsquo;t remember why that didn&amp;rsquo;t work.&lt;/p&gt;
&lt;p&gt;Then I discovered the &lt;a href=&#34;https://en.wikipedia.org/wiki/Finger_protocol&#34;&gt;finger protocol&lt;/a&gt;. Or rather how it actually worked. It&amp;rsquo;s simply telnet with one input, the user name. Perfect.&lt;/p&gt;
&lt;p&gt;The solution then became a python daemon, listening at the standard finger port, making a call to YR&amp;rsquo;s free API and caching the results. I found a &lt;a href=&#34;https://github.com/ways/pyyrlib&#34;&gt;python lib for using the API&lt;/a&gt;, so I could get right on to presenting the data.&lt;/p&gt;
&lt;p&gt;The first working code gave:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;finger1.jpg&#34; alt=&#34;Graph.no v.1&#34;&gt;&lt;/p&gt;
&lt;p&gt;After a few long nights it became more or less how it is today:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;finger2.png&#34; alt=&#34;Current graph.no&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;press&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#press&#34;&gt;
        #
    &lt;/a&gt;
    Press
&lt;/div&gt;
&lt;/h2&gt;
&lt;p&gt;I announced it at &lt;a href=&#34;http://tillegg.yr.no/application/pyyrascii/&#34;&gt;tillegg.yr.no&lt;/a&gt; (first runner up for top rated), and at &lt;a href=&#34;http://www.reddit.com/r/linux/comments/ouday/retro_weather_forecast_finger/&#34;&gt;reddit.com/r/linux&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;After that the part owner of YR, &lt;a href=&#34;http://nrk.no&#34;&gt;NRK&lt;/a&gt;, which has a blog discussing new media, the tech behind what they do, etc. called &lt;a href=&#34;http://nrkbeta.no&#34;&gt;NRK Beta&lt;/a&gt;, wrote an article about it: &lt;a href=&#34;http://nrkbeta.no/2012/04/06/old-skool-vaervarsling/&#34;&gt;Old Skool-værvarsling&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s also been used in a hackathon for littleprinter, see &lt;a href=&#34;http://twitpic.com/a298vv&#34;&gt;twitpic&lt;/a&gt; and &lt;a href=&#34;http://www.flickr.com/photos/knolleary/7473137758/in/photostream/&#34;&gt;flickr&lt;/a&gt;, and in various screenshot threads in forums.&lt;/p&gt;
&lt;h2 id=&#34;my-use&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#my-use&#34;&gt;
        #
    &lt;/a&gt;
    My use
&lt;/div&gt;
&lt;/h2&gt;
&lt;p&gt;I mainly made it for personal use. I have it at home on a monitor above the door and on a monitor at work. There are also options for small, one-liner outputs, which I&amp;rsquo;ve used in tmux/screen status bars.&lt;/p&gt;
&lt;h2 id=&#34;improving-on-tech-from-the-seventies&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#improving-on-tech-from-the-seventies&#34;&gt;
        #
    &lt;/a&gt;
    Improving on tech from the seventies
&lt;/div&gt;
&lt;/h2&gt;
&lt;p&gt;I can&amp;rsquo;t use unicode, colors, a larger display, as that would make it incompatible with the original goal of the project. But I&amp;rsquo;m fond of icons, so I made a client. Yes, a client for a finger weather service. It consists of some messy bash code to fetch, present and refresh the forecast using unicode and colors. You can find it in the git repo of the project, called &lt;a href=&#34;https://github.com/ways/pyyrascii/blob/master/graph.sh&#34;&gt;graph.sh&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;finger3.png&#34; alt=&#34;Client graph.sh&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;stats&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#stats&#34;&gt;
        #
    &lt;/a&gt;
    Stats
&lt;/div&gt;
&lt;/h2&gt;
&lt;p&gt;I do get that there isn&amp;rsquo;t a big market for this. Especially when it&amp;rsquo;s so hard to use on a phone (with for example &lt;a href=&#34;https://play.google.com/store/apps/details?id=ca.lotuspond.finger&#34;&gt;Unix Finger Client&lt;/a&gt;), and there are such beautiful alternatives as i.e. &lt;a href=&#34;http://forecast.io/&#34;&gt;forecast.io&lt;/a&gt;. Oh, yes, not everyone uses terminals anymore either.&lt;/p&gt;
&lt;p&gt;Still I do seem to have gathered a few loyal followers. I even had to block a user once, for hammering the service at about every second.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an excerpt from my logs the day before I wrote this:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Date: 2014-12-12
Total hits today: 377
Unique IPs today: 11
Top 10 users with hitcount:
 230 85.89.x.x
 36 77.179.x.x
 25 176.68.x.x
 24 77.179.x.x
 21 138.246.x.x
 16 176.11.x.x
 12 217.186.x.x
  4 93.93.x.x
  4 176.11.x.x
  3 46.212.x.x

Top 10 locations:
 230 katowice,
  72 dresden,
  24 oslo,
  21 munich,
  14 karlskrona,
   4 4730,
   2 hurdal,
   2 help,
   1 trondheim,
   1 time,
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;give-it-a-try&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#give-it-a-try&#34;&gt;
        #
    &lt;/a&gt;
    Give it a try
&lt;/div&gt;
&lt;/h2&gt;
&lt;p&gt;Now it&amp;rsquo;s time for you to try.&lt;/p&gt;
&lt;h3 id=&#34;linux&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#linux&#34;&gt;
        ##
    &lt;/a&gt;
    Linux
&lt;/div&gt;
&lt;/h3&gt;
&lt;p&gt;On Linux you probably have one of these installed:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e2e4e5;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;telnet
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;netcat / nc
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;finger
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If not, it&amp;rsquo;s usually a simple &lt;code&gt;sudo apt-get install finger&lt;/code&gt;&lt;/p&gt;
&lt;h3 id=&#34;os-x&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#os-x&#34;&gt;
        ##
    &lt;/a&gt;
    OS X
&lt;/div&gt;
&lt;/h3&gt;
&lt;p&gt;Look for the commands above.&lt;/p&gt;
&lt;h3 id=&#34;windows&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#windows&#34;&gt;
        ##
    &lt;/a&gt;
    Windows
&lt;/div&gt;
&lt;/h3&gt;
&lt;p&gt;On Windows 7 you can &lt;a href=&#34;http://social.technet.microsoft.com/wiki/contents/articles/910.windows-7-enabling-telnet-client.aspx&#34;&gt;activate telnet&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;for-all-oses&#34; &gt;
&lt;div&gt;
    &lt;a href=&#34;#for-all-oses&#34;&gt;
        ##
    &lt;/a&gt;
    For all OSes
&lt;/div&gt;
&lt;/h3&gt;
&lt;p&gt;Try one of the following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e2e4e5;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;finger newyork@graph.no
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff5c57&#34;&gt;echo&lt;/span&gt; newyork | telnet@graph.no finger
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff5c57&#34;&gt;echo&lt;/span&gt; newyork | netcat graph.no finger
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If those won&amp;rsquo;t work, try:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e2e4e5;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;telnet graph.no &lt;span style=&#34;color:#ff9f43&#34;&gt;79&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And then type &amp;ldquo;newyork&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Have a look at the help section for more info:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e2e4e5;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;finger @graph.no
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
  </channel>
</rss>
