script to get hard disk health in fedora/ubuntu

First, put this in a script.

#!/bin/bash

#Change as appropriate
HDD=sda

export sub="SmartCtl data for HDD"
echo 'To: <Your Email>
Sub: [Cron] $sub
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline

<html><pre>'


echo '<style>

hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;
}
</style>
'

echo '<h2>Errors on HDD:</h2>'
echo '<hr>'
sudo smartctl -l error  /dev/$HDD
echo '<h2>Health of HDD:</h2>'
echo '<hr>'
sudo smartctl -H  /dev/$HDD

echo '<h2>Detailed info</h2>'
echo '<hr>'
sudo smartctl -a -d ata /dev/$HDD

echo '<h2>Journalctl output for smartd</h2>'
echo '<hr>'

if [[ -f /etc/fedora-release ]]
then
journalctl -x --show-cursor -u smartd --since=yesterday
else
#This is for Ubuntu.. still using dmesg

dmesg -T -l err,crit,alert,emerg

fi


echo '<h2>All Details</h2>'
echo '<hr>'

sudo smartctl --xall /dev/$HDD


echo "Thanks for using Amit Agarwal's script"
echo '</pre></html>'

and then put this in cron:

30 15 * * 5 <script name> |/usr/sbin/sendmail -t

You need to have mail configured to receive the mails.

Whaaw! light weight media player

Description : Whaaw! Media Player is a lightweight media player that supports fullscreen
            : mode, seeking, changing video colour settings and more. It will play any audio
            : or video files that GStreamer can play. It is intended to be a basic media
            : player without any GNOME dependencies.

So, this is light weight media player with not too many features but does good as a simple media player.

To install:

 

sudo yum install whaawmp

ncurses based eFTE editor – programmers lightweight editor

nefte is a lightweight programmers editor. Here is descriptioin:

 

Description : eFTE is an advanced programmers editor with goals of being lightweight, yet
            : totally configurable. Support for user defined programming languages, menu
            : systems and key bindings are provided with many common defaults already
            : defined. eFTE is still a new project, however, we extend from the FTE editor
            : which was first released in 1995, so eFTE is tried and true with many features
            : for the programmer/text editor.
            : 
            : This package contains nefte, the ncurses version of the editor.

And to install:

sudo yum install nefte

nefte a.sh

There are lot of features taht you can explore and use.
It is quite lightweight programmers editor.

nomacs – light weight image viewer

To install:

1
sudo yum install nomacs

nomacs is a very light weight viewer for images with some fetures that you find useful (rotate image,
crop and see in 1:1. Not too much features but definately very light weight and good for daily use.

Description : nomacs is image viewer based on Qt4 library.
: nomacs is small, fast and able to handle the most common image formats.
: Additionally it is possible to synchronize multiple viewers
: running on the same computer or via LAN is possible.
: It allows to compare images and spot the differences
: e.g. schemes of architects to show the progress).

Search CVE – web interface with php

So, last few weeks have been very busy with lot of security issues, so I thought of having a local CVE Search app. But all I could find on google and github.com were on python and nothing that I could use quickly. So here is link to one that I wrote quickly:

CVE Search PHP

 

It’s in php. So just download in some folder and access from a web-server and you are done.

Multiple entry in .ssh/config file

Here is a link to one post on ssh config file.

However, if you want entries for lot of servers with their IPs or names, then it could be cumbersome to add all the entries in the .ssh/config file. So, here is a shortcut notation:

Host 1 2 3 4 5 6
Hostname 192.168.1.%h
    User 
    
    Ciphers arcfour

where '%h' denotes the IP that you use in the ssh command.

The following escape character substitutions will be performed:
             ‘%d’ (local user's home directory), ‘%h’ (remote host name), ‘%l’ (local host name),
              ‘%n’ (host name as provided on the command line), ‘%p’ (remote port),
              ‘%r’ (remote user name) or ‘%u’ (local user name).

nice little bash function to search for running processes

Here is a nice little handy function that I use very regurlarly.

You can use this function with parameter to just grep for that or just type psa to see all the running processes.

Just put this in your .bashrc file.

You might find it useful:

 

psa () 
{ 
    if [[ $1 == "" ]]; then
        ps -eaf;
    else
        ps -eaf | grep --color=auto -i $1;
    fi
}