Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Publicaciones sobre sysadmin (publicaciones antiguas, página 8)

Why no packaging software should replace your config files

When you up­grade a piece of soft­ware on Lin­ux, there are two paths it can go when there are in­com­pat­i­ble changes in the con­fig files (ok, 3 path­s, De­bian asks you what to do):

  1. The "rp­m­new" way: in­­stall the new con­­fig file as "what­ev­er.rp­m­new", which means the soft­­warewill break im­me­di­ate­­ly, but that's ok, be­­cause you are do­ing up­­­grades, so you should be watch­ing al­ready.

  2. The "rp­m­save" way: re­­place the old file and save a copy as "what­ev­er.rp­m­save".

This has two prob­lem­s:

  1. The soft­­ware may fail or not, or fail in a sub­­­tle way, and you will not no­tice right away.

  2. Maybe the old file will be lost any­way:

    lrwxrwxrwx  1 root root 32 jul 15 22:41 /etc/named.conf -> /var/named/chroot/etc/named.conf
    lrwxrwxrwx  1 root root 32 jul 15 22:36 /etc/named.conf.rpmsave -> /var/named/chroot/etc/named.conf

In this case the "file" was a sym­link, so by "sav­ing a copy" it on­ly saved an­oth­er sym­link to the soon-­to-be-over­writ­ten file.

And that's why, ladies and gen­tle­men, the rpm­new way is the good way.

Adding MSN notifications to Argus

I am a us­er of Ar­gus as a mon­i­tor­ing soft­ware. Since it's very flex­i­ble and easy to ex­tend, I want­ed to add MSN alert­s, the same way I had added SMS alerts a while ago. It was eas­i­er than I thought!

  1. In­­stall msnlib

  2. In­stall the ex­am­ple msnbot, mod­i­fied so do_­work is like this:

    def do_work():
       """
       Here you do your stuff and send messages using m.sendmsg()
       This is the only place your code lives
       """
    
       # wait a bit for everything to settle down (sync taking efect
       # basically)
       time.sleep(15)
    
       msg=sys.stdin.read()
       for d in sys.argv[3].split('+'):
               print m.sendmsg(d,msg)
    
    
       # give time to send the messages
       time.sleep(30)
    
       # and then quit
       quit()
  3. De­fine a cus­tom no­ti­fi­ca­tion in ar­gus like this:

    Method "msn" {
       command: /usr/local/bin/msnbot alerts@mycompany mypass %R >/tmp/XXX 2>&1
       send: %M\n
    }
  4. Wher­ev­er you want MSN no­ti­fi­ca­tion­s, add this (on no­ti­fy or es­ca­late di­rec­tives, us­ing as many guys MSN ad­dress­es as you need):

    msn:admin1@hotmai1.com+admin2@hotmai1.com

That's it.

Wine kinda works nowadays

I had stopped try­ing to run stuff in WINE a few years ago,be­cause pret­ty much noth­ing worked.

You know what? They areright about ap­proach­ing 1.0, I had to try a few win­dowsy things late­ly, and each one has worked just fine.

Ku­dos wine peo­ple!

PS: can you make the wid­gets look less ug­ly, though? I heard ru­mours of a them­ing en­gine, but have no clue as to where one would look. Even some­thing like GTK's clear­looks would be bear­able.

¡Examen Sorpresa!

Res­pues­ta:

[root@victima ~]# qmail-qstat
messages in queue: 151369
messages in queue but not yet preprocessed: 9

Lec­ció­n:

  • Hay un mo­­­ti­­vo por el cual no te de­­ja ha­­cer eso por de­­fau­l­­t.

  • De­­be­­­ría li­­mi­­tar el co­­­rreo salien­­te por cuen­­ta por de­­fault en to­­­dos los se­r­­ve­r­s. Me­­jor me po­n­­go a tra­­ba­­jar en eso.

Linux ayuda a Windows: Mandar SMS

Es­toy se­gu­ro que tie­ne que ha­ber al­gu­na ma­ne­ra de ha­cer­lo an­da­r. Por otro la­do, ya lo te­nía an­dan­do en Li­nu­x... así que uno pue­de sim­ple­men­te usar es­to en un Li­nux ami­go, y man­dar men­sa­jes SMS ac­ce­dien­do a una URL es­pe­cia­l:

#!/usr/bin/env python
from colubrid import BaseApplication, HttpResponse, execute
import os

class SMSApplication(BaseApplication):

  def process_request(self):
      numero = self.request.args.get('numero')
      mensaje = self.request.args.get('mensaje')
      [entrada,salida]=os.popen4('/usr/bin/gnokii --sendsms %s'%numero,mode='rw')
      entrada.write(mensaje)
      entrada.flush()
      entrada.close()
      msg=salida.read()
      response = HttpResponse(msg)
      response['Content-Type'] = 'text/plain'
      return response

if __name__ == '__main__':
  execute(SMSApplication,debug=True, hostname='mybox.domain.internal', port=8080,reload=True)

Si alguien abre http://­m­y­bo­x.­do­mai­n.in­ter­na­l:8080/?­nu­me­ro­=1234?­men­sa­je=ho­la%20­mun­do manda "hola mundo" al numero 1234.

Su­pon­go que po­dría de­cir que es un ser­vi­cio web de te­le­fo­nía, pe­ro es la so­lu­ción de 5 mi­nu­tos que se me ocu­rrió.

Usa una co­sa que se lla­ma co­lu­brid que no es real­men­te un fra­mewo­rk web y no al­go co­no­ci­do por­que que­ría man­te­ner­lo sim­ple, y no se po­ne mu­cho más sim­ple que es­to.


Contents © 2000-2020 Roberto Alsina